From 64ae24aef7c08f2bc5c4e365e3c43746196e8913 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 22:47:44 +0100 Subject: [PATCH 001/104] =?UTF-8?q?mesh-delivery:=20remove=20the=20indexer?= =?UTF-8?q?'s=20state=20config-candidates=20and=20its=20readers=20(issue?= =?UTF-8?q?=201982;=20ADR=200681=20=C2=A72)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mesh knows no pull request (design 47 G, G-1 §38-39), so the indexer keeps no pull request's config declarations. Removed: the code that writes the state (control_records.go: the candidate writes after a merge and for a pull message), its bucket, view family (views.config-candidates) and read tool (indexer_read_config_candidates) in the indexer's module.json, the view's tool indexer_config_candidates and its read of the indexer's tool, the state and its fixtures in the seat mesh-catalog's definition (generated Go and TypeScript regenerated by seatgen). indexer_config_readers no longer names an open pull request as a reader of a key. The state `predefined` stays. Builds: ADR 0681 §2 (the indexer keeps no config candidate: state, read tool and view, the seat contract's layout; `predefined` stays), §1 (indexer_config_readers names no pull request). Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshcatalog/contract.go | 65 ----- .../go/seats/meshcatalog/contract_test.go | 12 - .../seats/mesh-catalog/fixtures/states.json | 38 --- .../seats/mesh-catalog/seat.json | 101 -------- .../ts/seats/meshcatalog/index.d.ts | 39 --- .../ts/seats/meshcatalog/index.js | 16 -- .../cmd/mesh-delivery-indexer-tools/views.go | 19 +- .../cmd/mesh-delivery-indexer/main.go | 9 +- .../internal/index/candidates.go | 16 +- .../internal/index/config_readers.go | 30 ++- .../internal/index/control_records.go | 225 +----------------- .../internal/index/control_records_test.go | 68 +----- .../internal/index/names.go | 25 +- .../internal/index/pending.go | 9 +- .../internal/index/pending_test.go | 2 +- .../internal/index/views.go | 3 +- .../mesh-delivery-indexer/manifest_test.go | 8 +- modules/mesh-delivery-indexer/module.json | 3 - .../cmd/mesh-delivery-view-tools/main.go | 19 +- .../mesh-delivery-view-tools/owners_test.go | 18 +- .../mesh-delivery-view/internal/view/names.go | 8 +- .../mesh-delivery-view/internal/view/read.go | 7 +- modules/mesh-delivery-view/manifest_test.go | 4 +- modules/mesh-delivery-view/module.json | 2 - 24 files changed, 73 insertions(+), 673 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 59ca3d53..5458633b 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -115,7 +115,6 @@ const ( StateCandidates = "candidates" StateVerdicts = "verdicts" StatePredefined = "predefined" - StateConfigCandidates = "config-candidates" StatePackages = "packages" StateCatalogRevisions = "catalog-revisions" StateRegistrations = "registrations" @@ -279,37 +278,6 @@ func DecodePredefinedByListValue(raw []byte) (PredefinedByListValue, error) { return v, nil } -// ConfigCandidatesByPullKey is the key of one value of the state config-candidates under the form "". -func ConfigCandidatesByPullKey(pull string) string { return pull } - -// ParseConfigCandidatesByPullKey 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 ParseConfigCandidatesByPullKey(key string) (string, bool) { - rest := key - if rest == "" { - return "", false - } - v0 := rest - rest = "" - if rest != "" { - return "", false - } - return v0, true -} - -// DecodeConfigCandidatesByPullValue reads one value of the state config-candidates under the form "", refusing a field ConfigCandidatesByPullValue does not know and any text after the value. -func DecodeConfigCandidatesByPullValue(raw []byte) (ConfigCandidatesByPullValue, error) { - var v ConfigCandidatesByPullValue - 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 -} - // PackagesByModuleKey is the key of one value of the state packages under the form "". func PackagesByModuleKey(module string) string { return module } @@ -1626,39 +1594,6 @@ type PredefinedByListValue struct { V int64 `json:"v,omitempty"` } -// ConfigCandidatesByPullValueDeclaresValueValue is a type of the contract. -type ConfigCandidatesByPullValueDeclaresValueValue struct { - // the default - Default any `json:"default"` - Description string `json:"description,omitempty"` - // the allowed values - Enum any `json:"enum,omitempty"` - Kind string `json:"kind"` - // a declared bound; 0 is a bound, absent is none - Maximum *float64 `json:"maximum,omitempty"` - // a declared bound; 0 is a bound, absent is none - Minimum *float64 `json:"minimum,omitempty"` - Pattern string `json:"pattern,omitempty"` - Predefined string `json:"predefined,omitempty"` - Required bool `json:"required,omitempty"` - Runtime bool `json:"runtime,omitempty"` - Trusted bool `json:"trusted,omitempty"` - Type string `json:"type,omitempty"` - Why string `json:"why"` -} - -// ConfigCandidatesByPullValue is one value of the state config-candidates under the key . -type ConfigCandidatesByPullValue struct { - // when (RFC 3339 time) - At *time.Time `json:"at,omitempty"` - // module to key to declaration - Declares map[string]map[string]ConfigCandidatesByPullValueDeclaresValueValue `json:"declares"` - Head string `json:"head"` - Pull string `json:"pull"` - // the layout version - V int64 `json:"v,omitempty"` -} - // PackagesByModuleValuePackagesItem is a type of the contract. type PackagesByModuleValuePackagesItem struct { Digest string `json:"digest"` 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 d2f2cc38..d19839f1 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go @@ -47,18 +47,6 @@ func TestFixtures(t *testing.T) { 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 pull request's configuration", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v ConfigCandidatesByPullValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a pull request's configuration state whose bounds are declared 0 (a zero is a bound, not none)", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v ConfigCandidatesByPullValue - 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}", decode: func(b []byte) (any, error) { var v PackagesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a package series", subject: "", given: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}", wire: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"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 0719d65a..ea38c88f 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json @@ -63,44 +63,6 @@ } } }, - { - "name": "a pull request's configuration", - "of": "state:config-candidates/", - "given": { - "v": 1, - "pull": "novox/mesh-catalog#1", - "head": "cccccccccccccccccccccccccccccccccccccccc", - "declares": { - "nats": { - "limit": { - "kind": "setting", - "default": 1, - "why": "a bound" - } - } - } - } - }, - { - "name": "a pull request's configuration state whose bounds are declared 0 (a zero is a bound, not none)", - "of": "state:config-candidates/", - "given": { - "v": 1, - "pull": "novox/mesh-catalog#1", - "head": "cccccccccccccccccccccccccccccccccccccccc", - "declares": { - "nats": { - "limit": { - "kind": "setting", - "default": 0, - "why": "a bound", - "minimum": 0, - "maximum": 0 - } - } - } - } - }, { "name": "a published Go module", "of": "state:packages/", diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index 118c8e13..f8163534 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -1364,107 +1364,6 @@ "description": "the kept predefined list", "history": 5 }, - { - "name": "config-candidates", - "template": "state", - "key-forms": [ - { - "key": "", - "value": { - "type": "object", - "properties": { - "v": { - "type": "integer", - "description": "the layout version" - }, - "pull": { - "type": "string" - }, - "head": { - "type": "string" - }, - "declares": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "type": "object", - "properties": { - "kind": { - "type": "string" - }, - "default": { - "description": "the default" - }, - "why": { - "type": "string" - }, - "type": { - "type": "string" - }, - "description": { - "type": "string" - }, - "enum": { - "description": "the allowed values" - }, - "minimum": { - "type": [ - "number", - "null" - ], - "description": "a declared bound; 0 is a bound, absent is none" - }, - "maximum": { - "type": [ - "number", - "null" - ], - "description": "a declared bound; 0 is a bound, absent is none" - }, - "pattern": { - "type": "string" - }, - "trusted": { - "type": "boolean" - }, - "predefined": { - "type": "string" - }, - "required": { - "type": "boolean" - }, - "runtime": { - "type": "boolean" - } - }, - "required": [ - "kind", - "default", - "why" - ] - } - }, - "description": "module to key to declaration" - }, - "at": { - "type": "string", - "description": "when (RFC 3339 time)", - "format": "date-time" - } - }, - "required": [ - "pull", - "head", - "declares" - ] - }, - "description": "the configuration a pull request declares" - } - ], - "description": "the configuration declared by open pull requests", - "history": 5 - }, { "name": "packages", "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 6f31c3a3..74890b98 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -74,7 +74,6 @@ export declare const states: { readonly candidates: "candidates"; readonly verdicts: "verdicts"; readonly predefined: "predefined"; - readonly configCandidates: "config-candidates"; readonly packages: "packages"; readonly catalogRevisions: "catalog-revisions"; readonly registrations: "registrations"; @@ -114,12 +113,6 @@ export declare function predefinedByListKey(): string; /** The parts of a key of the form "list", or undefined for a key of another form. */ export declare function parsePredefinedByListKey(_key: string): { } | undefined; -/** The key of one value of the state config-candidates under the form "". */ -export declare function configCandidatesByPullKey(pull: string): string; - -/** The parts of a key of the form "", or undefined for a key of another form. */ -export declare function parseConfigCandidatesByPullKey(_key: string): { pull: string } | undefined; - /** The key of one value of the state packages under the form "". */ export declare function packagesByModuleKey(module: string): string; @@ -1072,38 +1065,6 @@ export interface PredefinedByListValue { "v"?: number; } -export interface ConfigCandidatesByPullValueDeclaresValueValue { - /** the default */ - "default": unknown; - "description"?: string; - /** the allowed values */ - "enum"?: unknown; - "kind": string; - /** a declared bound; 0 is a bound, absent is none */ - "maximum"?: number | null; - /** a declared bound; 0 is a bound, absent is none */ - "minimum"?: number | null; - "pattern"?: string; - "predefined"?: string; - "required"?: boolean; - "runtime"?: boolean; - "trusted"?: boolean; - "type"?: string; - "why": string; -} - -/** is one value of the state config-candidates under the key . */ -export interface ConfigCandidatesByPullValue { - /** when (RFC 3339 time) */ - "at"?: string; - /** module to key to declaration */ - "declares": Record>; - "head": string; - "pull": string; - /** the layout version */ - "v"?: number; -} - export interface PackagesByModuleValuePackagesItem { "digest": string; "package": string; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js index 47978710..1607daa0 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js @@ -76,7 +76,6 @@ export const states = { candidates: "candidates", verdicts: "verdicts", predefined: "predefined", - configCandidates: "config-candidates", packages: "packages", catalogRevisions: "catalog-revisions", registrations: "registrations", @@ -160,21 +159,6 @@ export function parsePredefinedByListKey(_key) { return { }; } -/** The key of one value of the state config-candidates under the form "". */ -export function configCandidatesByPullKey(pull) { - return pull; -} - -/** The parts of a key of the form "", or undefined for a key of another form. */ -export function parseConfigCandidatesByPullKey(_key) { - let _rest = _key; - if (_rest === "") return undefined; - const pull = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { pull }; -} - /** The key of one value of the state packages under the form "". */ export function packagesByModuleKey(module) { return module; diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go index e4a5ecb8..a6a5eff3 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "fmt" "time" @@ -37,14 +36,13 @@ func viewTools(getenv func(string) string, state func(string) views.Source, now func keptSource(name string) views.Source { return views.KeptSource{State: stdio.State(name)} } // configReadersTool is indexer_config_readers (design 32 *A value no longer read*; DLV-I10): read from one watched copy -// of the indexer's manifests and config-candidates states and its view of the trunk (the newest catalog graph revision), so an ask on each manifest-accepted reads no state +// of the indexer's manifests state and its view of the trunk (the newest catalog graph revision), so an ask on each manifest-accepted reads no state // whole again. func configReadersTool(watched *stdio.WatchedStates, modules views.Source) stdio.Tool { return stdio.Tool{Name: index.ConfigReadersTool, Description: "Who reads a module's config keys now (design 32): every value key and own secret any manifest of the module " + - "the indexer keeps ever declared, each with its readers — the module itself where its trunk's manifest declares it, and " + - "each open pull request (owner/repository#number) whose head declares it. A key with no reader is no longer read by any " + - "trunk or pull request, which mesh-config retires; which nodes still run a build reading it is not the indexer's to say.", + "the indexer keeps ever declared, each with its readers — the module itself where its trunk's manifest declares it. " + + "A key with no reader is no longer read by any trunk manifest, which mesh-config retires; which nodes still run a build reading it is not the indexer's to say.", Input: map[string]any{"type": "object", "required": []string{"module"}, "properties": map[string]any{ "module": map[string]any{"type": "string", "description": "the module whose config keys are asked"}}}, Run: func(args map[string]any) (any, error) { @@ -74,16 +72,7 @@ func configReadersTool(watched *stdio.WatchedStates, modules views.Source) stdio kept[k] = m } } - var pulls []meshcatalog.ConfigCandidatesByPullValue - if cands, err := watched.Values(index.ConfigCandidatesState); err == nil { - for _, v := range cands { - var c meshcatalog.ConfigCandidatesByPullValue - if json.Unmarshal(v, &c) == nil { - pulls = append(pulls, c) - } - } - } - return map[string]any{"readers": index.ConfigReaders(module, trunk, kept, pulls)}, nil + return map[string]any{"readers": index.ConfigReaders(module, trunk, kept)}, nil }} } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index d523c58e..301b6dc4 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -376,9 +376,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // Its taken state (ADR 0556 clause 1) is bound when it appears, as every state a delivery adds (issue 1790): until then // a merge's taken key is said and not written, and the rest of the indexer runs. taken := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.TakenState), "no repository's taken key is written", logger.Printf) - // The control records (ADR 0565 §2), new with this delivery and bound when they appear: until then nothing is written to them. + // The control record (ADR 0565 §2), new with its delivery and bound when they appear: until then nothing is written to them. predefined := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.PredefinedState), "no predefined list is written", logger.Printf) - configCandidates := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.ConfigCandidatesState), "no pull request's config declarations are written", logger.Printf) // The builder's log (ADR 0571 clause 1), read on the indexer's own credential (the calls connection) through its declared read: every entry it // keeps at the start, then each new one as the builder appends it (no timer). It names the directory of a module whose key // names none (fillPaths) and the places a registered module was built from; no build moves a fingerprint (ADR 0530 §1). @@ -459,7 +458,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro defer stopInput() ix := &index.Indexer{Module: cred.Module, NamedSets: named, Findings: writer, OldSections: awaitedStore{b: oldSections}, Unjudged: awaitedStore{b: unjudged}, Requirements: awaitedStore{b: requirements}, Store: kvStore{candidates}, Modules: modules, Manifests: kvStore{manifests}, Taken: awaitedStore{b: taken}, Builds: known, Verdicts: awaitedStore{b: verdicts}, SayRefused: sayRefused(conn, cred, logger.Printf), SayAccepted: sayAccepted(conn, cred), - Predefined: awaitedStore{b: predefined}, ConfigCandidates: awaitedStore{b: configCandidates}, Logf: logger.Printf, + Predefined: awaitedStore{b: predefined}, Logf: logger.Printf, Named: namedVia(calls.Call), Trunk: trunkVia(calls.Call), BranchHead: branchHeadVia(calls.Call), Contains: containsVia(calls.Call), Read: readVia(calls.Call), ReadOpen: openVia(calls.Call), Packages: awaitedStore{b: packages, js: js, name: index.Bucket(cred.Module, index.PackagesState)}, Files: filesVia(calls.Call), GoSum: goSumVia(calls.Call), GoMod: goModVia(calls.Call), OwnBuild: ownBuildVia(calls.Call, cred.Module, cred.Node), OwnBuildState: awaitedStore{b: ownBuildState}, Heard: heardStore, Placement: placementVia(calls.CallKept), RunningWhole: runningWholeVia(js), Runs: awaitedStore{b: runs}, Graph: graph, @@ -821,8 +820,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro startViews(ctx, js, cred, marks, writer, map[string]readyOf{"manifests": boundNow(manifests), "candidates": boundNow(candidates), index.VerdictsState: awaited(verdicts), index.PredefinedState: awaited(predefined), - index.ConfigCandidatesState: awaited(configCandidates), index.PackagesState: awaited(packages), - index.HeardState: awaited(heard.b), "taken": awaited(taken), "findings": awaited(findings), + index.PackagesState: awaited(packages), + index.HeardState: awaited(heard.b), "taken": awaited(taken), "findings": awaited(findings), index.SeatDefinitionsState: awaited(seatDefs)}, errs, logger.Printf) cc, err := process.HearEvents(cons, func(m jetstream.Msg) { handle(ctx, m, ix, heard, logger) diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index f6ac1594..5a9f8bd7 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -66,8 +66,8 @@ type Indexer struct { Modules Store // Manifests is the manifests bucket; nil writes no manifests (issue 1449). Manifests Store - // Predefined and ConfigCandidates are the control records' states (control_records.go, ADR 0565 §2); nil writes none. - Predefined, ConfigCandidates Store + // Predefined is the control record's state (control_records.go, ADR 0565 §2); nil writes none. + Predefined Store // Taken is the taken bucket: per repository the last merge taken in (taken.go, ADR 0556); nil writes none. Taken Store // Verdicts is the verdicts state (verdicts.go, novox/hq ADR 0578 §1); nil judges nothing. @@ -278,14 +278,10 @@ func (ix *Indexer) ApplyMessage(ctx context.Context, f forgemsg.Forge) (Applied, if err := ix.writeTakenKnown(ctx, f, w.asked); err != nil { return applied, err } - // The control records (ADR 0565 §2): the catalogue's predefined list, and the open pull requests' config - // declarations judged again against the trunk this merge moved. + // The control record (ADR 0565 §2): the catalogue's predefined list. if err := ix.writePredefined(ctx, f); err != nil { return applied, err } - if err := ix.configCandidatesAfterMerge(ctx, f, writtenModules(w.written)); err != nil { - return applied, err - } // Each package's name in its own ecosystem, which the builder numbers it under (design 32), kept before the // manifests are judged: a manifest of this merge naming a package this merge brings is judged knowing its name. if err := ix.KeepPackageNames(ctx, f); err != nil { @@ -332,12 +328,6 @@ func (ix *Indexer) ApplyMessage(ctx context.Context, f forgemsg.Forge) (Applied, } } ix.judgeDigests(ctx, over, fmt.Sprintf("%s#%d", f.Repository, f.Number)) - if err := ix.configCandidateOfPull(ctx, f, held); err != nil { - if !errors.Is(err, ErrUnreadable) { - return applied, err - } - ix.logf("%s#%d: its config declarations are not written: %v", f.Repository, f.Number, err) - } } return applied, ix.writeCandidate(ctx, f, digests, held) } diff --git a/modules/mesh-delivery-indexer/internal/index/config_readers.go b/modules/mesh-delivery-indexer/internal/index/config_readers.go index 9a096388..ba5740a9 100644 --- a/modules/mesh-delivery-indexer/internal/index/config_readers.go +++ b/modules/mesh-delivery-indexer/internal/index/config_readers.go @@ -8,8 +8,8 @@ import ( ) // ConfigReadersTool is the indexer's tool that says who reads a module's config keys (design 32 *A value no longer -// read*): mesh-config asks it on each manifest-accepted, and a key no manifest on any trunk or open pull request reads -// any more is a retiring value. +// read*): mesh-config asks it on each manifest-accepted, and a key no manifest on any trunk reads any more is a retiring +// value. const ConfigReadersTool = "indexer_config_readers" // The kinds of a config key. @@ -19,8 +19,7 @@ const ( ) // ConfigReaderRow is one key of a module's config: its kind (a value, or one of its own secrets) and who reads it now — -// the module itself where its trunk's manifest declares it, and each open pull request (owner/repository#number) whose -// head declares it. Nodes is left out: which nodes' applied builds read a key is the node-engines' word, not the +// the module itself where its trunk's manifest declares it. Nodes is left out: which nodes' applied builds read a key is the node-engines' word, not the // indexer's, so mesh-config reads it there (an empty list would say "no node", which the indexer cannot know). type ConfigReaderRow struct { Module string `json:"module"` @@ -32,15 +31,19 @@ type ConfigReaderRow struct { // configKeys are a manifest's config value keys (its `config` or `settings`) and its own secrets' names. func configKeys(raw string) (values, secrets []string) { - if d, err := DeclarationsOf(raw); err == nil { - for k := range d { - values = append(values, k) - } - } var m struct { + Config map[string]json.RawMessage `json:"config"` + Settings map[string]json.RawMessage `json:"settings"` OwnSecrets map[string]json.RawMessage `json:"own-secrets"` } if json.Unmarshal([]byte(raw), &m) == nil { + declared := m.Config + if declared == nil { + declared = m.Settings + } + for k := range declared { + values = append(values, k) + } for k := range m.OwnSecrets { secrets = append(secrets, k) } @@ -50,8 +53,8 @@ func configKeys(raw string) (values, secrets []string) { // ConfigReaders are the rows of module's config keys: every key any manifest of the module the indexer keeps ever // declared (so a key no manifest declares any more is a row with no reader), each with who reads it now. trunk is the -// modules state, manifests the manifests state by digest, candidates the open pull requests' config declarations. -func ConfigReaders(module string, trunk map[string]meshcatalog.ModulesByModuleValue, manifests map[string]meshcatalog.ManifestsByDigestValue, candidates []meshcatalog.ConfigCandidatesByPullValue) []ConfigReaderRow { +// modules state, manifests the manifests state by digest. +func ConfigReaders(module string, trunk map[string]meshcatalog.ModulesByModuleValue, manifests map[string]meshcatalog.ManifestsByDigestValue) []ConfigReaderRow { rows := map[string]*ConfigReaderRow{} add := func(kind, key, reader string) { id := kind + "|" + key @@ -84,11 +87,6 @@ func ConfigReaders(module string, trunk map[string]meshcatalog.ModulesByModuleVa add(ConfigKindSecret, k, reader) } } - for _, c := range candidates { - for key := range c.Declares[module] { - add(ConfigKindValue, key, c.Pull) - } - } out := make([]ConfigReaderRow, 0, len(rows)) for _, r := range rows { slices.Sort(r.Readers) diff --git a/modules/mesh-delivery-indexer/internal/index/control_records.go b/modules/mesh-delivery-indexer/internal/index/control_records.go index b14dde83..3fe9f329 100644 --- a/modules/mesh-delivery-indexer/internal/index/control_records.go +++ b/modules/mesh-delivery-indexer/internal/index/control_records.go @@ -4,23 +4,19 @@ import ( "context" "encoding/json" "errors" - "fmt" - "reflect" - "strconv" "strings" "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" ) -// The indexer's two control records (novox/hq ADR 0565 §2, issue 1953 D2, D3): the catalogue's predefined list, read from the -// forge bridge's merged message, and each open pull request's config declarations, read from its pull message's manifests -// against the trunk's manifests the indexer holds. mesh-config reads both in place of the controller's mirror and its -// `pull-declares`; a key's write is its event, nothing polls. +// The indexer's control record (novox/hq ADR 0565 §2, issue 1953 D2): the catalogue's predefined list, read from the forge +// bridge's merged message. mesh-config reads it in place of the controller's mirror; a key's write is its event, nothing +// polls. A pull request's config declarations are no longer kept: the mesh knows no pull request (design 47 G, ADR 0565 §2 +// and §3 ended by the operator's word, record pending). // writePredefined keeps the predefined list a merged message carries, unless the key names a later merge: a merge older // than the one it names never replaces it (ADR 0348 §7). The same list at the same merge writes nothing (ADR 0289 §1). @@ -70,208 +66,6 @@ func (ix *Indexer) now() time.Time { return time.Now() } -// PullName is a pull request as mesh-config names it, `owner/repository#number`. -func PullName(repository string, number int) string { return repository + "#" + strconv.Itoa(number) } - -// DeclarationsOf is a manifest's config declarations by key, in the layout of the controller's declared-config mirror: the -// config form's `config`, else the settings form's `settings`, each default and enum encoded the one way. -func DeclarationsOf(raw string) (map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue, error) { - var m struct { - Config map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue `json:"config"` - Settings map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue `json:"settings"` - } - if err := json.Unmarshal([]byte(raw), &m); err != nil { - return nil, err - } - declared := m.Config - if declared == nil { - declared = m.Settings - } - // A default and an enum decoded into the contract's `any` are written again in the one canonical way (keys sorted). - out := make(map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue, len(declared)) - for key, d := range declared { - out[key] = d - } - return out, nil -} - -// changedDeclarations are the declarations head adds or changes against trunk. -func changedDeclarations(head, trunk map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue) map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue { - out := map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue{} - for key, d := range head { - if before, there := trunk[key]; !there || !reflect.DeepEqual(before, d) { - out[key] = d - } - } - return out -} - -// trunkManifest is the manifest the indexer holds for a module on the trunk, "" when it holds none. -func (ix *Indexer) trunkManifest(ctx context.Context, held map[string]meshcatalog.ModulesByModuleValue, module string) (string, error) { - m, ok := held[module] - if !ok || m.Manifest == "" || ix.Manifests == nil { - return "", nil - } - raw, _, found, err := ix.Manifests.Get(ctx, m.Manifest) - if err != nil || !found { - return "", err - } - kept, err := meshcatalogclient.DecodeManifest(raw) - if err != nil { - return "", err - } - return kept.Manifest, nil -} - -// candidateDeclares are, per module of a pull request's head, the declarations its manifest adds or changes against the -// trunk's (an empty set for a module that adds none): heads are the head's manifests by module. -func (ix *Indexer) candidateDeclares(ctx context.Context, held map[string]meshcatalog.ModulesByModuleValue, heads map[string]string) (map[string]map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue, error) { - out := map[string]map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue{} - for module, raw := range heads { - head, err := DeclarationsOf(raw) - if err != nil { - return nil, fmt.Errorf("%w: the manifest of %s at the head: %v", ErrUnreadable, module, err) - } - trunkRaw, err := ix.trunkManifest(ctx, held, module) - if err != nil { - return nil, err - } - trunk := map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue{} - if trunkRaw != "" { - if trunk, err = DeclarationsOf(trunkRaw); err != nil { - return nil, fmt.Errorf("the trunk's manifest of %s: %w", module, err) - } - } - if changed := changedDeclarations(head, trunk); len(changed) > 0 { - out[module] = changed - } - } - return out, nil -} - -// writeConfigCandidate writes a pull request's key of config-candidates from its head's manifests by module: written when -// what it says differs (its time apart), never for the same head and declarations twice. -func (ix *Indexer) writeConfigCandidate(ctx context.Context, repository string, number int, head string, held map[string]meshcatalog.ModulesByModuleValue, heads map[string]string) error { - if ix.ConfigCandidates == nil { - return nil - } - pull := PullName(repository, number) - key, err := ConfigCandidateKey(pull) - if err != nil { - return fmt.Errorf("%w: %v", ErrUnreadable, err) - } - declares, err := ix.candidateDeclares(ctx, held, heads) - if err != nil { - return err - } - return ix.notYet(ConfigCandidatesState, write(ctx, ix.ConfigCandidates, key, func(value []byte, found bool) ([]byte, bool, error) { - if found { - var cur meshcatalog.ConfigCandidatesByPullValue - if json.Unmarshal(value, &cur) == nil && cur.Head == head && reflect.DeepEqual(cur.Declares, declares) { - return nil, false, nil - } - } - next, err := json.Marshal(meshcatalog.ConfigCandidatesByPullValue{V: keys.Version, Pull: pull, Head: head, Declares: declares, At: ptr(ix.now())}) - return next, false, err - })) -} - -// dropConfigCandidate deletes a pull request's key: it merged or closed. -func (ix *Indexer) dropConfigCandidate(ctx context.Context, repository string, number int) error { - if ix.ConfigCandidates == nil { - return nil - } - key, err := ConfigCandidateKey(PullName(repository, number)) - if err != nil { - return nil - } - return ix.notYet(ConfigCandidatesState, write(ctx, ix.ConfigCandidates, key, func(_ []byte, found bool) ([]byte, bool, error) { return nil, found, nil })) -} - -// configCandidateOfPull is a pull message's part in config-candidates: a head whose manifests the message carries is written, -// a closed one deleted. A head held again without its directories leaves the key as it is. -func (ix *Indexer) configCandidateOfPull(ctx context.Context, f forgemsg.Forge, held map[string]meshcatalog.ModulesByModuleValue) error { - if f.Action == forgemsg.PullClosed { - return ix.dropConfigCandidate(ctx, f.Repository, f.Number) - } - if !f.DirsKnown { - return nil - } - heads := map[string]string{} - for dir, raw := range f.Manifests { - heads[moduleOfDir(held, f, dir)] = raw - } - return ix.writeConfigCandidate(ctx, f.Repository, f.Number, f.Head, held, heads) -} - -// configCandidatesAfterMerge writes again every open pull request's key that names a module the merge changed, since what -// it adds is judged against the trunk (ADR 0565 §2), from the head's manifests its candidate keeps; and deletes the merged -// pull request's. -func (ix *Indexer) configCandidatesAfterMerge(ctx context.Context, f forgemsg.Forge, changed []string) error { - if ix.ConfigCandidates == nil { - return nil - } - if err := ix.dropConfigCandidate(ctx, f.Repository, f.Number); err != nil { - return err - } - if len(changed) == 0 || ix.Store == nil || ix.Manifests == nil { - return nil - } - held, err := ix.heldModules(ctx) - if err != nil { - return err - } - if _, err := ix.ConfigCandidates.Keys(ctx); errors.Is(err, process.ErrNotYet) { - return nil - } - groups, err := ix.Store.Keys(ctx) - if err != nil { - return err - } - var errs []error - for _, g := range groups { - if meshcatalogclient.IsTryGroup(g) { - continue // a run's candidate holds no pull request's config declarations (runcandidates.go) - } - raw, _, found, err := ix.Store.Get(ctx, g) - if err != nil || !found { - continue - } - c, err := DecodeCandidate(raw) - if err != nil { - continue - } - for _, p := range c.Pulls { - if !touchesAny(p, changed) { - continue - } - heads := map[string]string{} - for module, fp := range p.Fps { - mraw, _, found, err := ix.Manifests.Get(ctx, fp.Manifest) - if err != nil || !found { - continue - } - if kept, err := meshcatalogclient.DecodeManifest(mraw); err == nil { - heads[module] = kept.Manifest - } - } - if err := ix.writeConfigCandidate(ctx, p.Repository, int(p.Number), p.Head, held, heads); err != nil { - errs = append(errs, err) - } - } - } - return errors.Join(errs...) -} - -func touchesAny(p meshcatalog.CandidatesByGroupValuePullsItem, modules []string) bool { - for _, m := range modules { - if _, ok := p.Fps[m]; ok { - return true - } - } - return false -} - // writtenModules are the modules a merged message wrote, from its written keys (`modules.`). func writtenModules(written []string) []string { var out []string @@ -282,14 +76,3 @@ func writtenModules(written []string) []string { } func ptr[T any](v T) *T { return &v } - -// ConfigCandidateKey is a pull request's key in config-candidates, `owner/repository#number` with `/` and `#` as dots, the form -// mesh-config keeps a pull request's values under. -func ConfigCandidateKey(pull string) (string, error) { - owner, rest, ok := strings.Cut(strings.TrimSpace(pull), "/") - repo, number, ok2 := strings.Cut(rest, "#") - if !ok || !ok2 || owner == "" || repo == "" || number == "" || strings.ContainsAny(owner+repo+number, ".*> ") { - return "", fmt.Errorf("index: %q is not a pull request, owner/repository#number", pull) - } - return meshcatalog.ConfigCandidatesByPullKey(owner + "." + repo + "." + number), nil -} diff --git a/modules/mesh-delivery-indexer/internal/index/control_records_test.go b/modules/mesh-delivery-indexer/internal/index/control_records_test.go index 7e42f18d..87cc2cf0 100644 --- a/modules/mesh-delivery-indexer/internal/index/control_records_test.go +++ b/modules/mesh-delivery-indexer/internal/index/control_records_test.go @@ -12,7 +12,6 @@ import ( mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" @@ -23,12 +22,10 @@ import ( ) // 1953/D2, D3 (novox/hq ADR 0565 §2): the indexer keeps the catalogue's predefined list from the merged message, a merge older -// than the one kept never replacing it; and each open pull request's config declarations its head adds or changes against the -// trunk's manifest, an empty set when none, written only when they change and deleted when it merges or closes. +// than the one kept never replacing it. (A pull request's config declarations are no longer kept: the mesh knows no pull request.) func TestTheControlRecords(t *testing.T) { // DLV-I10 (design 32 *A value no longer read*): every key any kept manifest of the module declared, each with who - // reads it now: the module for its trunk's manifest, an open pull request for its head's declarations; a key no - // manifest declares now has no reader. + // reads it now: the module for its trunk's manifest; a key no manifest declares now has no reader. t.Run("indexer_config_readers", func(t *testing.T) { d1, d2 := strings.Repeat("1", 64), strings.Repeat("2", 64) manifests := map[string]meshcatalog.ManifestsByDigestValue{ @@ -37,10 +34,8 @@ func TestTheControlRecords(t *testing.T) { strings.Repeat("3", 64): {Module: "db", Manifest: `{"module":"db","config":{"old":{"kind":"value","why":"w"}}}`}, } trunk := map[string]meshcatalog.ModulesByModuleValue{"web": {Manifest: d2}} - pulls := []meshcatalog.ConfigCandidatesByPullValue{{Pull: "novox/web#7", Declares: map[string]map[string]meshcatalog.ConfigCandidatesByPullValueDeclaresValueValue{"web": {"new": {}}}}} - got := ConfigReaders("web", trunk, manifests, pulls) + got := ConfigReaders("web", trunk, manifests) want := []ConfigReaderRow{{Module: "web", Key: "key", Kind: ConfigKindSecret, Readers: []string{}}, - {Module: "web", Key: "new", Kind: ConfigKindValue, Readers: []string{"novox/web#7"}}, {Module: "web", Key: "old", Kind: ConfigKindValue, Readers: []string{}}, {Module: "web", Key: "port", Kind: ConfigKindValue, Readers: []string{"web"}}} if !reflect.DeepEqual(got, want) { @@ -618,63 +613,6 @@ func TestTheControlRecords(t *testing.T) { t.Errorf("a state not on the bus yet stopped the message: %v", err) } }) - t.Run("a pull request's config declarations against the trunk", func(t *testing.T) { - ix, _, _ := manifestsIndexer(t, rec(t, "build-1", "avahi", catalogueRepo, "modules/avahi", "main", "", "2026-10-19T09:00:00Z", aInputs)) - cands := newMem() - ix.ConfigCandidates, ix.Now = cands, func() time.Time { return at } - trunk := `{"module":"avahi","version":"1.0","config":{"port":{"type":"integer","default":5353,"why":"mDNS"}}}` - if err := ix.Apply(ctx, withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "t1"}), map[string]string{"modules/avahi": trunk}, nil)); err != nil { - t.Fatal(err) - } - key := "novox.mesh-catalog.7" - head := strings.Replace(trunk, `"why":"mDNS"}`, `"why":"mDNS"},"name":{"type":"string","default":"x","why":"shown"}`, 1) - p := withManifests(pull(catalogueRepo, 7, "feat/y", h1, "modules/avahi"), map[string]string{"modules/avahi": head}, nil) - if err := ix.Apply(ctx, p); err != nil { - t.Fatal(err) - } - var c meshcatalog.ConfigCandidatesByPullValue - if err := json.Unmarshal(cands.vals[key], &c); err != nil || c.Pull != "novox/mesh-catalog#7" || c.Head != h1 || len(c.Declares["avahi"]) != 1 || - c.Declares["avahi"]["name"].Default != "x" { - t.Fatalf("candidate = %+v (%v)", c, err) - } - writes := cands.writes - if err := ix.Apply(ctx, p); err != nil || cands.writes != writes { - t.Errorf("the same head wrote again (%v)", err) - } - same := withManifests(pull(catalogueRepo, 7, "feat/y", strings.Repeat("d", 40), "modules/avahi"), map[string]string{"modules/avahi": trunk}, nil) - if err := ix.Apply(ctx, same); err != nil { - t.Fatal(err) - } - c = meshcatalog.ConfigCandidatesByPullValue{} - if err := json.Unmarshal(cands.vals[key], &c); err != nil || len(c.Declares) != 0 || c.Declares == nil { - t.Errorf("a head declaring nothing new = %+v, want an empty set", c) - } - closed := pull(catalogueRepo, 7, "feat/y", strings.Repeat("d", 40)) - closed.Action = forgemsg.PullClosed - if err := ix.Apply(ctx, closed); err != nil { - t.Fatal(err) - } - if _, ok := cands.vals[key]; ok { - t.Error("a closed pull request's declarations stayed") - } - // A group try's candidate (number 0) holds no pull request's declarations: a merge that touches its module writes none - // for it (fails when configCandidatesAfterMerge no longer skips a try's group). - tryPull := meshcatalog.CandidatesByGroupValuePullsItem{Repository: catalogueRepo, Head: h1, Modules: []string{"avahi"}, - Fps: map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"avahi": {Manifest: meshcatalogclient.ManifestDigest([]byte(trunk)), None2: meshcatalogclient.NoneNoPreview}}} - tryCand := meshcatalog.CandidatesByGroupValue{V: keys.Version, Group: "try-5", Pulls: []meshcatalog.CandidatesByGroupValuePullsItem{tryPull}} - tryCand.Heads, _ = meshdeliveryclient.HeadsHash([]meshdeliveryclient.Head{{Repository: tryPull.Repository, Head: tryPull.Head}}) - tryCand.Fpset = meshcatalogclient.FingerprintSet(tryCand.Pulls) - data, err := EncodeCandidate(tryCand) - if err != nil { - t.Fatal(err) - } - if err := ix.Store.Create(ctx, "try-5", data); err != nil { - t.Fatal(err) - } - if err := ix.configCandidatesAfterMerge(ctx, mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "t2"}), []string{"avahi"}); err != nil || len(cands.vals) != 0 { - t.Errorf("a merge touching a try's module wrote %v for it (%v), want none", cands.vals, err) - } - }) } // memSource is a state as views.Source, for the indexer's tools that answer from its own states. diff --git a/modules/mesh-delivery-indexer/internal/index/names.go b/modules/mesh-delivery-indexer/internal/index/names.go index 78fbb8be..c096efa2 100644 --- a/modules/mesh-delivery-indexer/internal/index/names.go +++ b/modules/mesh-delivery-indexer/internal/index/names.go @@ -11,19 +11,18 @@ const ( ManifestsState = "manifests" ManifestsHistory = 1 // VerdictsState is in verdicts.go. - VerdictsHistory = 5 - PredefinedState = "predefined" - ConfigCandidatesState = "config-candidates" - PackagesState = "packages" - PackagesHistory = 5 - TakenState = "taken" - PredefinedListKey = "list" - ForgeBridgeModule = "mesh-delivery-forge-bridge" - GateModule = "mesh-delivery-gate" - CheckerModule = "mesh-delivery-checker" - PreviewsBucket = CheckerModule + "_previews" - PreviewsHistory = 5 - toolchainsState = "toolchains" + VerdictsHistory = 5 + PredefinedState = "predefined" + PackagesState = "packages" + PackagesHistory = 5 + TakenState = "taken" + PredefinedListKey = "list" + ForgeBridgeModule = "mesh-delivery-forge-bridge" + GateModule = "mesh-delivery-gate" + CheckerModule = "mesh-delivery-checker" + PreviewsBucket = CheckerModule + "_previews" + PreviewsHistory = 5 + toolchainsState = "toolchains" ) // ToolchainsBucket is the toolchains state of a build module (reads: mesh-build-go.toolchains, mesh-build-node.toolchains). diff --git a/modules/mesh-delivery-indexer/internal/index/pending.go b/modules/mesh-delivery-indexer/internal/index/pending.go index fe930595..6c27b250 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending.go +++ b/modules/mesh-delivery-indexer/internal/index/pending.go @@ -895,10 +895,10 @@ func (ix *Indexer) waitingLine(w Waits) string { // dryRun is an indexer computing a take-in without writing it, and the overlays of what it would have written. type dryRun struct { - ix *Indexer - modules, graph, verdicts *overlayStore - candidates, taken, predefined, configs *overlayStore - oldSections *overlayStore + ix *Indexer + modules, graph, verdicts *overlayStore + candidates, taken, predefined *overlayStore + oldSections *overlayStore } // dry is an indexer over overlays of this one's states (overlay.go): what a take-in would write stays in memory and @@ -933,7 +933,6 @@ func (ix *Indexer) dry() *dryRun { x.Verdicts, d.verdicts = over(ix.Verdicts) x.Taken, d.taken = over(ix.Taken) x.Predefined, d.predefined = over(ix.Predefined) - x.ConfigCandidates, d.configs = over(ix.ConfigCandidates) x.OldSections, d.oldSections = over(ix.OldSections) // What the trunk holds unjudged is read through, as fresh; what the dry run would keep stays in its overlay (issue 1966). x.Unjudged, _ = over(ix.Unjudged) diff --git a/modules/mesh-delivery-indexer/internal/index/pending_test.go b/modules/mesh-delivery-indexer/internal/index/pending_test.go index 07792014..de4ecf7c 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pending_test.go @@ -1052,7 +1052,7 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) t.Run("the dry run names every field of the indexer", func(t *testing.T) { // dry (pending.go) builds an indexer field by field: a field added to Indexer is named there, or this fails. named := map[string]bool{} - for _, f := range []string{"Module", "Store", "Modules", "Manifests", "Predefined", "ConfigCandidates", "Taken", "Verdicts", "OldSections", "Unjudged", + for _, f := range []string{"Module", "Store", "Modules", "Manifests", "Predefined", "Taken", "Verdicts", "OldSections", "Unjudged", "JudgeID", "SayRefused", "SayAccepted", "Packages", "Graph", "Files", "GoSum", "GoMod", "Now", "Builds", "Named", "Trunk", "BranchHead", "Read", "Contains", "Logf", "ReadOpen", "OwnBuild", "Message", "Pending", "SayTakeIn", "Requirements", "Findings", "SeatDefinitions", "ReadFile", "SaySeatDefinition", "Runs", "OwnBuildState", "Heard", "Placement", "RunningWhole", "Revisions", "SayCatalogRevision", "SayFill", "EntryIndex", "NamedSets", "Registry", "SeedModules", "Versions", "SayVersionReleased", "SayVersionsFilled", "Inputs", "InputObjects", "BuildEdges", "Pins", "PinsPending", "ValidationAsks", "AskVerb"} { diff --git a/modules/mesh-delivery-indexer/internal/index/views.go b/modules/mesh-delivery-indexer/internal/index/views.go index 3c5814a1..70b0edf7 100644 --- a/modules/mesh-delivery-indexer/internal/index/views.go +++ b/modules/mesh-delivery-indexer/internal/index/views.go @@ -25,7 +25,6 @@ var FirstViewTools = []ViewedTool{ var ReadTools = []ViewedTool{ {Tool: "indexer_read_manifests", State: "manifests", Words: "every manifest the indexer keeps, by its digest."}, {Tool: "indexer_read_predefined", State: PredefinedState, Words: "the predefined config values of each module on the trunk."}, - {Tool: "indexer_read_config_candidates", State: ConfigCandidatesState, Words: "the config declarations of each open pull request."}, {Tool: "indexer_read_candidates", State: "candidates", Words: "the candidate groups: the pull requests sharing a branch, their heads and the modules each touches."}, {Tool: "indexer_read_packages", State: PackagesState, Words: "the published packages per series."}, {Tool: "indexer_read_graph", State: graph.State, Words: "the module graph: each module's build and provision edges."}, @@ -44,7 +43,7 @@ type ViewedTool struct { // ViewedStates are the states the indexer's views family says: the ones its readers read. var ViewedStates = map[string]bool{ - ManifestsState: true, VerdictsState: true, PredefinedState: true, ConfigCandidatesState: true, CandidatesState: true, + ManifestsState: true, VerdictsState: true, PredefinedState: true, CandidatesState: true, PackagesState: true, HeardState: true, TakenState: true, TakeInsState: true, FindingsState: true, SeatDefinitionsState: true, UnjudgedState: true, } diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index d23677fc..a5aa7235 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -127,7 +127,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build t.Errorf("uses = %v, invokes = %v, want the seat operator-channel used and seat:mesh-module-assigner.assignments invoked", m.Uses, m.Invokes) } // 1126 note 76: heard keeps the last 64 FORGE messages the indexer handled, for indexer_heard. - if want := []state{{Name: "candidates", History: 10}, {Name: "heard", History: 64}, {Name: "manifests", History: 1}, {Name: "predefined", History: 5}, {Name: "config-candidates", History: 5}, {Name: "taken", History: 1}, {Name: "takeins", History: 1}, {Name: "verdicts", History: 5}, {Name: "oldsections", History: 1}, {Name: index.RunsState, History: 1}, {Name: "own-build", History: 1}, {Name: index.PackagesState, History: index.PackagesHistory}, + if want := []state{{Name: "candidates", History: 10}, {Name: "heard", History: 64}, {Name: "manifests", History: 1}, {Name: "predefined", History: 5}, {Name: "taken", History: 1}, {Name: "takeins", History: 1}, {Name: "verdicts", History: 5}, {Name: "oldsections", History: 1}, {Name: index.RunsState, History: 1}, {Name: "own-build", History: 1}, {Name: index.PackagesState, History: index.PackagesHistory}, {Name: views.MarksState, History: 1}, {Name: index.FindingsState, History: 5}, {Name: views.StatusState, History: 1}, {Name: index.RequirementsState, History: 5}, {Name: index.SeatDefinitionsState, History: 5}, {Name: index.PendingState, History: 1}, {Name: index.UnjudgedState, History: 1}, {Name: index.EntryIndexState, History: 1, MaxMiB: 8}, {Name: index.NamedState, History: 1, MaxMiB: 4}, // design 47 G §695 @@ -147,7 +147,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // A-296: its own buckets are named from its credential's module (index.Bucket), each a state its manifest keeps. own := func(state string) string { return index.Bucket("a-indexer", state) } for bucket, history := range map[string]int{own(index.CandidatesState): index.CandidatesHistory, own(index.ManifestsState): index.ManifestsHistory, - own(index.VerdictsState): index.VerdictsHistory, own(index.PackagesState): index.PackagesHistory, own(index.TakenState): 1, own(index.PredefinedState): 5, own(index.ConfigCandidatesState): 5} { + own(index.VerdictsState): index.VerdictsHistory, own(index.PackagesState): index.PackagesHistory, own(index.TakenState): 1, own(index.PredefinedState): 5} { if !slices.ContainsFunc(m.State, func(st state) bool { return "a-indexer_"+st.Name == bucket && st.History == history }) { t.Errorf("the indexer names its bucket %s with %d revisions, its manifest's states are %+v", bucket, history, m.State) } @@ -203,7 +203,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build index.CatalogRevisionTool, index.CatalogRevisionsTool, index.CandidateGraphsTool, index.RecomputeTool, index.DropCandidateGraphTool, index.EntryIndexTool, index.NamedDropTool, // design 47 G §675 index.ProposalsTool, index.ProposalDropTool, index.SeedAgainTool, index.InputsTool, index.PinsTool, index.UnpinTool, index.ConsumerTool, index.RunsTool, index.RunDropTool) // design 47 G §667, §8, §579, §64 (A-194) - if !reflect.DeepEqual(m.Tools, want) || len(want) != 51 || !slices.Contains(m.Tools, "modules") { + if !reflect.DeepEqual(m.Tools, want) || len(want) != 50 || !slices.Contains(m.Tools, "modules") { t.Errorf("tools = %v, want %v", m.Tools, want) } // Design 47 G §2, §9: every version of every registration is kept with no age limit, 64 MiB, on the old streams section. @@ -307,7 +307,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // ADR 0636 §4: seat-definition-changed and -removed are the seat mesh-catalog's events, said on the seat's subject and kept // on the shared events stream, and not among its own emits. // Design 47 G A-360: modules too, at each new trunk revision that changes it. - for _, state := range []string{"candidates", "config-candidates", "findings", "graph", "heard", "manifests", "modules", "packages", "predefined", "seat-definitions", "taken", "verdicts"} { + for _, state := range []string{"candidates", "findings", "graph", "heard", "manifests", "modules", "packages", "predefined", "seat-definitions", "taken", "verdicts"} { if !slices.Contains(m.Emits, views.EventPrefix+state) { t.Errorf("emits = %v: want %s%s", m.Emits, views.EventPrefix, state) } diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index d460a233..899db78f 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -37,7 +37,6 @@ "graph", "indexer_read_manifests", "indexer_read_predefined", - "indexer_read_config_candidates", "indexer_read_candidates", "indexer_read_packages", "indexer_read_graph", @@ -111,7 +110,6 @@ { "name": "heard", "history": 64 }, { "name": "manifests", "history": 1 }, { "name": "predefined", "history": 5 }, - { "name": "config-candidates", "history": 5 }, { "name": "taken", "history": 1 }, { "name": "takeins", "history": 1 }, { "name": "verdicts", "history": 5 }, @@ -147,7 +145,6 @@ "take-in.pending", "take-in.taken", "views.candidates", - "views.config-candidates", "views.findings", "views.graph", "views.heard", diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go index b3138c12..9e75c8b2 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go @@ -213,16 +213,6 @@ func Tools(r view.Reader, u view.UsageReader) []stdio.Tool { Run: func(map[string]any) (any, error) { return view.ControlRecord(r.PredefinedState, view.IndexerPredefinedState, view.PredefinedListKey) }}, - {Name: view.ConfigCandidatesReadTool, - Description: "Each open pull request's config declarations as the indexer keeps them (novox/hq ADR 0565 §2): per pull " + - "request (owner.repository.number), its head and per module the config keys its manifests add or change against the " + - "trunk's, an empty set when none; deleted when it merges or closes. Give key for one. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "key": map[string]any{"type": "string", "description": "one pull request's key, owner.repository.number"}}}, - Run: func(args map[string]any) (any, error) { - key, _ := args["key"].(string) - return view.ControlRecord(r.ConfigCandidatesState, view.IndexerConfigCandidatesState, key) - }}, {Name: view.PackagesReadTool, Description: "The mesh packages as the indexer publishes them (novox/hq ADR 0593 §2): per mesh Go module (its module " + "path, such as git.novox.be/novox/mesh-sdk/go), the trunk merge that published it (the version a build pins), the " + @@ -422,11 +412,10 @@ func ownersRead(ask func(key string, body any) (json.RawMessage, error), holder } return module + "_" + meshwants.StateWants }, - HeardState: indexer("indexer_read_heard"), - PredefinedState: indexer("indexer_read_predefined"), - ConfigCandidatesState: indexer("indexer_read_config_candidates"), - PackagesState: indexer("indexer_read_packages"), - GraphState: indexer("indexer_read_graph")} + HeardState: indexer("indexer_read_heard"), + PredefinedState: indexer("indexer_read_predefined"), + PackagesState: indexer("indexer_read_packages"), + GraphState: indexer("indexer_read_graph")} } // holderOf is a seat's holder as mesh-sdk's seatlist.HolderOf answers it (design 47 G A-126): false while the seat has none or diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go index acdd693b..93c1ed2f 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go @@ -75,11 +75,10 @@ func ownersAnswerTheToolsAsBefore(t *testing.T) { view.IndexerModule + ".candidates": {"feat/x": cand, "fix": `{"v":1,"group":"fix","base":3,"heads":"h","pulls":[{"modules":["netcheck"]}]}`}, assignerModule + ".wants": {"want.ace.zsh": `{"fp":"` + fp2A + `"}`, "want.novox.zsh": `{"fp":"` + fp2B + `"}`, "held." + keyB: `{"node":"ace","words":"failed"}`}, - assignerModule + ".differences": {"ace.zsh": `{"unexplained":true}`, "novox.zsh": `{"rule":3}`}, - view.IndexerModule + "." + view.IndexerPredefinedState: {view.PredefinedListKey: `{"v":1,"keys":["dir:state"]}`}, - view.IndexerModule + "." + view.IndexerConfigCandidatesState: {"novox.r.7": `{"v":1,"pull":"novox/r#7"}`}, - view.IndexerModule + "." + view.PackagesState: {pkgKey: `{"v":1,"module":"git.novox.be/novox/mesh-sdk/go","commit":"c1"}`}, - view.IndexerModule + "." + graph.State: {}, + assignerModule + ".differences": {"ace.zsh": `{"unexplained":true}`, "novox.zsh": `{"rule":3}`}, + view.IndexerModule + "." + view.IndexerPredefinedState: {view.PredefinedListKey: `{"v":1,"keys":["dir:state"]}`}, + view.IndexerModule + "." + view.PackagesState: {pkgKey: `{"v":1,"module":"git.novox.be/novox/mesh-sdk/go","commit":"c1"}`}, + view.IndexerModule + "." + graph.State: {}, } // The kept history of the indexer's modules and heard and the assigner's wants (each declared with more than one // revision in its owner's manifest), which indexer_module_history, indexer_heard and view_tiers' times read. @@ -94,10 +93,9 @@ func ownersAnswerTheToolsAsBefore(t *testing.T) { st := func(name string) view.StateRead { return fake(states[name]).reader().State } direct := view.Reader{CandidatesState: st(view.IndexerModule + ".candidates"), WantsState: st(assignerModule + ".wants"), DifferencesState: st(assignerModule + ".differences"), - PredefinedState: st(view.IndexerModule + "." + view.IndexerPredefinedState), - ConfigCandidatesState: st(view.IndexerModule + "." + view.IndexerConfigCandidatesState), - PackagesState: st(view.IndexerModule + "." + view.PackagesState), - GraphState: st(view.IndexerModule + "." + graph.State)} + PredefinedState: st(view.IndexerModule + "." + view.IndexerPredefinedState), + PackagesState: st(view.IndexerModule + "." + view.PackagesState), + GraphState: st(view.IndexerModule + "." + graph.State)} // The owners' read tools, answered by the owner's own Read over the same state; any other address is refused. tools := map[string]string{} for name := range states { @@ -153,8 +151,6 @@ func ownersAnswerTheToolsAsBefore(t *testing.T) { {view.WantReadTool, map[string]any{"node": "ace", "module": "zsh"}}, {view.DifferencesReadTool, map[string]any{"node": "novox"}}, {view.PredefinedReadTool, map[string]any{}}, - {view.ConfigCandidatesReadTool, map[string]any{}}, - {view.ConfigCandidatesReadTool, map[string]any{"key": "novox.r.7"}}, {view.PackagesReadTool, map[string]any{"module": "git.novox.be/novox/mesh-sdk/go"}}, {view.PackagesReadTool, nil}, } { diff --git a/modules/mesh-delivery-view/internal/view/names.go b/modules/mesh-delivery-view/internal/view/names.go index 6cc46244..047ae983 100644 --- a/modules/mesh-delivery-view/internal/view/names.go +++ b/modules/mesh-delivery-view/internal/view/names.go @@ -30,11 +30,9 @@ const ( TakenBucket = IndexerModule + "_taken" PackagesState = "packages" PackagesBucket = IndexerModule + "_" + PackagesState - // IndexerPredefinedState and IndexerConfigCandidatesState are the indexer's states of the foundation's predefined list - // and of the config candidates; PredefinedListKey is the one key of the first. - IndexerPredefinedState = "predefined" - PredefinedListKey = "list" - IndexerConfigCandidatesState = "config-candidates" + // IndexerPredefinedState is the indexer's state of the foundation's predefined list; PredefinedListKey its one key. + IndexerPredefinedState = "predefined" + PredefinedListKey = "list" // The seats mesh-module-assigner's and mesh-wants' views the process follows, its pictures named in the seat form // `_` (design 47 G §717, A-303): no module is named. Where a name must be the holder's real bucket (the diff --git a/modules/mesh-delivery-view/internal/view/read.go b/modules/mesh-delivery-view/internal/view/read.go index 0627b273..6df09c17 100644 --- a/modules/mesh-delivery-view/internal/view/read.go +++ b/modules/mesh-delivery-view/internal/view/read.go @@ -65,8 +65,8 @@ type Reader struct { // ConditionsState, AttemptsState, PresenceState and StuckState are what status reads beside the wants and the haves // (ADR 0564 §10): the condition keeper's open conditions, mesh-healers' attempts, the watchman's presence and stuck keys. ConditionsState, AttemptsState, PresenceState, StuckState StateRead - // PredefinedState and ConfigCandidatesState are the indexer's control records (ADR 0565 §2, §15); unset reads none. - PredefinedState, ConfigCandidatesState StateRead + // PredefinedState is the indexer's control record (ADR 0565 §2, §15); unset reads none. + PredefinedState StateRead // PackagesState is the indexer's published packages (PackagesBucket, ADR 0593 §2); unset reads none. PackagesState StateRead // GraphState is the indexer's module graph (graph.Bucket, ADR 0603 §2) and ProvisionsState the provisioner's keys: what @@ -90,8 +90,7 @@ type LogSince func(at time.Time, keys string, limit int) (*stdio.LogPage, error) // The read tools of the indexer's control records (ADR 0565 §15): the indexer serves no tool of its own (ADR 0437 §4). const ( - PredefinedReadTool = "indexer_predefined" - ConfigCandidatesReadTool = "indexer_config_candidates" + PredefinedReadTool = "indexer_predefined" // PackagesReadTool reads the indexer's published packages (ADR 0593 §2): what a fingerprint takes of a mesh package. PackagesReadTool = "indexer_packages" ) diff --git a/modules/mesh-delivery-view/manifest_test.go b/modules/mesh-delivery-view/manifest_test.go index bbb62347..9f56d84b 100644 --- a/modules/mesh-delivery-view/manifest_test.go +++ b/modules/mesh-delivery-view/manifest_test.go @@ -167,7 +167,7 @@ func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 // The indexer's and the assigner's states are asked of their owners' read tools (design 25 § 12.2), the six the process // follows then heard on their views families (ADR 0615 §1, §5; DLV-M4). if want := []invoke{{Verb: "mesh-delivery-assigner.assigner_read_differences"}, - {Verb: "mesh-delivery-assigner.assigner_read_wants"}, {Verb: "mesh-delivery-indexer.indexer_read_candidates"}, {Verb: "mesh-delivery-indexer.indexer_read_config_candidates"}, + {Verb: "mesh-delivery-assigner.assigner_read_wants"}, {Verb: "mesh-delivery-indexer.indexer_read_candidates"}, {Verb: "mesh-delivery-indexer.indexer_read_graph"}, {Verb: "mesh-delivery-indexer.indexer_read_heard"}, {Verb: "mesh-delivery-indexer.indexer_pending"}, {Verb: "mesh-delivery-indexer.indexer_read_packages"}, {Verb: "mesh-delivery-indexer.indexer_read_predefined"}, {Verb: "mesh-delivery-indexer.indexer_read_taken"}, {Verb: "mesh-delivery-teller.teller_read_answers"}, // A-175: the teller's answers by their views family @@ -223,7 +223,7 @@ func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 } // The two read tools of the indexer's modules (issue 1562), carried by a bundle the runtime launches; the indexer // itself serves no tool (ADR 0437 §4). Carrying them gives the tool runner read access to every bucket the view reads. - if want := []string{"view_status", "indexer_module", "indexer_modules", "indexer_candidate", "indexer_candidates", "indexer_predefined", "indexer_config_candidates", "indexer_packages", "builder_build", "builder_builds", "builder_history", "assigner_wants", "assigner_want", "assigner_differences", "node_haves", "node_trusts", "build_usage", "view_reach", "indexer_module_history", "indexer_heard", "view_tiers", "view_first_views", "view_first_view_again", "node_manifest_reads", "view_seat_list", "view_seat_list_again", "answers"}; !reflect.DeepEqual(m.Tools, want) { + if want := []string{"view_status", "indexer_module", "indexer_modules", "indexer_candidate", "indexer_candidates", "indexer_predefined", "indexer_packages", "builder_build", "builder_builds", "builder_history", "assigner_wants", "assigner_want", "assigner_differences", "node_haves", "node_trusts", "build_usage", "view_reach", "indexer_module_history", "indexer_heard", "view_tiers", "view_first_views", "view_first_view_again", "node_manifest_reads", "view_seat_list", "view_seat_list_again", "answers"}; !reflect.DeepEqual(m.Tools, want) { t.Errorf("tools = %v, want %v", m.Tools, want) } // D-11: the holders and buckets the view names are its manifest's (no contract names a holder, novox/hq ADR 0634 §1): a diff --git a/modules/mesh-delivery-view/module.json b/modules/mesh-delivery-view/module.json index 853ffb0f..5161ae9f 100644 --- a/modules/mesh-delivery-view/module.json +++ b/modules/mesh-delivery-view/module.json @@ -10,7 +10,6 @@ "indexer_candidate", "indexer_candidates", "indexer_predefined", - "indexer_config_candidates", "indexer_packages", "builder_build", "builder_builds", @@ -100,7 +99,6 @@ "mesh-delivery-assigner.assigner_read_differences", "mesh-delivery-assigner.assigner_read_wants", "mesh-delivery-indexer.indexer_read_candidates", - "mesh-delivery-indexer.indexer_read_config_candidates", "mesh-delivery-indexer.indexer_read_graph", "mesh-delivery-indexer.indexer_read_heard", "mesh-delivery-indexer.indexer_pending", -- 2.54.0 From bf642c45b7d6e4c3f81f77c7f8acb200bc175543 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 23:05:21 +0100 Subject: [PATCH 002/104] =?UTF-8?q?mesh-delivery:=20the=20old=20hand-kept?= =?UTF-8?q?=20mesh-catalog=20contract=20copy=20loses=20the=20config-candid?= =?UTF-8?q?ates=20layout=20(issue=201982;=20ADR=200681=20=C2=A72)=20The=20?= =?UTF-8?q?copy=20under=20contracts/go/seats/meshcatalog=20still=20held=20?= =?UTF-8?q?the=20layout,=20its=20key=20helpers,=20its=20constant=20and=20t?= =?UTF-8?q?wo=20fixture=20cases;=20nothing=20in=20contracts/=20or=20sdk/?= =?UTF-8?q?=20uses=20them,=20and=20ADR=200681=20=C2=A77's=20check=20greps?= =?UTF-8?q?=20the=20trunk=20for=20the=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: ADR 0681 §2 (mesh-sdk keeps no config-candidate layout; the contract keeps none), §7. --- contracts/go/seats/meshcatalog/contract.go | 77 ++----------------- .../go/seats/meshcatalog/contract_test.go | 12 --- 2 files changed, 6 insertions(+), 83 deletions(-) diff --git a/contracts/go/seats/meshcatalog/contract.go b/contracts/go/seats/meshcatalog/contract.go index 32870c7c..4c98ac35 100644 --- a/contracts/go/seats/meshcatalog/contract.go +++ b/contracts/go/seats/meshcatalog/contract.go @@ -58,13 +58,12 @@ const SubjectManifestAccepted = "mesh.seat.mesh-catalog.event.manifest-accepted" const SubjectManifestRefused = "mesh.seat.mesh-catalog.event.manifest-refused" const ( - StateManifests = "manifests" - StateModules = "modules" - StateCandidates = "candidates" - StateVerdicts = "verdicts" - StatePredefined = "predefined" - StateConfigCandidates = "config-candidates" - StatePackages = "packages" + StateManifests = "manifests" + StateModules = "modules" + StateCandidates = "candidates" + StateVerdicts = "verdicts" + StatePredefined = "predefined" + StatePackages = "packages" ) // ManifestsByDigestKey is the key of one value of the state manifests under the form "". @@ -221,37 +220,6 @@ func DecodePredefinedByListValue(raw []byte) (PredefinedByListValue, error) { return v, nil } -// ConfigCandidatesByPullKey is the key of one value of the state config-candidates under the form "". -func ConfigCandidatesByPullKey(pull string) string { return pull } - -// ParseConfigCandidatesByPullKey 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 ParseConfigCandidatesByPullKey(key string) (string, bool) { - rest := key - if rest == "" { - return "", false - } - v0 := rest - rest = "" - if rest != "" { - return "", false - } - return v0, true -} - -// DecodeConfigCandidatesByPullValue reads one value of the state config-candidates under the form "", refusing a field ConfigCandidatesByPullValue does not know and any text after the value. -func DecodeConfigCandidatesByPullValue(raw []byte) (ConfigCandidatesByPullValue, error) { - var v ConfigCandidatesByPullValue - 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 -} - // PackagesByModuleKey is the key of one value of the state packages under the form "". func PackagesByModuleKey(module string) string { return module } @@ -584,39 +552,6 @@ type PredefinedByListValue struct { V int64 `json:"v,omitempty"` } -// ConfigCandidatesByPullValueDeclaresValueValue is a type of the contract. -type ConfigCandidatesByPullValueDeclaresValueValue struct { - // the default - Default any `json:"default"` - Description string `json:"description,omitempty"` - // the allowed values - Enum any `json:"enum,omitempty"` - Kind string `json:"kind"` - // a declared bound; 0 is a bound, absent is none - Maximum *float64 `json:"maximum,omitempty"` - // a declared bound; 0 is a bound, absent is none - Minimum *float64 `json:"minimum,omitempty"` - Pattern string `json:"pattern,omitempty"` - Predefined string `json:"predefined,omitempty"` - Required bool `json:"required,omitempty"` - Runtime bool `json:"runtime,omitempty"` - Trusted bool `json:"trusted,omitempty"` - Type string `json:"type,omitempty"` - Why string `json:"why"` -} - -// ConfigCandidatesByPullValue is one value of the state config-candidates under the key . -type ConfigCandidatesByPullValue struct { - // when (RFC 3339 time) - At *time.Time `json:"at,omitempty"` - // module to key to declaration - Declares map[string]map[string]ConfigCandidatesByPullValueDeclaresValueValue `json:"declares"` - Head string `json:"head"` - Pull string `json:"pull"` - // the layout version - V int64 `json:"v,omitempty"` -} - // PackagesByModuleValuePackagesItem is a type of the contract. type PackagesByModuleValuePackagesItem struct { Digest string `json:"digest"` diff --git a/contracts/go/seats/meshcatalog/contract_test.go b/contracts/go/seats/meshcatalog/contract_test.go index b6d95b15..8c962d92 100644 --- a/contracts/go/seats/meshcatalog/contract_test.go +++ b/contracts/go/seats/meshcatalog/contract_test.go @@ -27,18 +27,6 @@ func TestFixtures(t *testing.T) { 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 pull request's configuration", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v ConfigCandidatesByPullValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a pull request's configuration state whose bounds are declared 0 (a zero is a bound, not none)", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v ConfigCandidatesByPullValue - 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}", decode: func(b []byte) (any, error) { var v PackagesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a package series", subject: "", given: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}", wire: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}", -- 2.54.0 From ce6edcd9b903621affe5f05d913bc281441a712d Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:36:30 +0100 Subject: [PATCH 003/104] C0: no seat definition names callers; the generator refuses one that does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every account may call every verb (ADR 0682 §10), so the callers lists of every seat definition and part of mesh-delivery-contracts go, and the generator, the one reader of definitions in this repository, refuses a verb or accepted kind that names callers instead of checking its forms. The generated contracts do not change: the generator made nothing of callers. Builds: design 47 H §752, §764 (every seat contract: the callers lists) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../parts/build-step.json | 20 -------- .../parts/registry.json | 17 ------- .../seats/container-image-registry/seat.json | 15 ------ .../seats/git/seat.json | 43 ----------------- .../seats/mesh-builds/seat.json | 11 +---- .../seats/mesh-catalog/seat.json | 36 --------------- .../seats/mesh-delivery/seat.json | 4 -- .../seats/mesh-wants/seat.json | 10 +--- .../seats/node-build-go/seat.json | 35 +++----------- .../seats/node-build-image/seat.json | 25 ++-------- .../seats/node-build-node/seat.json | 25 ++-------- .../seats/oci-artifact-registry/seat.json | 9 ---- modules/mesh-delivery-sdk/seatgen/callers.go | 46 ++----------------- .../mesh-delivery-sdk/seatgen/layout_test.go | 34 ++++++-------- .../contracts/seats/a-registry/seat.json | 2 +- 15 files changed, 38 insertions(+), 294 deletions(-) diff --git a/modules/mesh-delivery-contracts/parts/build-step.json b/modules/mesh-delivery-contracts/parts/build-step.json index 5f0261a3..fcaebd62 100644 --- a/modules/mesh-delivery-contracts/parts/build-step.json +++ b/modules/mesh-delivery-contracts/parts/build-step.json @@ -42,11 +42,6 @@ { "name": "drop", "description": "End an ask this node holds for a caller that no longer waits for it: a step not yet running is ended dropped when the bus gives it, one running is cancelled; both end the step dropped, naming who dropped it and why. Writes dropped. in the pauses state; the build module removes the key when it has acted.", - "callers": [ - "seat:mesh-pipeline-runner", - "seat:mesh-builds", - "seat:mesh-delivery-checker" - ], "input": { "type": "object", "properties": { @@ -153,20 +148,11 @@ "fp" ] }, - "callers": [ - "seat:node-engine" - ], "class": "read" }, { "name": "steps", "description": "Which pipeline steps an artifact can run, found by its language's convention (design 47 *Pipeline steps and the policy*): lint always, unit and integration tests where its packages hold them. Kept by the artifact's fingerprint; again finds them anew. With drop and why it deletes the artifact's kept key instead, writes the act in the hand-act log of the seat mesh-hand-acts first (a log that refuses deletes nothing and answers error), and answers dropped (design 47 G section 463, section 480).", - "callers": [ - "seat:mesh-pipeline-runner", - "seat:mesh-catalog", - "operator", - "sessions" - ], "input": { "type": "object", "properties": { @@ -237,12 +223,6 @@ { "name": "output", "class": "read", - "callers": [ - "seat:mesh-catalog", - "seat:mesh-wants", - "seat:mesh-delivery-checker", - "seat:mesh-pipeline-runner" - ], "description": "A step's answer by its ask, when the step's key or a run's step-ended names it as `output-object` because the answer is over what the steps state's value or the event carries (design 47 G A-254, A-290): the answer's bytes in chunks of at most 512 KiB on the chunk subject of the call, each acknowledged by the caller on the ack subject within 30 seconds; the answer is of any size. An answer inline in the key or the event is never asked here.", "input": { "type": "object", diff --git a/modules/mesh-delivery-contracts/parts/registry.json b/modules/mesh-delivery-contracts/parts/registry.json index 7dd7844e..dd6669b6 100644 --- a/modules/mesh-delivery-contracts/parts/registry.json +++ b/modules/mesh-delivery-contracts/parts/registry.json @@ -6,11 +6,6 @@ { "name": "publish", "description": "Open a transfer, naming the artifact and the digest of every part; answers the digests the holder lacks, which the caller then sends by publish-part. A transfer already open answers the parts held, so a cut transfer goes on from there. With no parts and a version, the held digest is published under that version and nothing is stored (the trunk's claim).", - "callers": [ - "seat:node-build-go", - "seat:node-build-node", - "seat:node-build-image" - ], "input": { "type": "object", "properties": { @@ -96,11 +91,6 @@ { "name": "publish-part", "description": "Send one chunk of one part of an open transfer; the last chunk of the last part ends the transfer, and the holder hashes what it received, asks builder_versions, stores it and says published or refused. A chunk's message stays under the bus's largest message (1 MiB), so at most 760 KiB of data, base64.", - "callers": [ - "seat:node-build-go", - "seat:node-build-node", - "seat:node-build-image" - ], "input": { "type": "object", "properties": { @@ -163,9 +153,6 @@ { "name": "versions", "description": "The versions the seat holds of one name, newest first: each one's version, tag, digest, kind and when it was published.", - "callers": [ - "invokers" - ], "input": { "type": "object", "properties": { @@ -207,10 +194,6 @@ { "name": "remove", "description": "Remove one tagged version; the holder refuses an untagged one but for the retention removal of a bundle, archive or copied base by the artifact sweep's holder. Every removal emits removed with its reason. A tagged version the store cannot remove alone, because another tag names its digest, stays whole, its tag and bytes kept: the answer says kept with the reason shared-digest and the tags still naming the digest, removed false, and kept is emitted, never removed; the caller ends there without a retry.", - "callers": [ - "seat:mesh-builds", - "seat:mesh-artifact-sweep" - ], "input": { "type": "object", "properties": { diff --git a/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json b/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json index 2afa16bc..ef6d16cd 100644 --- a/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json +++ b/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json @@ -13,9 +13,6 @@ { "name": "mirror", "description": "Copy an outside image into the store by its pinned digest; emits published or refused.", - "callers": [ - "seat:node-build-image" - ], "input": { "type": "object", "properties": { @@ -60,9 +57,6 @@ { "name": "tags", "description": "The tags of one image and the digest each names.", - "callers": [ - "invokers" - ], "input": { "type": "object", "properties": { @@ -114,9 +108,6 @@ { "name": "hold", "description": "Keep one untagged bundle, archive or copied base from removal by retention, as the artifact sweep's rules keep it (ADR 0617 \u00a72); never an image of the holder's own. Emits held.", - "callers": [ - "seat:mesh-artifact-sweep" - ], "input": { "type": "object", "properties": { @@ -160,9 +151,6 @@ { "name": "release", "description": "Let a hold go; emits released. A release of what is not held answers released false and emits nothing, never an error: the outcome asked holds already. By hand only through the holder's own tool, the operator's session as the proved caller, recorded as a hand act.", - "callers": [ - "seat:mesh-artifact-sweep" - ], "input": { "type": "object", "properties": { @@ -202,9 +190,6 @@ { "name": "list", "description": "What the store holds of one repository, or of every repository the seat holds when none is named: every image manifest and index, each with its digest, whether it is an index (and the manifests an index names), the tags naming it, its size and whether it is held. Read from the store itself, so a manifest no tag names is listed too; it reads only (ADR 0632 \u00a73).", - "callers": [ - "invokers" - ], "input": { "type": "object", "properties": { diff --git a/modules/mesh-delivery-contracts/seats/git/seat.json b/modules/mesh-delivery-contracts/seats/git/seat.json index 283ca432..c24a4f12 100644 --- a/modules/mesh-delivery-contracts/seats/git/seat.json +++ b/modules/mesh-delivery-contracts/seats/git/seat.json @@ -52,9 +52,6 @@ }, "description": "what pull answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -107,9 +104,6 @@ }, "description": "what branch answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -143,9 +137,6 @@ "pulls" ] }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -210,9 +201,6 @@ }, "description": "what tags answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -304,9 +292,6 @@ }, "description": "what trees answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -373,9 +358,6 @@ }, "description": "what file answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -436,9 +418,6 @@ }, "description": "what contains answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -493,9 +472,6 @@ }, "description": "what statuses answers; error and error-kind alone when it fails" }, - "callers": [ - "invokers" - ], "class": "read" }, { @@ -578,9 +554,6 @@ }, "description": "what status answers; error and error-kind alone when it fails" }, - "callers": [ - "module:mesh-delivery-forge-bridge" - ], "class": "act" }, { @@ -642,9 +615,6 @@ }, "description": "what comment answers; error and error-kind alone when it fails" }, - "callers": [ - "module:mesh-delivery-forge-bridge" - ], "class": "act" }, { @@ -706,9 +676,6 @@ }, "description": "what view answers; error and error-kind alone when it fails" }, - "callers": [ - "module:mesh-delivery-forge-bridge" - ], "class": "act" }, { @@ -771,9 +738,6 @@ }, "description": "what note answers; error and error-kind alone when it fails" }, - "callers": [ - "module:mesh-delivery-forge-bridge" - ], "class": "act" }, { @@ -866,18 +830,11 @@ }, "description": "what merge-pull answers; error and error-kind alone when it fails" }, - "callers": [ - "persons", - "sessions" - ], "class": "act" }, { "name": "tag", "class": "act", - "callers": [ - "seat:mesh-builds" - ], "description": "Write the git tag of a released version, go/vMAJOR.MINOR.PATCH, at the commit its build was made from; the builder writes it only on the catalog's version-released (design 47 G section 370). A tag already at that commit is answered performed. An error answer carries error and error-kind.", "input": { "type": "object", diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json index b9920457..d10eec4f 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json @@ -10,12 +10,6 @@ { "name": "reserved", "class": "read", - "callers": [ - "seat:go-package-registry", - "seat:npm-package-registry", - "seat:container-image-registry", - "seat:oci-artifact-registry" - ], "description": "A module's reserved version with each artifact's digest, for a registry holder deciding whether to publish; asked by the module or by a package's name in its ecosystem (design 47 G section 369, section 478; design 51, Publishing).", "input": { "type": "object", @@ -83,10 +77,7 @@ "name": "step", "body": { "$ref": "#/defs/StepRun" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } } ], "events": [ diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index f8163534..ba7fdd0f 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -355,10 +355,6 @@ { "name": "register", "description": "Register a module whole, as an authorising ask of tier approve naming every value; written only on its warrant, a Decline or an expiry writes nothing. Refuses a watched branch the forge does not protect, read through the seat git's branch, and code review as a required step until forge accounts are bound to bus identities (ADR 0666 sections 2, 3, 22).", - "callers": [ - "operator", - "sessions" - ], "input": { "type": "object", "properties": { @@ -381,10 +377,6 @@ { "name": "policy", "description": "Change one module's step statuses, or one artifact's, as an authorising ask naming each moved status on its own line; refuses code review as required (ADR 0666 sections 2, 22).", - "callers": [ - "operator", - "sessions" - ], "input": { "type": "object", "properties": { @@ -415,10 +407,6 @@ { "name": "watch", "description": "Add a watched branch to a module's registration, as an authorising ask; refuses a branch the forge does not protect, naming it (ADR 0666 sections 2, 3).", - "callers": [ - "operator", - "sessions" - ], "input": { "type": "object", "properties": { @@ -445,10 +433,6 @@ { "name": "unwatch", "description": "Remove a watched branch from a module's registration, as an authorising ask (ADR 0666 section 2).", - "callers": [ - "operator", - "sessions" - ], "input": { "type": "object", "properties": { @@ -475,15 +459,6 @@ { "name": "versions", "class": "read", - "callers": [ - "seat:mesh-builds", - "seat:go-package-registry", - "seat:npm-package-registry", - "seat:container-image-registry", - "seat:oci-artifact-registry", - "persons", - "sessions" - ], "description": "A module's released versions, each artifact's digest, the source revision built and its edge entries; a reserved version is not in it (design 47 G section 349).", "input": { "type": "object", @@ -520,12 +495,6 @@ { "name": "outdated", "class": "read", - "callers": [ - "persons", - "sessions", - "healers", - "seat:mesh-pipeline-runner" - ], "description": "Every entry behind, by the part's digest: its module and version or build, the kind, the dependency with its watched branch and source revision, what was recorded and what is newest, and the act; may be asked for one dependency (design 47 G section 375).", "input": { "type": "object", @@ -558,11 +527,6 @@ { "name": "input", "class": "read", - "callers": [ - "seat:node-build-go", - "seat:node-build-node", - "seat:node-build-image" - ], "description": "A step's input by its digest, as the indexer keeps it for a validation step it asked a build seat to run (design 47 G section 354): its fields, then the bytes in chunks of at most 512 KiB on the chunk subject of the call, each acknowledged by the caller on the ack subject within 30 seconds; the input is of any size.", "input": { "type": "object", diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json index 93f31549..f6f75f8b 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json @@ -164,10 +164,6 @@ { "name": "recovery", "class": "act", - "callers": [ - "operator", - "sessions" - ], "description": "Mark a merge its author names a recovery: the commit and why; the delivery record is marked recovery with the caller the runtime proves, and recovery-merged is said (design 47 G section 305).", "input": { "type": "object", diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json index beece893..597df58f 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json @@ -159,11 +159,6 @@ { "name": "input", "class": "read", - "callers": [ - "seat:node-build-go", - "seat:node-build-node", - "seat:node-build-image" - ], "description": "A step's input by its digest, as the assigner keeps it for the composition step it asked a build seat to run (design 47 G section 354): its fields, then the bytes in chunks of at most 512 KiB on the chunk subject of the call, each acknowledged by the caller on the ack subject within 30 seconds; the input is of any size.", "input": { "type": "object", @@ -289,10 +284,7 @@ "name": "step", "body": { "$ref": "#/defs/StepRun" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } } ], "events": [ diff --git a/modules/mesh-delivery-contracts/seats/node-build-go/seat.json b/modules/mesh-delivery-contracts/seats/node-build-go/seat.json index f9be14f8..44ad2671 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-go/seat.json +++ b/modules/mesh-delivery-contracts/seats/node-build-go/seat.json @@ -19,63 +19,40 @@ "name": "delivery", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-builds" - ] + } }, { "name": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-delivery-checker", - "seat:mesh-catalog", - "seat:mesh-pipeline-runner" - ] + } }, { "name": "step", "stream": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } }, { "name": "step", "stream": "delivery", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } }, { "name": "recheck", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-delivery-checker" - ] + } }, { "name": "run", "stream": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner", - "seat:mesh-catalog", - "seat:mesh-wants", - "seat:mesh-delivery-checker" - ] + } } ], "description": "The Go build module on a node: it takes the asks of the builder and the checker, runs them as steps and answers.", diff --git a/modules/mesh-delivery-contracts/seats/node-build-image/seat.json b/modules/mesh-delivery-contracts/seats/node-build-image/seat.json index 57b1f438..fe1d6afd 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-image/seat.json +++ b/modules/mesh-delivery-contracts/seats/node-build-image/seat.json @@ -19,48 +19,33 @@ "name": "delivery", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-builds" - ] + } }, { "name": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-delivery-checker" - ] + } }, { "name": "step", "stream": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } }, { "name": "step", "stream": "delivery", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } }, { "name": "recheck", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-delivery-checker" - ] + } } ], "description": "The image build module on a node: it takes the asks of the builder and the checker, runs them as steps and answers.", diff --git a/modules/mesh-delivery-contracts/seats/node-build-node/seat.json b/modules/mesh-delivery-contracts/seats/node-build-node/seat.json index 910ff77c..a291d993 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-node/seat.json +++ b/modules/mesh-delivery-contracts/seats/node-build-node/seat.json @@ -19,48 +19,33 @@ "name": "delivery", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-builds" - ] + } }, { "name": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-delivery-checker" - ] + } }, { "name": "step", "stream": "check", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } }, { "name": "step", "stream": "delivery", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-pipeline-runner" - ] + } }, { "name": "recheck", "body": { "$ref": "#/defs/StepAsk" - }, - "callers": [ - "seat:mesh-delivery-checker" - ] + } } ], "description": "The Node build module on a node: it takes the asks of the builder and the checker, runs them as steps and answers.", diff --git a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json index 5db56ae1..a4fda915 100644 --- a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json +++ b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json @@ -13,9 +13,6 @@ { "name": "hold", "description": "Keep one untagged bundle, archive or copied base from removal by retention, as the artifact sweep's rules keep it (ADR 0617 \u00a72); never an image of the holder's own. Emits held.", - "callers": [ - "seat:mesh-artifact-sweep" - ], "input": { "type": "object", "properties": { @@ -59,9 +56,6 @@ { "name": "release", "description": "Let a hold go; emits released. A release of what is not held answers released false and emits nothing, never an error: the outcome asked holds already. By hand only through the holder's own tool, the operator's session as the proved caller, recorded as a hand act.", - "callers": [ - "seat:mesh-artifact-sweep" - ], "input": { "type": "object", "properties": { @@ -101,9 +95,6 @@ { "name": "list", "description": "What the store holds of one repository, or of every repository the seat holds when none is named: every manifest keeping one bundle or archive, each with its digest, whether it is an index (and the manifests an index names), the tags naming it, its size and whether it is held. Read from the store itself, so a manifest no tag names is listed too; it reads only (ADR 0632 \u00a73).", - "callers": [ - "invokers" - ], "input": { "type": "object", "properties": { diff --git a/modules/mesh-delivery-sdk/seatgen/callers.go b/modules/mesh-delivery-sdk/seatgen/callers.go index a4a40d55..1fb90987 100644 --- a/modules/mesh-delivery-sdk/seatgen/callers.go +++ b/modules/mesh-delivery-sdk/seatgen/callers.go @@ -3,35 +3,10 @@ package seatgen import ( "encoding/json" "fmt" - re "regexp" - "strings" ) -// callerName is a seat's or a module's name inside a caller entry. -var callerName = re.MustCompile(`^[a-z][a-z0-9]*(-[a-z0-9]+)*$`) - -// callerClasses are the entries that take no name (design 47 G §336, §392). -var callerClasses = map[string]bool{"operator": true, "healers": true, "persons": true, "sessions": true, "invokers": true} - -// callerForm says whether an entry is one of the forms of design 47 G §336 as §392 writes them: `operator`, `healers`, -// `persons`, `sessions`, `invokers`, `seat:`, `module:` and `holder:@same-node`. -func callerForm(entry string) bool { - switch { - case callerClasses[entry]: - return true - case strings.HasPrefix(entry, "seat:"): - return callerName.MatchString(strings.TrimPrefix(entry, "seat:")) - case strings.HasPrefix(entry, "module:"): - return callerName.MatchString(strings.TrimPrefix(entry, "module:")) - case strings.HasPrefix(entry, "holder:") && strings.HasSuffix(entry, "@same-node"): - return callerName.MatchString(strings.TrimSuffix(strings.TrimPrefix(entry, "holder:"), "@same-node")) - } - return false -} - -// checkCallers refuses a definition or part whose verb or accepted kind names a `callers` that is no list of the -// forms of §336, naming the entry (design 47 G §339: the generator reads `callers` and makes nothing of it; the -// grants part reads them from the definition). Text, the old form, is refused as one entry. +// checkCallers refuses a definition or part whose verb or accepted kind names `callers`, naming the entry: no seat +// definition names callers, every account may call every verb (design 47 H §752, §764; ADR 0682 §10). func checkCallers(file string, raw []byte) error { var doc struct { Verbs []callerHolder `json:"verbs"` @@ -45,21 +20,8 @@ func checkCallers(file string, raw []byte) error { items []callerHolder }{{"verbs", doc.Verbs}, {"accepts", doc.Accepts}} { for _, it := range group.items { - if len(it.Callers) == 0 { - continue - } - var list []string - if err := json.Unmarshal(it.Callers, &list); err != nil { - var text string - if json.Unmarshal(it.Callers, &text) != nil { - return fmt.Errorf("%s: %s %q: callers is neither a list nor text", file, group.field, it.Name) - } - list = []string{text} - } - for _, e := range list { - if !callerForm(e) { - return fmt.Errorf("%s: %s %q: caller %q is no form of the format (operator, healers, persons, sessions, invokers, seat:, module:, holder:@same-node)", file, group.field, it.Name, e) - } + if it.Callers != nil { + return fmt.Errorf("%s: %s %q names callers: no seat definition names callers (design 47 H §752)", file, group.field, it.Name) } } } diff --git a/modules/mesh-delivery-sdk/seatgen/layout_test.go b/modules/mesh-delivery-sdk/seatgen/layout_test.go index 0d86fa16..144b73e3 100644 --- a/modules/mesh-delivery-sdk/seatgen/layout_test.go +++ b/modules/mesh-delivery-sdk/seatgen/layout_test.go @@ -181,38 +181,34 @@ func TestEachSeatDefinedWholeIsAGoModuleOfItsOwn(t *testing.T) { } } -// TestCallersAreTheFormsOfTheFormat is design 47 G §339's check: the generator refuses a definition (or a part) -// whose verb or accepted kind names a caller that is no form of §336, naming the entry, and the contracts it writes -// carry no caller check. -func TestCallersAreTheFormsOfTheFormat(t *testing.T) { - for _, tc := range []struct { - name, callers, refused string - }{ - {"every form", `["operator","healers","persons","sessions","invokers","seat:mesh-wants","module:gitea","holder:node-backup@same-node"]`, ""}, - {"text", `"any caller whose role grants it"`, "any caller whose role grants it"}, - {"a bare seat name", `["mesh-wants"]`, "mesh-wants"}, - {"holder without the node", `["holder:node-backup"]`, "holder:node-backup"}, - {"seat with no name", `["seat:"]`, "seat:"}, +// TestADefinitionNamingCallersIsRefused is design 47 H §752's check for the generator (C0/AC1): a definition (or a +// part) whose verb or accepted kind names callers, in any form, is refused naming the entry, and the contracts it +// writes carry no caller check. +func TestADefinitionNamingCallersIsRefused(t *testing.T) { + for _, tc := range []struct{ name, callers string }{ + {"a list of forms", `["operator","seat:mesh-wants"]`}, + {"text", `"any caller whose role grants it"`}, + {"an empty list", `[]`}, } { for _, place := range []string{"verbs", "accepts"} { t.Run(tc.name+"/"+place, func(t *testing.T) { raw := []byte(`{"format":1,"seat":"x","` + place + `":[{"name":"v","callers":` + tc.callers + `}]}`) err := checkCallers("seats/x/seat.json", raw) - switch { - case tc.refused == "" && err != nil: - t.Fatalf("refused: %v", err) - case tc.refused != "" && (err == nil || !strings.Contains(err.Error(), tc.refused) || !strings.Contains(err.Error(), "seats/x/seat.json")): - t.Fatalf("error %v, want one naming %q", err, tc.refused) + if err == nil || !strings.Contains(err.Error(), `"v"`) || !strings.Contains(err.Error(), "seats/x/seat.json") { + t.Fatalf("error %v, want one naming the entry", err) } }) } } - // Load refuses an unknown entry in a definition before it reads it. + if err := checkCallers("seats/x/seat.json", []byte(`{"format":1,"seat":"x","verbs":[{"name":"v"}]}`)); err != nil { + t.Fatalf("a verb naming no callers refused: %v", err) + } + // Load refuses a definition naming callers before it reads it. dir := t.TempDir() if err := os.MkdirAll(dir+"/seats/x", 0o755); err != nil { t.Fatal(err) } - def := `{"format":1,"seat":"x","scope":"mesh","grain":"seat-list","verbs":[{"name":"v","callers":["somebody"]}]}` + def := `{"format":1,"seat":"x","scope":"mesh","grain":"seat-list","verbs":[{"name":"somebody","callers":["persons"]}]}` if err := os.WriteFile(dir+"/seats/x/seat.json", []byte(def), 0o644); err != nil { t.Fatal(err) } diff --git a/modules/mesh-delivery-sdk/seatgen/testdata/contracts/seats/a-registry/seat.json b/modules/mesh-delivery-sdk/seatgen/testdata/contracts/seats/a-registry/seat.json index dbcd3a8a..d719b537 100644 --- a/modules/mesh-delivery-sdk/seatgen/testdata/contracts/seats/a-registry/seat.json +++ b/modules/mesh-delivery-sdk/seatgen/testdata/contracts/seats/a-registry/seat.json @@ -1,5 +1,5 @@ {"format":1,"seat":"a-registry","scope":"mesh","grain":"whole","domain":"Module","decision":"ADR 1","includes":["registry"], - "verbs":[{"name":"hold","class":"read","callers":["invokers","persons","sessions","seat:b-registry","module:gitea","operator","healers","holder:node-backup@same-node"],"input":{"type":"object"},"answer":{"type":"object"}}, + "verbs":[{"name":"hold","class":"read","input":{"type":"object"},"answer":{"type":"object"}}, {"name":"peek","input":{"type":"object"},"answer":{"$ref":"#/bodies/Finding"}}], "accepts":[ {"name":"step","stream":"check","body":{"type":"object","properties":{"id":{"type":"string"}}}}, -- 2.54.0 From 8e5e5dbb4232e6663991344adfe7271d5b1d80c3 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:36:37 +0100 Subject: [PATCH 004/104] seatgen: an identifier splits on ':' too, so want:version is a Go constant The node-engine seat's enum value want:version must yield a parseable Go constant; ':' splits as '-', '_', '.' and a space do. No existing generated output changes (the generator's check of mesh-delivery-contracts is unchanged). Builds: design 47 H lead answer H-A-64 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- modules/mesh-delivery-sdk/seatgen/layout_test.go | 11 +++++++++++ modules/mesh-delivery-sdk/seatgen/load.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-sdk/seatgen/layout_test.go b/modules/mesh-delivery-sdk/seatgen/layout_test.go index 144b73e3..140ee906 100644 --- a/modules/mesh-delivery-sdk/seatgen/layout_test.go +++ b/modules/mesh-delivery-sdk/seatgen/layout_test.go @@ -373,3 +373,14 @@ func TestBodiesAreTypesAndAcceptedKindsRideStreams(t *testing.T) { t.Errorf("index.js lacks the delivery stream's subject:\n%s", js) } } + +// TestAnIdentifierSplitsOnEverySeparator is H-A-64's check: an enum value such as `want:version` yields a parseable +// Go identifier, `:` splitting as `-`, `_`, `.` and a space do. +func TestAnIdentifierSplitsOnEverySeparator(t *testing.T) { + for name, want := range map[string]string{"want:version": "WantVersion", "publish-part": "PublishPart", + "step_id": "StepID", "a.b c": "ABC", "cap-mib": "CapMiB"} { + if got := ident(name); got != want { + t.Errorf("ident(%q) = %q, want %q", name, got, want) + } + } +} diff --git a/modules/mesh-delivery-sdk/seatgen/load.go b/modules/mesh-delivery-sdk/seatgen/load.go index 62c42967..9a83d4b6 100644 --- a/modules/mesh-delivery-sdk/seatgen/load.go +++ b/modules/mesh-delivery-sdk/seatgen/load.go @@ -182,7 +182,7 @@ func pkgName(name string) string { return strings.ReplaceAll(name, "-", "") } // PreviewWritten, local-name → LocalName, id → ID. func ident(name string) string { var b strings.Builder - for _, w := range strings.FieldsFunc(name, func(r rune) bool { return r == '-' || r == '_' || r == '.' || r == ' ' }) { + for _, w := range strings.FieldsFunc(name, func(r rune) bool { return r == '-' || r == '_' || r == '.' || r == ' ' || r == ':' }) { switch w { case "id": b.WriteString("ID") -- 2.54.0 From f006ab50bcc2e5759627f20fa7e5a9c62501032d Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:41:07 +0100 Subject: [PATCH 005/104] C1: the take-in's form is the lines' fields; policies gain validate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit take-in.taken carries branch, source, revision, call, entries (one {module, commit, fingerprint, repository} per mover, no pull), skipped, and by and why for a hand act; take-in.pending carries branch, source and why; the keys, kinds, merges, groups and the other fields of the earlier take-in go, so readers pair a wait by . (H-A-31). StepStatuses gains validate before composition; the seat says no manifest-accepted or manifest-refused. Builds: design 47 H §743, §744, §745, §763 (G §476, §648), §764 (the indexer's manifest events); lead answer H-A-31 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../clients/meshcatalogclient/catalog_test.go | 68 +++- .../go/seats/meshcatalog/contract.go | 161 ++------ .../seats/mesh-catalog/seat.json | 367 +++--------------- .../ts/seats/meshcatalog/index.d.ts | 149 ++----- .../ts/seats/meshcatalog/index.js | 6 - 5 files changed, 161 insertions(+), 590 deletions(-) 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 b56f9be0..78a304fd 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" + "slices" "strings" "testing" @@ -167,23 +168,62 @@ func TestCandidatesKeyEscapesTheGroupAndReadsBack(t *testing.T) { } } -// CT15 (design 47 G §476, §493, §648): the seat's `bodies` give the types the indexer writes and the runner reads: a -// take-in.taken names its branch, source revision and entries (an entry of a merged message names its pull request), -// a take-in.pending its branch, and a revision answer for a branch with no revision yet is `none-yet` alone. +// CT15 (design 47 H §743, §744, §745, §763): the seat's `bodies` give the types the indexer writes and the runner +// reads: each take-in body reads back as the lines' fields alone, an entry naming pull loses it, a policy holds +// validate, the seat says no manifest event, and a revision answer for a branch with no revision yet is `none-yet` +// alone. func TestTakeInBodiesAndNoneYetAreTheSeatsTypes(t *testing.T) { - var taken seat.TakeInTaken - body := `{"v":1,"kind":"taken","key":"m.00000000000000000007","what":"revision","branch":"beta","source":3590,"since":"2026-11-11T10:00:00Z",` + - `"merges":[{"repository":"novox/mesh-sdk","number":9,"merge":"cc"}],` + - `"entries":[{"module":"nats","commit":"cc","fingerprint":"src2:aa","repository":"novox/mesh-sdk","pull":9},{"module":"zsh","commit":"cc","fingerprint":"src2:bb"}]}` - if err := json.Unmarshal([]byte(body), &taken); err != nil { - t.Fatal(err) + roundTrip := func(given string, into any) string { + t.Helper() + if err := json.Unmarshal([]byte(given), into); err != nil { + t.Fatal(err) + } + b, err := json.Marshal(into) + if err != nil { + t.Fatal(err) + } + return string(b) } - if taken.Branch != "beta" || taken.Source != 3590 || len(taken.Entries) != 2 || taken.Entries[0].Pull != 9 || taken.Entries[1].Repository != "" { - t.Errorf("take-in.taken read as %+v", taken) + for _, tc := range []struct { + name, given, wire string + into any + }{ + { // C1/AC1 (§743, §763) + name: "taken with movers, an entry's pull dropped", + given: `{"branch":"main","source":1044,"revision":1044,"call":"0123456789abcdef","entries":[{"module":"mesh-sdk","commit":"aaaa","fingerprint":"fp1","repository":"novox/mesh-sdk","pull":7}]}`, + wire: `{"branch":"main","call":"0123456789abcdef","entries":[{"commit":"aaaa","fingerprint":"fp1","module":"mesh-sdk","repository":"novox/mesh-sdk"}],"revision":1044,"source":1044}`, + into: &seat.TakeInTaken{}, + }, + { // C1/AC2 (§744): a skip by hand + name: "taken, skipped", + given: `{"branch":"main","source":1045,"call":"0123456789abcdef","skipped":true,"by":"lead@workstation","why":"store full"}`, + wire: `{"branch":"main","by":"lead@workstation","call":"0123456789abcdef","skipped":true,"source":1045,"why":"store full"}`, + into: &seat.TakeInTaken{}, + }, + { // C1/AC2 (§744) + name: "pending", + given: `{"branch":"main","source":1045,"why":"the catalog store is full"}`, + wire: `{"branch":"main","source":1045,"why":"the catalog store is full"}`, + into: &seat.TakeInPending{}, + }, + { // C1/AC3 (§745) + name: "a policy's validate", + given: `{"validate":"required"}`, + wire: `{"validate":"required"}`, + into: &seat.StepStatuses{}, + }, + } { + t.Run(tc.name, func(t *testing.T) { + if got := roundTrip(tc.given, tc.into); got != tc.wire { + t.Errorf("reads back as %s, want %s", got, tc.wire) + } + }) } - var pending seat.TakeInPending - if err := json.Unmarshal([]byte(`{"v":1,"kind":"pending","key":"m.1","what":"revision","branch":"beta","since":"2026-11-11T10:00:00Z","merges":[]}`), &pending); err != nil || pending.Branch != "beta" { - t.Errorf("take-in.pending read as %+v, %v", pending, err) + // C1/AC3 (§745, §764): the seat says no manifest-accepted or manifest-refused. + for _, e := range []string{"manifest-accepted", "manifest-refused"} { + if slices.Contains(seat.Events(), e) { + t.Errorf("the seat still says %s", e) + } } var none seat.RevisionAnswer if err := json.Unmarshal([]byte(`{"none-yet":true}`), &none); err != nil || !none.NoneYet || none.Revision != nil { diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 5458633b..f236b5e6 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -35,8 +35,6 @@ const ( const ( EventSeatDefinitionChanged = "seat-definition-changed" EventSeatDefinitionRemoved = "seat-definition-removed" - EventManifestAccepted = "manifest-accepted" - EventManifestRefused = "manifest-refused" EventCatalogRevision = "catalog-revision" EventFilling = "filling" EventFull = "full" @@ -53,7 +51,7 @@ func Verbs() []string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventSeatDefinitionChanged, EventSeatDefinitionRemoved, EventManifestAccepted, EventManifestRefused, EventCatalogRevision, EventFilling, EventFull, EventRoom, EventRegistrationChanged, EventVersionReleased, EventVersionsFilled} + return []string{EventSeatDefinitionChanged, EventSeatDefinitionRemoved, EventCatalogRevision, EventFilling, EventFull, EventRoom, EventRegistrationChanged, EventVersionReleased, EventVersionsFilled} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -68,12 +66,6 @@ const SubjectSeatDefinitionChanged = "mesh.seat.mesh-catalog.event.seat-definiti // SubjectSeatDefinitionRemoved is where seat-definition-removed is published. const SubjectSeatDefinitionRemoved = "mesh.seat.mesh-catalog.event.seat-definition-removed" -// SubjectManifestAccepted is where manifest-accepted is published. -const SubjectManifestAccepted = "mesh.seat.mesh-catalog.event.manifest-accepted" - -// SubjectManifestRefused is where manifest-refused is published. -const SubjectManifestRefused = "mesh.seat.mesh-catalog.event.manifest-refused" - // SubjectCatalogRevision is where catalog-revision is published, on mesh.seat.mesh-catalog.event.catalog-revision.. func SubjectCatalogRevision(branch string) string { return "mesh.seat.mesh-catalog.event.catalog-revision." + branch @@ -940,6 +932,8 @@ type StepStatuses struct { Review string `json:"review,omitempty"` // required runs and holds the delivery until it passes; optional runs, a failure is shown and may be accepted; bypass runs nothing and is said as bypassed Unit string `json:"unit,omitempty"` + // required runs and holds the delivery until it passes; optional runs, a failure is shown and may be accepted; bypass runs nothing and is said as bypassed + Validate string `json:"validate,omitempty"` } // The values of StepStatuses's approval. @@ -984,6 +978,13 @@ const ( StepStatusesUnitBypass = "bypass" ) +// The values of StepStatuses's validate. +const ( + StepStatusesValidateRequired = "required" + StepStatusesValidateOptional = "optional" + StepStatusesValidateBypass = "bypass" +) + // ToolchainUsed is a toolchain a fingerprint was computed with (ADR 0405 clause 7). type ToolchainUsed struct { Language string `json:"language"` @@ -1034,107 +1035,43 @@ type VersionEntry struct { Version string `json:"version"` } -// TakeInEntry is one module of a taken-in revision (design 47 G section 476, section 648). +// TakeInEntry is one mover of a taken-in source revision (design 47 H §743, §763). type TakeInEntry struct { Commit string `json:"commit"` // the module's build-input fingerprint at the commit Fingerprint string `json:"fingerprint"` Module string `json:"module"` - // from a merged message; absent for a pushed one (design 47 G section 648) - Pull int64 `json:"pull,omitempty"` - // from a merged message; absent for a pushed one (design 47 G section 648) - Repository string `json:"repository,omitempty"` -} - -// TakeInMember is one pull request at one commit. -type TakeInMember struct { - Head string `json:"head"` - Number int64 `json:"number"` + // the repository the module is registered for Repository string `json:"repository"` } -// TakeInMerge is one merge a take-in event holds: the repository, its pull request and the merge commit the forge made of it. -type TakeInMerge struct { - Merge string `json:"merge"` - Number int64 `json:"number"` - Repository string `json:"repository"` -} - -// TakeInPending is the body of the indexer's take-in.pending: a wait for a revision or a group, with the watched branch (design 47 G section 493). +// TakeInPending is the body of the indexer's take-in.pending: a source revision's take-in held, said once per source (design 47 H §744). type TakeInPending struct { - // the watched branch the revision is of (design 47 G section 476, section 493) - Branch string `json:"branch,omitempty"` - // who acted by hand, on a taken event - By string `json:"by,omitempty"` - // a hand drop: the merges are not taken in - Dropped bool `json:"dropped,omitempty"` - // the delivery group, for a group being gathered - Group string `json:"group,omitempty"` - // the wait's key: m. of its oldest merge, or g. for a group being gathered - Key string `json:"key"` - // the event's kind, pending or taken - Kind string `json:"kind"` - // the keys of merges whose message the forge bridge's stream no longer holds - Lost []string `json:"lost,omitempty"` - // every approved member of a group with its head - Members []TakeInMember `json:"members,omitempty"` - // the merges it holds, oldest first - Merges []TakeInMerge `json:"merges"` - // why the indexer holds a merge it does not take in although no indexer build is named - OwnBuildUnknown string `json:"own-build-unknown,omitempty"` - // why the manifest of the indexer the revision names was refused - Refused string `json:"refused,omitempty"` - // when the wait began - Since time.Time `json:"since"` - // the layout version - V int64 `json:"v"` - // the indexer build a revision waits for - WaitsFor string `json:"waits-for,omitempty"` - // what waits: a revision or a group - What string `json:"what"` - // why they acted by hand, on a taken event - Why string `json:"why,omitempty"` + // the watched branch + Branch string `json:"branch"` + // the source revision held + Source int64 `json:"source"` + // why it cannot be written, such as the catalog store full + Why string `json:"why"` } -// TakeInTaken is the body of the indexer's take-in.taken: a wait ended, with the branch, the source revision and the entries (design 47 G section 476, section 493). +// TakeInTaken is the body of the indexer's take-in.taken: a source revision taken in, said once, with one entry per mover (design 47 H §743, §744). type TakeInTaken struct { - // the watched branch the revision is of (design 47 G section 476, section 493) - Branch string `json:"branch,omitempty"` - // who acted by hand, on a taken event + // the watched branch + Branch string `json:"branch"` + // who acted by hand By string `json:"by,omitempty"` - // a hand drop: the merges are not taken in - Dropped bool `json:"dropped,omitempty"` - // one entry per module of that revision; none for a hand drop (design 47 G section 476, section 493) + // the merge call the source revision names + Call string `json:"call"` + // one entry per mover; none for a take-in with no mover or a skip Entries []TakeInEntry `json:"entries,omitempty"` - // the delivery group, for a group being gathered - Group string `json:"group,omitempty"` - // the wait's key: m. of its oldest merge, or g. for a group being gathered - Key string `json:"key"` - // the event's kind, pending or taken - Kind string `json:"kind"` - // the keys of merges whose message the forge bridge's stream no longer holds - Lost []string `json:"lost,omitempty"` - // every approved member of a group with its head - Members []TakeInMember `json:"members,omitempty"` - // the merges it holds, oldest first - Merges []TakeInMerge `json:"merges"` - // why the indexer holds a merge it does not take in although no indexer build is named - OwnBuildUnknown string `json:"own-build-unknown,omitempty"` - // why the manifest of the indexer the revision names was refused - Refused string `json:"refused,omitempty"` - // the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448) + // the catalog revision of the branch the take-in wrote; absent for a skip Revision int64 `json:"revision,omitempty"` - // when the wait began - Since time.Time `json:"since"` - // the source revision taken in (design 47 G section 476) - Source int64 `json:"source,omitempty"` - // the layout version - V int64 `json:"v"` - // the indexer build a revision waits for - WaitsFor string `json:"waits-for,omitempty"` - // what waits: a revision or a group - What string `json:"what"` - // why they acted by hand, on a taken event + // acknowledged unwritten by the tool indexer_take_in_skip (design 47 H §744) + Skipped bool `json:"skipped,omitempty"` + // the source revision taken in + Source int64 `json:"source"` + // why they acted by hand Why string `json:"why,omitempty"` } @@ -1391,40 +1328,6 @@ type SeatDefinitionRemovedEvent struct { Seat string `json:"seat"` } -// ManifestAcceptedEventBusStateItem is a type of the contract. -type ManifestAcceptedEventBusStateItem struct { - Configuration map[string]any `json:"configuration,omitempty"` - Name string `json:"name"` - Options map[string]any `json:"options,omitempty"` - Storage string `json:"storage"` - Template string `json:"template,omitempty"` - Types []map[string]any `json:"types,omitempty"` -} - -// ManifestAcceptedEvent is the body of the event manifest-accepted. -type ManifestAcceptedEvent struct { - BusState []ManifestAcceptedEventBusStateItem `json:"bus-state"` - Digest string `json:"digest"` - Judge string `json:"judge"` - Module string `json:"module"` - // each problem the indexer's re-judgement finds in a manifest it keeps accepted because its digest is unchanged: the manifest validator's strings, the same items its verdict writes as warnings, in the same order; an empty list when none (design 47 G section 668, 692) - Problems []string `json:"problems"` - // the indexer's revision of the verdict it says; a reader asks its first view again on a gap in it; zero from an indexer that does not say it - Revision int64 `json:"revision,omitempty"` - V int64 `json:"v"` -} - -// ManifestRefusedEvent is the body of the event manifest-refused. -type ManifestRefusedEvent struct { - Digest string `json:"digest"` - Judge string `json:"judge"` - Module string `json:"module"` - Problems []string `json:"problems"` - // the indexer's revision of the verdict it says; a reader asks its first view again on a gap in it; zero from an indexer that does not say it - Revision int64 `json:"revision,omitempty"` - V int64 `json:"v"` -} - // CatalogRevisionEvent is the body of the event catalog-revision. type CatalogRevisionEvent struct { At *time.Time `json:"at,omitempty"` diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index ba7fdd0f..b3c7c8a9 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -638,115 +638,6 @@ ] } }, - { - "name": "manifest-accepted", - "body": { - "type": "object", - "properties": { - "v": { - "type": "integer" - }, - "module": { - "type": "string" - }, - "digest": { - "type": "string" - }, - "judge": { - "type": "string" - }, - "revision": { - "type": "integer", - "description": "the indexer's revision of the verdict it says; a reader asks its first view again on a gap in it; zero from an indexer that does not say it" - }, - "problems": { - "type": "array", - "items": { - "type": "string" - }, - "description": "each problem the indexer's re-judgement finds in a manifest it keeps accepted because its digest is unchanged: the manifest validator's strings, the same items its verdict writes as warnings, in the same order; an empty list when none (design 47 G section 668, 692)" - }, - "bus-state": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "storage": { - "type": "string" - }, - "template": { - "type": "string" - }, - "options": { - "type": "object" - }, - "configuration": { - "type": "object" - }, - "types": { - "type": "array", - "items": { - "type": "object" - } - } - }, - "required": [ - "name", - "storage" - ] - } - } - }, - "required": [ - "v", - "module", - "digest", - "judge", - "bus-state", - "problems" - ] - } - }, - { - "name": "manifest-refused", - "body": { - "type": "object", - "properties": { - "v": { - "type": "integer" - }, - "module": { - "type": "string" - }, - "digest": { - "type": "string" - }, - "judge": { - "type": "string" - }, - "revision": { - "type": "integer", - "description": "the indexer's revision of the verdict it says; a reader asks its first view again on a gap in it; zero from an indexer that does not say it" - }, - "problems": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "v", - "module", - "digest", - "judge", - "problems" - ] - } - }, { "name": "catalog-revision", "body": { @@ -2194,6 +2085,15 @@ ], "description": "required runs and holds the delivery until it passes; optional runs, a failure is shown and may be accepted; bypass runs nothing and is said as bypassed" }, + "validate": { + "type": "string", + "enum": [ + "required", + "optional", + "bypass" + ], + "description": "required runs and holds the delivery until it passes; optional runs, a failure is shown and may be accepted; bypass runs nothing and is said as bypassed" + }, "composition": { "type": "string", "enum": [ @@ -2638,49 +2538,9 @@ } }, "bodies": { - "TakeInMerge": { - "type": "object", - "description": "one merge a take-in event holds: the repository, its pull request and the merge commit the forge made of it", - "properties": { - "repository": { - "type": "string" - }, - "number": { - "type": "integer" - }, - "merge": { - "type": "string" - } - }, - "required": [ - "repository", - "number", - "merge" - ] - }, - "TakeInMember": { - "type": "object", - "description": "one pull request at one commit", - "properties": { - "repository": { - "type": "string" - }, - "number": { - "type": "integer" - }, - "head": { - "type": "string" - } - }, - "required": [ - "repository", - "number", - "head" - ] - }, "TakeInEntry": { "type": "object", - "description": "one module of a taken-in revision (design 47 G section 476, section 648)", + "description": "one mover of a taken-in source revision (design 47 H §743, §763)", "properties": { "module": { "type": "string" @@ -2694,208 +2554,83 @@ }, "repository": { "type": "string", - "description": "from a merged message; absent for a pushed one (design 47 G section 648)" - }, - "pull": { - "type": "integer", - "description": "from a merged message; absent for a pushed one (design 47 G section 648)" + "description": "the repository the module is registered for" } }, "required": [ "module", "commit", - "fingerprint" + "fingerprint", + "repository" ] }, "TakeInPending": { "type": "object", - "description": "the body of the indexer's take-in.pending: a wait for a revision or a group, with the watched branch (design 47 G section 493)", + "description": "the body of the indexer's take-in.pending: a source revision's take-in held, said once per source (design 47 H §744)", "properties": { - "v": { + "branch": { + "type": "string", + "description": "the watched branch" + }, + "source": { "type": "integer", - "description": "the layout version" - }, - "kind": { - "type": "string", - "description": "the event's kind, pending or taken" - }, - "key": { - "type": "string", - "description": "the wait's key: m. of its oldest merge, or g. for a group being gathered" - }, - "what": { - "type": "string", - "description": "what waits: a revision or a group" - }, - "merges": { - "type": "array", - "items": { - "$ref": "#/bodies/TakeInMerge" - }, - "description": "the merges it holds, oldest first" - }, - "group": { - "type": "string", - "description": "the delivery group, for a group being gathered" - }, - "members": { - "type": "array", - "items": { - "$ref": "#/bodies/TakeInMember" - }, - "description": "every approved member of a group with its head" - }, - "waits-for": { - "type": "string", - "description": "the indexer build a revision waits for" - }, - "since": { - "type": "string", - "description": "when the wait began", - "format": "date-time" - }, - "by": { - "type": "string", - "description": "who acted by hand, on a taken event" + "description": "the source revision held" }, "why": { "type": "string", - "description": "why they acted by hand, on a taken event" - }, - "dropped": { - "type": "boolean", - "description": "a hand drop: the merges are not taken in" - }, - "lost": { - "type": "array", - "items": { - "type": "string" - }, - "description": "the keys of merges whose message the forge bridge's stream no longer holds" - }, - "refused": { - "type": "string", - "description": "why the manifest of the indexer the revision names was refused" - }, - "own-build-unknown": { - "type": "string", - "description": "why the indexer holds a merge it does not take in although no indexer build is named" - }, - "branch": { - "type": "string", - "description": "the watched branch the revision is of (design 47 G section 476, section 493)" + "description": "why it cannot be written, such as the catalog store full" } }, "required": [ - "v", - "kind", - "key", - "what", - "merges", - "since" + "branch", + "source", + "why" ] }, "TakeInTaken": { "type": "object", - "description": "the body of the indexer's take-in.taken: a wait ended, with the branch, the source revision and the entries (design 47 G section 476, section 493)", + "description": "the body of the indexer's take-in.taken: a source revision taken in, said once, with one entry per mover (design 47 H §743, §744)", "properties": { - "v": { - "type": "integer", - "description": "the layout version" - }, - "kind": { - "type": "string", - "description": "the event's kind, pending or taken" - }, - "key": { - "type": "string", - "description": "the wait's key: m. of its oldest merge, or g. for a group being gathered" - }, - "what": { - "type": "string", - "description": "what waits: a revision or a group" - }, - "merges": { - "type": "array", - "items": { - "$ref": "#/bodies/TakeInMerge" - }, - "description": "the merges it holds, oldest first" - }, - "revision": { - "type": "integer", - "description": "the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448)" - }, - "group": { - "type": "string", - "description": "the delivery group, for a group being gathered" - }, - "members": { - "type": "array", - "items": { - "$ref": "#/bodies/TakeInMember" - }, - "description": "every approved member of a group with its head" - }, - "waits-for": { - "type": "string", - "description": "the indexer build a revision waits for" - }, - "since": { - "type": "string", - "description": "when the wait began", - "format": "date-time" - }, - "by": { - "type": "string", - "description": "who acted by hand, on a taken event" - }, - "why": { - "type": "string", - "description": "why they acted by hand, on a taken event" - }, - "dropped": { - "type": "boolean", - "description": "a hand drop: the merges are not taken in" - }, - "lost": { - "type": "array", - "items": { - "type": "string" - }, - "description": "the keys of merges whose message the forge bridge's stream no longer holds" - }, - "refused": { - "type": "string", - "description": "why the manifest of the indexer the revision names was refused" - }, - "own-build-unknown": { - "type": "string", - "description": "why the indexer holds a merge it does not take in although no indexer build is named" - }, "branch": { "type": "string", - "description": "the watched branch the revision is of (design 47 G section 476, section 493)" + "description": "the watched branch" }, "source": { "type": "integer", - "description": "the source revision taken in (design 47 G section 476)" + "description": "the source revision taken in" + }, + "revision": { + "type": "integer", + "description": "the catalog revision of the branch the take-in wrote; absent for a skip" + }, + "call": { + "type": "string", + "description": "the merge call the source revision names" }, "entries": { "type": "array", "items": { "$ref": "#/bodies/TakeInEntry" }, - "description": "one entry per module of that revision; none for a hand drop (design 47 G section 476, section 493)" + "description": "one entry per mover; none for a take-in with no mover or a skip" + }, + "skipped": { + "type": "boolean", + "description": "acknowledged unwritten by the tool indexer_take_in_skip (design 47 H §744)" + }, + "by": { + "type": "string", + "description": "who acted by hand" + }, + "why": { + "type": "string", + "description": "why they acted by hand" } }, "required": [ - "v", - "kind", - "key", - "what", - "merges", - "since" + "branch", + "source", + "call" ] } } 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 74890b98..6c5acce9 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -25,8 +25,6 @@ export declare const verbs: { export declare const events: { readonly seatDefinitionChanged: "seat-definition-changed"; readonly seatDefinitionRemoved: "seat-definition-removed"; - readonly manifestAccepted: "manifest-accepted"; - readonly manifestRefused: "manifest-refused"; readonly catalogRevision: "catalog-revision"; readonly filling: "filling"; readonly full: "full"; @@ -42,10 +40,6 @@ export declare const seatDefinitionChangedSubject: "mesh.seat.mesh-catalog.event export declare const seatDefinitionRemovedSubject: "mesh.seat.mesh-catalog.event.seat-definition-removed"; -export declare const manifestAcceptedSubject: "mesh.seat.mesh-catalog.event.manifest-accepted"; - -export declare const manifestRefusedSubject: "mesh.seat.mesh-catalog.event.manifest-refused"; - export declare function catalogRevisionSubject(branch: string): string; export declare const catalogRevisionSubjectAll: "mesh.seat.mesh-catalog.event.catalog-revision.*"; @@ -462,6 +456,8 @@ export interface StepStatuses { "review"?: "required" | "optional" | "bypass"; /** required runs and holds the delivery until it passes; optional runs, a failure is shown and may be accepted; bypass runs nothing and is said as bypassed */ "unit"?: "required" | "optional" | "bypass"; + /** required runs and holds the delivery until it passes; optional runs, a failure is shown and may be accepted; bypass runs nothing and is said as bypassed */ + "validate"?: "required" | "optional" | "bypass"; } /** a toolchain a fingerprint was computed with (ADR 0405 clause 7) */ @@ -513,107 +509,43 @@ export interface VersionEntry { "version": string; } -/** one module of a taken-in revision (design 47 G section 476, section 648) */ +/** one mover of a taken-in source revision (design 47 H §743, §763) */ export interface TakeInEntry { "commit": string; /** the module's build-input fingerprint at the commit */ "fingerprint": string; "module": string; - /** from a merged message; absent for a pushed one (design 47 G section 648) */ - "pull"?: number; - /** from a merged message; absent for a pushed one (design 47 G section 648) */ - "repository"?: string; -} - -/** one pull request at one commit */ -export interface TakeInMember { - "head": string; - "number": number; + /** the repository the module is registered for */ "repository": string; } -/** one merge a take-in event holds: the repository, its pull request and the merge commit the forge made of it */ -export interface TakeInMerge { - "merge": string; - "number": number; - "repository": string; -} - -/** the body of the indexer's take-in.pending: a wait for a revision or a group, with the watched branch (design 47 G section 493) */ +/** the body of the indexer's take-in.pending: a source revision's take-in held, said once per source (design 47 H §744) */ export interface TakeInPending { - /** the watched branch the revision is of (design 47 G section 476, section 493) */ - "branch"?: string; - /** who acted by hand, on a taken event */ - "by"?: string; - /** a hand drop: the merges are not taken in */ - "dropped"?: boolean; - /** the delivery group, for a group being gathered */ - "group"?: string; - /** the wait's key: m. of its oldest merge, or g. for a group being gathered */ - "key": string; - /** the event's kind, pending or taken */ - "kind": string; - /** the keys of merges whose message the forge bridge's stream no longer holds */ - "lost"?: string[]; - /** every approved member of a group with its head */ - "members"?: TakeInMember[]; - /** the merges it holds, oldest first */ - "merges": TakeInMerge[]; - /** why the indexer holds a merge it does not take in although no indexer build is named */ - "own-build-unknown"?: string; - /** why the manifest of the indexer the revision names was refused */ - "refused"?: string; - /** when the wait began */ - "since": string; - /** the layout version */ - "v": number; - /** the indexer build a revision waits for */ - "waits-for"?: string; - /** what waits: a revision or a group */ - "what": string; - /** why they acted by hand, on a taken event */ - "why"?: string; + /** the watched branch */ + "branch": string; + /** the source revision held */ + "source": number; + /** why it cannot be written, such as the catalog store full */ + "why": string; } -/** the body of the indexer's take-in.taken: a wait ended, with the branch, the source revision and the entries (design 47 G section 476, section 493) */ +/** the body of the indexer's take-in.taken: a source revision taken in, said once, with one entry per mover (design 47 H §743, §744) */ export interface TakeInTaken { - /** the watched branch the revision is of (design 47 G section 476, section 493) */ - "branch"?: string; - /** who acted by hand, on a taken event */ + /** the watched branch */ + "branch": string; + /** who acted by hand */ "by"?: string; - /** a hand drop: the merges are not taken in */ - "dropped"?: boolean; - /** one entry per module of that revision; none for a hand drop (design 47 G section 476, section 493) */ + /** the merge call the source revision names */ + "call": string; + /** one entry per mover; none for a take-in with no mover or a skip */ "entries"?: TakeInEntry[]; - /** the delivery group, for a group being gathered */ - "group"?: string; - /** the wait's key: m. of its oldest merge, or g. for a group being gathered */ - "key": string; - /** the event's kind, pending or taken */ - "kind": string; - /** the keys of merges whose message the forge bridge's stream no longer holds */ - "lost"?: string[]; - /** every approved member of a group with its head */ - "members"?: TakeInMember[]; - /** the merges it holds, oldest first */ - "merges": TakeInMerge[]; - /** why the indexer holds a merge it does not take in although no indexer build is named */ - "own-build-unknown"?: string; - /** why the manifest of the indexer the revision names was refused */ - "refused"?: string; - /** the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448) */ + /** the catalog revision of the branch the take-in wrote; absent for a skip */ "revision"?: number; - /** when the wait began */ - "since": string; - /** the source revision taken in (design 47 G section 476) */ - "source"?: number; - /** the layout version */ - "v": number; - /** the indexer build a revision waits for */ - "waits-for"?: string; - /** what waits: a revision or a group */ - "what": string; - /** why they acted by hand, on a taken event */ + /** acknowledged unwritten by the tool indexer_take_in_skip (design 47 H §744) */ + "skipped"?: boolean; + /** the source revision taken in */ + "source": number; + /** why they acted by hand */ "why"?: string; } @@ -866,39 +798,6 @@ export interface SeatDefinitionRemovedEvent { "seat": string; } -export interface ManifestAcceptedEventBusStateItem { - "configuration"?: Record; - "name": string; - "options"?: Record; - "storage": string; - "template"?: string; - "types"?: Record[]; -} - -/** is the body of the event manifest-accepted. */ -export interface ManifestAcceptedEvent { - "bus-state": ManifestAcceptedEventBusStateItem[]; - "digest": string; - "judge": string; - "module": string; - /** each problem the indexer's re-judgement finds in a manifest it keeps accepted because its digest is unchanged: the manifest validator's strings, the same items its verdict writes as warnings, in the same order; an empty list when none (design 47 G section 668, 692) */ - "problems": string[]; - /** the indexer's revision of the verdict it says; a reader asks its first view again on a gap in it; zero from an indexer that does not say it */ - "revision"?: number; - "v": number; -} - -/** is the body of the event manifest-refused. */ -export interface ManifestRefusedEvent { - "digest": string; - "judge": string; - "module": string; - "problems": string[]; - /** the indexer's revision of the verdict it says; a reader asks its first view again on a gap in it; zero from an indexer that does not say it */ - "revision"?: number; - "v": number; -} - /** is the body of the event catalog-revision. */ export interface CatalogRevisionEvent { "at"?: string; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js index 1607daa0..4913e7bc 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js @@ -25,8 +25,6 @@ export const verbs = { export const events = { seatDefinitionChanged: "seat-definition-changed", seatDefinitionRemoved: "seat-definition-removed", - manifestAccepted: "manifest-accepted", - manifestRefused: "manifest-refused", catalogRevision: "catalog-revision", filling: "filling", full: "full", @@ -42,10 +40,6 @@ export const seatDefinitionChangedSubject = "mesh.seat.mesh-catalog.event.seat-d export const seatDefinitionRemovedSubject = "mesh.seat.mesh-catalog.event.seat-definition-removed"; -export const manifestAcceptedSubject = "mesh.seat.mesh-catalog.event.manifest-accepted"; - -export const manifestRefusedSubject = "mesh.seat.mesh-catalog.event.manifest-refused"; - export function catalogRevisionSubject(branch) { return "mesh.seat.mesh-catalog.event.catalog-revision." + branch; } -- 2.54.0 From f8bbde9627255fe37bd6603a40fcce14fb61d97b Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:44:23 +0100 Subject: [PATCH 006/104] C2: the merge call's contract: merge-pull takes pulls and by, merge-called, calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit merge-pull takes a list of one or more members {repository, number, head} and by, judges no branch protection and answers once, at the call's end, the call and each member's outcome {repository, number, state, commit|why} (H-A-21, H-A-22); its caller id goes, and it names a timeout of 120 s (H-A-43). The seat says merge-called on merge-called., kept 30 days and 64 MiB on SEAT_git_merge-called, its body in bodies; the state calls keeps each call with said (H-A-47). branch answers no protected. Builds: design 47 H §734, §735, §736, §766, §767, §764 (the single-pull form, the protection judgement); lead answers H-A-21, H-A-22, H-A-23, H-A-24, H-A-43, H-A-47 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/git/contract.go | 189 ++++++++-- .../go/seats/git/contract_test.go | 26 +- .../seats/git/fixtures/events.json | 27 ++ .../seats/git/fixtures/states.json | 25 ++ .../seats/git/fixtures/verbs.json | 141 ++++--- .../seats/git/seat.json | 344 ++++++++++++++---- .../ts/seats/git/index.d.ts | 127 +++++-- .../ts/seats/git/index.js | 29 +- 8 files changed, 713 insertions(+), 195 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract.go b/modules/mesh-delivery-contracts/go/seats/git/contract.go index 30f7c416..7d4172ff 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract.go @@ -1,6 +1,6 @@ // Code generated by seatgen from the seat definitions; DO NOT EDIT. -// Package git is the contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. The act verbs are the forge bridge's alone. +// Package git is the contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. package git import ( @@ -40,6 +40,7 @@ const ( EventForgeDelete = "forge-delete" EventRepoWritable = "repo-writable" EventBranchMoved = "branch-moved" + EventMergeCalled = "merge-called" ) // Verbs is every verb the seat serves, in its definition's order: a new copy each call. @@ -49,7 +50,7 @@ func Verbs() []string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventPullUpdated, EventPullMerged, EventPullClosed, EventForgePull, EventForgeStatus, EventForgeDelete, EventRepoWritable, EventBranchMoved} + return []string{EventPullUpdated, EventPullMerged, EventPullClosed, EventForgePull, EventForgeStatus, EventForgeDelete, EventRepoWritable, EventBranchMoved, EventMergeCalled} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -85,8 +86,18 @@ const StreamBranchMoved = "SEAT_git_branch-moved" // SubjectBranchMoved is where branch-moved is published. const SubjectBranchMoved = "mesh.seat.git.event.branch-moved" +// StreamMergeCalled is the stream merge-called is kept in. +const StreamMergeCalled = "SEAT_git_merge-called" + +// SubjectMergeCalled is where merge-called is published, on mesh.seat.git.event.merge-called.. +func SubjectMergeCalled(call string) string { return "mesh.seat.git.event.merge-called." + call } + +// SubjectMergeCalledAll hears every merge-called. +const SubjectMergeCalledAll = "mesh.seat.git.event.merge-called.*" + const ( StateFailedSteps = "failed-steps" + StateCalls = "calls" ) // FailedStepsByModuleFingerprintStepKey is the key of one value of the state failed-steps under the form "..". @@ -132,6 +143,72 @@ func DecodeFailedStepsByModuleFingerprintStepValue(raw []byte) (FailedStepsByMod return v, nil } +// CallsByCallCallKey is the key of one value of the state calls under the form "call.". +func CallsByCallCallKey(call string) string { return "call." + call } + +// ParseCallsByCallCallKey reads the parts of a key of the form "call.", in the order of the form; the last result is false for a key of another form. +func ParseCallsByCallCallKey(key string) (string, bool) { + rest := key + if !strings.HasPrefix(rest, "call.") { + return "", false + } + rest = rest[5:] + if rest == "" { + return "", false + } + v1 := rest + rest = "" + if rest != "" { + return "", false + } + return v1, true +} + +// DecodeCallsByCallCallValue reads one value of the state calls under the form "call.", refusing a field CallsByCallCallValue does not know and any text after the value. +func DecodeCallsByCallCallValue(raw []byte) (CallsByCallCallValue, error) { + var v CallsByCallCallValue + 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 +} + +// Call is one merge call, written before its first merge and updated as each member merges (design 47 H §766). +type Call struct { + // the bus account the tool runner proved for the call + Account string `json:"account"` + At time.Time `json:"at"` + // the caller as who@node + By string `json:"by"` + Members []CallMember `json:"members"` + // merge-called was said for it + Said bool `json:"said"` +} + +// CallMember is one member of a kept call. +type CallMember struct { + // for merged, the merge commit + Commit string `json:"commit,omitempty"` + Head string `json:"head"` + Number int64 `json:"number"` + Repository string `json:"repository"` + State string `json:"state"` + // for refused, why + Why string `json:"why,omitempty"` +} + +// The values of CallMember's state. +const ( + CallMemberStateJudged = "judged" + CallMemberStateMerged = "merged" + CallMemberStateRefused = "refused" +) + // Change is what a pull request changed. type Change struct { // the changed directories that hold a module at its head; absent when they could not be read @@ -173,6 +250,25 @@ type FailedStep struct { V int64 `json:"v,omitempty"` } +// MemberOutcome is one member of a merge call and where it stands (design 47 H §766, H-A-22). +type MemberOutcome struct { + // for merged, the merge commit; for a member refused already-merged, its commit + Commit string `json:"commit,omitempty"` + Number int64 `json:"number"` + Repository string `json:"repository"` + // judged, judged and not merged; merged, with its commit; refused, with why + State string `json:"state"` + // for refused, why, naming the step for a failed required step + Why string `json:"why,omitempty"` +} + +// The values of MemberOutcome's state. +const ( + MemberOutcomeStateJudged = "judged" + MemberOutcomeStateMerged = "merged" + MemberOutcomeStateRefused = "refused" +) + // Merging is what the forge would merge now, for an open pull request (issues 1275, 1945; ADR 0441 §1): answered whole or not at all, and a read the forge could not make answers the verb's error, never a guess; absent for a merged or closed one. type Merging struct { // the forge's own word on whether it merges into its base now: false while it is in conflict with its base, or while the forge works that out after the base moved @@ -243,6 +339,40 @@ type Status struct { Target string `json:"target,omitempty"` } +// MergeCalledMembersItem is a type of the contract. +type MergeCalledMembersItem struct { + // the pull request's base, a watched branch + Branch string `json:"branch"` + // the merge commit the forge records for the pull request + Commit string `json:"commit"` + Head string `json:"head"` + Number int64 `json:"number"` + Repository string `json:"repository"` +} + +// MergeCalledRefusedItem is a type of the contract. +type MergeCalledRefusedItem struct { + Number int64 `json:"number"` + Repository string `json:"repository"` + Why string `json:"why"` +} + +// MergeCalled is a merge call's members merged or refused, said once by the forge module (design 47 H §736, §767). +type MergeCalled struct { + // the bus account the tool runner proved + Account string `json:"account"` + // the time of the last merge + At time.Time `json:"at"` + // the caller as who@node + By string `json:"by"` + // the merge call, 16 lowercase hex characters made once per call + Call string `json:"call"` + // one per landed member + Members []MergeCalledMembersItem `json:"members"` + // one per member not merged after every member was judged (design 47 H §767) + Refused []MergeCalledRefusedItem `json:"refused,omitempty"` +} + // PullInput is what pull takes. type PullInput struct { // instead of the number: the merge commit it made @@ -276,9 +406,7 @@ type BranchAnswer struct { Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` // a commit, its full 40-hex sha - Head string `json:"head,omitempty"` - // a protection rule refuses a direct push and admits only merges - Protected bool `json:"protected,omitempty"` + Head string `json:"head,omitempty"` Repository string `json:"repository,omitempty"` } @@ -541,52 +669,35 @@ type NoteAnswer struct { Performed bool `json:"performed,omitempty"` } -// MergePullInput is what merge-pull takes. -type MergePullInput struct { +// MergePullInputPullsItem is a type of the contract. +type MergePullInputPullsItem struct { // the head the caller names Head string `json:"head"` - // the act's id - ID string `json:"id"` // the pull request's number Number int64 `json:"number"` // the repository, / Repository string `json:"repository"` } +// MergePullInput is what merge-pull takes. +type MergePullInput struct { + // the caller as who@node, recorded beside the bus account the tool runner proves + By string `json:"by"` + // the members, in the order they are merged + Pulls []MergePullInputPullsItem `json:"pulls"` +} + // MergePullAnswer is what merge-pull answers. type MergePullAnswer struct { + // the merge call, 16 lowercase hex characters made once per call + Call string `json:"call,omitempty"` // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` - // the id was already held on the pull request or the note, so nothing was done again - Held bool `json:"held,omitempty"` - // the act's id, as the caller gave it - ID string `json:"id,omitempty"` - // the merge commit - MergeCommit string `json:"merge-commit,omitempty"` - // for policy-failed, the module - Module string `json:"module,omitempty"` - // the forge holds the act now - Performed bool `json:"performed,omitempty"` - // why the forge or the holder refused the merge; the act is not performed - Refused string `json:"refused,omitempty"` - // which refusal, set with refused: head-moved, the pull request's head is not the one named; unprotected, the base branch's protection does not refuse a direct push; policy-failed, a run at the head's fingerprint failed a required step (run, module and step name it); no-registrations, no registration-changed heard yet (ADR 0667 section 10); git-refused, git refused the merge - RefusedKind string `json:"refused-kind,omitempty"` - // for policy-failed, the run that failed the step: the runner's pipeline key - Run string `json:"run,omitempty"` - // for policy-failed, the step - Step string `json:"step,omitempty"` + // each member's outcome, in the order named + Members []MemberOutcome `json:"members,omitempty"` } -// The values of MergePullAnswer's refused-kind. -const ( - MergePullAnswerRefusedKindHeadMoved = "head-moved" - MergePullAnswerRefusedKindUnprotected = "unprotected" - MergePullAnswerRefusedKindPolicyFailed = "policy-failed" - MergePullAnswerRefusedKindNoRegistrations = "no-registrations" - MergePullAnswerRefusedKindGitRefused = "git-refused" -) - // TagInput is what tag takes. type TagInput struct { // the commit it is written at @@ -748,5 +859,11 @@ type BranchMovedEvent struct { Repository string `json:"repository"` } +// MergeCalledEvent is the body of the event merge-called. +type MergeCalledEvent = MergeCalled + // FailedStepsByModuleFingerprintStepValue is one value of the state failed-steps under the key ... type FailedStepsByModuleFingerprintStepValue = FailedStep + +// CallsByCallCallValue is one value of the state calls under the key call.. +type CallsByCallCallValue = Call diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract_test.go b/modules/mesh-delivery-contracts/go/seats/git/contract_test.go index 9d6e2151..c797bf52 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract_test.go @@ -33,12 +33,16 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v RepoWritableEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.repo-writable$")}, {name: "a branch moved by a merge", subject: "mesh.seat.git.event.branch-moved", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-catalog\"}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-catalog\"}", decode: func(b []byte) (any, error) { var v BranchMovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.branch-moved$")}, + {name: "merge-called is said once per call", subject: "mesh.seat.git.event.merge-called.0123456789abcdef", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"call\":\"0123456789abcdef\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}],\"refused\":[{\"number\":261,\"repository\":\"novox/mesh-delivery\",\"why\":\"the forge refused the merge: conflict\"}]}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"call\":\"0123456789abcdef\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}],\"refused\":[{\"number\":261,\"repository\":\"novox/mesh-delivery\",\"why\":\"the forge refused the merge: conflict\"}]}", + decode: func(b []byte) (any, error) { var v MergeCalledEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.merge-called\\.[^.*> ]+$")}, {name: "a failed required step kept", subject: "", given: "{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"commits\":[\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"run\":\"main.12.nats\",\"said\":\"TestTheBusWhole failed\",\"step\":\"unit\",\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"commits\":[\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"run\":\"main.12.nats\",\"said\":\"TestTheBusWhole failed\",\"step\":\"unit\",\"v\":1}", decode: func(b []byte) (any, error) { var v FailedStepsByModuleFingerprintStepValue err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, + {name: "a merge call kept", subject: "", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", + decode: func(b []byte) (any, error) { var v CallsByCallCallValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "pull asks", subject: "", given: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", decode: func(b []byte) (any, error) { var v PullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "pull answers", subject: "", given: "{\"pull\":{\"author\":\"alice\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"merged-at\":\"2026-11-09T19:40:00Z\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/178\"}}", wire: "{\"pull\":{\"author\":\"alice\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"merged-at\":\"2026-11-09T19:40:00Z\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/178\"}}", @@ -113,19 +117,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v NoteAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "note answers an error, never none", subject: "", given: "{\"error\":\"the note ref could not be pushed\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the note ref could not be pushed\",\"error-kind\":\"failed\"}", decode: func(b []byte) (any, error) { var v NoteAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "merge-pull asks", subject: "", given: "{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"owed-5\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"owed-5\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", - decode: func(b []byte) (any, error) { var v MergePullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "merge-pull answers", subject: "", given: "{\"id\":\"owed-5\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"performed\":true}", wire: "{\"id\":\"owed-5\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"performed\":true}", - decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "merge-pull answers", subject: "", given: "{\"id\":\"owed-5\",\"refused\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"refused-kind\":\"head-moved\"}", wire: "{\"id\":\"owed-5\",\"refused\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"refused-kind\":\"head-moved\"}", - decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "merge-pull answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}", - decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "merge-pull refuses a failed required step, naming the run, the module and the step", subject: "", given: "{\"id\":\"merge-7\",\"module\":\"nats\",\"refused\":\"unit of nats:program failed at fp-0123 in main.12.nats\",\"refused-kind\":\"policy-failed\",\"run\":\"main.12.nats\",\"step\":\"unit\"}", wire: "{\"id\":\"merge-7\",\"module\":\"nats\",\"refused\":\"unit of nats:program failed at fp-0123 in main.12.nats\",\"refused-kind\":\"policy-failed\",\"run\":\"main.12.nats\",\"step\":\"unit\"}", - decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "branch asks a branch", subject: "", given: "{\"branch\":\"main\",\"repository\":\"novox/mesh-catalog\"}", wire: "{\"branch\":\"main\",\"repository\":\"novox/mesh-catalog\"}", decode: func(b []byte) (any, error) { var v BranchInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "branch answers its head and protection", subject: "", given: "{\"branch\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"protected\":true,\"repository\":\"novox/mesh-catalog\"}", wire: "{\"branch\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"protected\":true,\"repository\":\"novox/mesh-catalog\"}", + {name: "branch answers its head", subject: "", given: "{\"branch\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-catalog\"}", wire: "{\"branch\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-catalog\"}", decode: func(b []byte) (any, error) { var v BranchAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "branch answers a branch the forge does not hold", subject: "", given: "{\"error\":\"no branch beta in novox/mesh-catalog\",\"error-kind\":\"not-found\"}", wire: "{\"error\":\"no branch beta in novox/mesh-catalog\",\"error-kind\":\"not-found\"}", decode: func(b []byte) (any, error) { var v BranchAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, @@ -135,6 +129,16 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v TagAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "tag answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 403\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge answered 403\",\"error-kind\":\"refused\"}", decode: func(b []byte) (any, error) { var v TagAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "merge-pull asks two pull requests in two repositories", subject: "", given: "{\"by\":\"lead-47@workstation\",\"pulls\":[{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\"},{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\"}]}", wire: "{\"by\":\"lead-47@workstation\",\"pulls\":[{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\"},{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\"}]}", + decode: func(b []byte) (any, error) { var v MergePullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "merge-pull answers the call and each member merged", subject: "", given: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"merged\"}]}", wire: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"merged\"}]}", + decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "merge-pull refuses every member when one is refused, naming why", subject: "", given: "{\"call\":\"0123456789abcdef\",\"members\":[{\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"refused\",\"why\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},{\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}]}", wire: "{\"call\":\"0123456789abcdef\",\"members\":[{\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"refused\",\"why\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},{\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}]}", + decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "merge-pull refuses a member already merged, naming its commit", subject: "", given: "{\"call\":\"fedcba9876543210\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"refused\",\"why\":\"already-merged\"}]}", wire: "{\"call\":\"fedcba9876543210\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"refused\",\"why\":\"already-merged\"}]}", + decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "merge-pull answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}", + decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/seats/git/fixtures/events.json b/modules/mesh-delivery-contracts/seats/git/fixtures/events.json index 98a0faa4..43d9aa1a 100644 --- a/modules/mesh-delivery-contracts/seats/git/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/git/fixtures/events.json @@ -118,5 +118,32 @@ "head": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "at": "2026-11-10T10:00:00Z" } + }, + { + "name": "merge-called is said once per call", + "of": "event:merge-called", + "subject": "mesh.seat.git.event.merge-called.0123456789abcdef", + "given": { + "account": "tools-shanks", + "at": "2026-11-20T02:00:00Z", + "by": "lead-47@workstation", + "call": "0123456789abcdef", + "members": [ + { + "branch": "main", + "commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "number": 178, + "repository": "novox/mesh-sdk" + } + ], + "refused": [ + { + "number": 261, + "repository": "novox/mesh-delivery", + "why": "the forge refused the merge: conflict" + } + ] + } } ] diff --git a/modules/mesh-delivery-contracts/seats/git/fixtures/states.json b/modules/mesh-delivery-contracts/seats/git/fixtures/states.json index 89510c7c..824f1999 100644 --- a/modules/mesh-delivery-contracts/seats/git/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/git/fixtures/states.json @@ -15,5 +15,30 @@ "said": "TestTheBusWhole failed", "at": "2026-11-10T10:00:00Z" } + }, + { + "name": "a merge call kept", + "of": "state:calls/call.", + "given": { + "account": "tools-shanks", + "at": "2026-11-20T02:00:00Z", + "by": "lead-47@workstation", + "members": [ + { + "commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "number": 178, + "repository": "novox/mesh-sdk", + "state": "merged" + }, + { + "head": "cccccccccccccccccccccccccccccccccccccccc", + "number": 261, + "repository": "novox/mesh-delivery", + "state": "judged" + } + ], + "said": false + } } ] diff --git a/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json index 384e6f7a..2cccbd42 100644 --- a/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json @@ -416,56 +416,6 @@ "error-kind": "failed" } }, - { - "name": "merge-pull asks", - "of": "verb:merge-pull.input", - "given": { - "id": "owed-5", - "repository": "novox/mesh-sdk", - "number": 178, - "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - } - }, - { - "name": "merge-pull answers", - "of": "verb:merge-pull.answer", - "given": { - "id": "owed-5", - "performed": true, - "merge-commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - } - }, - { - "name": "merge-pull answers", - "of": "verb:merge-pull.answer", - "given": { - "id": "owed-5", - "refused": "the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "refused-kind": "head-moved" - }, - "why": "a head that moved is refused by name, not performed" - }, - { - "name": "merge-pull answers an error, never none", - "of": "verb:merge-pull.answer", - "why": "a failed read or act is an error the caller reads as a failure (design 47 *The seat git*)", - "given": { - "error": "the forge answered 502", - "error-kind": "failed" - } - }, - { - "name": "merge-pull refuses a failed required step, naming the run, the module and the step", - "of": "verb:merge-pull.answer", - "given": { - "id": "merge-7", - "refused": "unit of nats:program failed at fp-0123 in main.12.nats", - "refused-kind": "policy-failed", - "run": "main.12.nats", - "module": "nats", - "step": "unit" - } - }, { "name": "branch asks a branch", "of": "verb:branch.input", @@ -475,13 +425,12 @@ } }, { - "name": "branch answers its head and protection", + "name": "branch answers its head", "of": "verb:branch.answer", "given": { "repository": "novox/mesh-catalog", "branch": "main", - "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "protected": true + "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } }, { @@ -518,5 +467,91 @@ "error": "the forge answered 403", "error-kind": "refused" } + }, + { + "name": "merge-pull asks two pull requests in two repositories", + "of": "verb:merge-pull.input", + "given": { + "pulls": [ + { + "repository": "novox/mesh-sdk", + "number": 178, + "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "repository": "novox/mesh-delivery", + "number": 261, + "head": "cccccccccccccccccccccccccccccccccccccccc" + } + ], + "by": "lead-47@workstation" + } + }, + { + "name": "merge-pull answers the call and each member merged", + "of": "verb:merge-pull.answer", + "given": { + "call": "0123456789abcdef", + "members": [ + { + "repository": "novox/mesh-sdk", + "number": 178, + "state": "merged", + "commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + }, + { + "repository": "novox/mesh-delivery", + "number": 261, + "state": "merged", + "commit": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + } + ] + } + }, + { + "name": "merge-pull refuses every member when one is refused, naming why", + "of": "verb:merge-pull.answer", + "why": "every member is judged before any is merged (design 47 H \u00a7735)", + "given": { + "call": "0123456789abcdef", + "members": [ + { + "repository": "novox/mesh-sdk", + "number": 178, + "state": "refused", + "why": "the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "repository": "novox/mesh-delivery", + "number": 261, + "state": "judged" + } + ] + } + }, + { + "name": "merge-pull refuses a member already merged, naming its commit", + "of": "verb:merge-pull.answer", + "given": { + "call": "fedcba9876543210", + "members": [ + { + "repository": "novox/mesh-sdk", + "number": 178, + "state": "refused", + "commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "why": "already-merged" + } + ] + } + }, + { + "name": "merge-pull answers an error, never none", + "of": "verb:merge-pull.answer", + "why": "a failed read or act is an error the caller reads as a failure (design 47 *The seat git*)", + "given": { + "error": "the forge answered 502", + "error-kind": "failed" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/git/seat.json b/modules/mesh-delivery-contracts/seats/git/seat.json index c24a4f12..7af220d3 100644 --- a/modules/mesh-delivery-contracts/seats/git/seat.json +++ b/modules/mesh-delivery-contracts/seats/git/seat.json @@ -5,7 +5,7 @@ "grain": "whole", "domain": "Delivery", "decision": "novox/hq ADR 0111", - "description": "The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 \u00a71, \u00a72). A failed read answers an error, never an empty answer. The act verbs are the forge bridge's alone.", + "description": "The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 \u00a71, \u00a72). A failed read answers an error, never an empty answer.", "delivers": "git", "verbs": [ { @@ -56,7 +56,7 @@ }, { "name": "branch", - "description": "A branch's head, and whether a protection rule refuses a direct push and admits only merges (design 47 *The seat git*, *Watched branches and the catalog graph per branch*). A branch the forge does not hold answers the error kind not-found.", + "description": "A branch's head (design 47 *The seat git*, *Watched branches and the catalog graph per branch*). A branch the forge does not hold answers the error kind not-found.", "input": { "type": "object", "properties": { @@ -90,10 +90,6 @@ "description": "a commit, its full 40-hex sha", "pattern": "^[0-9a-f]{40}$" }, - "protected": { - "type": "boolean", - "description": "a protection rule refuses a direct push and admits only merges" - }, "error": { "type": "string", "description": "why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none" @@ -742,83 +738,66 @@ }, { "name": "merge-pull", - "description": "Merge a pull request with the forge tools' account at the head the caller names (design 47 *Approval is a step, and a session merges a pull request*). It judges that this is still the pull request's head and that the base branch's protection refuses a direct push, read again on every branch-moved, and refuses a head when any run at its build-input fingerprint failed a required step, judged from its own state failed-steps heard from the runner's step-ended, never by a call; a head with no run yet or a passed one merges, it never waits for a run and never asks an Approve (ADR 0666 section 11). Refused, naming why: a head that moved, a branch no protection guards, a failed required step (naming the run, the module and the step), no registrations yet (ADR 0667 section 10), a merge git refuses. A pull request already merged at that head is answered performed.", + "description": "Merge one or more pull requests with the forge tools' account, each at the head the caller names: one merge call, a delivery's start and, with two or more members, its group (design 47 H \u00a7734, \u00a7735, \u00a7766; ADR 0682 \u00a71, \u00a72). Every member is judged before any is merged: still the pull request's head, its base a watched branch, no run at the head's build-input fingerprint failed a required step (judged from its own state failed-steps), registrations heard; no branch protection is read. When one member is refused, none is merged. Then it merges them in the order named, writing the call in its state calls before the first merge, and says merge-called once. It answers once, at the call's end, naming the call and each member's outcome; a member already merged is refused already-merged, naming its commit.", "input": { "type": "object", "properties": { - "id": { + "pulls": { + "type": "array", + "minItems": 1, + "description": "the members, in the order they are merged", + "items": { + "type": "object", + "properties": { + "repository": { + "type": "string", + "description": "the repository, /", + "minLength": 1 + }, + "number": { + "type": "integer", + "description": "the pull request's number" + }, + "head": { + "type": "string", + "description": "the head the caller names", + "pattern": "^[0-9a-f]{40}$" + } + }, + "additionalProperties": false, + "required": [ + "repository", + "number", + "head" + ] + } + }, + "by": { "type": "string", - "description": "the act's id", + "description": "the caller as who@node, recorded beside the bus account the tool runner proves", "minLength": 1 - }, - "repository": { - "type": "string", - "description": "the repository, /", - "minLength": 1 - }, - "number": { - "type": "integer", - "description": "the pull request's number" - }, - "head": { - "type": "string", - "description": "the head the caller names", - "pattern": "^[0-9a-f]{40}$" } }, "additionalProperties": false, "required": [ - "id", - "repository", - "number", - "head" + "pulls", + "by" ] }, "answer": { "type": "object", "properties": { - "id": { + "call": { "type": "string", - "description": "the act's id, as the caller gave it" + "description": "the merge call, 16 lowercase hex characters made once per call", + "pattern": "^[0-9a-f]{16}$" }, - "performed": { - "type": "boolean", - "description": "the forge holds the act now" - }, - "held": { - "type": "boolean", - "description": "the id was already held on the pull request or the note, so nothing was done again" - }, - "merge-commit": { - "type": "string", - "description": "the merge commit" - }, - "refused": { - "type": "string", - "description": "why the forge or the holder refused the merge; the act is not performed" - }, - "refused-kind": { - "type": "string", - "enum": [ - "head-moved", - "unprotected", - "policy-failed", - "no-registrations", - "git-refused" - ], - "description": "which refusal, set with refused: head-moved, the pull request's head is not the one named; unprotected, the base branch's protection does not refuse a direct push; policy-failed, a run at the head's fingerprint failed a required step (run, module and step name it); no-registrations, no registration-changed heard yet (ADR 0667 section 10); git-refused, git refused the merge" - }, - "run": { - "type": "string", - "description": "for policy-failed, the run that failed the step: the runner's pipeline key" - }, - "module": { - "type": "string", - "description": "for policy-failed, the module" - }, - "step": { - "type": "string", - "description": "for policy-failed, the step" + "members": { + "type": "array", + "description": "each member's outcome, in the order named", + "items": { + "$ref": "#/defs/MemberOutcome" + } }, "error": { "type": "string", @@ -828,9 +807,10 @@ "$ref": "#/defs/ErrorKind" } }, - "description": "what merge-pull answers; error and error-kind alone when it fails" + "description": "what merge-pull answers at the call's end; error and error-kind alone when it fails" }, - "class": "act" + "class": "act", + "timeout": 120 }, { "name": "tag", @@ -1242,6 +1222,17 @@ "max-age-days": 90, "max-mib": 64 } + }, + { + "name": "merge-called", + "subject": "merge-called.", + "body": { + "$ref": "#/bodies/MergeCalled" + }, + "keep": { + "max-age-days": 30, + "max-mib": 64 + } } ], "family": { @@ -1263,6 +1254,21 @@ "description": "a failed required step" } ] + }, + { + "name": "calls", + "template": "state", + "history": 1, + "description": "every merge call, written before its first merge; one whose merge-called is not said is said at the holder's start; deleted past the stream merge-called's age (design 47 H \u00a7766, H-A-47)", + "key-forms": [ + { + "key": "call.", + "value": { + "$ref": "#/defs/Call" + }, + "description": "one merge call" + } + ] } ], "defs": { @@ -1520,6 +1526,206 @@ "run", "commits" ] + }, + "MemberOutcome": { + "type": "object", + "description": "one member of a merge call and where it stands (design 47 H \u00a7766, H-A-22)", + "properties": { + "repository": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "state": { + "type": "string", + "enum": [ + "judged", + "merged", + "refused" + ], + "description": "judged, judged and not merged; merged, with its commit; refused, with why" + }, + "commit": { + "type": "string", + "description": "for merged, the merge commit; for a member refused already-merged, its commit", + "pattern": "^[0-9a-f]{40}$" + }, + "why": { + "type": "string", + "description": "for refused, why, naming the step for a failed required step" + } + }, + "required": [ + "repository", + "number", + "state" + ] + }, + "Call": { + "type": "object", + "description": "one merge call, written before its first merge and updated as each member merges (design 47 H \u00a7766)", + "properties": { + "by": { + "type": "string", + "description": "the caller as who@node" + }, + "account": { + "type": "string", + "description": "the bus account the tool runner proved for the call" + }, + "at": { + "type": "string", + "format": "date-time" + }, + "members": { + "type": "array", + "items": { + "$ref": "#/defs/CallMember" + } + }, + "said": { + "type": "boolean", + "description": "merge-called was said for it" + } + }, + "required": [ + "by", + "account", + "at", + "members", + "said" + ] + }, + "CallMember": { + "type": "object", + "description": "one member of a kept call", + "properties": { + "repository": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "head": { + "type": "string", + "pattern": "^[0-9a-f]{40}$" + }, + "state": { + "type": "string", + "enum": [ + "judged", + "merged", + "refused" + ] + }, + "commit": { + "type": "string", + "description": "for merged, the merge commit", + "pattern": "^[0-9a-f]{40}$" + }, + "why": { + "type": "string", + "description": "for refused, why" + } + }, + "required": [ + "repository", + "number", + "head", + "state" + ] + } + }, + "bodies": { + "MergeCalled": { + "type": "object", + "description": "a merge call's members merged or refused, said once by the forge module (design 47 H \u00a7736, \u00a7767)", + "properties": { + "call": { + "type": "string", + "description": "the merge call, 16 lowercase hex characters made once per call", + "pattern": "^[0-9a-f]{16}$" + }, + "by": { + "type": "string", + "description": "the caller as who@node" + }, + "account": { + "type": "string", + "description": "the bus account the tool runner proved" + }, + "at": { + "type": "string", + "format": "date-time", + "description": "the time of the last merge" + }, + "members": { + "type": "array", + "description": "one per landed member", + "items": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "branch": { + "type": "string", + "description": "the pull request's base, a watched branch" + }, + "head": { + "type": "string", + "pattern": "^[0-9a-f]{40}$" + }, + "commit": { + "type": "string", + "description": "the merge commit the forge records for the pull request", + "pattern": "^[0-9a-f]{40}$" + } + }, + "required": [ + "repository", + "number", + "branch", + "head", + "commit" + ] + } + }, + "refused": { + "type": "array", + "description": "one per member not merged after every member was judged (design 47 H \u00a7767)", + "items": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "why": { + "type": "string" + } + }, + "required": [ + "repository", + "number", + "why" + ] + } + } + }, + "required": [ + "call", + "by", + "account", + "at", + "members" + ] } } } diff --git a/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts index 5fee3889..b2ee42ed 100644 --- a/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts @@ -1,6 +1,6 @@ // Code generated by seatgen from the seat definitions; DO NOT EDIT. -// The contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. The act verbs are the forge bridge's alone. +// The contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. export declare const seat: "git"; @@ -30,6 +30,7 @@ export declare const events: { readonly forgeDelete: "forge-delete"; readonly repoWritable: "repo-writable"; readonly branchMoved: "branch-moved"; + readonly mergeCalled: "merge-called"; }; export declare const family: { readonly name: "git.events"; readonly maxAgeDays: 7 }; @@ -52,8 +53,15 @@ export declare const branchMovedStream: "SEAT_git_branch-moved"; export declare const branchMovedSubject: "mesh.seat.git.event.branch-moved"; +export declare const mergeCalledStream: "SEAT_git_merge-called"; + +export declare function mergeCalledSubject(call: string): string; + +export declare const mergeCalledSubjectAll: "mesh.seat.git.event.merge-called.*"; + export declare const states: { readonly failedSteps: "failed-steps"; + readonly calls: "calls"; }; /** The key of one value of the state failed-steps under the form "..". */ @@ -62,6 +70,36 @@ export declare function failedStepsByModuleFingerprintStepKey(module: string, fi /** The parts of a key of the form "..", or undefined for a key of another form. */ export declare function parseFailedStepsByModuleFingerprintStepKey(_key: string): { module: string; fingerprint: string; step: string } | undefined; +/** The key of one value of the state calls under the form "call.". */ +export declare function callsByCallCallKey(call: string): string; + +/** The parts of a key of the form "call.", or undefined for a key of another form. */ +export declare function parseCallsByCallCallKey(_key: string): { call: string } | undefined; + +/** one merge call, written before its first merge and updated as each member merges (design 47 H §766) */ +export interface Call { + /** the bus account the tool runner proved for the call */ + "account": string; + "at": string; + /** the caller as who@node */ + "by": string; + "members": CallMember[]; + /** merge-called was said for it */ + "said": boolean; +} + +/** one member of a kept call */ +export interface CallMember { + /** for merged, the merge commit */ + "commit"?: string; + "head": string; + "number": number; + "repository": string; + "state": "judged" | "merged" | "refused"; + /** for refused, why */ + "why"?: string; +} + /** what a pull request changed */ export interface Change { /** the changed directories that hold a module at its head; absent when they could not be read */ @@ -96,6 +134,18 @@ export interface FailedStep { "v"?: number; } +/** one member of a merge call and where it stands (design 47 H §766, H-A-22) */ +export interface MemberOutcome { + /** for merged, the merge commit; for a member refused already-merged, its commit */ + "commit"?: string; + "number": number; + "repository": string; + /** judged, judged and not merged; merged, with its commit; refused, with why */ + "state": "judged" | "merged" | "refused"; + /** for refused, why, naming the step for a failed required step */ + "why"?: string; +} + /** what the forge would merge now, for an open pull request (issues 1275, 1945; ADR 0441 §1): answered whole or not at all, and a read the forge could not make answers the verb's error, never a guess; absent for a merged or closed one */ export interface Merging { /** the forge's own word on whether it merges into its base now: false while it is in conflict with its base, or while the forge works that out after the base moved */ @@ -159,6 +209,38 @@ export interface Status { "target"?: string; } +export interface MergeCalledMembersItem { + /** the pull request's base, a watched branch */ + "branch": string; + /** the merge commit the forge records for the pull request */ + "commit": string; + "head": string; + "number": number; + "repository": string; +} + +export interface MergeCalledRefusedItem { + "number": number; + "repository": string; + "why": string; +} + +/** a merge call's members merged or refused, said once by the forge module (design 47 H §736, §767) */ +export interface MergeCalled { + /** the bus account the tool runner proved */ + "account": string; + /** the time of the last merge */ + "at": string; + /** the caller as who@node */ + "by": string; + /** the merge call, 16 lowercase hex characters made once per call */ + "call": string; + /** one per landed member */ + "members": MergeCalledMembersItem[]; + /** one per member not merged after every member was judged (design 47 H §767) */ + "refused"?: MergeCalledRefusedItem[]; +} + /** is what pull takes. */ export interface PullInput { /** instead of the number: the merge commit it made */ @@ -193,8 +275,6 @@ export interface BranchAnswer { "error-kind"?: ErrorKind; /** a commit, its full 40-hex sha */ "head"?: string; - /** a protection rule refuses a direct push and admits only merges */ - "protected"?: boolean; "repository"?: string; } @@ -448,41 +528,32 @@ export interface NoteAnswer { "performed"?: boolean; } -/** is what merge-pull takes. */ -export interface MergePullInput { +export interface MergePullInputPullsItem { /** the head the caller names */ "head": string; - /** the act's id */ - "id": string; /** the pull request's number */ "number": number; /** the repository, / */ "repository": string; } +/** is what merge-pull takes. */ +export interface MergePullInput { + /** the caller as who@node, recorded beside the bus account the tool runner proves */ + "by": string; + /** the members, in the order they are merged */ + "pulls": MergePullInputPullsItem[]; +} + /** is what merge-pull answers. */ export interface MergePullAnswer { + /** the merge call, 16 lowercase hex characters made once per call */ + "call"?: string; /** why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none */ "error"?: string; "error-kind"?: ErrorKind; - /** the id was already held on the pull request or the note, so nothing was done again */ - "held"?: boolean; - /** the act's id, as the caller gave it */ - "id"?: string; - /** the merge commit */ - "merge-commit"?: string; - /** for policy-failed, the module */ - "module"?: string; - /** the forge holds the act now */ - "performed"?: boolean; - /** why the forge or the holder refused the merge; the act is not performed */ - "refused"?: string; - /** which refusal, set with refused: head-moved, the pull request's head is not the one named; unprotected, the base branch's protection does not refuse a direct push; policy-failed, a run at the head's fingerprint failed a required step (run, module and step name it); no-registrations, no registration-changed heard yet (ADR 0667 section 10); git-refused, git refused the merge */ - "refused-kind"?: "head-moved" | "unprotected" | "policy-failed" | "no-registrations" | "git-refused"; - /** for policy-failed, the run that failed the step: the runner's pipeline key */ - "run"?: string; - /** for policy-failed, the step */ - "step"?: string; + /** each member's outcome, in the order named */ + "members"?: MemberOutcome[]; } /** is what tag takes. */ @@ -646,6 +717,12 @@ export interface BranchMovedEvent { "repository": string; } +/** is the body of the event merge-called. */ +export type MergeCalledEvent = MergeCalled; + /** is one value of the state failed-steps under the key ... */ export type FailedStepsByModuleFingerprintStepValue = FailedStep; +/** is one value of the state calls under the key call.. */ +export type CallsByCallCallValue = Call; + diff --git a/modules/mesh-delivery-contracts/ts/seats/git/index.js b/modules/mesh-delivery-contracts/ts/seats/git/index.js index c0bea488..8fb5955d 100644 --- a/modules/mesh-delivery-contracts/ts/seats/git/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/git/index.js @@ -1,6 +1,6 @@ // Code generated by seatgen from the seat definitions; DO NOT EDIT. -// The contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. The act verbs are the forge bridge's alone. +// The contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. export const seat = "git"; @@ -30,6 +30,7 @@ export const events = { forgeDelete: "forge-delete", repoWritable: "repo-writable", branchMoved: "branch-moved", + mergeCalled: "merge-called", }; export const family = { name: "git.events", maxAgeDays: 7 }; @@ -52,8 +53,17 @@ export const branchMovedStream = "SEAT_git_branch-moved"; export const branchMovedSubject = "mesh.seat.git.event.branch-moved"; +export const mergeCalledStream = "SEAT_git_merge-called"; + +export function mergeCalledSubject(call) { + return "mesh.seat.git.event.merge-called." + call; +} + +export const mergeCalledSubjectAll = "mesh.seat.git.event.merge-called.*"; + export const states = { failedSteps: "failed-steps", + calls: "calls", }; /** The key of one value of the state failed-steps under the form "..". */ @@ -79,3 +89,20 @@ export function parseFailedStepsByModuleFingerprintStepKey(_key) { return { module, fingerprint, step }; } +/** The key of one value of the state calls under the form "call.". */ +export function callsByCallCallKey(call) { + return "call." + call; +} + +/** The parts of a key of the form "call.", or undefined for a key of another form. */ +export function parseCallsByCallCallKey(_key) { + let _rest = _key; + if (!_rest.startsWith("call.")) return undefined; + _rest = _rest.slice(5); + if (_rest === "") return undefined; + const call = _rest; + _rest = ""; + if (_rest !== "") return undefined; + return { call }; +} + -- 2.54.0 From 6e027de59773affe80d7bf45cf49d81292893ff1 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:49:32 +0100 Subject: [PATCH 007/104] C3: the source revision's contract: source-moved per source, record-opened per call, heads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit source-moved is said on source-moved.. with v, branch, source, call, start and heads [{repository, commit}], kept 30 days and 64 MiB on its own stream; its wildcard has two tokens (H-A-26). record-opened is said on record-opened.; it and record-ended carry branch, source and call, the milestone ., no forge-made fields (H-A-25). The source value carries source and call, the verb source answers call; the state heads keeps each untaken head {head, since} by .. The states merges, asks and turns, the verb groups, and the events approval-carried, pinned, freed, pins-stated and heads-replaced go (H-A-28, H-A-48), with their helpers in meshdeliveryclient. Builds: design 47 H §737, §740, §749, §764 (the gate's states, groups and switch); lead answers H-A-23, H-A-25, H-A-26, H-A-28, H-A-33, H-A-48 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/clients/meshdeliveryclient/gate.go | 277 +------ .../clients/meshdeliveryclient/gate_test.go | 114 +-- .../go/seats/meshdelivery/contract.go | 463 ++---------- .../go/seats/meshdelivery/contract_test.go | 44 +- .../seats/mesh-delivery/fixtures/events.json | 142 +--- .../seats/mesh-delivery/fixtures/states.json | 56 +- .../seats/mesh-delivery/fixtures/verbs.json | 70 +- .../seats/mesh-delivery/seat.json | 709 +++--------------- .../ts/seats/meshdelivery/index.d.ts | 321 ++------ .../ts/seats/meshdelivery/index.js | 92 +-- 10 files changed, 325 insertions(+), 1963 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go index 076ffc66..055d9398 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go +++ b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go @@ -5,15 +5,12 @@ import ( "encoding/json" "fmt" "reflect" - "strconv" - "strings" - "time" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-sdk/go/keys" ) -// The values of the seat's states `source`, `merges`, `asks`, `owed` and `turns`, in the seat's types: each is stamped +// The values of the seat's states `source` and `owed`, in the seat's types: each is stamped // with Version when encoded, read strictly (an unknown field refused) and its version checked when decoded, and its rules // held on both sides, so the gate that writes them and the readers (the forge bridge, the teller, the assigner, the view) // agree. What the schema cannot say is written here once (ADR 0625 §4). @@ -21,16 +18,6 @@ import ( // Version is the layout version of the seat's values. const Version = 1 -// MergeState is the state of a pull request in a merge. -type MergeState string - -// The states a merge's pull request is in. -const ( - MergeMerging MergeState = "merging" - MergeMerged MergeState = "merged" - MergeRefused MergeState = "refused" -) - // SourceKey is the key of the state source for a watched branch (design 47 *Watched branches and the catalog graph per // branch*: source. in place of source.main). func SourceKey(branch string) string { return seat.SourceByBranchKey(branch) } @@ -43,37 +30,6 @@ func encodeValue(v any, check error, stamp func()) ([]byte, error) { return json.Marshal(v) } -// ApprovedKey is the key, in a merge's approved heads, of a pull request: `@`. -func ApprovedKey(repository string, number int) string { - return repository + "@" + strconv.Itoa(number) -} - -// TurnsKey is the key, in the state turns, of a repository: `.`, lower-case and escaped. -func TurnsKey(repository string) (string, error) { - repository = strings.ToLower(repository) - part, err := escapeRepository(repository) - if err != nil { - return "", err - } - return strings.Replace(part, "/", ".", 1), nil -} - -// ParseTurnsKey is the inverse of TurnsKey; a key that does not name a lower-case / is refused. -func ParseTurnsKey(key string) (string, error) { - owner, name, ok := strings.Cut(key, ".") - if !ok || owner == "" || name == "" || strings.Contains(name, ".") { - return "", fmt.Errorf("meshdeliveryclient: %q is not a turns key, .", key) - } - repository, err := unescapeRepository(owner + "/" + name) - if err != nil { - return "", fmt.Errorf("meshdeliveryclient: %q is not a turns key: %w", key, err) - } - if again, err := TurnsKey(repository); err != nil || again != key { - return "", fmt.Errorf("meshdeliveryclient: %q is not a turns key: it does not name a lowercase /", key) - } - return repository, nil -} - // ----- source // CheckSource refuses a source naming no repository, a repository with no name or an empty head. @@ -112,120 +68,6 @@ func DecodeSource(data []byte) (seat.SourceByBranchValue, error) { // SameSource says whether two sources are the same. func SameSource(a, b seat.SourceByBranchValue) bool { return reflect.DeepEqual(a, b) } -// ----- merge - -// CheckMerge refuses a merge naming no group, ask or pull request, a pull request outside the approved heads or at -// another head than the Approve was for, and a state that lacks what it needs: merged its commit, refused the forge's words. -func CheckMerge(m seat.MergesByGroupValue) error { - if m.Group == "" { - return fmt.Errorf("meshdeliveryclient: a merge names no group") - } - if m.Ask == "" { - return fmt.Errorf("meshdeliveryclient: a merge names no ask") - } - if len(m.Pulls) == 0 { - return fmt.Errorf("meshdeliveryclient: a merge names no pull request") - } - for key, sha := range m.Approved { - if sha == "" { - return fmt.Errorf("meshdeliveryclient: the approved head of %s is empty", key) - } - } - for _, p := range m.Pulls { - who := fmt.Sprintf("%s#%d", p.Repository, p.Number) - if len(m.Approved) > 0 { - sha, ok := m.Approved[ApprovedKey(p.Repository, int(p.Number))] - if !ok { - return fmt.Errorf("meshdeliveryclient: the pull request %s is handed to the merge but is not among the approved heads", who) - } - if sha != p.Head { - return fmt.Errorf("meshdeliveryclient: the pull request %s is handed at head %q but the Approve was for %q", who, p.Head, sha) - } - } - switch MergeState(p.State) { - case MergeMerging: - case MergeMerged: - if p.Commit == "" { - return fmt.Errorf("meshdeliveryclient: the merged pull request %s has no merge commit", who) - } - case MergeRefused: - if p.Words == "" { - return fmt.Errorf("meshdeliveryclient: the refused pull request %s has no words of the forge", who) - } - default: - return fmt.Errorf("meshdeliveryclient: the state %q of %s is not merging, merged or refused", p.State, who) - } - } - return nil -} - -// EncodeMerge is m as the value of a group's key. -func EncodeMerge(m seat.MergesByGroupValue) ([]byte, error) { - return encodeValue(&m, CheckMerge(m), func() { m.V = Version }) -} - -// DecodeMerge reads the value of a group's key. -func DecodeMerge(data []byte) (seat.MergesByGroupValue, error) { - if err := keys.CheckVersion(data); err != nil { - return seat.MergesByGroupValue{}, err - } - m, err := seat.DecodeMergesByGroupValue(data) - if err != nil { - return m, fmt.Errorf("meshdeliveryclient: a merge does not fit its shape: %w", err) - } - return m, CheckMerge(m) -} - -// SameMerge says whether two merges are the same. -func SameMerge(a, b seat.MergesByGroupValue) bool { return reflect.DeepEqual(a, b) } - -// ----- ask - -// HeadsOf are an ask's heads as Heads (for HeadsHash and MergeAskKey). -func HeadsOf(items []seat.AsksByMergeGroupHeadsValueHeadsItem) []Head { - out := make([]Head, len(items)) - for i, h := range items { - out[i] = Head{Repository: h.Repository, Number: int(h.Number), Head: h.Head} - } - return out -} - -// CheckAsk refuses an ask with no group or heads, a negative count, or an ask that is no object. -func CheckAsk(a seat.AsksByMergeGroupHeadsValue) error { - if a.Asking < 0 { - return fmt.Errorf("meshdeliveryclient: the ask's asking %d is negative", a.Asking) - } - if _, err := MergeAskKey(a.Group, HeadsOf(a.Heads)); err != nil { - return fmt.Errorf("meshdeliveryclient: an ask needs its group and at least one pull request's head: %w", err) - } - raw, err := json.Marshal(a.Ask) - var fields map[string]json.RawMessage - if err != nil || len(bytes.TrimSpace(raw)) == 0 || json.Unmarshal(raw, &fields) != nil || fields == nil { - return fmt.Errorf("meshdeliveryclient: the value carries no router's ask") - } - return nil -} - -// EncodeAsk is a as the value of a merge ask's key; a.Ask may be a json.RawMessage. -func EncodeAsk(a seat.AsksByMergeGroupHeadsValue) ([]byte, error) { - return encodeValue(&a, CheckAsk(a), func() { a.V = Version }) -} - -// DecodeAsk reads the value of a merge ask's key; its Ask is the router's ask as a decoded object. -func DecodeAsk(data []byte) (seat.AsksByMergeGroupHeadsValue, error) { - if err := keys.CheckVersion(data); err != nil { - return seat.AsksByMergeGroupHeadsValue{}, err - } - a, err := seat.DecodeAsksByMergeGroupHeadsValue(data) - if err != nil { - return a, fmt.Errorf("meshdeliveryclient: an ask does not fit its shape: %w", err) - } - return a, CheckAsk(a) -} - -// SameAsk says whether two asks are the same (the router's ask by its content). -func SameAsk(a, b seat.AsksByMergeGroupHeadsValue) bool { return reflect.DeepEqual(a, b) } - // ----- owed // EncodeOwed is o as the value of an owed key, after CheckOwed. @@ -248,123 +90,6 @@ func DecodeOwed(data []byte) (seat.OwedByRepositoryNumberHeadActValue, error) { // SameOwed says whether two owed values are the same. func SameOwed(a, b seat.OwedByRepositoryNumberHeadActValue) bool { return a == b } -// ----- turns - -// CheckTurn refuses a turn whose repository is not lower-case, that names no delivery, or whose deliveries repeat a heads -// hash, lack their times, are out of the order of the Approve, or name a wait without a verdict key. -func CheckTurn(t seat.TurnsByRepositoryValue) error { - repository := strings.ToLower(t.Repository) - if repository != t.Repository { - return fmt.Errorf("meshdeliveryclient: the turn's repository %q is not lowercase", t.Repository) - } - if _, err := escapeRepository(repository); err != nil { - return err - } - if len(t.Waiting) == 0 { - return fmt.Errorf("meshdeliveryclient: the turn of %s names no delivery: its key is deleted instead", t.Repository) - } - seen := map[string]bool{} - for i, w := range t.Waiting { - if w.Group == "" { - return fmt.Errorf("meshdeliveryclient: a delivery in the turn of %s names no group", t.Repository) - } - if !hashOK.MatchString(w.Heads) { - return fmt.Errorf("meshdeliveryclient: the heads hash %q in the turn of %s is not 12 lowercase hex digits", w.Heads, t.Repository) - } - if seen[w.Heads] { - return fmt.Errorf("meshdeliveryclient: the turn of %s names the heads %s twice", t.Repository, w.Heads) - } - seen[w.Heads] = true - if w.Approved.IsZero() || w.Since.IsZero() { - return fmt.Errorf("meshdeliveryclient: the delivery %s in the turn of %s says no time of its Approve or of its wait", w.Group, t.Repository) - } - if i > 0 && w.Approved.Before(t.Waiting[i-1].Approved) { - return fmt.Errorf("meshdeliveryclient: the turn of %s is not in the order of the Approve: %s was approved before %s", t.Repository, w.Group, t.Waiting[i-1].Group) - } - if w.WaitsFor != "" { - if _, _, err := parseVerdictKey(w.WaitsFor); err != nil { - return fmt.Errorf("meshdeliveryclient: the delivery %s in the turn of %s waits for what is not a verdict key: %w", w.Group, t.Repository, err) - } - } else if (w.WaitsSince != nil && !w.WaitsSince.IsZero()) || w.Step != "" { - return fmt.Errorf("meshdeliveryclient: the delivery %s in the turn of %s says when and where a check runs, and names no check", w.Group, t.Repository) - } - } - return nil -} - -// parseVerdictKey is the checker's verdict key `.` (the checker's client has the same rule over its -// own seat; a client uses its own seat's contract alone). -func parseVerdictKey(key string) (group, heads string, err error) { - i := strings.LastIndex(key, ".") - if i < 0 || !hashOK.MatchString(key[i+1:]) || i == 0 || strings.Contains(key[:i], ".") { - return "", "", fmt.Errorf("%q is not a verdict key, .", key) - } - if group, err = keys.UnescapeName(key[:i]); err != nil { - return "", "", err - } - return group, key[i+1:], nil -} - -// TurnHolds says whether a delivery at these heads is not in the turn while the turn names others: the delivery's -// check or merge holds back for the one before it. -func TurnHolds(t seat.TurnsByRepositoryValue, heads string) bool { - if len(t.Waiting) == 0 { - return false - } - for _, w := range t.Waiting { - if w.Heads == heads { - return false - } - } - return true -} - -// EncodeTurn is t as the value of a repository's key. -func EncodeTurn(t seat.TurnsByRepositoryValue) ([]byte, error) { - if err := CheckTurn(t); err != nil { - return nil, err - } - t.V = Version - return json.Marshal(t) -} - -// DecodeTurn reads the value of a repository's key. -func DecodeTurn(data []byte) (seat.TurnsByRepositoryValue, error) { - if err := keys.CheckVersion(data); err != nil { - return seat.TurnsByRepositoryValue{}, err - } - t, err := seat.DecodeTurnsByRepositoryValue(data) - if err != nil { - return t, fmt.Errorf("meshdeliveryclient: a turn does not fit its shape: %w", err) - } - return t, CheckTurn(t) -} - -// SameTurn says whether two turns are the same, a time by the instant it names. -func SameTurn(a, b seat.TurnsByRepositoryValue) bool { - if len(a.Waiting) != len(b.Waiting) || a.Repository != b.Repository || a.V != b.V { - return false - } - for i := range a.Waiting { - x, y := a.Waiting[i], b.Waiting[i] - if !x.Approved.Equal(y.Approved) || !x.Since.Equal(y.Since) || !sameTime(x.WaitsSince, y.WaitsSince) { - return false - } - x.Approved, y.Approved, x.Since, y.Since, x.WaitsSince, y.WaitsSince = time.Time{}, time.Time{}, time.Time{}, time.Time{}, nil, nil - if !reflect.DeepEqual(x, y) { - return false - } - } - return true -} - -func sameTime(a, b *time.Time) bool { - if a == nil || a.IsZero() { - return b == nil || b.IsZero() - } - return b != nil && a.Equal(*b) -} - // Answer is the operator's answer to a merge ask as the gate acts on it: the option chosen, the warrant that proves who // answered, and the words said. It is the teller's state `answers` under the ask's key (the teller's own record; this is // its layout for the gate that reads it). diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go index 0e751573..c9cf3499 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go @@ -4,9 +4,7 @@ import ( "encoding/json" "errors" "reflect" - "strings" "testing" - "time" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-sdk/go/keys" @@ -31,8 +29,6 @@ func sameJSON(t *testing.T, got []byte, want string) { // The goldens are the output of go/delivery's Encode* before it was deleted; each value must encode to the same // document and decode back to what it was. func TestGateValuesEncodeAsGoDeliveryDid(t *testing.T) { - ap := time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC) - wait := ap.Add(2 * time.Minute) for _, c := range []struct { name string encode func() ([]byte, error) @@ -41,36 +37,15 @@ func TestGateValuesEncodeAsGoDeliveryDid(t *testing.T) { golden string }{ {"source", func() ([]byte, error) { - return EncodeSource(seat.SourceByBranchValue{Group: "fix/1.2", Heads: map[string]string{"novox/a": "aaaa", "novox/b": "bbbb"}}) + return EncodeSource(seat.SourceByBranchValue{Source: 1044, Call: "0123456789abcdef", Heads: map[string]string{"novox/a": "aaaa", "novox/b": "bbbb"}}) }, func(b []byte) (any, error) { return DecodeSource(b) }, - seat.SourceByBranchValue{V: 1, Group: "fix/1.2", Heads: map[string]string{"novox/a": "aaaa", "novox/b": "bbbb"}}, - `{"v":1,"group":"fix/1.2","heads":{"novox/a":"aaaa","novox/b":"bbbb"}}`}, - {"merge", func() ([]byte, error) { - return EncodeMerge(seat.MergesByGroupValue{Group: "g", Ask: "merge.g.0123456789ab", Approved: map[string]string{"novox/a@7": "h1"}, - Pulls: []seat.MergesByGroupValuePullsItem{{Repository: "novox/a", Number: 7, Head: "h1", State: "merged", Commit: "c1"}}}) - }, func(b []byte) (any, error) { return DecodeMerge(b) }, - seat.MergesByGroupValue{V: 1, Group: "g", Ask: "merge.g.0123456789ab", Approved: map[string]string{"novox/a@7": "h1"}, - Pulls: []seat.MergesByGroupValuePullsItem{{Repository: "novox/a", Number: 7, Head: "h1", State: "merged", Commit: "c1"}}}, - `{"v":1,"group":"g","ask":"merge.g.0123456789ab","approved":{"novox/a@7":"h1"},"pulls":[{"repository":"novox/a","number":7,"head":"h1","state":"merged","commit":"c1"}]}`}, - {"ask", func() ([]byte, error) { - return EncodeAsk(seat.AsksByMergeGroupHeadsValue{Group: "g", Asking: 2, Ask: json.RawMessage(`{"headline":"x"}`), - Heads: []seat.AsksByMergeGroupHeadsValueHeadsItem{{Repository: "novox/a", Number: 7, Head: "h1"}}}) - }, func(b []byte) (any, error) { return DecodeAsk(b) }, - seat.AsksByMergeGroupHeadsValue{V: 1, Group: "g", Asking: 2, Ask: map[string]any{"headline": "x"}, - Heads: []seat.AsksByMergeGroupHeadsValueHeadsItem{{Repository: "novox/a", Number: 7, Head: "h1"}}}, - `{"v":1,"group":"g","heads":[{"repository":"novox/a","number":7,"head":"h1"}],"ask":{"headline":"x"},"asking":2}`}, + seat.SourceByBranchValue{V: 1, Source: 1044, Call: "0123456789abcdef", Heads: map[string]string{"novox/a": "aaaa", "novox/b": "bbbb"}}, + `{"v":1,"source":1044,"call":"0123456789abcdef","heads":{"novox/a":"aaaa","novox/b":"bbbb"}}`}, {"owed", func() ([]byte, error) { return EncodeOwed(seat.OwedByRepositoryNumberHeadActValue{Act: OwedStatus, Context: StatusContextCheck, Target: "t", State: "pending"}) }, func(b []byte) (any, error) { return DecodeOwed(b) }, seat.OwedByRepositoryNumberHeadActValue{V: 1, Act: OwedStatus, Context: StatusContextCheck, Target: "t", State: "pending"}, `{"v":1,"act":"status","context":"mesh/check","target":"t","state":"pending"}`}, - {"turn", func() ([]byte, error) { - return EncodeTurn(seat.TurnsByRepositoryValue{Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{ - Group: "g", Heads: "0123456789ab", Ask: "k", Approved: ap, Since: ap.Add(time.Minute), WaitsFor: "g.0123456789ab", WaitsSince: &wait, Step: "s"}}}) - }, func(b []byte) (any, error) { return DecodeTurn(b) }, - seat.TurnsByRepositoryValue{V: 1, Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{ - Group: "g", Heads: "0123456789ab", Ask: "k", Approved: ap, Since: ap.Add(time.Minute), WaitsFor: "g.0123456789ab", WaitsSince: &wait, Step: "s"}}}, - `{"v":1,"repository":"novox/a","waiting":[{"group":"g","heads":"0123456789ab","ask":"k","approved":"2026-11-05T10:00:00Z","since":"2026-11-05T10:01:00Z","waits-for":"g.0123456789ab","waits-since":"2026-11-05T10:02:00Z","step":"s"}]}`}, {"answer", func() ([]byte, error) { return EncodeAnswer(Answer{Option: "merge", Warrant: "w", Words: "ok"}) }, func(b []byte) (any, error) { return DecodeAnswer(b) }, Answer{V: 1, Option: "merge", Warrant: "w", Words: "ok"}, `{"v":1,"option":"merge","warrant":"w","words":"ok"}`}, @@ -88,26 +63,6 @@ func TestGateValuesEncodeAsGoDeliveryDid(t *testing.T) { } func TestGateKeysAsGoDeliveryHadThem(t *testing.T) { - for in, want := range map[string]string{"novox/Mesh-sdk": "novox.mesh-sdk", "novox/mesh-sdk": "novox.mesh-sdk", "novox/mesh.x": "novox.mesh=2ex"} { - got, err := TurnsKey(in) - if err != nil || got != want { - t.Errorf("TurnsKey(%q) = %q, %v; want %q", in, got, err, want) - } - } - if r, err := ParseTurnsKey("novox.mesh=2ex"); err != nil || r != "novox/mesh.x" { - t.Errorf("%q %v", r, err) - } - for _, bad := range []string{"novox", "novox.Mesh", "a.b.c", ".x", "novox.mesh-sdk."} { - if _, err := ParseTurnsKey(bad); err == nil { - t.Errorf("%q parses as a turns key", bad) - } - } - if _, err := TurnsKey("novox"); err == nil { - t.Error("a repository with no slash keys") - } - if k := ApprovedKey("novox/a", 7); k != "novox/a@7" { - t.Error(k) - } if SourceKey("beta") != seat.SourceByBranchKey("beta") || SourceKey("beta") != "beta" { t.Error("the source's key is the seat's, one per watched branch") } @@ -176,73 +131,16 @@ func TestGateKeysAsGoDeliveryHadThem(t *testing.T) { } func TestGateValuesRefuseWhatTheirRulesRefuse(t *testing.T) { - ap := time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC) - pull := seat.MergesByGroupValuePullsItem{Repository: "novox/a", Number: 7, Head: "h1", State: "merging"} - merge := func(edit func(*seat.MergesByGroupValue)) error { - m := seat.MergesByGroupValue{Group: "g", Ask: "k", Pulls: []seat.MergesByGroupValuePullsItem{pull}} - edit(&m) - _, err := EncodeMerge(m) - return err - } - turn := func(edit func(*seat.TurnsByRepositoryValue)) error { - tv := seat.TurnsByRepositoryValue{Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{Group: "g", Heads: "0123456789ab", Approved: ap, Since: ap}}} - edit(&tv) - _, err := EncodeTurn(tv) - return err - } - for name, c := range map[string]struct { - err error - want string - }{ - "merge: no group": {merge(func(m *seat.MergesByGroupValue) { m.Group = "" }), "no group"}, - "merge: no pull": {merge(func(m *seat.MergesByGroupValue) { m.Pulls = nil }), "no pull request"}, - "merge: not approved": {merge(func(m *seat.MergesByGroupValue) { m.Approved = map[string]string{"novox/b@1": "x"} }), "not among the approved"}, - "merge: other head": {merge(func(m *seat.MergesByGroupValue) { m.Approved = map[string]string{"novox/a@7": "x"} }), "Approve was for"}, - "merge: merged no commit": {merge(func(m *seat.MergesByGroupValue) { m.Pulls[0].State = "merged" }), "no merge commit"}, - "merge: refused no words": {merge(func(m *seat.MergesByGroupValue) { m.Pulls[0].State = "refused" }), "no words"}, - "merge: unknown state": {merge(func(m *seat.MergesByGroupValue) { m.Pulls[0].State = "lost" }), "not merging, merged or refused"}, - "turn: upper case": {turn(func(v *seat.TurnsByRepositoryValue) { v.Repository = "Novox/a" }), "not lowercase"}, - "turn: empty": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting = nil }), "names no delivery"}, - "turn: bad hash": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].Heads = "xyz" }), "12 lowercase hex"}, - "turn: no time": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].Since = time.Time{} }), "no time"}, - "turn: step with no wait": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].Step = "s" }), "names no check"}, - "turn: not a verdict key": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].WaitsFor = "nope" }), "not a verdict key"}, - } { - if c.err == nil || !strings.Contains(c.err.Error(), c.want) { - t.Errorf("%s: %v, want %q", name, c.err, c.want) - } - } - if _, err := EncodeSource(seat.SourceByBranchValue{Group: "g"}); err == nil { + if _, err := EncodeSource(seat.SourceByBranchValue{Source: 1, Call: "0123456789abcdef"}); err == nil { t.Error("an empty source encodes") } - if _, err := EncodeAsk(seat.AsksByMergeGroupHeadsValue{Group: "g", Ask: "text", Heads: []seat.AsksByMergeGroupHeadsValueHeadsItem{{Repository: "novox/a", Number: 1, Head: "h"}}}); err == nil { - t.Error("an ask that is no object encodes") - } if _, err := EncodeAnswer(Answer{Option: "merge"}); err == nil { t.Error("an answer with no warrant encodes") } - if _, err := DecodeSource([]byte(`{"v":2,"group":"g","heads":{"a":"b"}}`)); !errors.Is(err, keys.ErrUnknownVersion) { + if _, err := DecodeSource([]byte(`{"v":2,"source":1,"call":"c","heads":{"a":"b"}}`)); !errors.Is(err, keys.ErrUnknownVersion) { t.Errorf("another version: %v", err) } - if _, err := DecodeMerge([]byte(`{"v":1,"group":"g","ask":"k","pulls":[],"extra":1}`)); err == nil { + if _, err := DecodeSource([]byte(`{"v":1,"source":1,"call":"c","heads":{"a":"b"},"extra":1}`)); err == nil { t.Error("an unknown field decodes") } } - -func TestTurnHoldsAndSameTurn(t *testing.T) { - ap := time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC) - tv := seat.TurnsByRepositoryValue{V: 1, Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{Group: "g", Heads: "0123456789ab", Approved: ap, Since: ap}}} - if TurnHolds(tv, "0123456789ab") || !TurnHolds(tv, "ba9876543210") || TurnHolds(seat.TurnsByRepositoryValue{}, "x") { - t.Error("a turn holds a delivery that is not in it while others wait") - } - other := tv - other.Waiting = []seat.TurnsByRepositoryValueWaitingItem{tv.Waiting[0]} - other.Waiting[0].Approved = ap.In(time.FixedZone("x", 3600)) - if !SameTurn(tv, other) { - t.Error("the same instant in another zone is another turn") - } - other.Waiting[0].Since = ap.Add(time.Second) - if SameTurn(tv, other) { - t.Error("another instant is the same turn") - } -} diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go index 1d72a015..bd4badad 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go @@ -17,36 +17,30 @@ const Seat = "mesh-delivery" const ( VerbDeliveries = "deliveries" VerbShow = "show" - VerbGroups = "groups" VerbSource = "source" VerbStalled = "stalled" VerbRecovery = "recovery" ) const ( - EventOwed = "owed" - EventPinned = "pinned" - EventFreed = "freed" - EventHeadsReplaced = "heads-replaced" - EventRecordOpened = "record-opened" - EventRecordEnded = "record-ended" - EventFilling = "filling" - EventFull = "full" - EventRoom = "room" - EventSourceMoved = "source-moved" - EventRecoveryMerged = "recovery-merged" - EventApprovalCarried = "approval-carried" - EventPinsStated = "pins-stated" + EventOwed = "owed" + EventRecordOpened = "record-opened" + EventRecordEnded = "record-ended" + EventFilling = "filling" + EventFull = "full" + EventRoom = "room" + EventSourceMoved = "source-moved" + EventRecoveryMerged = "recovery-merged" ) // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { - return []string{VerbDeliveries, VerbShow, VerbGroups, VerbSource, VerbStalled, VerbRecovery} + return []string{VerbDeliveries, VerbShow, VerbSource, VerbStalled, VerbRecovery} } // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventOwed, EventPinned, EventFreed, EventHeadsReplaced, EventRecordOpened, EventRecordEnded, EventFilling, EventFull, EventRoom, EventSourceMoved, EventRecoveryMerged, EventApprovalCarried, EventPinsStated} + return []string{EventOwed, EventRecordOpened, EventRecordEnded, EventFilling, EventFull, EventRoom, EventSourceMoved, EventRecoveryMerged} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -66,17 +60,13 @@ func SubjectOwed(repository, number string) string { // SubjectOwedAll hears every owed. const SubjectOwedAll = "mesh.seat.mesh-delivery.event.owed.*.*" -// SubjectPinned is where pinned is published. -const SubjectPinned = "mesh.seat.mesh-delivery.event.pinned" +// SubjectRecordOpened is where record-opened is published, on mesh.seat.mesh-delivery.event.record-opened.. +func SubjectRecordOpened(call string) string { + return "mesh.seat.mesh-delivery.event.record-opened." + call +} -// SubjectFreed is where freed is published. -const SubjectFreed = "mesh.seat.mesh-delivery.event.freed" - -// SubjectHeadsReplaced is where heads-replaced is published. -const SubjectHeadsReplaced = "mesh.seat.mesh-delivery.event.heads-replaced" - -// SubjectRecordOpened is where record-opened is published. -const SubjectRecordOpened = "mesh.seat.mesh-delivery.event.record-opened" +// SubjectRecordOpenedAll hears every record-opened. +const SubjectRecordOpenedAll = "mesh.seat.mesh-delivery.event.record-opened.*" // SubjectRecordEnded is where record-ended is published. const SubjectRecordEnded = "mesh.seat.mesh-delivery.event.record-ended" @@ -90,37 +80,24 @@ const SubjectFull = "mesh.seat.mesh-delivery.event.full" // SubjectRoom is where room is published. const SubjectRoom = "mesh.seat.mesh-delivery.event.room" -// SubjectSourceMoved is where source-moved is published, on mesh.seat.mesh-delivery.event.source-moved.. -func SubjectSourceMoved(branch string) string { - return "mesh.seat.mesh-delivery.event.source-moved." + branch +// StreamSourceMoved is the stream source-moved is kept in. +const StreamSourceMoved = "SEAT_mesh-delivery_source-moved" + +// SubjectSourceMoved is where source-moved is published, on mesh.seat.mesh-delivery.event.source-moved... +func SubjectSourceMoved(branch, source string) string { + return "mesh.seat.mesh-delivery.event.source-moved." + branch + "." + source } // SubjectSourceMovedAll hears every source-moved. -const SubjectSourceMovedAll = "mesh.seat.mesh-delivery.event.source-moved.*" +const SubjectSourceMovedAll = "mesh.seat.mesh-delivery.event.source-moved.*.*" // SubjectRecoveryMerged is where recovery-merged is published. const SubjectRecoveryMerged = "mesh.seat.mesh-delivery.event.recovery-merged" -// StreamApprovalCarried is the stream approval-carried is kept in. -const StreamApprovalCarried = "SEAT_mesh-delivery_approval-carried" - -// SubjectApprovalCarried is where approval-carried is published, on mesh.seat.mesh-delivery.event.approval-carried... -func SubjectApprovalCarried(repository, pull string) string { - return "mesh.seat.mesh-delivery.event.approval-carried." + repository + "." + pull -} - -// SubjectApprovalCarriedAll hears every approval-carried. -const SubjectApprovalCarriedAll = "mesh.seat.mesh-delivery.event.approval-carried.*.*" - -// SubjectPinsStated is where pins-stated is published. -const SubjectPinsStated = "mesh.seat.mesh-delivery.event.pins-stated" - const ( StateSource = "source" - StateMerges = "merges" - StateAsks = "asks" StateOwed = "owed" - StateTurns = "turns" + StateHeads = "heads" ) // SourceByBranchKey is the key of one value of the state source under the form "". @@ -154,77 +131,6 @@ func DecodeSourceByBranchValue(raw []byte) (SourceByBranchValue, error) { return v, nil } -// MergesByGroupKey is the key of one value of the state merges under the form "". -func MergesByGroupKey(group string) string { return group } - -// ParseMergesByGroupKey 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 ParseMergesByGroupKey(key string) (string, bool) { - rest := key - if rest == "" { - return "", false - } - v0 := rest - rest = "" - if rest != "" { - return "", false - } - return v0, true -} - -// DecodeMergesByGroupValue reads one value of the state merges under the form "", refusing a field MergesByGroupValue does not know and any text after the value. -func DecodeMergesByGroupValue(raw []byte) (MergesByGroupValue, error) { - var v MergesByGroupValue - 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 -} - -// AsksByMergeGroupHeadsKey is the key of one value of the state asks under the form "merge..". -func AsksByMergeGroupHeadsKey(group, heads string) string { return "merge." + group + "." + heads } - -// ParseAsksByMergeGroupHeadsKey reads the parts of a key of the form "merge..", in the order of the form; the last result is false for a key of another form. -func ParseAsksByMergeGroupHeadsKey(key string) (string, string, bool) { - rest := key - if !strings.HasPrefix(rest, "merge.") { - return "", "", false - } - rest = rest[6:] - v1, after1, found1 := strings.Cut(rest, ".") - if !found1 || v1 == "" { - return "", "", false - } - rest = after1 - if rest == "" { - return "", "", false - } - v3 := rest - rest = "" - if rest != "" { - return "", "", false - } - return v1, v3, true -} - -// DecodeAsksByMergeGroupHeadsValue reads one value of the state asks under the form "merge..", refusing a field AsksByMergeGroupHeadsValue does not know and any text after the value. -func DecodeAsksByMergeGroupHeadsValue(raw []byte) (AsksByMergeGroupHeadsValue, error) { - var v AsksByMergeGroupHeadsValue - 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 @@ -273,26 +179,31 @@ func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumbe return v, nil } -// TurnsByRepositoryKey is the key of one value of the state turns under the form "". -func TurnsByRepositoryKey(repository string) string { return repository } +// HeadsByRepositoryBranchKey is the key of one value of the state heads under the form ".". +func HeadsByRepositoryBranchKey(repository, branch string) string { return repository + "." + branch } -// ParseTurnsByRepositoryKey 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 ParseTurnsByRepositoryKey(key string) (string, bool) { +// ParseHeadsByRepositoryBranchKey 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 ParseHeadsByRepositoryBranchKey(key string) (string, string, bool) { rest := key - if rest == "" { - return "", false + v0, after0, found0 := strings.Cut(rest, ".") + if !found0 || v0 == "" { + return "", "", false } - v0 := rest + rest = after0 + if rest == "" { + return "", "", false + } + v2 := rest rest = "" if rest != "" { - return "", false + return "", "", false } - return v0, true + return v0, v2, true } -// DecodeTurnsByRepositoryValue reads one value of the state turns under the form "", refusing a field TurnsByRepositoryValue does not know and any text after the value. -func DecodeTurnsByRepositoryValue(raw []byte) (TurnsByRepositoryValue, error) { - var v TurnsByRepositoryValue +// DecodeHeadsByRepositoryBranchValue reads one value of the state heads under the form ".", refusing a field HeadsByRepositoryBranchValue does not know and any text after the value. +func DecodeHeadsByRepositoryBranchValue(raw []byte) (HeadsByRepositoryBranchValue, error) { + var v HeadsByRepositoryBranchValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { @@ -304,46 +215,6 @@ func DecodeTurnsByRepositoryValue(raw []byte) (TurnsByRepositoryValue, error) { return v, nil } -// Act is an act the gate said for a group, with its recorded outcome once the forge bridge said one. -type Act struct { - // when the outcome was recorded - At *time.Time `json:"at,omitempty"` - // the outcome the forge bridge said as owed.ended and the gate recorded; absent while unanswered - Outcome string `json:"outcome,omitempty"` - Owed Owed `json:"owed"` - // the forge's own words for a refusal, the error for an act that could not be performed, why one is undecodable or dropped - Words string `json:"words,omitempty"` -} - -// The values of Act's outcome. -const ( - ActOutcomePerformed = "performed" - ActOutcomeRefused = "refused" - ActOutcomeCouldNotBePerformed = "could not be performed" - ActOutcomeUndecodable = "undecodable" - ActOutcomeDropped = "dropped" -) - -// Ask is the one Approve ask of a milestone (ADR 0493 §9), said apart from each delivery's transition. -type Ask struct { - // on answered: approve or decline - Answer string `json:"answer,omitempty"` - // the ask's id - Ask string `json:"ask"` - // when - At *time.Time `json:"at,omitempty"` - // on answered: who answered - By string `json:"by,omitempty"` - // its delivery group - Group string `json:"group"` - // repository to the head asked - Heads map[string]string `json:"heads,omitempty"` - // the milestone - Milestone string `json:"milestone"` - // on withdrawn: why, such as a new head of a member - Why string `json:"why,omitempty"` -} - // Fill is the delivery records' ledger's fill against its cap. type Fill struct { // when @@ -357,40 +228,6 @@ type Fill struct { Store string `json:"store"` } -// Group is one delivery group: its members, its derived state and the acts the gate said for it. -type Group struct { - // the acts the gate said for it, each with its id and its recorded outcome; an id said and not answered is the forge bridge's to perform - Acts []Act `json:"acts"` - // the group's check: its verdict, or asked as - Check string `json:"check,omitempty"` - // the group's id, its branch - ID string `json:"id"` - // its members in merge order - Members []Member `json:"members"` - // its state, derived from its members - State string `json:"state"` - // why it is in that state - Why string `json:"why,omitempty"` -} - -// Member is one member of a group: a pull request. -type Member struct { - // the branch it merges into - Base string `json:"base,omitempty"` - // its head - Head string `json:"head"` - // the member's delivery id - ID string `json:"id"` - // the pull request's number - Number int64 `json:"number"` - // the pull request is open: not merged, closed or final - Open bool `json:"open,omitempty"` - // the repository, / - Repository string `json:"repository"` - // the member's delivery state - State string `json:"state"` -} - // Owed is one act the gate owes the forge, said once under its id and safe to repeat at the forge (design 47 *What the gate owes the forge*); the forge bridge performs it through the seat git's verb of the same act. type Owed struct { // the act: merge (the seat git's merge-pull), status, view, comment or note @@ -434,28 +271,6 @@ const ( OwedActNote = "note" ) -// PinsCatalogItem is one catalog graph revision, named by its watched branch and its number on the seat mesh-catalog (revisions are numbered per branch). -type PinsCatalogItem struct { - // the watched branch the revision belongs to - Branch string `json:"branch"` - // its number on that branch - Revision int64 `json:"revision"` -} - -// Pins is the graph revisions a delivery record starts or stops pointing at. -type Pins struct { - // assignment graph revisions, by their number on the seat mesh-wants - Assignment []int64 `json:"assignment,omitempty"` - // catalog graph revisions, by watched branch and number on the seat mesh-catalog - Catalog []PinsCatalogItem `json:"catalog,omitempty"` - // the record's milestone - Milestone string `json:"milestone"` - // the record's id - Record string `json:"record"` - // on freed: the record ended past its retention, or was removed by hand - Why string `json:"why,omitempty"` -} - // SourceHead is one repository of the source revision: its trunk branch and that trunk's head. type SourceHead struct { // the trunk's head the source revision names @@ -496,27 +311,6 @@ type ShowInput struct { // ShowAnswer is what show answers. type ShowAnswer = map[string]any -// GroupsInput is what groups takes. -type GroupsInput struct { - // "true": the groups that ended too - All string `json:"all,omitempty"` - // one group's id: that group alone, ended or not - Group string `json:"group,omitempty"` -} - -// The values of GroupsInput's all. -const ( - GroupsInputAllTrue = "true" - GroupsInputAllFalse = "false" -) - -// GroupsAnswer is what groups answers. -type GroupsAnswer struct { - // why it could not answer at all; a group it does not know is answered with no groups, never an error - Error string `json:"error,omitempty"` - Groups []Group `json:"groups,omitempty"` -} - // SourceInput is what source takes. type SourceInput struct { // the watched branch, escaped as a key name is; absent: the answer is the list of the branches the gate keeps a source revision of (design 47 G section 690) @@ -529,10 +323,10 @@ type SourceAnswer struct { Branch string `json:"branch,omitempty"` // given no branch: the branch name of each source. key the gate keeps, which every reader of the catalog half follows before the first registrations (design 47 G section 614, section 690) Branches []string `json:"branches,omitempty"` + // the merge call that moved the source revision last; absent before the first + Call string `json:"call,omitempty"` // why it could not be read Error string `json:"error,omitempty"` - // the group that moved the source revision last; absent before the first - Group string `json:"group,omitempty"` // every repository the source revision names, by name Repositories []SourceHead `json:"repositories,omitempty"` // the source revision's number on the bus; 0 before the first @@ -570,48 +364,20 @@ type RecoveryAnswer struct { // OwedEvent is the body of the event owed. type OwedEvent = Owed -// PinnedEvent is the body of the event pinned. -type PinnedEvent = Pins - -// FreedEvent is the body of the event freed. -type FreedEvent = Pins - -// HeadsReplacedEvent is the body of the event heads-replaced. -type HeadsReplacedEvent struct { - // when - At *time.Time `json:"at,omitempty"` - // the pull request closed - Closed bool `json:"closed,omitempty"` - // the group - Group string `json:"group"` - // its new head; absent when it closed - Head string `json:"head,omitempty"` - // the candidate's heads, 12 hex digits, as its revisions are keyed - Heads string `json:"heads"` - // its pull request's number - Number int64 `json:"number"` - // the member whose head moved or which closed - Repository string `json:"repository"` -} - // RecordOpenedEvent is the body of the event record-opened. type RecordOpenedEvent struct { // when At *time.Time `json:"at,omitempty"` - // for a forge-made record, the branch the merge moved - Branch string `json:"branch,omitempty"` - // for a forge-made record, the merge commit - Commit string `json:"commit,omitempty"` - // a merge made at the forge, with no Approve - ForgeMade bool `json:"forge-made,omitempty"` - // its milestone + // the watched branch + Branch string `json:"branch"` + // the merge call + Call string `json:"call"` + // its milestone, . Milestone string `json:"milestone"` - // for a forge-made record, the pull request's number - Pull int64 `json:"pull,omitempty"` // the record's id Record string `json:"record"` - // for a forge-made record, the repository, / - Repository string `json:"repository,omitempty"` + // the source revision + Source int64 `json:"source"` } // RecordEndedEventAwayItem is a type of the contract. @@ -628,12 +394,16 @@ type RecordEndedEvent struct { At *time.Time `json:"at,omitempty"` // the nodes away, each with since when; it ends without them Away []RecordEndedEventAwayItem `json:"away,omitempty"` - // a merge made at the forge, with no Approve - ForgeMade bool `json:"forge-made,omitempty"` - // its milestone + // the watched branch + Branch string `json:"branch"` + // the merge call + Call string `json:"call"` + // its milestone, . Milestone string `json:"milestone"` // the record's id Record string `json:"record"` + // the source revision + Source int64 `json:"source"` } // FillingEvent is the body of the event filling. @@ -645,14 +415,24 @@ type FullEvent = Fill // RoomEvent is the body of the event room. type RoomEvent = Fill +// SourceMovedEventHeadsItem is a type of the contract. +type SourceMovedEventHeadsItem struct { + Commit string `json:"commit"` + Repository string `json:"repository"` +} + // SourceMovedEvent is the body of the event source-moved. type SourceMovedEvent struct { - At *time.Time `json:"at,omitempty"` - Branch string `json:"branch"` - // the group that moved it, when one did - Group string `json:"group,omitempty"` - Revision int64 `json:"revision"` - V int64 `json:"v,omitempty"` + Branch string `json:"branch"` + // the merge call that moved it + Call string `json:"call"` + // the repositories it moved + Heads []SourceMovedEventHeadsItem `json:"heads"` + // the source revision, numbered by the gate alone + Source int64 `json:"source"` + // true only for a branch's first revision (design 47 H §768) + Start bool `json:"start"` + V int64 `json:"v"` } // RecoveryMergedEvent is the body of the event recovery-merged. @@ -673,76 +453,14 @@ type RecoveryMergedEvent struct { Why string `json:"why"` } -// ApprovalCarriedEvent is the body of the event approval-carried. -type ApprovalCarriedEvent struct { - // who approved: the operator - Approver string `json:"approver"` - // when it was said, RFC 3339 - At time.Time `json:"at"` - // the head the Approve named - Commit string `json:"commit"` - // the pull request's number - Pull int64 `json:"pull"` - // the repository - Repository string `json:"repository"` -} - -// PinsStatedEvent is the body of the event pins-stated. -type PinsStatedEvent struct { - // when it was said, RFC 3339 - At time.Time `json:"at"` -} - // SourceByBranchValue is one value of the state source under the key . type SourceByBranchValue struct { - // the group that moved it - Group string `json:"group"` + // the merge call that moved it; a call the newest revision already carries writes nothing (design 47 H §737, H-A-33) + Call string `json:"call"` // repository to the merged head, a full commit Heads map[string]string `json:"heads"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// MergesByGroupValuePullsItem is a type of the contract. -type MergesByGroupValuePullsItem struct { - Commit string `json:"commit,omitempty"` - Head string `json:"head"` - Number int64 `json:"number"` - Repository string `json:"repository"` - // merging, merged or refused - State string `json:"state"` - Words string `json:"words,omitempty"` -} - -// MergesByGroupValue is one value of the state merges under the key . -type MergesByGroupValue struct { - // @ to the approved head - Approved map[string]string `json:"approved,omitempty"` - // the ask key - Ask string `json:"ask"` - Group string `json:"group"` - Pulls []MergesByGroupValuePullsItem `json:"pulls"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// AsksByMergeGroupHeadsValueHeadsItem is a type of the contract. -type AsksByMergeGroupHeadsValueHeadsItem struct { - // the full commit - Head string `json:"head"` - Number int64 `json:"number"` - // / - Repository string `json:"repository"` -} - -// AsksByMergeGroupHeadsValue is one value of the state asks under the key merge... -type AsksByMergeGroupHeadsValue struct { - // the operator-channel ask as raised - Ask any `json:"ask"` - // the number of times it was asked - Asking int64 `json:"asking,omitempty"` - Group string `json:"group"` - Heads []AsksByMergeGroupHeadsValueHeadsItem `json:"heads"` + // the branch's source revision, one above its newest + Source int64 `json:"source"` // the layout version V int64 `json:"v,omitempty"` } @@ -760,25 +478,10 @@ type OwedByRepositoryNumberHeadActValue struct { V int64 `json:"v,omitempty"` } -// TurnsByRepositoryValueWaitingItem is a type of the contract. -type TurnsByRepositoryValueWaitingItem struct { - // when (RFC 3339 time) - Approved time.Time `json:"approved"` - Ask string `json:"ask,omitempty"` - Group string `json:"group"` - Heads string `json:"heads"` - // when (RFC 3339 time) - Since time.Time `json:"since"` - Step string `json:"step,omitempty"` - WaitsFor string `json:"waits-for,omitempty"` - // when (RFC 3339 time) - WaitsSince *time.Time `json:"waits-since,omitempty"` -} - -// TurnsByRepositoryValue is one value of the state turns under the key . -type TurnsByRepositoryValue struct { - Repository string `json:"repository"` - // the layout version - V int64 `json:"v,omitempty"` - Waiting []TurnsByRepositoryValueWaitingItem `json:"waiting"` +// HeadsByRepositoryBranchValue is one value of the state heads under the key .. +type HeadsByRepositoryBranchValue struct { + // the head head-moved said + Head string `json:"head"` + // when it was first heard + Since time.Time `json:"since"` } diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go index 74c1e381..364734a0 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go @@ -21,19 +21,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "owed is said, a status", subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}", wire: "{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"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\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "pinned is said", subject: "mesh.seat.mesh-delivery.event.pinned", given: "{\"assignment\":[1204],\"catalog\":[{\"branch\":\"main\",\"revision\":3610}],\"milestone\":\"47/G\",\"record\":\"47-G\"}", wire: "{\"assignment\":[1204],\"catalog\":[{\"branch\":\"main\",\"revision\":3610}],\"milestone\":\"47/G\",\"record\":\"47-G\"}", - decode: func(b []byte) (any, error) { var v PinnedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.pinned$")}, - {name: "freed is said", subject: "mesh.seat.mesh-delivery.event.freed", given: "{\"assignment\":[1204],\"catalog\":[{\"branch\":\"main\",\"revision\":3610}],\"milestone\":\"47/G\",\"record\":\"47-G\",\"why\":\"past its retention of 90 days\"}", wire: "{\"assignment\":[1204],\"catalog\":[{\"branch\":\"main\",\"revision\":3610}],\"milestone\":\"47/G\",\"record\":\"47-G\",\"why\":\"past its retention of 90 days\"}", - decode: func(b []byte) (any, error) { var v FreedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.freed$")}, - {name: "heads-replaced is said", subject: "mesh.seat.mesh-delivery.event.heads-replaced", given: "{\"at\":\"2026-11-09T20:05:00Z\",\"group\":\"feat/47-G\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"at\":\"2026-11-09T20:05:00Z\",\"group\":\"feat/47-G\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", - decode: func(b []byte) (any, error) { var v HeadsReplacedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.heads-replaced$")}, - {name: "heads-replaced is said for a closed pull request", subject: "mesh.seat.mesh-delivery.event.heads-replaced", given: "{\"closed\":true,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"closed\":true,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", - decode: func(b []byte) (any, error) { var v HeadsReplacedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.heads-replaced$")}, - {name: "record-opened is said", subject: "mesh.seat.mesh-delivery.event.record-opened", given: "{\"at\":\"2026-11-09T18:00:00Z\",\"milestone\":\"47/G\",\"record\":\"47-G\"}", wire: "{\"at\":\"2026-11-09T18:00:00Z\",\"milestone\":\"47/G\",\"record\":\"47-G\"}", - decode: func(b []byte) (any, error) { var v RecordOpenedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-opened$")}, - {name: "record-opened is said for a merge made at the forge", subject: "mesh.seat.mesh-delivery.event.record-opened", given: "{\"at\":\"2026-11-09T18:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"forge-made\":true,\"milestone\":\"47/G\",\"pull\":35,\"record\":\"mesh-tools-35\",\"repository\":\"novox/mesh-tools\"}", wire: "{\"at\":\"2026-11-09T18:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"forge-made\":true,\"milestone\":\"47/G\",\"pull\":35,\"record\":\"mesh-tools-35\",\"repository\":\"novox/mesh-tools\"}", - decode: func(b []byte) (any, error) { var v RecordOpenedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-opened$")}, - {name: "record-ended is said", subject: "mesh.seat.mesh-delivery.event.record-ended", given: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"milestone\":\"47/G\",\"record\":\"47-G\"}", wire: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"milestone\":\"47/G\",\"record\":\"47-G\"}", + {name: "record-opened is said", subject: "mesh.seat.mesh-delivery.event.record-opened.0123456789abcdef", given: "{\"at\":\"2026-11-20T02:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", wire: "{\"at\":\"2026-11-20T02:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", + decode: func(b []byte) (any, error) { var v RecordOpenedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-opened\\.[^.*> ]+$")}, + {name: "record-ended is said", subject: "mesh.seat.mesh-delivery.event.record-ended", given: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", wire: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", decode: func(b []byte) (any, error) { var v RecordEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-ended$")}, {name: "filling is said", subject: "mesh.seat.mesh-delivery.event.filling", given: "{\"bytes\":650000000,\"cap\":805306368,\"store\":\"records\"}", wire: "{\"bytes\":650000000,\"cap\":805306368,\"store\":\"records\"}", decode: func(b []byte) (any, error) { var v FillingEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.filling$")}, @@ -41,43 +31,31 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v FullEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.full$")}, {name: "room is said", subject: "mesh.seat.mesh-delivery.event.room", given: "{\"bytes\":400000000,\"cap\":805306368,\"store\":\"records\"}", wire: "{\"bytes\":400000000,\"cap\":805306368,\"store\":\"records\"}", decode: func(b []byte) (any, error) { var v RoomEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.room$")}, - {name: "main moved to its next source revision", subject: "mesh.seat.mesh-delivery.event.source-moved.main", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"revision\":3590,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"revision\":3590,\"v\":1}", - decode: func(b []byte) (any, error) { var v SourceMovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.source-moved\\.[^.*> ]+$")}, + {name: "main moved to its next source revision", subject: "mesh.seat.mesh-delivery.event.source-moved.main.1044", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"heads\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}],\"source\":1044,\"start\":false,\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"heads\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}],\"source\":1044,\"start\":false,\"v\":1}", + decode: func(b []byte) (any, error) { var v SourceMovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.source-moved\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a recovery merged", subject: "mesh.seat.mesh-delivery.event.recovery-merged", given: "{\"at\":\"2026-11-11T10:00:00Z\",\"branch\":\"main\",\"by\":\"alice\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"mesh-sdk\",\"repository\":\"novox/mesh-sdk\",\"v\":1,\"why\":\"the live delivery was broken\"}", wire: "{\"at\":\"2026-11-11T10:00:00Z\",\"branch\":\"main\",\"by\":\"alice\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"mesh-sdk\",\"repository\":\"novox/mesh-sdk\",\"v\":1,\"why\":\"the live delivery was broken\"}", decode: func(b []byte) (any, error) { var v RecoveryMergedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.recovery-merged$")}, - {name: "approval-carried is said for a pull request approved before G", subject: "mesh.seat.mesh-delivery.event.approval-carried.mesh-tools.35", given: "{\"approver\":\"operator\",\"at\":\"2026-11-11T10:00:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"pull\":35,\"repository\":\"mesh-tools\"}", wire: "{\"approver\":\"operator\",\"at\":\"2026-11-11T10:00:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"pull\":35,\"repository\":\"mesh-tools\"}", - decode: func(b []byte) (any, error) { var v ApprovalCarriedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.approval-carried\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "pins-stated is said once the pins are", subject: "mesh.seat.mesh-delivery.event.pins-stated", given: "{\"at\":\"2026-11-11T10:00:00Z\"}", wire: "{\"at\":\"2026-11-11T10:00:00Z\"}", - decode: func(b []byte) (any, error) { var v PinsStatedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.pins-stated$")}, - {name: "the source revision", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":{\"novox/mesh-sdk\":\"cccccccccccccccccccccccccccccccccccccccc\"},\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":{\"novox/mesh-sdk\":\"cccccccccccccccccccccccccccccccccccccccc\"},\"v\":1}", + {name: "a branch's first source revision, seeded", subject: "mesh.seat.mesh-delivery.event.source-moved.main.1", given: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"heads\":[{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-sdk\"},{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-catalog\"}],\"source\":1,\"start\":true,\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"heads\":[{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-sdk\"},{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-catalog\"}],\"source\":1,\"start\":true,\"v\":1}", + decode: func(b []byte) (any, error) { var v SourceMovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.source-moved\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "the source revision", subject: "", given: "{\"call\":\"0123456789abcdef\",\"heads\":{\"novox/mesh-sdk\":\"cccccccccccccccccccccccccccccccccccccccc\"},\"source\":1044,\"v\":1}", wire: "{\"call\":\"0123456789abcdef\",\"heads\":{\"novox/mesh-sdk\":\"cccccccccccccccccccccccccccccccccccccccc\"},\"source\":1044,\"v\":1}", decode: func(b []byte) (any, error) { var v SourceByBranchValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a merge", subject: "", given: "{\"ask\":\"merge.feat=registry.0123456789ab\",\"group\":\"feat/registry\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"v\":1}", wire: "{\"ask\":\"merge.feat=registry.0123456789ab\",\"group\":\"feat/registry\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"v\":1}", - decode: func(b []byte) (any, error) { var v MergesByGroupValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "an act owed", subject: "", given: "{\"act\":\"view\",\"v\":1}", wire: "{\"act\":\"view\",\"v\":1}", decode: func(b []byte) (any, error) { var v OwedByRepositoryNumberHeadActValue err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a turn", subject: "", given: "{\"repository\":\"novox/mesh-sdk\",\"v\":1,\"waiting\":[{\"approved\":\"2026-11-05T10:00:00Z\",\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"since\":\"2026-11-05T10:01:00Z\"}]}", wire: "{\"repository\":\"novox/mesh-sdk\",\"v\":1,\"waiting\":[{\"approved\":\"2026-11-05T10:00:00Z\",\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"since\":\"2026-11-05T10:01:00Z\"}]}", - decode: func(b []byte) (any, error) { var v TurnsByRepositoryValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "an ask", subject: "", given: "{\"ask\":{\"headline\":\"merge\"},\"group\":\"feat/registry\",\"heads\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}", wire: "{\"ask\":{\"headline\":\"merge\"},\"group\":\"feat/registry\",\"heads\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}", + {name: "an untaken head", subject: "", given: "{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"since\":\"2026-11-20T02:00:00Z\"}", wire: "{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"since\":\"2026-11-20T02:00:00Z\"}", decode: func(b []byte) (any, error) { - var v AsksByMergeGroupHeadsValue + var v HeadsByRepositoryBranchValue err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "groups asks for one group", subject: "", given: "{\"group\":\"feat/47-G\"}", wire: "{\"group\":\"feat/47-G\"}", - decode: func(b []byte) (any, error) { var v GroupsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "groups answers a group with its members and acts", subject: "", given: "{\"groups\":[{\"acts\":[{\"at\":\"2026-11-09T20:01:00Z\",\"outcome\":\"performed\",\"owed\":{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}},{\"owed\":{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}}],\"check\":\"pass\",\"id\":\"feat/47-G\",\"members\":[{\"base\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"novox/mesh-sdk#178\",\"number\":178,\"open\":true,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"state\":\"merging\",\"why\":\"novox/mesh-sdk#178 merges first\"}]}", wire: "{\"groups\":[{\"acts\":[{\"at\":\"2026-11-09T20:01:00Z\",\"outcome\":\"performed\",\"owed\":{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}},{\"owed\":{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}}],\"check\":\"pass\",\"id\":\"feat/47-G\",\"members\":[{\"base\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"novox/mesh-sdk#178\",\"number\":178,\"open\":true,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"state\":\"merging\",\"why\":\"novox/mesh-sdk#178 merges first\"}]}", - decode: func(b []byte) (any, error) { var v GroupsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "groups answers a group it does not know with no groups", subject: "", given: "{}", wire: "{}", - decode: func(b []byte) (any, error) { var v GroupsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "source is asked for one branch", subject: "", given: "{\"branch\":\"main\"}", wire: "{\"branch\":\"main\"}", decode: func(b []byte) (any, error) { var v SourceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "source is asked with no branch", subject: "", given: "{}", wire: "{}", decode: func(b []byte) (any, error) { var v SourceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "source answers each repository's trunk and head", subject: "", given: "{\"branch\":\"main\",\"group\":\"feat/47-G\",\"repositories\":[{\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"main\"}],\"revision\":42}", wire: "{\"branch\":\"main\",\"group\":\"feat/47-G\",\"repositories\":[{\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"main\"}],\"revision\":42}", + {name: "source answers each repository's trunk and head", subject: "", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"repositories\":[{\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"main\"}],\"revision\":42}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"repositories\":[{\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"main\"}],\"revision\":42}", decode: func(b []byte) (any, error) { var v SourceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "source answers the branches it keeps", subject: "", given: "{\"branches\":[\"main\",\"beta\"]}", wire: "{\"branches\":[\"main\",\"beta\"]}", decode: func(b []byte) (any, error) { var v SourceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json index b59fb1f1..03bf11b8 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json @@ -30,91 +30,17 @@ "target": "https://forge.test/x" } }, - { - "name": "pinned is said", - "of": "event:pinned", - "subject": "mesh.seat.mesh-delivery.event.pinned", - "given": { - "record": "47-G", - "milestone": "47/G", - "catalog": [ - { - "branch": "main", - "revision": 3610 - } - ], - "assignment": [ - 1204 - ] - } - }, - { - "name": "freed is said", - "of": "event:freed", - "subject": "mesh.seat.mesh-delivery.event.freed", - "given": { - "record": "47-G", - "milestone": "47/G", - "catalog": [ - { - "branch": "main", - "revision": 3610 - } - ], - "assignment": [ - 1204 - ], - "why": "past its retention of 90 days" - } - }, - { - "name": "heads-replaced is said", - "of": "event:heads-replaced", - "subject": "mesh.seat.mesh-delivery.event.heads-replaced", - "given": { - "group": "feat/47-G", - "heads": "0123456789ab", - "repository": "novox/mesh-sdk", - "number": 178, - "head": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", - "at": "2026-11-09T20:05:00Z" - } - }, - { - "name": "heads-replaced is said for a closed pull request", - "of": "event:heads-replaced", - "subject": "mesh.seat.mesh-delivery.event.heads-replaced", - "given": { - "group": "feat/47-G", - "heads": "0123456789ab", - "repository": "novox/mesh-sdk", - "number": 178, - "closed": true - } - }, { "name": "record-opened is said", "of": "event:record-opened", - "subject": "mesh.seat.mesh-delivery.event.record-opened", + "subject": "mesh.seat.mesh-delivery.event.record-opened.0123456789abcdef", "given": { - "record": "47-G", - "milestone": "47/G", - "at": "2026-11-09T18:00:00Z" - } - }, - { - "name": "record-opened is said for a merge made at the forge", - "of": "event:record-opened", - "subject": "mesh.seat.mesh-delivery.event.record-opened", - "given": { - "record": "mesh-tools-35", - "milestone": "47/G", - "forge-made": true, - "repository": "novox/mesh-tools", - "pull": 35, - "commit": "0123456789abcdef0123456789abcdef01234567", + "record": "main.1044", + "milestone": "main.1044", "branch": "main", - "at": "2026-11-09T18:00:00Z" + "source": 1044, + "call": "0123456789abcdef", + "at": "2026-11-20T02:00:00Z" } }, { @@ -122,15 +48,18 @@ "of": "event:record-ended", "subject": "mesh.seat.mesh-delivery.event.record-ended", "given": { - "record": "47-G", - "milestone": "47/G", + "record": "main.1044", + "milestone": "main.1044", "away": [ { "node": "laptop", "since": "2026-11-09T18:00:00Z" } ], - "at": "2026-11-09T21:00:00Z" + "at": "2026-11-09T21:00:00Z", + "branch": "main", + "source": 1044, + "call": "0123456789abcdef" } }, { @@ -167,12 +96,19 @@ { "name": "main moved to its next source revision", "of": "event:source-moved", - "subject": "mesh.seat.mesh-delivery.event.source-moved.main", + "subject": "mesh.seat.mesh-delivery.event.source-moved.main.1044", "given": { "v": 1, "branch": "main", - "revision": 3590, - "at": "2026-11-10T10:00:00Z" + "source": 1044, + "call": "0123456789abcdef", + "start": false, + "heads": [ + { + "repository": "novox/mesh-sdk", + "commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + } + ] } }, { @@ -191,23 +127,25 @@ } }, { - "name": "approval-carried is said for a pull request approved before G", - "of": "event:approval-carried", - "subject": "mesh.seat.mesh-delivery.event.approval-carried.mesh-tools.35", + "name": "a branch's first source revision, seeded", + "of": "event:source-moved", + "subject": "mesh.seat.mesh-delivery.event.source-moved.main.1", "given": { - "repository": "mesh-tools", - "pull": 35, - "commit": "0123456789abcdef0123456789abcdef01234567", - "approver": "operator", - "at": "2026-11-11T10:00:00Z" - } - }, - { - "name": "pins-stated is said once the pins are", - "of": "event:pins-stated", - "subject": "mesh.seat.mesh-delivery.event.pins-stated", - "given": { - "at": "2026-11-11T10:00:00Z" + "v": 1, + "branch": "main", + "source": 1, + "call": "fedcba9876543210", + "start": true, + "heads": [ + { + "repository": "novox/mesh-sdk", + "commit": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "repository": "novox/mesh-catalog", + "commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + } + ] } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/states.json index 78776547..1381da75 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/states.json @@ -4,27 +4,11 @@ "of": "state:source/", "given": { "v": 1, - "group": "feat/registry", "heads": { "novox/mesh-sdk": "cccccccccccccccccccccccccccccccccccccccc" - } - } - }, - { - "name": "a merge", - "of": "state:merges/", - "given": { - "v": 1, - "group": "feat/registry", - "ask": "merge.feat=registry.0123456789ab", - "pulls": [ - { - "repository": "novox/mesh-sdk", - "number": 1, - "head": "cccccccccccccccccccccccccccccccccccccccc", - "state": "merging" - } - ] + }, + "source": 1044, + "call": "0123456789abcdef" } }, { @@ -36,37 +20,11 @@ } }, { - "name": "a turn", - "of": "state:turns/", + "name": "an untaken head", + "of": "state:heads/.", "given": { - "v": 1, - "repository": "novox/mesh-sdk", - "waiting": [ - { - "group": "feat/registry", - "heads": "0123456789ab", - "approved": "2026-11-05T10:00:00Z", - "since": "2026-11-05T10:01:00Z" - } - ] - } - }, - { - "name": "an ask", - "of": "state:asks/merge..", - "given": { - "v": 1, - "group": "feat/registry", - "heads": [ - { - "repository": "novox/mesh-sdk", - "number": 1, - "head": "cccccccccccccccccccccccccccccccccccccccc" - } - ], - "ask": { - "headline": "merge" - } + "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "since": "2026-11-20T02:00:00Z" } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/verbs.json index 65bc3c2c..3d38ba18 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/verbs.json @@ -1,70 +1,4 @@ [ - { - "name": "groups asks for one group", - "of": "verb:groups.input", - "given": { - "group": "feat/47-G" - } - }, - { - "name": "groups answers a group with its members and acts", - "of": "verb:groups.answer", - "given": { - "groups": [ - { - "id": "feat/47-G", - "state": "merging", - "why": "novox/mesh-sdk#178 merges first", - "check": "pass", - "members": [ - { - "id": "novox/mesh-sdk#178", - "repository": "novox/mesh-sdk", - "number": 178, - "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "base": "main", - "state": "merging", - "open": true - } - ], - "acts": [ - { - "owed": { - "id": "merge.feat=47-G.0123456789ab.novox/mesh-sdk#178", - "act": "merge", - "repository": "novox/mesh-sdk", - "number": 178, - "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "group": "feat/47-G", - "ask": "merge.feat=47-G.0123456789ab", - "said": "2026-11-09T20:00:00Z" - }, - "outcome": "performed", - "at": "2026-11-09T20:01:00Z" - }, - { - "owed": { - "id": "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate", - "act": "status", - "repository": "novox/mesh-sdk", - "number": 178, - "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "context": "mesh/merge-gate", - "state": "pending", - "description": "waits for the operator's Approve", - "target": "https://forge.test/x" - } - } - ] - } - ] - } - }, - { - "name": "groups answers a group it does not know with no groups", - "of": "verb:groups.answer", - "given": {} - }, { "name": "source is asked for one branch", "of": "verb:source.input", @@ -81,7 +15,6 @@ "name": "source answers each repository's trunk and head", "of": "verb:source.answer", "given": { - "group": "feat/47-G", "revision": 42, "repositories": [ { @@ -90,7 +23,8 @@ "head": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" } ], - "branch": "main" + "branch": "main", + "call": "0123456789abcdef" } }, { diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json index f6f75f8b..5546f304 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json @@ -62,46 +62,9 @@ }, "class": "read" }, - { - "name": "groups", - "description": "Every delivery group: its members in merge order, its check and its state, derived from its members, and the acts the gate said it owes the forge for it, each with its id and its recorded outcome (design 47 *What the gate owes the forge*). With a group, that group alone, and none for a group it does not know: the forge bridge reads a group's members and catches up on what it owes from here, never from the gate's state.", - "input": { - "type": "object", - "properties": { - "all": { - "description": "\"true\": the groups that ended too", - "enum": [ - "true", - "false" - ], - "type": "string" - }, - "group": { - "type": "string", - "description": "one group's id: that group alone, ended or not" - } - } - }, - "answer": { - "type": "object", - "properties": { - "groups": { - "type": "array", - "items": { - "$ref": "#/defs/Group" - } - }, - "error": { - "type": "string", - "description": "why it could not answer at all; a group it does not know is answered with no groups, never an error" - } - } - }, - "class": "read" - }, { "name": "source", - "description": "One watched branch's source revision (design 47 *Watched branches and the catalog graph per branch*: source. in place of source.main): The source revision the gate holds: every repository it names, its trunk branch and that trunk's head as the gate merged or seeded it, and the group that moved it last. Read, never written: the node-engines read it to call a reverted build's catch-up tool once per repository, never the gate's state (design 47). Given no branch it answers branches alone, the branch of each source key the gate keeps; given a branch, that branch's source revision (design 47 G section 690).", + "description": "One watched branch's source revision (design 47 *Watched branches and the catalog graph per branch*: source. in place of source.main): The source revision the gate holds: every repository it names, its trunk branch and that trunk's head as the gate merged or seeded it, and the merge call that moved it last. Read, never written: the node-engines read it to call a reverted build's catch-up tool once per repository, never the gate's state (design 47). Given no branch it answers branches alone, the branch of each source key the gate keeps; given a branch, that branch's source revision (design 47 G section 690).", "input": { "type": "object", "properties": { @@ -114,14 +77,14 @@ "answer": { "type": "object", "properties": { - "group": { - "type": "string", - "description": "the group that moved the source revision last; absent before the first" - }, "revision": { "type": "integer", "description": "the source revision's number on the bus; 0 before the first" }, + "call": { + "type": "string", + "description": "the merge call that moved the source revision last; absent before the first" + }, "repositories": { "type": "array", "items": { @@ -229,68 +192,11 @@ "$ref": "#/defs/Owed" } }, - { - "name": "pinned", - "body": { - "$ref": "#/defs/Pins" - } - }, - { - "name": "freed", - "body": { - "$ref": "#/defs/Pins" - } - }, - { - "name": "heads-replaced", - "body": { - "type": "object", - "description": "a candidate's heads replaced or its pull request closed: its graphs mean nothing any more", - "properties": { - "group": { - "type": "string", - "description": "the group" - }, - "heads": { - "type": "string", - "description": "the candidate's heads, 12 hex digits, as its revisions are keyed" - }, - "repository": { - "type": "string", - "description": "the member whose head moved or which closed" - }, - "number": { - "type": "integer", - "description": "its pull request's number" - }, - "head": { - "type": "string", - "description": "its new head; absent when it closed", - "pattern": "^[0-9a-f]{40}$" - }, - "closed": { - "type": "boolean", - "description": "the pull request closed" - }, - "at": { - "type": "string", - "format": "date-time", - "description": "when" - } - }, - "required": [ - "group", - "heads", - "repository", - "number" - ] - } - }, { "name": "record-opened", "body": { "type": "object", - "description": "a delivery record opened: its merge was taken in, and the watchman times it against 24 hours", + "description": "a delivery record opened for one source revision of a merge call (design 47 H \u00a7737)", "properties": { "record": { "type": "string", @@ -298,27 +204,19 @@ }, "milestone": { "type": "string", - "description": "its milestone" - }, - "forge-made": { - "type": "boolean", - "description": "a merge made at the forge, with no Approve" - }, - "repository": { - "type": "string", - "description": "for a forge-made record, the repository, /" - }, - "pull": { - "type": "integer", - "description": "for a forge-made record, the pull request's number" - }, - "commit": { - "type": "string", - "description": "for a forge-made record, the merge commit" + "description": "its milestone, ." }, "branch": { "type": "string", - "description": "for a forge-made record, the branch the merge moved" + "description": "the watched branch" + }, + "source": { + "type": "integer", + "description": "the source revision" + }, + "call": { + "type": "string", + "description": "the merge call" }, "at": { "type": "string", @@ -328,9 +226,13 @@ }, "required": [ "record", - "milestone" + "milestone", + "branch", + "source", + "call" ] - } + }, + "subject": "record-opened." }, { "name": "record-ended", @@ -344,11 +246,19 @@ }, "milestone": { "type": "string", - "description": "its milestone" + "description": "its milestone, ." }, - "forge-made": { - "type": "boolean", - "description": "a merge made at the forge, with no Approve" + "branch": { + "type": "string", + "description": "the watched branch" + }, + "source": { + "type": "integer", + "description": "the source revision" + }, + "call": { + "type": "string", + "description": "the merge call" }, "away": { "type": "array", @@ -379,7 +289,10 @@ }, "required": [ "record", - "milestone" + "milestone", + "branch", + "source", + "call" ] } }, @@ -403,10 +316,10 @@ }, { "name": "source-moved", - "subject": "source-moved.", + "subject": "source-moved..", "body": { "type": "object", - "description": "a new source revision of a watched branch (design 47 *The verbs*)", + "description": "a source revision of a watched branch, named once per merge call (design 47 H \u00a7737)", "properties": { "v": { "type": "integer" @@ -414,22 +327,51 @@ "branch": { "type": "string" }, - "revision": { - "type": "integer" + "source": { + "type": "integer", + "description": "the source revision, numbered by the gate alone" }, - "group": { + "call": { "type": "string", - "description": "the group that moved it, when one did" + "description": "the merge call that moved it" }, - "at": { - "type": "string", - "format": "date-time" + "start": { + "type": "boolean", + "description": "true only for a branch's first revision (design 47 H \u00a7768)" + }, + "heads": { + "type": "array", + "description": "the repositories it moved", + "items": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "commit": { + "type": "string", + "pattern": "^[0-9a-f]{40}$" + } + }, + "required": [ + "repository", + "commit" + ] + } } }, "required": [ + "v", "branch", - "revision" + "source", + "call", + "start", + "heads" ] + }, + "keep": { + "max-age-days": 30, + "max-mib": 64 } }, { @@ -477,65 +419,6 @@ "why" ] } - }, - { - "name": "approval-carried", - "subject": "approval-carried..", - "keep": { - "max-age-days": 90 - }, - "body": { - "type": "object", - "description": "an Approve given before G, carried as that pull request's approval step: said at G's switch for each merges key the old bridge had not performed (design 47 G 542)", - "properties": { - "repository": { - "type": "string", - "description": "the repository" - }, - "pull": { - "type": "integer", - "description": "the pull request's number", - "minimum": 1 - }, - "commit": { - "type": "string", - "description": "the head the Approve named" - }, - "approver": { - "type": "string", - "description": "who approved: the operator" - }, - "at": { - "type": "string", - "description": "when it was said, RFC 3339", - "format": "date-time" - } - }, - "required": [ - "repository", - "pull", - "commit", - "approver", - "at" - ] - } - }, - { - "name": "pins-stated", - "body": { - "type": "object", - "description": "the gate states every pin it holds once its pinned events are said, so an indexer whose state pins was made later hears them all; kept as pinned is, on the seat's family (design 47 G 579, 652)", - "properties": { - "at": { - "type": "string", - "description": "when it was said, RFC 3339", - "format": "date-time" - } - }, - "required": [ - "at" - ] - } } ], "states": [ @@ -552,20 +435,25 @@ "type": "integer", "description": "the layout version" }, - "group": { - "type": "string", - "description": "the group that moved it" - }, "heads": { "type": "object", "additionalProperties": { "type": "string" }, "description": "repository to the merged head, a full commit" + }, + "source": { + "type": "integer", + "description": "the branch's source revision, one above its newest" + }, + "call": { + "type": "string", + "description": "the merge call that moved it; a call the newest revision already carries writes nothing (design 47 H \u00a7737, H-A-33)" } }, "required": [ - "group", + "source", + "call", "heads" ], "description": "every repository's merged head; its revision is the mesh's source revision" @@ -576,140 +464,6 @@ "description": "the mesh's source revision", "history": 64 }, - { - "name": "merges", - "template": "state", - "key-forms": [ - { - "key": "", - "value": { - "type": "object", - "properties": { - "v": { - "type": "integer", - "description": "the layout version" - }, - "group": { - "type": "string" - }, - "ask": { - "type": "string", - "description": "the ask key" - }, - "approved": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "@ to the approved head" - }, - "pulls": { - "type": "array", - "items": { - "type": "object", - "properties": { - "repository": { - "type": "string" - }, - "number": { - "type": "integer" - }, - "head": { - "type": "string" - }, - "state": { - "type": "string", - "description": "merging, merged or refused" - }, - "commit": { - "type": "string" - }, - "words": { - "type": "string" - } - }, - "required": [ - "repository", - "number", - "head", - "state" - ] - } - } - }, - "required": [ - "group", - "ask", - "pulls" - ], - "description": "one group's merge and how far each pull request is" - }, - "description": "a group's merge" - } - ], - "description": "the merges", - "history": 10 - }, - { - "name": "asks", - "template": "state", - "key-forms": [ - { - "key": "merge..", - "value": { - "type": "object", - "properties": { - "v": { - "type": "integer", - "description": "the layout version" - }, - "group": { - "type": "string" - }, - "heads": { - "type": "array", - "items": { - "type": "object", - "properties": { - "repository": { - "type": "string", - "description": "/" - }, - "number": { - "type": "integer" - }, - "head": { - "type": "string", - "description": "the full commit" - } - }, - "required": [ - "repository", - "number", - "head" - ] - } - }, - "ask": { - "description": "the operator-channel ask as raised" - }, - "asking": { - "type": "integer", - "description": "the number of times it was asked" - } - }, - "required": [ - "group", - "heads", - "ask" - ] - }, - "description": "the ask of the operator for one group at one set of heads" - } - ], - "description": "the asks of the operator for a merge", - "history": 5 - }, { "name": "owed", "template": "state", @@ -755,77 +509,36 @@ "history": 5 }, { - "name": "turns", + "name": "heads", "template": "state", + "history": 1, + "description": "each head the forge bridge's head-moved said that source. does not name for that repository; deleted when source. names it (design 47 H \u00a7740)", "key-forms": [ { - "key": "", + "key": ".", "value": { "type": "object", "properties": { - "v": { - "type": "integer", - "description": "the layout version" + "head": { + "type": "string", + "description": "the head head-moved said", + "pattern": "^[0-9a-f]{40}$" }, - "repository": { - "type": "string" - }, - "waiting": { - "type": "array", - "items": { - "type": "object", - "properties": { - "group": { - "type": "string" - }, - "heads": { - "type": "string" - }, - "ask": { - "type": "string" - }, - "approved": { - "type": "string", - "format": "date-time", - "description": "when (RFC 3339 time)" - }, - "since": { - "type": "string", - "format": "date-time", - "description": "when (RFC 3339 time)" - }, - "waits-for": { - "type": "string" - }, - "waits-since": { - "type": "string", - "format": "date-time", - "description": "when (RFC 3339 time)" - }, - "step": { - "type": "string" - } - }, - "required": [ - "group", - "heads", - "approved", - "since" - ] - } + "since": { + "type": "string", + "format": "date-time", + "description": "when it was first heard" } }, "required": [ - "repository", - "waiting" + "head", + "since" ], - "description": "the merges of a repository in the order they wait for their turn" + "description": "an untaken head" }, - "description": "the merges waiting on a repository" + "description": "one repository on one watched branch" } - ], - "description": "which merge waits for which", - "history": 5 + ] } ], "defs": { @@ -913,122 +626,6 @@ "head" ] }, - "Act": { - "type": "object", - "description": "an act the gate said for a group, with its recorded outcome once the forge bridge said one", - "properties": { - "owed": { - "$ref": "#/defs/Owed" - }, - "outcome": { - "type": "string", - "enum": [ - "performed", - "refused", - "could not be performed", - "undecodable", - "dropped" - ], - "description": "the outcome the forge bridge said as owed.ended and the gate recorded; absent while unanswered" - }, - "words": { - "type": "string", - "description": "the forge's own words for a refusal, the error for an act that could not be performed, why one is undecodable or dropped" - }, - "at": { - "type": "string", - "format": "date-time", - "description": "when the outcome was recorded" - } - }, - "required": [ - "owed" - ] - }, - "Member": { - "type": "object", - "description": "one member of a group: a pull request", - "properties": { - "id": { - "type": "string", - "description": "the member's delivery id" - }, - "repository": { - "type": "string", - "description": "the repository, /" - }, - "number": { - "type": "integer", - "description": "the pull request's number" - }, - "head": { - "type": "string", - "description": "its head", - "pattern": "^[0-9a-f]{40}$" - }, - "base": { - "type": "string", - "description": "the branch it merges into" - }, - "state": { - "type": "string", - "description": "the member's delivery state" - }, - "open": { - "type": "boolean", - "description": "the pull request is open: not merged, closed or final" - } - }, - "required": [ - "id", - "repository", - "number", - "head", - "state" - ] - }, - "Group": { - "type": "object", - "description": "one delivery group: its members, its derived state and the acts the gate said for it", - "properties": { - "id": { - "type": "string", - "description": "the group's id, its branch" - }, - "state": { - "type": "string", - "description": "its state, derived from its members" - }, - "why": { - "type": "string", - "description": "why it is in that state" - }, - "check": { - "type": "string", - "description": "the group's check: its verdict, or asked as " - }, - "members": { - "type": "array", - "items": { - "$ref": "#/defs/Member" - }, - "description": "its members in merge order" - }, - "acts": { - "type": "array", - "items": { - "$ref": "#/defs/Act" - }, - "description": "the acts the gate said for it, each with its id and its recorded outcome; an id said and not answered is the forge bridge's to perform" - } - }, - "required": [ - "id", - "state", - "members", - "acts" - ] - }, "Fill": { "type": "object", "description": "the delivery records' ledger's fill against its cap", @@ -1060,104 +657,6 @@ "cap" ] }, - "Pins": { - "type": "object", - "description": "the graph revisions a delivery record starts or stops pointing at", - "properties": { - "record": { - "type": "string", - "description": "the record's id" - }, - "milestone": { - "type": "string", - "description": "the record's milestone" - }, - "catalog": { - "type": "array", - "items": { - "type": "object", - "description": "one catalog graph revision, named by its watched branch and its number on the seat mesh-catalog (revisions are numbered per branch)", - "properties": { - "branch": { - "type": "string", - "description": "the watched branch the revision belongs to" - }, - "revision": { - "type": "integer", - "description": "its number on that branch" - } - }, - "required": [ - "branch", - "revision" - ] - }, - "description": "catalog graph revisions, by watched branch and number on the seat mesh-catalog" - }, - "assignment": { - "type": "array", - "items": { - "type": "integer" - }, - "description": "assignment graph revisions, by their number on the seat mesh-wants" - }, - "why": { - "type": "string", - "description": "on freed: the record ended past its retention, or was removed by hand" - } - }, - "required": [ - "record", - "milestone" - ] - }, - "Ask": { - "type": "object", - "description": "the one Approve ask of a milestone (ADR 0493 \u00a79), said apart from each delivery's transition", - "properties": { - "milestone": { - "type": "string", - "description": "the milestone" - }, - "ask": { - "type": "string", - "description": "the ask's id" - }, - "group": { - "type": "string", - "description": "its delivery group" - }, - "heads": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "repository to the head asked" - }, - "answer": { - "type": "string", - "description": "on answered: approve or decline" - }, - "by": { - "type": "string", - "description": "on answered: who answered" - }, - "why": { - "type": "string", - "description": "on withdrawn: why, such as a new head of a member" - }, - "at": { - "type": "string", - "format": "date-time", - "description": "when" - } - }, - "required": [ - "milestone", - "ask", - "group" - ] - }, "SourceHead": { "type": "object", "description": "one repository of the source revision: its trunk branch and that trunk's head", diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts index 64cf716b..11e963b8 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts @@ -7,7 +7,6 @@ export declare const seat: "mesh-delivery"; export declare const verbs: { readonly deliveries: "deliveries"; readonly show: "show"; - readonly groups: "groups"; readonly source: "source"; readonly stalled: "stalled"; readonly recovery: "recovery"; @@ -15,9 +14,6 @@ export declare const verbs: { export declare const events: { readonly owed: "owed"; - readonly pinned: "pinned"; - readonly freed: "freed"; - readonly headsReplaced: "heads-replaced"; readonly recordOpened: "record-opened"; readonly recordEnded: "record-ended"; readonly filling: "filling"; @@ -25,8 +21,6 @@ export declare const events: { readonly room: "room"; readonly sourceMoved: "source-moved"; readonly recoveryMerged: "recovery-merged"; - readonly approvalCarried: "approval-carried"; - readonly pinsStated: "pins-stated"; }; export declare const family: { readonly name: "mesh-delivery.events"; readonly maxAgeDays: 7 }; @@ -37,13 +31,9 @@ export declare function owedSubject(repository: string, number: string): string; export declare const owedSubjectAll: "mesh.seat.mesh-delivery.event.owed.*.*"; -export declare const pinnedSubject: "mesh.seat.mesh-delivery.event.pinned"; +export declare function recordOpenedSubject(call: string): string; -export declare const freedSubject: "mesh.seat.mesh-delivery.event.freed"; - -export declare const headsReplacedSubject: "mesh.seat.mesh-delivery.event.heads-replaced"; - -export declare const recordOpenedSubject: "mesh.seat.mesh-delivery.event.record-opened"; +export declare const recordOpenedSubjectAll: "mesh.seat.mesh-delivery.event.record-opened.*"; export declare const recordEndedSubject: "mesh.seat.mesh-delivery.event.record-ended"; @@ -53,26 +43,18 @@ export declare const fullSubject: "mesh.seat.mesh-delivery.event.full"; export declare const roomSubject: "mesh.seat.mesh-delivery.event.room"; -export declare function sourceMovedSubject(branch: string): string; +export declare const sourceMovedStream: "SEAT_mesh-delivery_source-moved"; -export declare const sourceMovedSubjectAll: "mesh.seat.mesh-delivery.event.source-moved.*"; +export declare function sourceMovedSubject(branch: string, source: string): string; + +export declare const sourceMovedSubjectAll: "mesh.seat.mesh-delivery.event.source-moved.*.*"; export declare const recoveryMergedSubject: "mesh.seat.mesh-delivery.event.recovery-merged"; -export declare const approvalCarriedStream: "SEAT_mesh-delivery_approval-carried"; - -export declare function approvalCarriedSubject(repository: string, pull: string): string; - -export declare const approvalCarriedSubjectAll: "mesh.seat.mesh-delivery.event.approval-carried.*.*"; - -export declare const pinsStatedSubject: "mesh.seat.mesh-delivery.event.pins-stated"; - export declare const states: { readonly source: "source"; - readonly merges: "merges"; - readonly asks: "asks"; readonly owed: "owed"; - readonly turns: "turns"; + readonly heads: "heads"; }; /** The key of one value of the state source under the form "". */ @@ -81,60 +63,17 @@ export declare function sourceByBranchKey(branch: string): string; /** The parts of a key of the form "", or undefined for a key of another form. */ export declare function parseSourceByBranchKey(_key: string): { branch: string } | undefined; -/** The key of one value of the state merges under the form "". */ -export declare function mergesByGroupKey(group: string): string; - -/** The parts of a key of the form "", or undefined for a key of another form. */ -export declare function parseMergesByGroupKey(_key: string): { group: string } | undefined; - -/** The key of one value of the state asks under the form "merge..". */ -export declare function asksByMergeGroupHeadsKey(group: string, heads: string): string; - -/** The parts of a key of the form "merge..", or undefined for a key of another form. */ -export declare function parseAsksByMergeGroupHeadsKey(_key: string): { group: string; heads: 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 turns under the form "". */ -export declare function turnsByRepositoryKey(repository: string): string; +/** The key of one value of the state heads under the form ".". */ +export declare function headsByRepositoryBranchKey(repository: string, branch: string): string; -/** The parts of a key of the form "", or undefined for a key of another form. */ -export declare function parseTurnsByRepositoryKey(_key: string): { repository: string } | undefined; - -/** an act the gate said for a group, with its recorded outcome once the forge bridge said one */ -export interface Act { - /** when the outcome was recorded */ - "at"?: string; - /** the outcome the forge bridge said as owed.ended and the gate recorded; absent while unanswered */ - "outcome"?: "performed" | "refused" | "could not be performed" | "undecodable" | "dropped"; - "owed": Owed; - /** the forge's own words for a refusal, the error for an act that could not be performed, why one is undecodable or dropped */ - "words"?: string; -} - -/** the one Approve ask of a milestone (ADR 0493 §9), said apart from each delivery's transition */ -export interface Ask { - /** on answered: approve or decline */ - "answer"?: string; - /** the ask's id */ - "ask": string; - /** when */ - "at"?: string; - /** on answered: who answered */ - "by"?: string; - /** its delivery group */ - "group": string; - /** repository to the head asked */ - "heads"?: Record; - /** the milestone */ - "milestone": string; - /** on withdrawn: why, such as a new head of a member */ - "why"?: string; -} +/** The parts of a key of the form ".", or undefined for a key of another form. */ +export declare function parseHeadsByRepositoryBranchKey(_key: string): { repository: string; branch: string } | undefined; /** the delivery records' ledger's fill against its cap */ export interface Fill { @@ -149,40 +88,6 @@ export interface Fill { "store": string; } -/** one delivery group: its members, its derived state and the acts the gate said for it */ -export interface Group { - /** the acts the gate said for it, each with its id and its recorded outcome; an id said and not answered is the forge bridge's to perform */ - "acts": Act[]; - /** the group's check: its verdict, or asked as */ - "check"?: string; - /** the group's id, its branch */ - "id": string; - /** its members in merge order */ - "members": Member[]; - /** its state, derived from its members */ - "state": string; - /** why it is in that state */ - "why"?: string; -} - -/** one member of a group: a pull request */ -export interface Member { - /** the branch it merges into */ - "base"?: string; - /** its head */ - "head": string; - /** the member's delivery id */ - "id": string; - /** the pull request's number */ - "number": number; - /** the pull request is open: not merged, closed or final */ - "open"?: boolean; - /** the repository, / */ - "repository": string; - /** the member's delivery state */ - "state": string; -} - /** one act the gate owes the forge, said once under its id and safe to repeat at the forge (design 47 *What the gate owes the forge*); the forge bridge performs it through the seat git's verb of the same act */ export interface Owed { /** the act: merge (the seat git's merge-pull), status, view, comment or note */ @@ -217,28 +122,6 @@ export interface Owed { "text"?: string; } -/** one catalog graph revision, named by its watched branch and its number on the seat mesh-catalog (revisions are numbered per branch) */ -export interface PinsCatalogItem { - /** the watched branch the revision belongs to */ - "branch": string; - /** its number on that branch */ - "revision": number; -} - -/** the graph revisions a delivery record starts or stops pointing at */ -export interface Pins { - /** assignment graph revisions, by their number on the seat mesh-wants */ - "assignment"?: number[]; - /** catalog graph revisions, by watched branch and number on the seat mesh-catalog */ - "catalog"?: PinsCatalogItem[]; - /** the record's milestone */ - "milestone": string; - /** the record's id */ - "record": string; - /** on freed: the record ended past its retention, or was removed by hand */ - "why"?: string; -} - /** one repository of the source revision: its trunk branch and that trunk's head */ export interface SourceHead { /** the trunk's head the source revision names */ @@ -273,21 +156,6 @@ export interface ShowInput { /** is what show answers. */ export type ShowAnswer = Record; -/** is what groups takes. */ -export interface GroupsInput { - /** "true": the groups that ended too */ - "all"?: "true" | "false"; - /** one group's id: that group alone, ended or not */ - "group"?: string; -} - -/** is what groups answers. */ -export interface GroupsAnswer { - /** why it could not answer at all; a group it does not know is answered with no groups, never an error */ - "error"?: string; - "groups"?: Group[]; -} - /** is what source takes. */ export interface SourceInput { /** the watched branch, escaped as a key name is; absent: the answer is the list of the branches the gate keeps a source revision of (design 47 G section 690) */ @@ -300,10 +168,10 @@ export interface SourceAnswer { "branch"?: string; /** given no branch: the branch name of each source. key the gate keeps, which every reader of the catalog half follows before the first registrations (design 47 G section 614, section 690) */ "branches"?: string[]; + /** the merge call that moved the source revision last; absent before the first */ + "call"?: string; /** why it could not be read */ "error"?: string; - /** the group that moved the source revision last; absent before the first */ - "group"?: string; /** every repository the source revision names, by name */ "repositories"?: SourceHead[]; /** the source revision's number on the bus; 0 before the first */ @@ -341,48 +209,20 @@ export interface RecoveryAnswer { /** is the body of the event owed. */ export type OwedEvent = Owed; -/** is the body of the event pinned. */ -export type PinnedEvent = Pins; - -/** is the body of the event freed. */ -export type FreedEvent = Pins; - -/** is the body of the event heads-replaced. */ -export interface HeadsReplacedEvent { - /** when */ - "at"?: string; - /** the pull request closed */ - "closed"?: boolean; - /** the group */ - "group": string; - /** its new head; absent when it closed */ - "head"?: string; - /** the candidate's heads, 12 hex digits, as its revisions are keyed */ - "heads": string; - /** its pull request's number */ - "number": number; - /** the member whose head moved or which closed */ - "repository": string; -} - /** is the body of the event record-opened. */ export interface RecordOpenedEvent { /** when */ "at"?: string; - /** for a forge-made record, the branch the merge moved */ - "branch"?: string; - /** for a forge-made record, the merge commit */ - "commit"?: string; - /** a merge made at the forge, with no Approve */ - "forge-made"?: boolean; - /** its milestone */ + /** the watched branch */ + "branch": string; + /** the merge call */ + "call": string; + /** its milestone, . */ "milestone": string; - /** for a forge-made record, the pull request's number */ - "pull"?: number; /** the record's id */ "record": string; - /** for a forge-made record, the repository, / */ - "repository"?: string; + /** the source revision */ + "source": number; } export interface RecordEndedEventAwayItem { @@ -398,12 +238,16 @@ export interface RecordEndedEvent { "at"?: string; /** the nodes away, each with since when; it ends without them */ "away"?: RecordEndedEventAwayItem[]; - /** a merge made at the forge, with no Approve */ - "forge-made"?: boolean; - /** its milestone */ + /** the watched branch */ + "branch": string; + /** the merge call */ + "call": string; + /** its milestone, . */ "milestone": string; /** the record's id */ "record": string; + /** the source revision */ + "source": number; } /** is the body of the event filling. */ @@ -415,14 +259,23 @@ export type FullEvent = Fill; /** is the body of the event room. */ export type RoomEvent = Fill; +export interface SourceMovedEventHeadsItem { + "commit": string; + "repository": string; +} + /** is the body of the event source-moved. */ export interface SourceMovedEvent { - "at"?: string; "branch": string; - /** the group that moved it, when one did */ - "group"?: string; - "revision": number; - "v"?: number; + /** the merge call that moved it */ + "call": string; + /** the repositories it moved */ + "heads": SourceMovedEventHeadsItem[]; + /** the source revision, numbered by the gate alone */ + "source": number; + /** true only for a branch's first revision (design 47 H §768) */ + "start": boolean; + "v": number; } /** is the body of the event recovery-merged. */ @@ -443,74 +296,14 @@ export interface RecoveryMergedEvent { "why": string; } -/** is the body of the event approval-carried. */ -export interface ApprovalCarriedEvent { - /** who approved: the operator */ - "approver": string; - /** when it was said, RFC 3339 */ - "at": string; - /** the head the Approve named */ - "commit": string; - /** the pull request's number */ - "pull": number; - /** the repository */ - "repository": string; -} - -/** is the body of the event pins-stated. */ -export interface PinsStatedEvent { - /** when it was said, RFC 3339 */ - "at": string; -} - /** is one value of the state source under the key . */ export interface SourceByBranchValue { - /** the group that moved it */ - "group": string; + /** the merge call that moved it; a call the newest revision already carries writes nothing (design 47 H §737, H-A-33) */ + "call": string; /** repository to the merged head, a full commit */ "heads": Record; - /** the layout version */ - "v"?: number; -} - -export interface MergesByGroupValuePullsItem { - "commit"?: string; - "head": string; - "number": number; - "repository": string; - /** merging, merged or refused */ - "state": string; - "words"?: string; -} - -/** is one value of the state merges under the key . */ -export interface MergesByGroupValue { - /** @ to the approved head */ - "approved"?: Record; - /** the ask key */ - "ask": string; - "group": string; - "pulls": MergesByGroupValuePullsItem[]; - /** the layout version */ - "v"?: number; -} - -export interface AsksByMergeGroupHeadsValueHeadsItem { - /** the full commit */ - "head": string; - "number": number; - /** / */ - "repository": string; -} - -/** is one value of the state asks under the key merge... */ -export interface AsksByMergeGroupHeadsValue { - /** the operator-channel ask as raised */ - "ask": unknown; - /** the number of times it was asked */ - "asking"?: number; - "group": string; - "heads": AsksByMergeGroupHeadsValueHeadsItem[]; + /** the branch's source revision, one above its newest */ + "source": number; /** the layout version */ "v"?: number; } @@ -528,25 +321,11 @@ export interface OwedByRepositoryNumberHeadActValue { "v"?: number; } -export interface TurnsByRepositoryValueWaitingItem { - /** when (RFC 3339 time) */ - "approved": string; - "ask"?: string; - "group": string; - "heads": string; - /** when (RFC 3339 time) */ +/** is one value of the state heads under the key .. */ +export interface HeadsByRepositoryBranchValue { + /** the head head-moved said */ + "head": string; + /** when it was first heard */ "since": string; - "step"?: string; - "waits-for"?: string; - /** when (RFC 3339 time) */ - "waits-since"?: string; -} - -/** is one value of the state turns under the key . */ -export interface TurnsByRepositoryValue { - "repository": string; - /** the layout version */ - "v"?: number; - "waiting": TurnsByRepositoryValueWaitingItem[]; } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.js b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.js index 5416d647..d8e6bfe0 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.js @@ -7,7 +7,6 @@ export const seat = "mesh-delivery"; export const verbs = { deliveries: "deliveries", show: "show", - groups: "groups", source: "source", stalled: "stalled", recovery: "recovery", @@ -15,9 +14,6 @@ export const verbs = { export const events = { owed: "owed", - pinned: "pinned", - freed: "freed", - headsReplaced: "heads-replaced", recordOpened: "record-opened", recordEnded: "record-ended", filling: "filling", @@ -25,8 +21,6 @@ export const events = { room: "room", sourceMoved: "source-moved", recoveryMerged: "recovery-merged", - approvalCarried: "approval-carried", - pinsStated: "pins-stated", }; export const family = { name: "mesh-delivery.events", maxAgeDays: 7 }; @@ -39,13 +33,11 @@ export function owedSubject(repository, number) { export const owedSubjectAll = "mesh.seat.mesh-delivery.event.owed.*.*"; -export const pinnedSubject = "mesh.seat.mesh-delivery.event.pinned"; +export function recordOpenedSubject(call) { + return "mesh.seat.mesh-delivery.event.record-opened." + call; +} -export const freedSubject = "mesh.seat.mesh-delivery.event.freed"; - -export const headsReplacedSubject = "mesh.seat.mesh-delivery.event.heads-replaced"; - -export const recordOpenedSubject = "mesh.seat.mesh-delivery.event.record-opened"; +export const recordOpenedSubjectAll = "mesh.seat.mesh-delivery.event.record-opened.*"; export const recordEndedSubject = "mesh.seat.mesh-delivery.event.record-ended"; @@ -55,30 +47,20 @@ export const fullSubject = "mesh.seat.mesh-delivery.event.full"; export const roomSubject = "mesh.seat.mesh-delivery.event.room"; -export function sourceMovedSubject(branch) { - return "mesh.seat.mesh-delivery.event.source-moved." + branch; +export const sourceMovedStream = "SEAT_mesh-delivery_source-moved"; + +export function sourceMovedSubject(branch, source) { + return "mesh.seat.mesh-delivery.event.source-moved." + branch + "." + source; } -export const sourceMovedSubjectAll = "mesh.seat.mesh-delivery.event.source-moved.*"; +export const sourceMovedSubjectAll = "mesh.seat.mesh-delivery.event.source-moved.*.*"; export const recoveryMergedSubject = "mesh.seat.mesh-delivery.event.recovery-merged"; -export const approvalCarriedStream = "SEAT_mesh-delivery_approval-carried"; - -export function approvalCarriedSubject(repository, pull) { - return "mesh.seat.mesh-delivery.event.approval-carried." + repository + "." + pull; -} - -export const approvalCarriedSubjectAll = "mesh.seat.mesh-delivery.event.approval-carried.*.*"; - -export const pinsStatedSubject = "mesh.seat.mesh-delivery.event.pins-stated"; - export const states = { source: "source", - merges: "merges", - asks: "asks", owed: "owed", - turns: "turns", + heads: "heads", }; /** The key of one value of the state source under the form "". */ @@ -96,42 +78,6 @@ export function parseSourceByBranchKey(_key) { return { branch }; } -/** The key of one value of the state merges under the form "". */ -export function mergesByGroupKey(group) { - return group; -} - -/** The parts of a key of the form "", or undefined for a key of another form. */ -export function parseMergesByGroupKey(_key) { - let _rest = _key; - if (_rest === "") return undefined; - const group = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { group }; -} - -/** The key of one value of the state asks under the form "merge..". */ -export function asksByMergeGroupHeadsKey(group, heads) { - return "merge." + group + "." + heads; -} - -/** The parts of a key of the form "merge..", or undefined for a key of another form. */ -export function parseAsksByMergeGroupHeadsKey(_key) { - let _rest = _key; - if (!_rest.startsWith("merge.")) return undefined; - _rest = _rest.slice(6); - const _at1 = _rest.indexOf("."); - if (_at1 <= 0) return undefined; - const group = _rest.slice(0, _at1); - _rest = _rest.slice(_at1 + 1); - if (_rest === "") return undefined; - const heads = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { group, heads }; -} - /** The key of one value of the state owed under the form "...". */ export function owedByRepositoryNumberHeadActKey(repository, number, head, act) { return repository + "." + number + "." + head + "." + act; @@ -159,18 +105,22 @@ export function parseOwedByRepositoryNumberHeadActKey(_key) { return { repository, number, head, act }; } -/** The key of one value of the state turns under the form "". */ -export function turnsByRepositoryKey(repository) { - return repository; +/** The key of one value of the state heads under the form ".". */ +export function headsByRepositoryBranchKey(repository, branch) { + return repository + "." + branch; } -/** The parts of a key of the form "", or undefined for a key of another form. */ -export function parseTurnsByRepositoryKey(_key) { +/** The parts of a key of the form ".", or undefined for a key of another form. */ +export function parseHeadsByRepositoryBranchKey(_key) { let _rest = _key; + const _at0 = _rest.indexOf("."); + if (_at0 <= 0) return undefined; + const repository = _rest.slice(0, _at0); + _rest = _rest.slice(_at0 + 1); if (_rest === "") return undefined; - const repository = _rest; + const branch = _rest; _rest = ""; if (_rest !== "") return undefined; - return { repository }; + return { repository, branch }; } -- 2.54.0 From 5042d9c4267304f69411b714fb09b8feb64b0f07 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:51:01 +0100 Subject: [PATCH 008/104] C-acts: the build seats' acting rules name no bound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit acts stays as the declaration the graph's edges and tiers are built from; the bound of the build seats' rule goes with the acting part's hold. The generated contracts do not change. Builds: design 47 H §750, §764 (the acting part's hold); lead answers H-A-57, H-A-70 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../mesh-delivery-contracts/seats/node-build-go/seat.json | 3 +-- .../seats/node-build-image/seat.json | 3 +-- .../seats/node-build-node/seat.json | 3 +-- modules/mesh-delivery-sdk/buildstep/seat_acts_test.go | 7 ++++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-contracts/seats/node-build-go/seat.json b/modules/mesh-delivery-contracts/seats/node-build-go/seat.json index 44ad2671..0de300b1 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-go/seat.json +++ b/modules/mesh-delivery-contracts/seats/node-build-go/seat.json @@ -10,8 +10,7 @@ "acts": [ { "step": "build", - "on": "go", - "bound": "60m" + "on": "go" } ], "accepts": [ diff --git a/modules/mesh-delivery-contracts/seats/node-build-image/seat.json b/modules/mesh-delivery-contracts/seats/node-build-image/seat.json index fe1d6afd..78bb6394 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-image/seat.json +++ b/modules/mesh-delivery-contracts/seats/node-build-image/seat.json @@ -10,8 +10,7 @@ "acts": [ { "step": "build", - "on": "kind:image", - "bound": "60m" + "on": "kind:image" } ], "accepts": [ diff --git a/modules/mesh-delivery-contracts/seats/node-build-node/seat.json b/modules/mesh-delivery-contracts/seats/node-build-node/seat.json index a291d993..a04b6240 100644 --- a/modules/mesh-delivery-contracts/seats/node-build-node/seat.json +++ b/modules/mesh-delivery-contracts/seats/node-build-node/seat.json @@ -10,8 +10,7 @@ "acts": [ { "step": "build", - "on": "typescript", - "bound": "60m" + "on": "typescript" } ], "accepts": [ diff --git a/modules/mesh-delivery-sdk/buildstep/seat_acts_test.go b/modules/mesh-delivery-sdk/buildstep/seat_acts_test.go index 53198d98..3458ae1a 100644 --- a/modules/mesh-delivery-sdk/buildstep/seat_acts_test.go +++ b/modules/mesh-delivery-sdk/buildstep/seat_acts_test.go @@ -6,7 +6,8 @@ import ( "testing" ) -// The seat's `build` acting rule matches an artifact by its kind, an image having no language (design 47 G §324, §397). +// The seat's `build` acting rule matches an artifact by its kind, an image having no language (design 47 G §324, §397), +// and names no bound: the acting part's hold ends (H-A-57, H-A-70). func TestTheSeatsBuildRuleActsOnTheKindImage(t *testing.T) { raw, err := os.ReadFile("../../mesh-delivery-contracts/seats/node-build-image/seat.json") if err != nil { @@ -18,7 +19,7 @@ func TestTheSeatsBuildRuleActsOnTheKindImage(t *testing.T) { if err := json.Unmarshal(raw, &def); err != nil { t.Fatal(err) } - if len(def.Acts) != 1 || def.Acts[0].Step != "build" || def.Acts[0].On != "kind:image" { - t.Errorf("acts = %+v; wanted the one rule {build, kind:image}", def.Acts) + if len(def.Acts) != 1 || def.Acts[0].Step != "build" || def.Acts[0].On != "kind:image" || def.Acts[0].Bound != "" { + t.Errorf("acts = %+v; wanted the one rule {build, kind:image} with no bound", def.Acts) } } -- 2.54.0 From d24d6a08905996841b62c723736339e809ca4625 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:51:26 +0100 Subject: [PATCH 009/104] C2: a kept call's member names its base branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So the forge module can say merge-called for what landed after a restart without reading the forge again, each member of the state calls keeps the pull request's base, read at judging. Builds: design 47 H §766; lead answer H-A-71 (2) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- modules/mesh-delivery-contracts/go/seats/git/contract.go | 2 ++ .../mesh-delivery-contracts/go/seats/git/contract_test.go | 2 +- .../mesh-delivery-contracts/seats/git/fixtures/states.json | 6 ++++-- modules/mesh-delivery-contracts/seats/git/seat.json | 5 +++++ modules/mesh-delivery-contracts/ts/seats/git/index.d.ts | 2 ++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract.go b/modules/mesh-delivery-contracts/go/seats/git/contract.go index 7d4172ff..e5ba278d 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract.go @@ -192,6 +192,8 @@ type Call struct { // CallMember is one member of a kept call. type CallMember struct { + // the pull request's base, a watched branch, read at judging + Branch string `json:"branch"` // for merged, the merge commit Commit string `json:"commit,omitempty"` Head string `json:"head"` diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract_test.go b/modules/mesh-delivery-contracts/go/seats/git/contract_test.go index c797bf52..4fb15c99 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract_test.go @@ -41,7 +41,7 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a merge call kept", subject: "", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", + {name: "a merge call kept", subject: "", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", decode: func(b []byte) (any, error) { var v CallsByCallCallValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "pull asks", subject: "", given: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", decode: func(b []byte) (any, error) { var v PullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, diff --git a/modules/mesh-delivery-contracts/seats/git/fixtures/states.json b/modules/mesh-delivery-contracts/seats/git/fixtures/states.json index 824f1999..84999ddc 100644 --- a/modules/mesh-delivery-contracts/seats/git/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/git/fixtures/states.json @@ -29,13 +29,15 @@ "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "number": 178, "repository": "novox/mesh-sdk", - "state": "merged" + "state": "merged", + "branch": "main" }, { "head": "cccccccccccccccccccccccccccccccccccccccc", "number": 261, "repository": "novox/mesh-delivery", - "state": "judged" + "state": "judged", + "branch": "main" } ], "said": false diff --git a/modules/mesh-delivery-contracts/seats/git/seat.json b/modules/mesh-delivery-contracts/seats/git/seat.json index 7af220d3..db42887f 100644 --- a/modules/mesh-delivery-contracts/seats/git/seat.json +++ b/modules/mesh-delivery-contracts/seats/git/seat.json @@ -1607,6 +1607,10 @@ "number": { "type": "integer" }, + "branch": { + "type": "string", + "description": "the pull request's base, a watched branch, read at judging" + }, "head": { "type": "string", "pattern": "^[0-9a-f]{40}$" @@ -1632,6 +1636,7 @@ "required": [ "repository", "number", + "branch", "head", "state" ] diff --git a/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts index b2ee42ed..a6547410 100644 --- a/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts @@ -90,6 +90,8 @@ export interface Call { /** one member of a kept call */ export interface CallMember { + /** the pull request's base, a watched branch, read at judging */ + "branch": string; /** for merged, the merge commit */ "commit"?: string; "head": string; -- 2.54.0 From b7b40870952cce1171207173f8767d8ca227c523 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:01:24 +0100 Subject: [PATCH 010/104] C-R: the runner's seat: one pipeline per take-in, its movers, the queue and place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pipeline is keyed . (and ..published.. for a publish), its movers {module, commit, fingerprint, repository, tier} carry what was per module (version, widens, tests, over-budget); group goes, run, published, unlogged and end-count stay; call and seq are added and the outcome gains waiting. Each step result names its module and the step enum gains validate. pipeline-started names the movers; pipeline-ended carries per mover its fingerprint, version, steps and tier. pipeline-started, pipeline-ended, wait-held and wait-ended are said on .; the step events and run-started on ... A wait gains step pipeline and on pipelines-at-once. The state queue holds queue.next and waiting.; the verb place takes pipeline and why. group-ended and its body go. The client builds and parses both subject forms. Builds: design 47 H §745, §746, §747, §748, §764 (the runner: group-ended, the key per module); lead answers H-A-35, H-A-36, H-A-51, H-A-52, H-A-53, H-A-72 (1) to (5) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../meshpipelinerunnerclient/client.go | 81 +-- .../meshpipelinerunnerclient/client_test.go | 58 ++- .../go/seats/meshpipelinerunner/contract.go | 451 ++++++++++------- .../seats/meshpipelinerunner/contract_test.go | 78 +-- .../mesh-pipeline-runner/fixtures/events.json | 303 ++++++----- .../mesh-pipeline-runner/fixtures/states.json | 121 +++-- .../mesh-pipeline-runner/fixtures/verbs.json | 53 +- .../seats/mesh-pipeline-runner/seat.json | 469 +++++++++--------- .../ts/seats/meshpipelinerunner/index.d.ts | 248 ++++----- .../ts/seats/meshpipelinerunner/index.js | 123 +++-- 10 files changed, 1133 insertions(+), 852 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client.go b/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client.go index 6737b00b..eb466b0b 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client.go +++ b/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client.go @@ -1,12 +1,13 @@ // Package meshpipelinerunnerclient is the logic the callers of the seat mesh-pipeline-runner share (ADR 0634 §1): the -// subjects of the runner's events, built and parsed, and their bodies decoded (design 47 G §73, §332). It names no -// module, repository or branch: every name is the caller's. +// subjects of the runner's events, built and parsed, and their bodies decoded (design 47 H §746). It names no module, +// repository or branch: every name is the caller's. package meshpipelinerunnerclient import ( "encoding/json" "fmt" "slices" + "strconv" "strings" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" @@ -16,35 +17,52 @@ import ( // eventPrefix starts every event subject of the seat. const eventPrefix = "mesh.seat." + seat.Seat + ".event." -// Subject is where the runner says event of a pipeline: mesh.seat.mesh-pipeline-runner.event.... -// , each name escaped as a key's name is (design 47 *Health and going back*), so a branch or a group -// holding a dot is one token. -func Subject(event, module, branch, commitOrGroup string) string { - return eventPrefix + event + "." + keys.EscapeName(module) + "." + keys.EscapeName(branch) + "." + keys.EscapeName(commitOrGroup) +// perSource are the events said per source revision, on .. (design 47 H §746, H-A-72 (3)). +var perSource = []string{seat.EventPipelineStarted, seat.EventPipelineEnded, seat.EventWaitHeld, seat.EventWaitEnded} + +// Subject is where the runner says a step's event or a run's start: mesh.seat.mesh-pipeline-runner.event.. +// .., each name escaped as a key's name is, so a branch holding a dot is one token (design 47 H +// H-A-72 (4)). +func Subject(event, module, branch, commit string) string { + return eventPrefix + event + "." + keys.EscapeName(module) + "." + keys.EscapeName(branch) + "." + keys.EscapeName(commit) } -// GroupEndedSubject is where the runner says a group's end: mesh.seat.mesh-pipeline-runner.event.group-ended.. -// , with no module part, since a group spans modules (design 47 G §332). -func GroupEndedSubject(branch, group string) string { - return eventPrefix + seat.EventGroupEnded + "." + keys.EscapeName(branch) + "." + keys.EscapeName(group) +// SourceSubject is where the runner says a pipeline's start and end and its waits: mesh.seat.mesh-pipeline-runner. +// event..., the branch escaped as a key's name is (design 47 H §746, H-A-72 (3)). +func SourceSubject(event, branch string, source int64) string { + return eventPrefix + event + "." + keys.EscapeName(branch) + "." + strconv.FormatInt(source, 10) } -// Of is what an event's subject names. A group-ended names no module. +// Of is what an event's subject names: a step's event or a run's start names the module, the branch and the commit; an +// event per source revision names the branch and the source. type Of struct { - Event, Module, Branch, CommitOrGroup string + Event, Module, Branch, Commit string + Source int64 } -// Parse reads a subject Subject or GroupEndedSubject built: an event of the seat's, and its names unescaped. +// Parse reads a subject Subject or SourceSubject built: an event of the seat's, and its names unescaped. func Parse(subject string) (Of, error) { rest, ok := strings.CutPrefix(subject, eventPrefix) toks := strings.Split(rest, ".") + bySource := len(toks) > 0 && slices.Contains(perSource, toks[0]) want := 4 - if len(toks) > 0 && toks[0] == seat.EventGroupEnded { + if bySource { want = 3 } if !ok || len(toks) != want || !slices.Contains(seat.Events(), toks[0]) { return Of{}, fmt.Errorf("meshpipelinerunnerclient: %q is no event subject of the seat %s", subject, seat.Seat) } + if bySource { + branch, err := keys.UnescapeName(toks[1]) + if err != nil || branch == "" { + return Of{}, fmt.Errorf("meshpipelinerunnerclient: %q: branch: %v", subject, err) + } + source, err := strconv.ParseInt(toks[2], 10, 64) + if err != nil || source < 1 { + return Of{}, fmt.Errorf("meshpipelinerunnerclient: %q: no source revision", subject) + } + return Of{Event: toks[0], Branch: branch, Source: source}, nil + } names := make([]string, 0, 3) for i, t := range toks[1:] { n, err := keys.UnescapeName(t) @@ -53,40 +71,25 @@ func Parse(subject string) (Of, error) { } names = append(names, n) } - if want == 3 { - return Of{Event: toks[0], Branch: names[0], CommitOrGroup: names[1]}, nil - } - return Of{Event: toks[0], Module: names[0], Branch: names[1], CommitOrGroup: names[2]}, nil + return Of{Event: toks[0], Module: names[0], Branch: names[1], Commit: names[2]}, nil } -// PipelineEnded decodes a pipeline-ended body, refusing one that names no pipeline, module, branch or commit. +// PipelineEnded decodes a pipeline-ended body, refusing one that names no pipeline, branch, source or mover, or a mover +// that names no module (design 47 H §746). func PipelineEnded(data []byte) (seat.PipelineEndedEvent, error) { var e seat.PipelineEndedEvent if err := json.Unmarshal(data, &e); err != nil { return e, fmt.Errorf("meshpipelinerunnerclient: pipeline-ended: %w", err) } - if e.Pipeline == "" || e.Module == "" || e.Branch == "" || e.Commit == "" { - return e, fmt.Errorf("meshpipelinerunnerclient: pipeline-ended names no pipeline, module, branch or commit") + if e.Pipeline == "" || e.Branch == "" || e.Source == 0 || len(e.Movers) == 0 { + return e, fmt.Errorf("meshpipelinerunnerclient: pipeline-ended names no pipeline, branch, source or mover") } - return e, nil -} - -// GroupEnded decodes a group-ended body, refusing one that names no group or branch, and each of its pipelines as -// PipelineEnded does. -func GroupEnded(data []byte) (seat.GroupEndedEvent, error) { - var g seat.GroupEndedEvent - if err := json.Unmarshal(data, &g); err != nil { - return g, fmt.Errorf("meshpipelinerunnerclient: group-ended: %w", err) - } - if g.Group == "" || g.Branch == "" { - return g, fmt.Errorf("meshpipelinerunnerclient: group-ended names no group or branch") - } - for _, p := range g.Pipelines { - if p.Pipeline == "" || p.Module == "" || p.Branch == "" || p.Commit == "" { - return g, fmt.Errorf("meshpipelinerunnerclient: group-ended %s: a pipeline names no pipeline, module, branch or commit", g.Group) + for _, m := range e.Movers { + if m.Module == "" { + return e, fmt.Errorf("meshpipelinerunnerclient: pipeline-ended %s: a mover names no module", e.Pipeline) } } - return g, nil + return e, nil } // StepEnded decodes a step-ended (or step-started) body, refusing one that names no pipeline, module or step. diff --git a/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client_test.go b/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client_test.go index d6ba83b3..355017f2 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client_test.go @@ -6,43 +6,49 @@ import ( seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) -// A-D7: the subject carries the module, the branch and the commit or group, each escaped as a key's name is, and is -// read back (design 47 *Health and going back*); a body naming nothing is refused. +// design 47 H §746, H-A-72 (3), (4): a pipeline's start and end and its waits are said per source revision, +// .; a step's events and a run's start per module, ..; each name escaped as a +// key's name is, and read back. group-ended is no event of the seat (§764); a body naming nothing is refused. func TestSubjectsAndBodies(t *testing.T) { - s := Subject(seat.EventPipelineEnded, "nats", "release.1", "feat/47-G") - if s != "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.release=2e1.feat/47-G" { + s := Subject(seat.EventStepEnded, "nats", "release.1", "c1") + if s != "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.release=2e1.c1" { t.Errorf("subject %s", s) } - if of, err := Parse(s); err != nil || of != (Of{seat.EventPipelineEnded, "nats", "release.1", "feat/47-G"}) { + if of, err := Parse(s); err != nil || of != (Of{Event: seat.EventStepEnded, Module: "nats", Branch: "release.1", Commit: "c1"}) { t.Errorf("parse %s: %+v, %v", s, of, err) } - for _, bad := range []string{"not.an.event.subject", "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main", - "mesh.seat.mesh-pipeline-runner.event.no-such.nats.main.c1", "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.ma=zz.c1"} { + ps := SourceSubject(seat.EventPipelineEnded, "release.1", 3589) + if ps != "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.release=2e1.3589" { + t.Errorf("pipeline-ended subject %s", ps) + } + if of, err := Parse(ps); err != nil || of != (Of{Event: seat.EventPipelineEnded, Branch: "release.1", Source: 3589}) { + t.Errorf("parse %s: %+v, %v", ps, of, err) + } + if of, err := Parse(SourceSubject(seat.EventWaitHeld, "main", 7)); err != nil || of.Source != 7 || of.Module != "" { + t.Errorf("wait-held: %+v, %v", of, err) + } + for _, bad := range []string{"not.an.event.subject", + "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main", + "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.c1", + "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.c1", + "mesh.seat.mesh-pipeline-runner.event.group-ended.main.g1", + "mesh.seat.mesh-pipeline-runner.event.no-such.nats.main.c1", + "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.ma=zz.c1"} { if _, err := Parse(bad); err == nil { t.Errorf("%s parsed", bad) } } - // design 47 G §332: a group's end is said under the branch and the group, with no module. - gs := GroupEndedSubject("main", "registry.1966") - if gs != "mesh.seat.mesh-pipeline-runner.event.group-ended.main.registry=2e1966" { - t.Errorf("group-ended subject %s", gs) + if e, err := PipelineEnded([]byte(`{"v":1,"pipeline":"main.3589","branch":"main","source":3589,"call":"0123456789abcdef","outcome":"passed","movers":[{"module":"nats","fingerprint":"fp","version":"0.1.15","tier":1,"steps":[]}]}`)); err != nil || e.Movers[0].Version != "0.1.15" { + t.Errorf("pipeline-ended: %+v, %v", e, err) } - if of, err := Parse(gs); err != nil || of != (Of{Event: seat.EventGroupEnded, Branch: "main", CommitOrGroup: "registry.1966"}) { - t.Errorf("parse %s: %+v, %v", gs, of, err) + for _, bad := range []string{`{"v":1,"branch":"main"}`, + `{"v":1,"pipeline":"main.3589","branch":"main","source":3589,"outcome":"passed","movers":[{"tier":1,"steps":[]}]}`, + `{"v":1,"pipeline":"main.12.nats","module":"nats","branch":"main","commit":"c1","outcome":"passed","steps":[]}`} { + if _, err := PipelineEnded([]byte(bad)); err == nil { + t.Errorf("pipeline-ended %s was taken", bad) + } } - if _, err := Parse("mesh.seat.mesh-pipeline-runner.event.group-ended.nats.main.g1"); err == nil { - t.Error("a group-ended with a module part parsed") - } - if _, err := PipelineEnded([]byte(`{"v":1,"pipeline":"main.12.nats","module":"nats","branch":"main","commit":"c1","outcome":"passed","steps":[]}`)); err != nil { - t.Error(err) - } - if _, err := PipelineEnded([]byte(`{"v":1,"module":"nats"}`)); err == nil { - t.Error("a pipeline-ended naming no pipeline was taken") - } - if _, err := GroupEnded([]byte(`{"v":1,"group":"g","branch":"main","outcome":"passed","pipelines":[{"module":"nats"}]}`)); err == nil { - t.Error("a group-ended with a pipeline naming nothing was taken") - } - if e, err := StepEnded([]byte(`{"v":1,"pipeline":"p","module":"nats","branch":"main","commit":"c1","result":{"step":"unit","status":"required","outcome":"passed","rerun":true,"by":"operator@workstation"}}`)); err != nil || !e.Result.Rerun { + if e, err := StepEnded([]byte(`{"v":1,"pipeline":"main.3589","module":"nats","branch":"main","commit":"c1","result":{"step":"validate","status":"required","outcome":"passed"}}`)); err != nil || e.Result.Step != "validate" { t.Errorf("step-ended: %+v, %v", e, err) } } diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 9962fb6f..9b5b3f87 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -26,6 +26,7 @@ const ( VerbRerun = "rerun" VerbAccept = "accept" VerbCancel = "cancel" + VerbPlace = "place" VerbAskAgain = "ask-again" VerbTestRuns = "test-runs" VerbTestRunsDrop = "test-runs-drop" @@ -34,7 +35,6 @@ const ( const ( EventPipelineStarted = "pipeline-started" EventPipelineEnded = "pipeline-ended" - EventGroupEnded = "group-ended" EventRunStarted = "run-started" EventStepStarted = "step-started" EventStepEnded = "step-ended" @@ -47,12 +47,12 @@ const ( // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { - return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbAskAgain, VerbTestRuns, VerbTestRunsDrop} + return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbPlace, VerbAskAgain, VerbTestRuns, VerbTestRunsDrop} } // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventPipelineStarted, EventPipelineEnded, EventGroupEnded, EventRunStarted, EventStepStarted, EventStepEnded, EventWaitHeld, EventWaitEnded, EventFilling, EventFull, EventRoom} + return []string{EventPipelineStarted, EventPipelineEnded, EventRunStarted, EventStepStarted, EventStepEnded, EventWaitHeld, EventWaitEnded, EventFilling, EventFull, EventRoom} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -64,42 +64,31 @@ const ( // StreamPipelineStarted is the stream pipeline-started is kept in. const StreamPipelineStarted = "SEAT_mesh-pipeline-runner_pipeline-started" -// SubjectPipelineStarted is where pipeline-started is published, on mesh.seat.mesh-pipeline-runner.event.pipeline-started.... -func SubjectPipelineStarted(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.pipeline-started." + module + "." + branch + "." + commitOrGroup +// SubjectPipelineStarted is where pipeline-started is published, on mesh.seat.mesh-pipeline-runner.event.pipeline-started... +func SubjectPipelineStarted(branch, source string) string { + return "mesh.seat.mesh-pipeline-runner.event.pipeline-started." + branch + "." + source } // SubjectPipelineStartedAll hears every pipeline-started. -const SubjectPipelineStartedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*.*" +const SubjectPipelineStartedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*" // StreamPipelineEnded is the stream pipeline-ended is kept in. const StreamPipelineEnded = "SEAT_mesh-pipeline-runner_pipeline-ended" -// SubjectPipelineEnded is where pipeline-ended is published, on mesh.seat.mesh-pipeline-runner.event.pipeline-ended.... -func SubjectPipelineEnded(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.pipeline-ended." + module + "." + branch + "." + commitOrGroup +// SubjectPipelineEnded is where pipeline-ended is published, on mesh.seat.mesh-pipeline-runner.event.pipeline-ended... +func SubjectPipelineEnded(branch, source string) string { + return "mesh.seat.mesh-pipeline-runner.event.pipeline-ended." + branch + "." + source } // SubjectPipelineEndedAll hears every pipeline-ended. -const SubjectPipelineEndedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*.*" - -// StreamGroupEnded is the stream group-ended is kept in. -const StreamGroupEnded = "SEAT_mesh-pipeline-runner_group-ended" - -// SubjectGroupEnded is where group-ended is published, on mesh.seat.mesh-pipeline-runner.event.group-ended... -func SubjectGroupEnded(branch, group string) string { - return "mesh.seat.mesh-pipeline-runner.event.group-ended." + branch + "." + group -} - -// SubjectGroupEndedAll hears every group-ended. -const SubjectGroupEndedAll = "mesh.seat.mesh-pipeline-runner.event.group-ended.*.*" +const SubjectPipelineEndedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*" // StreamRunStarted is the stream run-started is kept in. const StreamRunStarted = "SEAT_mesh-pipeline-runner_run-started" -// SubjectRunStarted is where run-started is published, on mesh.seat.mesh-pipeline-runner.event.run-started.... -func SubjectRunStarted(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.run-started." + module + "." + branch + "." + commitOrGroup +// SubjectRunStarted is where run-started is published, on mesh.seat.mesh-pipeline-runner.event.run-started.... +func SubjectRunStarted(module, branch, commit string) string { + return "mesh.seat.mesh-pipeline-runner.event.run-started." + module + "." + branch + "." + commit } // SubjectRunStartedAll hears every run-started. @@ -108,9 +97,9 @@ const SubjectRunStartedAll = "mesh.seat.mesh-pipeline-runner.event.run-started.* // StreamStepStarted is the stream step-started is kept in. const StreamStepStarted = "SEAT_mesh-pipeline-runner_step-started" -// SubjectStepStarted is where step-started is published, on mesh.seat.mesh-pipeline-runner.event.step-started.... -func SubjectStepStarted(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.step-started." + module + "." + branch + "." + commitOrGroup +// SubjectStepStarted is where step-started is published, on mesh.seat.mesh-pipeline-runner.event.step-started.... +func SubjectStepStarted(module, branch, commit string) string { + return "mesh.seat.mesh-pipeline-runner.event.step-started." + module + "." + branch + "." + commit } // SubjectStepStartedAll hears every step-started. @@ -119,9 +108,9 @@ const SubjectStepStartedAll = "mesh.seat.mesh-pipeline-runner.event.step-started // StreamStepEnded is the stream step-ended is kept in. const StreamStepEnded = "SEAT_mesh-pipeline-runner_step-ended" -// SubjectStepEnded is where step-ended is published, on mesh.seat.mesh-pipeline-runner.event.step-ended.... -func SubjectStepEnded(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.step-ended." + module + "." + branch + "." + commitOrGroup +// SubjectStepEnded is where step-ended is published, on mesh.seat.mesh-pipeline-runner.event.step-ended.... +func SubjectStepEnded(module, branch, commit string) string { + return "mesh.seat.mesh-pipeline-runner.event.step-ended." + module + "." + branch + "." + commit } // SubjectStepEndedAll hears every step-ended. @@ -130,24 +119,24 @@ const SubjectStepEndedAll = "mesh.seat.mesh-pipeline-runner.event.step-ended.*.* // StreamWaitHeld is the stream wait-held is kept in. const StreamWaitHeld = "SEAT_mesh-pipeline-runner_wait-held" -// SubjectWaitHeld is where wait-held is published, on mesh.seat.mesh-pipeline-runner.event.wait-held.... -func SubjectWaitHeld(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.wait-held." + module + "." + branch + "." + commitOrGroup +// SubjectWaitHeld is where wait-held is published, on mesh.seat.mesh-pipeline-runner.event.wait-held... +func SubjectWaitHeld(branch, source string) string { + return "mesh.seat.mesh-pipeline-runner.event.wait-held." + branch + "." + source } // SubjectWaitHeldAll hears every wait-held. -const SubjectWaitHeldAll = "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*.*" +const SubjectWaitHeldAll = "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*" // StreamWaitEnded is the stream wait-ended is kept in. const StreamWaitEnded = "SEAT_mesh-pipeline-runner_wait-ended" -// SubjectWaitEnded is where wait-ended is published, on mesh.seat.mesh-pipeline-runner.event.wait-ended.... -func SubjectWaitEnded(module, branch, commitOrGroup string) string { - return "mesh.seat.mesh-pipeline-runner.event.wait-ended." + module + "." + branch + "." + commitOrGroup +// SubjectWaitEnded is where wait-ended is published, on mesh.seat.mesh-pipeline-runner.event.wait-ended... +func SubjectWaitEnded(branch, source string) string { + return "mesh.seat.mesh-pipeline-runner.event.wait-ended." + branch + "." + source } // SubjectWaitEndedAll hears every wait-ended. -const SubjectWaitEndedAll = "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*.*" +const SubjectWaitEndedAll = "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*" // SubjectFilling is where filling is published. const SubjectFilling = "mesh.seat.mesh-pipeline-runner.event.filling" @@ -160,43 +149,150 @@ const SubjectRoom = "mesh.seat.mesh-pipeline-runner.event.room" const ( StatePipelines = "pipelines" + StateQueue = "queue" StateKept = "kept" StateStepLog = "step-log" StateStepOutputs = "step-outputs" ) -// PipelinesByBranchRevisionModuleKey is the key of one value of the state pipelines under the form "..". -func PipelinesByBranchRevisionModuleKey(branch, revision, module string) string { - return branch + "." + revision + "." + module -} +// PipelinesByBranchSourceKey is the key of one value of the state pipelines under the form ".". +func PipelinesByBranchSourceKey(branch, source string) string { return branch + "." + source } -// ParsePipelinesByBranchRevisionModuleKey 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 ParsePipelinesByBranchRevisionModuleKey(key string) (string, string, string, bool) { +// ParsePipelinesByBranchSourceKey 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 ParsePipelinesByBranchSourceKey(key string) (string, string, bool) { rest := key v0, after0, found0 := strings.Cut(rest, ".") if !found0 || v0 == "" { - return "", "", "", false + return "", "", false } rest = after0 - v2, after2, found2 := strings.Cut(rest, ".") - if !found2 || v2 == "" { - return "", "", "", false - } - rest = after2 if rest == "" { - return "", "", "", false + return "", "", false } - v4 := rest + v2 := rest rest = "" if rest != "" { - return "", "", "", false + return "", "", false } - return v0, v2, v4, true + return v0, v2, true } -// DecodePipelinesByBranchRevisionModuleValue reads one value of the state pipelines under the form "..", refusing a field PipelinesByBranchRevisionModuleValue does not know and any text after the value. -func DecodePipelinesByBranchRevisionModuleValue(raw []byte) (PipelinesByBranchRevisionModuleValue, error) { - var v PipelinesByBranchRevisionModuleValue +// DecodePipelinesByBranchSourceValue reads one value of the state pipelines under the form ".", refusing a field PipelinesByBranchSourceValue does not know and any text after the value. +func DecodePipelinesByBranchSourceValue(raw []byte) (PipelinesByBranchSourceValue, error) { + var v PipelinesByBranchSourceValue + 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 +} + +// PipelinesByBranchSourcePublishedPackageVersionKey is the key of one value of the state pipelines under the form "..published..". +func PipelinesByBranchSourcePublishedPackageVersionKey(branch, source, packagePart, version string) string { + return branch + "." + source + ".published." + packagePart + "." + version +} + +// ParsePipelinesByBranchSourcePublishedPackageVersionKey reads the parts of a key of the form "..published..", in the order of the form; the last result is false for a key of another form. +func ParsePipelinesByBranchSourcePublishedPackageVersionKey(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, ".published.") + 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 +} + +// DecodePipelinesByBranchSourcePublishedPackageVersionValue reads one value of the state pipelines under the form "..published..", refusing a field PipelinesByBranchSourcePublishedPackageVersionValue does not know and any text after the value. +func DecodePipelinesByBranchSourcePublishedPackageVersionValue(raw []byte) (PipelinesByBranchSourcePublishedPackageVersionValue, error) { + var v PipelinesByBranchSourcePublishedPackageVersionValue + 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 +} + +// QueueByQueueNextKey is the key of one value of the state queue under the form "queue.next". +func QueueByQueueNextKey() string { return "queue.next" } + +// ParseQueueByQueueNextKey reads the parts of a key of the form "queue.next", in the order of the form; the last result is false for a key of another form. +func ParseQueueByQueueNextKey(key string) bool { + rest := key + if !strings.HasPrefix(rest, "queue.next") { + return false + } + rest = rest[10:] + if rest != "" { + return false + } + return true +} + +// DecodeQueueByQueueNextValue reads one value of the state queue under the form "queue.next", refusing a field QueueByQueueNextValue does not know and any text after the value. +func DecodeQueueByQueueNextValue(raw []byte) (QueueByQueueNextValue, error) { + var v QueueByQueueNextValue + 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 +} + +// QueueByWaitingSequenceKey is the key of one value of the state queue under the form "waiting.". +func QueueByWaitingSequenceKey(sequence string) string { return "waiting." + sequence } + +// ParseQueueByWaitingSequenceKey reads the parts of a key of the form "waiting.", in the order of the form; the last result is false for a key of another form. +func ParseQueueByWaitingSequenceKey(key string) (string, bool) { + rest := key + if !strings.HasPrefix(rest, "waiting.") { + return "", false + } + rest = rest[8:] + if rest == "" { + return "", false + } + v1 := rest + rest = "" + if rest != "" { + return "", false + } + return v1, true +} + +// DecodeQueueByWaitingSequenceValue reads one value of the state queue under the form "waiting.", refusing a field QueueByWaitingSequenceValue does not know and any text after the value. +func DecodeQueueByWaitingSequenceValue(raw []byte) (QueueByWaitingSequenceValue, error) { + var v QueueByWaitingSequenceValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { @@ -336,31 +432,6 @@ type Fill struct { Store string `json:"store"` } -// GroupEnded is a group's one pipeline's end on a watched branch, said once every member's modules have ended; a group's wants are written on it alone (ADR 0666 section 9). -type GroupEnded struct { - Branch string `json:"branch"` - Ended *time.Time `json:"ended,omitempty"` - Group string `json:"group"` - Outcome string `json:"outcome"` - // every member module's pipeline, each ended - Pipelines []PipelineEnded `json:"pipelines"` - Revision int64 `json:"revision,omitempty"` - // the group's one source revision of the watched branch - Source int64 `json:"source,omitempty"` - V int64 `json:"v"` - Why string `json:"why,omitempty"` -} - -// The values of GroupEnded's outcome. -const ( - GroupEndedOutcomeRunning = "running" - GroupEndedOutcomePassed = "passed" - GroupEndedOutcomeFailed = "failed" - GroupEndedOutcomeRefused = "refused" - GroupEndedOutcomeSuperseded = "superseded" - GroupEndedOutcomeCancelled = "cancelled" -) - // KeptResult is a package's passing result the runner keeps, by the digest of what its tests read (ADR 0666 section 8). type KeptResult struct { // sha256: of what the package's tests read @@ -432,51 +503,75 @@ type Member struct { Module string `json:"module"` } -// Pipeline is one pipeline as the runner keeps it in its state pipelines, by compare-and-set (design 47 *The runner's kept data*). +// Mover is one module a pipeline moves: an entry of its take-in.taken, with what the pipeline found of it (design 47 H §746, H-A-35, H-A-72). +type Mover struct { + // the commit the module's entry was last changed at + Commit string `json:"commit"` + // the module's build-input fingerprint at the commit + Fingerprint string `json:"fingerprint"` + Module string `json:"module"` + // yes when the module is over its test budget (design 47 G section 419) + OverBudget bool `json:"over-budget,omitempty"` + Repository string `json:"repository"` + Tests *TestCounts `json:"tests,omitempty"` + // the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H §746) + Tier int64 `json:"tier"` + // the version released for the mover in this pipeline (version-released), absent until one is (design 47 H-A-52) + Version string `json:"version,omitempty"` + Widens []Widening `json:"widens,omitempty"` +} + +// MoverEnded is one mover at its pipeline's end (design 47 H §746). +type MoverEnded struct { + // the module's build-input fingerprint the pipeline ran at + Fingerprint string `json:"fingerprint"` + Module string `json:"module"` + // the mover's step results, each naming its module (design 47 H-A-72) + Steps []StepResult `json:"steps"` + // the mover's tier in the delivery order, from 1 (ADR 0666 section 14) + Tier int64 `json:"tier"` + // the version released for the mover, absent when none was released + Version string `json:"version,omitempty"` +} + +// Pipeline is one pipeline of one take-in, its movers the take-in's entries, as the runner keeps it in its state pipelines by compare-and-set (design 47 H §746). type Pipeline struct { // the watched branch, or the branch of a run on request Branch string `json:"branch"` - // the commit the module's entry was last changed at - Commit string `json:"commit"` + // the merge call whose source revision the take-in took in (design 47 H §746) + Call string `json:"call,omitempty"` // how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325) EndCount int64 `json:"end-count,omitempty"` Ended *time.Time `json:"ended,omitempty"` - // the module's build-input fingerprint at the commit - Fingerprint string `json:"fingerprint,omitempty"` - // the gathered group, when the pipeline is its - Group string `json:"group,omitempty"` - Module string `json:"module"` - Outcome string `json:"outcome"` - // yes when the module is over its test budget (design 47 G section 419) - OverBudget bool `json:"over-budget,omitempty"` - // the pipeline's key, .., a branch escaped as a key's name is - Pipeline string `json:"pipeline,omitempty"` + // the modules the pipeline moves, its take-in's entries (design 47 H §746) + Movers []Mover `json:"movers"` + Outcome string `json:"outcome"` + // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) + Pipeline string `json:"pipeline"` // for a pipeline a package's publish started, that publish (A-202) - Published *Published `json:"published,omitempty"` - Repository string `json:"repository,omitempty"` + Published *Published `json:"published,omitempty"` // the catalog graph revision of the branch the pipeline runs for Revision int64 `json:"revision,omitempty"` // the run on request's id, for a pipeline of a run; such a pipeline delivers nothing Run string `json:"run,omitempty"` + // for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748) + Seq int64 `json:"seq,omitempty"` // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) - Source int64 `json:"source,omitempty"` + Source int64 `json:"source"` Started *time.Time `json:"started,omitempty"` - // every step, approval last + // every mover's steps, each naming its mover, approval last Steps []StepResult `json:"steps"` - Tests *TestCounts `json:"tests,omitempty"` // the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606) Unlogged []LogEntry `json:"unlogged,omitempty"` // the layout version V int64 `json:"v,omitempty"` - // the version package-published names, for a pipeline the runner started from a publication or from outdated; none for any other (design 47 G 550) - Version string `json:"version,omitempty"` // for a pipeline that did not pass, the steps that held it - Why string `json:"why,omitempty"` - Widens []Widening `json:"widens,omitempty"` + Why string `json:"why,omitempty"` } // The values of Pipeline's outcome. const ( + PipelineOutcomeWaiting = "waiting" PipelineOutcomeRunning = "running" PipelineOutcomePassed = "passed" PipelineOutcomeFailed = "failed" @@ -485,41 +580,34 @@ const ( PipelineOutcomeCancelled = "cancelled" ) -// PipelineEnded is a pipeline's end with every step's result, its test counts, the source revision and widens (design 47 *Health and going back*); the assigner writes a want only from one whose every required step passed. +// PipelineEnded is a pipeline's end, said once, with per mover its released version, step results and tier (design 47 H §746); the assigner writes wants only from a passed one. type PipelineEnded struct { // the watched branch, or the branch of a run on request Branch string `json:"branch"` - // the commit the module's entry was last changed at - Commit string `json:"commit"` + // the merge call whose source revision the take-in took in (design 47 H §746) + Call string `json:"call,omitempty"` // how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325) EndCount int64 `json:"end-count,omitempty"` Ended *time.Time `json:"ended,omitempty"` - // the module's build-input fingerprint at the commit - Fingerprint string `json:"fingerprint,omitempty"` - // the gathered group, when the pipeline is its - Group string `json:"group,omitempty"` - Module string `json:"module"` - Outcome string `json:"outcome"` - // yes when the module is over its test budget (500 unit or 50 integration tests; design 47 G section 419) - OverBudget bool `json:"over-budget,omitempty"` - // the pipeline's key, .., a branch escaped as a key's name is + // per mover its fingerprint, released version, step results and tier, in the delivery order (design 47 H §746, H-A-2) + Movers []MoverEnded `json:"movers"` + Outcome string `json:"outcome"` + // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) Pipeline string `json:"pipeline"` // the catalog graph revision of the branch the pipeline runs for Revision int64 `json:"revision,omitempty"` // the run on request's id, for a pipeline of a run; such a pipeline delivers nothing Run string `json:"run,omitempty"` // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) - Source int64 `json:"source,omitempty"` - Started *time.Time `json:"started,omitempty"` - Steps []StepResult `json:"steps"` - Tests *TestCounts `json:"tests,omitempty"` - V int64 `json:"v"` - Why string `json:"why,omitempty"` - Widens []Widening `json:"widens,omitempty"` + Source int64 `json:"source"` + Started *time.Time `json:"started,omitempty"` + V int64 `json:"v"` + Why string `json:"why,omitempty"` } // The values of PipelineEnded's outcome. const ( + PipelineEndedOutcomeWaiting = "waiting" PipelineEndedOutcomeRunning = "running" PipelineEndedOutcomePassed = "passed" PipelineEndedOutcomeFailed = "failed" @@ -528,44 +616,16 @@ const ( PipelineEndedOutcomeCancelled = "cancelled" ) -// PipelineStartedStepsItem is a type of the contract. -type PipelineStartedStepsItem struct { - Artifact string `json:"artifact,omitempty"` - Status string `json:"status"` - Step string `json:"step"` -} - -// The values of PipelineStartedStepsItem's status. -const ( - PipelineStartedStepsItemStatusRequired = "required" - PipelineStartedStepsItemStatusOptional = "optional" - PipelineStartedStepsItemStatusBypass = "bypass" -) - -// The values of PipelineStartedStepsItem's step. -const ( - PipelineStartedStepsItemStepBuild = "build" - PipelineStartedStepsItemStepLint = "lint" - PipelineStartedStepsItemStepUnit = "unit" - PipelineStartedStepsItemStepIntegration = "integration" - PipelineStartedStepsItemStepComposition = "composition" - PipelineStartedStepsItemStepReview = "review" - PipelineStartedStepsItemStepApproval = "approval" -) - -// PipelineStarted is a pipeline's start. +// PipelineStarted is a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52). type PipelineStarted struct { At *time.Time `json:"at,omitempty"` // the watched branch, or the branch of a run on request Branch string `json:"branch"` - // the commit the module's entry was last changed at - Commit string `json:"commit"` - // the module's build-input fingerprint at the commit - Fingerprint string `json:"fingerprint,omitempty"` - // the gathered group, when the pipeline is its - Group string `json:"group,omitempty"` - Module string `json:"module"` - // the pipeline's key, .., a branch escaped as a key's name is + // the merge call whose source revision the take-in took in (design 47 H §746) + Call string `json:"call,omitempty"` + // the pipeline's movers + Movers []Mover `json:"movers"` + // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) Pipeline string `json:"pipeline"` // for a pipeline a package's publish started, that publish (A-202) Published *Published `json:"published,omitempty"` @@ -574,10 +634,8 @@ type PipelineStarted struct { // the run on request's id, for a pipeline of a run; such a pipeline delivers nothing Run string `json:"run,omitempty"` // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) - Source int64 `json:"source,omitempty"` - // the steps the policy gives it - Steps []PipelineStartedStepsItem `json:"steps,omitempty"` - V int64 `json:"v"` + Source int64 `json:"source"` + V int64 `json:"v"` } // Published is the publish of a package that started a pipeline: a newer publish of the same artifact on the same branch supersedes it (design 47 G section 31, A-202). @@ -627,10 +685,8 @@ type StepEvent struct { Commit string `json:"commit"` // the module's build-input fingerprint at the commit Fingerprint string `json:"fingerprint,omitempty"` - // the gathered group, when the pipeline is its - Group string `json:"group,omitempty"` - Module string `json:"module"` - // the pipeline's key, .., a branch escaped as a key's name is + Module string `json:"module"` + // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) Pipeline string `json:"pipeline"` Result StepResult `json:"result"` // the catalog graph revision of the branch the pipeline runs for @@ -656,6 +712,8 @@ type StepResult struct { Ended *time.Time `json:"ended,omitempty"` // the artifact's build-input fingerprint the step ran at Fingerprint string `json:"fingerprint,omitempty"` + // the mover the step is of (design 47 H-A-35) + Module string `json:"module,omitempty"` // the node whose holder ended it Node string `json:"node,omitempty"` // for a waiting step, who or what it waits on: a person, a build node, the revision view @@ -707,6 +765,7 @@ const ( // The values of StepResult's step. const ( + StepResultStepValidate = "validate" StepResultStepBuild = "build" StepResultStepLint = "lint" StepResultStepUnit = "unit" @@ -779,7 +838,7 @@ type ToolchainUsed struct { Version string `json:"version"` } -// Wait is a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283). +// Wait is a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283); said on . (design 47 H-A-72). type Wait struct { Artifact string `json:"artifact,omitempty"` // the step's own ask, where it has one (design 47 G §731) @@ -790,14 +849,13 @@ type Wait struct { Commit string `json:"commit,omitempty"` // the module's build-input fingerprint at the commit Fingerprint string `json:"fingerprint,omitempty"` - // the gathered group, when the pipeline is its - Group string `json:"group,omitempty"` // for its end, how it ended: answered, ran, superseded - How string `json:"how,omitempty"` - Module string `json:"module"` + How string `json:"how,omitempty"` + // for a step's wait, the mover whose step waits (design 47 H-A-72) + Module string `json:"module,omitempty"` // what the step waits on (design 47 *Health and going back*) On string `json:"on"` - // the pipeline's key, .., a branch escaped as a key's name is + // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) Pipeline string `json:"pipeline"` // the catalog graph revision of the branch the pipeline runs for Revision int64 `json:"revision,omitempty"` @@ -808,7 +866,7 @@ type Wait struct { Since time.Time `json:"since"` // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) Source int64 `json:"source,omitempty"` - // a pipeline step a wait inside a pipeline is in + // the pipeline step a wait is in, or pipeline for a pipeline waiting its turn (design 47 H §748) Step string `json:"step"` V int64 `json:"v"` // for a wait on a person, who: the operator, a reviewer @@ -817,13 +875,15 @@ type Wait struct { // The values of Wait's on. const ( - WaitOnPerson = "person" - WaitOnBuildNode = "build node" - WaitOnRevisionView = "revision view" + WaitOnPerson = "person" + WaitOnBuildNode = "build node" + WaitOnRevisionView = "revision view" + WaitOnPipelinesAtOnce = "pipelines-at-once" ) // The values of Wait's step. const ( + WaitStepValidate = "validate" WaitStepBuild = "build" WaitStepLint = "lint" WaitStepUnit = "unit" @@ -831,8 +891,15 @@ const ( WaitStepComposition = "composition" WaitStepReview = "review" WaitStepApproval = "approval" + WaitStepPipeline = "pipeline" ) +// Waiting is a pipeline waiting its turn under pipelines-at-once (design 47 H §748, H-A-72). +type Waiting struct { + // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) + Pipeline string `json:"pipeline"` +} + // Widening is a part serving a step the change alters, or an acting rule, a grant or a credential it widens, computed by the running runner (ADR 0666 section 23). type Widening struct { // the part, rule, grant or credential @@ -926,6 +993,7 @@ type WhyCarriedInput struct { // The values of WhyCarriedInput's step. const ( + WhyCarriedInputStepValidate = "validate" WhyCarriedInputStepBuild = "build" WhyCarriedInputStepLint = "lint" WhyCarriedInputStepUnit = "unit" @@ -988,6 +1056,7 @@ type RerunInput struct { // The values of RerunInput's step. const ( + RerunInputStepValidate = "validate" RerunInputStepBuild = "build" RerunInputStepLint = "lint" RerunInputStepUnit = "unit" @@ -1015,6 +1084,7 @@ type AcceptInput struct { // The values of AcceptInput's step. const ( + AcceptInputStepValidate = "validate" AcceptInputStepBuild = "build" AcceptInputStepLint = "lint" AcceptInputStepUnit = "unit" @@ -1042,6 +1112,19 @@ type CancelAnswer struct { Pipeline Pipeline `json:"pipeline"` } +// PlaceInput is what place takes. +type PlaceInput struct { + // the pipeline's key + Pipeline string `json:"pipeline"` + // why, written with the caller the runtime proves in the hand-act log + Why string `json:"why"` +} + +// PlaceAnswer is what place answers. +type PlaceAnswer struct { + Pipeline Pipeline `json:"pipeline"` +} + // AskAgainInput is what ask-again takes. type AskAgainInput struct { // the pipeline's key @@ -1099,9 +1182,6 @@ type PipelineStartedEvent = PipelineStarted // PipelineEndedEvent is the body of the event pipeline-ended. type PipelineEndedEvent = PipelineEnded -// GroupEndedEvent is the body of the event group-ended. -type GroupEndedEvent = GroupEnded - // RunStartedEvent is the body of the event run-started. type RunStartedEvent = RunStarted @@ -1126,8 +1206,17 @@ type FullEvent = Fill // RoomEvent is the body of the event room. type RoomEvent = Fill -// PipelinesByBranchRevisionModuleValue is one value of the state pipelines under the key ... -type PipelinesByBranchRevisionModuleValue = Pipeline +// PipelinesByBranchSourceValue is one value of the state pipelines under the key .. +type PipelinesByBranchSourceValue = Pipeline + +// PipelinesByBranchSourcePublishedPackageVersionValue is one value of the state pipelines under the key ..published... +type PipelinesByBranchSourcePublishedPackageVersionValue = Pipeline + +// QueueByQueueNextValue is one value of the state queue under the key queue.next. +type QueueByQueueNextValue = int64 + +// QueueByWaitingSequenceValue is one value of the state queue under the key waiting.. +type QueueByWaitingSequenceValue = Waiting // KeptByLevelDigestValue is one value of the state kept under the key .. type KeptByLevelDigestValue = KeptResult diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index b5ec6e57..d00cc41c 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -17,68 +17,84 @@ func TestFixtures(t *testing.T) { decode func([]byte) (any, error) subjectIs *regexp.Regexp }{ - {name: "a pipeline started with the steps its policy gives", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"status\":\"required\",\"step\":\"lint\"},{\"status\":\"bypass\",\"step\":\"review\"}],\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"status\":\"required\",\"step\":\"lint\"},{\"status\":\"bypass\",\"step\":\"review\"}],\"v\":1}", - decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a pipeline ended passed, an optional step failed, over budget and widening named", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tests\":{\"integration\":3,\"unit\":42},\"v\":1,\"widens\":[{\"name\":\"mesh-build-go:program\",\"said\":\"its test runner\",\"what\":\"serving part\"}]}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tests\":{\"integration\":3,\"unit\":42},\"v\":1,\"widens\":[{\"name\":\"mesh-build-go:program\",\"said\":\"its test runner\",\"what\":\"serving part\"}]}", - decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a pipeline ended failed, naming the step that held it, its approval not asked", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"v\":1,\"why\":\"unit of nats:program failed\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"v\":1,\"why\":\"unit of nats:program failed\"}", - decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a group's one pipeline ended on a watched branch", subject: "mesh.seat.mesh-pipeline-runner.event.group-ended.main.registry-1966", given: "{\"branch\":\"main\",\"ended\":\"2026-11-10T10:20:00Z\",\"group\":\"registry-1966\",\"outcome\":\"passed\",\"pipelines\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"group\":\"registry-1966\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}],\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"ended\":\"2026-11-10T10:20:00Z\",\"group\":\"registry-1966\",\"outcome\":\"passed\",\"pipelines\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"group\":\"registry-1966\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}],\"revision\":12,\"source\":3589,\"v\":1}", - decode: func(b []byte) (any, error) { var v GroupEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.group-ended\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a take-in's pipeline started with its two movers", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.3589", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", + decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a pipeline ended passed: per mover its version, steps and tier, an optional step failed", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\"},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\"},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}", + decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a pipeline ended failed, naming the step that held it, no version released", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"module\":\"nats\",\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"tier\":1}],\"outcome\":\"failed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1,\"why\":\"unit of nats:program failed\"}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"module\":\"nats\",\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"tier\":1}],\"outcome\":\"failed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1,\"why\":\"unit of nats:program failed\"}", + decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a pipeline over pipelines-at-once waits its turn", subject: "mesh.seat.mesh-pipeline-runner.event.wait-held.main.3590", given: "{\"branch\":\"main\",\"on\":\"pipelines-at-once\",\"pipeline\":\"main.3590\",\"revision\":13,\"since\":\"2026-11-10T10:01:00Z\",\"source\":3590,\"step\":\"pipeline\",\"v\":1}", wire: "{\"branch\":\"main\",\"on\":\"pipelines-at-once\",\"pipeline\":\"main.3590\",\"revision\":13,\"since\":\"2026-11-10T10:01:00Z\",\"source\":3590,\"step\":\"pipeline\",\"v\":1}", + decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-held\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a run on request started", subject: "mesh.seat.mesh-pipeline-runner.event.run-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"fix-1965@workstation\",\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}],\"run\":\"run-m2kx9a\",\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"fix-1965@workstation\",\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}],\"run\":\"run-m2kx9a\",\"v\":1}", decode: func(b []byte) (any, error) { var v RunStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.run-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a step started", subject: "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},\"revision\":12,\"source\":3589,\"v\":1}", + {name: "a step started", subject: "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v StepStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a rerun step ended passed, with its proved caller", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"by\":\"operator@workstation\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"rerun\":true,\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"by\":\"operator@workstation\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"rerun\":true,\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", + {name: "a rerun step ended passed, with its proved caller", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:program\",\"by\":\"operator@workstation\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"rerun\":true,\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:program\",\"by\":\"operator@workstation\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"rerun\":true,\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a bypassed step said", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},\"revision\":12,\"source\":3589,\"v\":1}", + {name: "a bypassed step said", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "an approval waits on the operator", subject: "mesh.seat.mesh-pipeline-runner.event.wait-held.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", - decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-held\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "the wait ended answered", subject: "mesh.seat.mesh-pipeline-runner.event.wait-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"how\":\"answered\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"how\":\"answered\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", - decode: func(b []byte) (any, error) { var v WaitEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "C1/AC2 a test step started reading a test run, naming its run and ask", subject: "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-17T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-17T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\"},\"revision\":12,\"source\":3589,\"v\":1}", + {name: "an approval waits on the operator", subject: "mesh.seat.mesh-pipeline-runner.event.wait-held.main.3589", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", + decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-held\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "the wait ended answered", subject: "mesh.seat.mesh-pipeline-runner.event.wait-ended.main.3589", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"how\":\"answered\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"how\":\"answered\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", + decode: func(b []byte) (any, error) { var v WaitEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-ended\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "C1/AC2 a test step started reading a test run, naming its run and ask", subject: "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-17T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-17T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\"},\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v StepStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "C1/AC2 a test step ended with the run another step asked", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"asked-by\":{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"asked-by\":{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", + {name: "C1/AC2 a test step ended with the run another step asked", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"asked-by\":{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"artifact\":\"nats:tools\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"shared\":[{\"ask\":\"t1a2\",\"asked-by\":{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},\"run\":\"main.12.unit.d1\"}],\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "C1 a composition step ended with mesh-wants' runs as they came", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"fingerprint\":\"fp-0123\",\"node\":\"laptop\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"shared\":[{\"ask\":\"r1a2b3\",\"machine\":\"anchor\",\"run\":\"main.12.anchor\"}],\"status\":\"required\",\"step\":\"composition\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"fingerprint\":\"fp-0123\",\"node\":\"laptop\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"shared\":[{\"ask\":\"r1a2b3\",\"machine\":\"anchor\",\"run\":\"main.12.anchor\"}],\"status\":\"required\",\"step\":\"composition\"},\"revision\":12,\"source\":3589,\"v\":1}", + {name: "C1 a composition step ended with mesh-wants' runs as they came", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"fingerprint\":\"fp-0123\",\"node\":\"laptop\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"shared\":[{\"ask\":\"r1a2b3\",\"machine\":\"anchor\",\"run\":\"main.12.anchor\"}],\"status\":\"required\",\"step\":\"composition\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-17T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"result\":{\"fingerprint\":\"fp-0123\",\"node\":\"laptop\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"shared\":[{\"ask\":\"r1a2b3\",\"machine\":\"anchor\",\"run\":\"main.12.anchor\"}],\"status\":\"required\",\"step\":\"composition\"},\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a pipeline kept", subject: "", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", + {name: "a take-in's pipeline kept, its steps naming their mover", subject: "", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", decode: func(b []byte) (any, error) { - var v PipelinesByBranchRevisionModuleValue + var v PipelinesByBranchSourceValue err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a pipeline a publication started, with the version it names (design 47 G 550)", subject: "", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1,\"version\":\"0.1.15\"}", + {name: "a pipeline a publish started, its mover the package's dependent, with the version released for it", subject: "", given: "{\"branch\":\"main\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589.published.mesh-sdk.0.1.21\",\"published\":{\"artifact\":\"mesh-sdk\",\"version\":\"0.1.21\"},\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589.published.mesh-sdk.0.1.21\",\"published\":{\"artifact\":\"mesh-sdk\",\"version\":\"0.1.21\"},\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", decode: func(b []byte) (any, error) { - var v PipelinesByBranchRevisionModuleValue + var v PipelinesByBranchSourcePublishedPackageVersionValue err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a kept result", subject: "", given: "{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}", wire: "{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}", + {name: "a kept result", subject: "", given: "{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.3589\"}", wire: "{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.3589\"}", decode: func(b []byte) (any, error) { var v KeptByLevelDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "the queue's counter", subject: "", given: "3", wire: "3", + decode: func(b []byte) (any, error) { var v QueueByQueueNextValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "a waiting pipeline in the queue", subject: "", given: "{\"pipeline\":\"main.3590\"}", wire: "{\"pipeline\":\"main.3590\"}", + decode: func(b []byte) (any, error) { + var v QueueByWaitingSequenceValue + err := json.Unmarshal(b, &v) + return v, err + }, subjectIs: nil}, + {name: "a pipeline waiting its turn, its seq given", subject: "", given: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"v\":1}", + decode: func(b []byte) (any, error) { + var v PipelinesByBranchSourceValue + err := json.Unmarshal(b, &v) + return v, err + }, subjectIs: nil}, {name: "run asks one member at a commit", subject: "", given: "{\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}]}", wire: "{\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}]}", decode: func(b []byte) (any, error) { var v RunInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "run answers its id and pipelines", subject: "", given: "{\"pipelines\":[\"feature~2f1966-x.0.nats\"],\"run\":\"run-m2kx9a\"}", wire: "{\"pipelines\":[\"feature~2f1966-x.0.nats\"],\"run\":\"run-m2kx9a\"}", decode: func(b []byte) (any, error) { var v RunAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "review of a commit", subject: "", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"said\":\"reads well\"}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"said\":\"reads well\"}", decode: func(b []byte) (any, error) { var v ReviewInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "review answers its step", subject: "", given: "{\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"passed\",\"status\":\"optional\",\"step\":\"review\"}}", wire: "{\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"passed\",\"status\":\"optional\",\"step\":\"review\"}}", + {name: "review answers its step", subject: "", given: "{\"pipeline\":\"main.3589\",\"result\":{\"outcome\":\"passed\",\"status\":\"optional\",\"step\":\"review\"}}", wire: "{\"pipeline\":\"main.3589\",\"result\":{\"outcome\":\"passed\",\"status\":\"optional\",\"step\":\"review\"}}", decode: func(b []byte) (any, error) { var v ReviewAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "show answers a pipeline with its log and fill", subject: "", given: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.12.nats\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", wire: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.12.nats\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", + {name: "show answers a pipeline with its log and fill", subject: "", given: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.3589\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", wire: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.3589\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", decode: func(b []byte) (any, error) { var v ShowAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "accept asks with why", subject: "", given: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", wire: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", + {name: "accept asks with why", subject: "", given: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", wire: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", decode: func(b []byte) (any, error) { var v AcceptInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "stands answers a wait on a build node", subject: "", given: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", wire: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", + {name: "stands answers a wait on a build node", subject: "", given: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", wire: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", decode: func(b []byte) (any, error) { var v StandsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "kept answers by digest", subject: "", given: "{\"fill\":{\"bytes\":300,\"cap\":134217728,\"store\":\"kept\"},\"kept\":[{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}]}", wire: "{\"fill\":{\"bytes\":300,\"cap\":134217728,\"store\":\"kept\"},\"kept\":[{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}]}", + {name: "kept answers by digest", subject: "", given: "{\"fill\":{\"bytes\":300,\"cap\":134217728,\"store\":\"kept\"},\"kept\":[{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.3589\"}]}", wire: "{\"fill\":{\"bytes\":300,\"cap\":134217728,\"store\":\"kept\"},\"kept\":[{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.3589\"}]}", decode: func(b []byte) (any, error) { var v KeptAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "C1/AC3 stands answers a waiting test step with its ask and the run it waits on", subject: "", given: "{\"stands\":[{\"artifact\":\"nats:tools\",\"ask\":\"t1a2\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"since\":\"2026-11-17T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", wire: "{\"stands\":[{\"artifact\":\"nats:tools\",\"ask\":\"t1a2\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"since\":\"2026-11-17T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", + {name: "C1/AC3 stands answers a waiting test step with its ask and the run it waits on", subject: "", given: "{\"stands\":[{\"artifact\":\"nats:tools\",\"ask\":\"t1a2\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"since\":\"2026-11-17T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", wire: "{\"stands\":[{\"artifact\":\"nats:tools\",\"ask\":\"t1a2\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"shared\":[{\"ask\":\"t1a2\",\"run\":\"main.12.unit.d1\"}],\"since\":\"2026-11-17T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", decode: func(b []byte) (any, error) { var v StandsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "C1 test-runs answers each run with its packages, readers and the fill", subject: "", given: "{\"fill\":{\"bytes\":2048,\"cap\":16777216,\"store\":\"test-runs\"},\"runs\":[{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}},{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"gone\":\"the run's output is gone\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}]}", wire: "{\"fill\":{\"bytes\":2048,\"cap\":16777216,\"store\":\"test-runs\"},\"runs\":[{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}},{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"gone\":\"the run's output is gone\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}]}", + {name: "C1 test-runs answers each run with its packages, readers and the fill", subject: "", given: "{\"fill\":{\"bytes\":2048,\"cap\":16777216,\"store\":\"test-runs\"},\"runs\":[{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}},{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"gone\":\"the run's output is gone\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}]}", wire: "{\"fill\":{\"bytes\":2048,\"cap\":16777216,\"store\":\"test-runs\"},\"runs\":[{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}},{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"gone\":\"the run's output is gone\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}]}", decode: func(b []byte) (any, error) { var v TestRunsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "C1 test-runs-drop answers the run it deleted and the readers it ended", subject: "", given: "{\"ended\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"run\":{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}}", wire: "{\"ended\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"run\":{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.12.nats\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}}", + {name: "C1 test-runs-drop answers the run it deleted and the readers it ended", subject: "", given: "{\"ended\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"run\":{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}}", wire: "{\"ended\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"run\":{\"ask\":\"t1a2\",\"digest\":\"d1\",\"ended\":\"2026-11-17T10:05:00Z\",\"key\":\"main.12.unit.d1\",\"level\":\"unit\",\"node\":\"anchor\",\"outcome\":\"failed\",\"output\":\"t1a2\",\"packages\":[{\"digest\":\"sha256:aa\",\"package\":\"git.novox.be/novox/nats/internal/x\"}],\"readers\":[{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\"},{\"artifact\":\"nats:tools\",\"pipeline\":\"main.3589\"}],\"said\":\"1 test failed\",\"seat\":\"node-build-go\",\"started\":\"2026-11-17T10:00:00Z\",\"tests\":{\"unit\":42}}}", decode: func(b []byte) (any, error) { var v TestRunsDropAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "place asks a waiting pipeline ahead of its turn, with why", subject: "", given: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}", wire: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}", + decode: func(b []byte) (any, error) { var v PlaceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json index 205105e4..668a0e77 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json @@ -1,170 +1,68 @@ [ { - "name": "a pipeline started with the steps its policy gives", + "name": "a take-in's pipeline started with its two movers", "of": "event:pipeline-started", - "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-started.nats.main.0123456789abcdef0123456789abcdef01234567", + "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.3589", "given": { - "pipeline": "main.12.nats", - "module": "nats", + "pipeline": "main.3589", "branch": "main", "revision": 12, "source": 3589, - "commit": "0123456789abcdef0123456789abcdef01234567", + "call": "0123456789abcdef", "v": 1, - "steps": [ + "movers": [ { - "step": "lint", - "artifact": "nats:program", - "status": "required" + "module": "mesh-sdk", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-sdk", + "repository": "mesh-sdk", + "tier": 1 }, { - "step": "review", - "status": "bypass" + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0123", + "repository": "mesh-networking", + "tier": 2 } ], - "at": "2026-11-10T10:00:00Z", - "fingerprint": "fp-0123" + "at": "2026-11-10T10:00:00Z" } }, { - "name": "a pipeline ended passed, an optional step failed, over budget and widening named", + "name": "a pipeline ended passed: per mover its version, steps and tier, an optional step failed", "of": "event:pipeline-ended", - "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.0123456789abcdef0123456789abcdef01234567", + "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", "given": { - "pipeline": "main.12.nats", - "module": "nats", + "pipeline": "main.3589", "branch": "main", "revision": 12, "source": 3589, "end-count": 1, - "commit": "0123456789abcdef0123456789abcdef01234567", "v": 1, "outcome": "passed", - "steps": [ - { - "step": "lint", - "artifact": "nats:program", - "status": "required", - "outcome": "passed", - "fingerprint": "fp-0123", - "seat": "node-build-go", - "node": "anchor", - "ask": "m2kx9a1b3c4d5e" - }, - { - "step": "unit", - "artifact": "nats:program", - "status": "required", - "outcome": "carried", - "fingerprint": "fp-0123", - "carried-from": "main.11.nats", - "tests": { - "unit": 42 - } - }, - { - "step": "integration", - "artifact": "nats:program", - "status": "optional", - "outcome": "failed", - "why": "TestTheBusWhole failed", - "fingerprint": "fp-0123", - "seat": "node-build-go", - "node": "home-server", - "tests": { - "integration": 3 - } - }, - { - "step": "composition", - "status": "required", - "outcome": "passed", - "seat": "mesh-wants" - }, - { - "step": "review", - "status": "bypass", - "outcome": "bypassed" - }, - { - "step": "approval", - "status": "required", - "outcome": "passed" - } - ], - "tests": { - "unit": 42, - "integration": 3 - }, - "over-budget": true, - "widens": [ - { - "what": "serving part", - "name": "mesh-build-go:program", - "said": "its test runner" - } - ], "started": "2026-11-10T10:00:00Z", "ended": "2026-11-10T10:20:00Z", - "fingerprint": "fp-0123" - } - }, - { - "name": "a pipeline ended failed, naming the step that held it, its approval not asked", - "of": "event:pipeline-ended", - "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.0123456789abcdef0123456789abcdef01234567", - "given": { - "pipeline": "main.12.nats", - "module": "nats", - "branch": "main", - "revision": 12, - "source": 3589, - "end-count": 1, - "commit": "0123456789abcdef0123456789abcdef01234567", - "v": 1, - "outcome": "failed", - "why": "unit of nats:program failed", - "steps": [ + "call": "0123456789abcdef", + "movers": [ { - "step": "unit", - "artifact": "nats:program", - "status": "required", - "outcome": "failed", - "fingerprint": "fp-0123" + "module": "mesh-sdk", + "fingerprint": "fp-sdk", + "version": "0.1.21", + "tier": 1, + "steps": [ + { + "module": "mesh-sdk", + "step": "validate", + "status": "required", + "outcome": "passed", + "seat": "mesh-wants" + } + ] }, { - "step": "approval", - "status": "required", - "outcome": "not asked", - "why": "unit of nats:program failed" - } - ], - "over-budget": true, - "fingerprint": "fp-0123" - } - }, - { - "name": "a group's one pipeline ended on a watched branch", - "of": "event:group-ended", - "subject": "mesh.seat.mesh-pipeline-runner.event.group-ended.main.registry-1966", - "given": { - "v": 1, - "group": "registry-1966", - "branch": "main", - "revision": 12, - "source": 3589, - "outcome": "passed", - "pipelines": [ - { - "pipeline": "main.12.nats", "module": "nats", - "branch": "main", - "revision": 12, - "source": 3589, - "commit": "0123456789abcdef0123456789abcdef01234567", - "v": 1, - "group": "registry-1966", - "outcome": "passed", + "fingerprint": "fp-0123", "steps": [ { "step": "lint", @@ -174,13 +72,114 @@ "fingerprint": "fp-0123", "seat": "node-build-go", "node": "anchor", - "ask": "m2kx9a1b3c4d5e" + "ask": "m2kx9a1b3c4d5e", + "module": "nats" + }, + { + "step": "unit", + "artifact": "nats:program", + "status": "required", + "outcome": "carried", + "fingerprint": "fp-0123", + "carried-from": "main.3588", + "tests": { + "unit": 42 + }, + "module": "nats" + }, + { + "step": "integration", + "artifact": "nats:program", + "status": "optional", + "outcome": "failed", + "why": "TestTheBusWhole failed", + "fingerprint": "fp-0123", + "seat": "node-build-go", + "node": "home-server", + "tests": { + "integration": 3 + }, + "module": "nats" + }, + { + "step": "composition", + "status": "required", + "outcome": "passed", + "seat": "mesh-wants", + "module": "nats" + }, + { + "step": "review", + "status": "bypass", + "outcome": "bypassed", + "module": "nats" + }, + { + "step": "approval", + "status": "required", + "outcome": "passed", + "module": "nats" } ], - "fingerprint": "fp-0123" + "tier": 2, + "version": "0.1.15" } - ], - "ended": "2026-11-10T10:20:00Z" + ] + } + }, + { + "name": "a pipeline ended failed, naming the step that held it, no version released", + "of": "event:pipeline-ended", + "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", + "given": { + "pipeline": "main.3589", + "branch": "main", + "revision": 12, + "source": 3589, + "end-count": 1, + "v": 1, + "outcome": "failed", + "why": "unit of nats:program failed", + "call": "0123456789abcdef", + "movers": [ + { + "module": "nats", + "fingerprint": "fp-0123", + "steps": [ + { + "step": "unit", + "artifact": "nats:program", + "status": "required", + "outcome": "failed", + "fingerprint": "fp-0123", + "module": "nats" + }, + { + "step": "approval", + "status": "required", + "outcome": "not asked", + "why": "unit of nats:program failed", + "module": "nats" + } + ], + "tier": 1 + } + ] + } + }, + { + "name": "a pipeline over pipelines-at-once waits its turn", + "of": "event:wait-held", + "subject": "mesh.seat.mesh-pipeline-runner.event.wait-held.main.3590", + "given": { + "pipeline": "main.3590", + "branch": "main", + "revision": 13, + "source": 3590, + "v": 1, + "step": "pipeline", + "on": "pipelines-at-once", + "since": "2026-11-10T10:01:00Z" } }, { @@ -206,7 +205,7 @@ "of": "event:step-started", "subject": "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -230,7 +229,7 @@ "of": "event:step-ended", "subject": "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -260,7 +259,7 @@ "of": "event:step-ended", "subject": "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -278,9 +277,9 @@ { "name": "an approval waits on the operator", "of": "event:wait-held", - "subject": "mesh.seat.mesh-pipeline-runner.event.wait-held.nats.main.0123456789abcdef0123456789abcdef01234567", + "subject": "mesh.seat.mesh-pipeline-runner.event.wait-held.main.3589", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -297,9 +296,9 @@ { "name": "the wait ended answered", "of": "event:wait-ended", - "subject": "mesh.seat.mesh-pipeline-runner.event.wait-ended.nats.main.0123456789abcdef0123456789abcdef01234567", + "subject": "mesh.seat.mesh-pipeline-runner.event.wait-ended.main.3589", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -319,7 +318,7 @@ "of": "event:step-started", "subject": "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -349,7 +348,7 @@ "of": "event:step-ended", "subject": "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -373,7 +372,7 @@ "run": "main.12.unit.d1", "ask": "t1a2", "asked-by": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:program" } } @@ -387,7 +386,7 @@ "of": "event:step-ended", "subject": "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json index e181baeb..4fc96cdc 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json @@ -1,15 +1,13 @@ [ { - "name": "a pipeline kept", - "of": "state:pipelines/..", + "name": "a take-in's pipeline kept, its steps naming their mover", + "of": "state:pipelines/.", "given": { - "pipeline": "main.12.nats", - "module": "nats", + "pipeline": "main.3589", "branch": "main", "revision": 12, "source": 3589, "end-count": 1, - "commit": "0123456789abcdef0123456789abcdef01234567", "v": 1, "outcome": "passed", "steps": [ @@ -21,7 +19,8 @@ "fingerprint": "fp-0123", "seat": "node-build-go", "node": "anchor", - "ask": "m2kx9a1b3c4d5e" + "ask": "m2kx9a1b3c4d5e", + "module": "nats" }, { "step": "unit", @@ -29,10 +28,11 @@ "status": "required", "outcome": "carried", "fingerprint": "fp-0123", - "carried-from": "main.11.nats", + "carried-from": "main.3588", "tests": { "unit": 42 - } + }, + "module": "nats" }, { "step": "integration", @@ -45,41 +45,52 @@ "node": "home-server", "tests": { "integration": 3 - } + }, + "module": "nats" }, { "step": "composition", "status": "required", "outcome": "passed", - "seat": "mesh-wants" + "seat": "mesh-wants", + "module": "nats" }, { "step": "review", "status": "bypass", - "outcome": "bypassed" + "outcome": "bypassed", + "module": "nats" }, { "step": "approval", "status": "required", - "outcome": "passed" + "outcome": "passed", + "module": "nats" } ], "started": "2026-11-10T10:00:00Z", "ended": "2026-11-10T10:20:00Z", - "fingerprint": "fp-0123" + "call": "0123456789abcdef", + "movers": [ + { + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0123", + "repository": "mesh-networking", + "tier": 1 + } + ] } }, { - "name": "a pipeline a publication started, with the version it names (design 47 G 550)", - "of": "state:pipelines/..", + "name": "a pipeline a publish started, its mover the package's dependent, with the version released for it", + "of": "state:pipelines/..published..", "given": { - "pipeline": "main.12.nats", - "module": "nats", + "pipeline": "main.3589.published.mesh-sdk.0.1.21", "branch": "main", "revision": 12, "source": 3589, "end-count": 1, - "commit": "0123456789abcdef0123456789abcdef01234567", "v": 1, "outcome": "passed", "steps": [ @@ -91,7 +102,8 @@ "fingerprint": "fp-0123", "seat": "node-build-go", "node": "anchor", - "ask": "m2kx9a1b3c4d5e" + "ask": "m2kx9a1b3c4d5e", + "module": "nats" }, { "step": "unit", @@ -99,10 +111,11 @@ "status": "required", "outcome": "carried", "fingerprint": "fp-0123", - "carried-from": "main.11.nats", + "carried-from": "main.3588", "tests": { "unit": 42 - } + }, + "module": "nats" }, { "step": "integration", @@ -115,29 +128,45 @@ "node": "home-server", "tests": { "integration": 3 - } + }, + "module": "nats" }, { "step": "composition", "status": "required", "outcome": "passed", - "seat": "mesh-wants" + "seat": "mesh-wants", + "module": "nats" }, { "step": "review", "status": "bypass", - "outcome": "bypassed" + "outcome": "bypassed", + "module": "nats" }, { "step": "approval", "status": "required", - "outcome": "passed" + "outcome": "passed", + "module": "nats" } ], "started": "2026-11-10T10:00:00Z", "ended": "2026-11-10T10:20:00Z", - "fingerprint": "fp-0123", - "version": "0.1.15" + "movers": [ + { + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0123", + "repository": "mesh-networking", + "tier": 1, + "version": "0.1.15" + } + ], + "published": { + "artifact": "mesh-sdk", + "version": "0.1.21" + } } }, { @@ -147,7 +176,43 @@ "package": "git.novox.be/novox/nats", "digest": "sha256:aa", "level": "unit", - "pipeline": "main.12.nats" + "pipeline": "main.3589" + } + }, + { + "name": "the queue's counter", + "of": "state:queue/queue.next", + "given": 3 + }, + { + "name": "a waiting pipeline in the queue", + "of": "state:queue/waiting.", + "given": { + "pipeline": "main.3590" + } + }, + { + "name": "a pipeline waiting its turn, its seq given", + "of": "state:pipelines/.", + "given": { + "pipeline": "main.3590", + "branch": "main", + "revision": 13, + "source": 3590, + "call": "fedcba9876543210", + "v": 1, + "seq": 2, + "outcome": "waiting", + "steps": [], + "movers": [ + { + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0124", + "repository": "mesh-networking", + "tier": 1 + } + ] } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json index 656d12bf..645ac715 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json @@ -37,7 +37,7 @@ "name": "review answers its step", "of": "verb:review.answer", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "result": { "step": "review", "status": "optional", @@ -50,12 +50,10 @@ "of": "verb:show.answer", "given": { "pipeline": { - "pipeline": "main.12.nats", - "module": "nats", + "pipeline": "main.3589", "branch": "main", "revision": 12, "source": 3589, - "commit": "0123456789abcdef0123456789abcdef01234567", "v": 1, "outcome": "running", "steps": [ @@ -67,14 +65,23 @@ "fingerprint": "fp-0123", "seat": "node-build-go", "node": "anchor", - "ask": "m2kx9a1b3c4d5e" + "ask": "m2kx9a1b3c4d5e", + "module": "nats" } ], - "fingerprint": "fp-0123" + "movers": [ + { + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0123", + "repository": "mesh-networking", + "tier": 1 + } + ] }, "log": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "step": "lint", "artifact": "nats:program", "what": "started", @@ -97,7 +104,7 @@ "name": "accept asks with why", "of": "verb:accept.input", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "step": "integration", "artifact": "nats:program", "why": "flaky upstream, issue 1966" @@ -109,7 +116,7 @@ "given": { "stands": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -134,7 +141,7 @@ "package": "git.novox.be/novox/nats", "digest": "sha256:aa", "level": "unit", - "pipeline": "main.12.nats" + "pipeline": "main.3589" } ], "fill": { @@ -150,7 +157,7 @@ "given": { "stands": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "module": "nats", "branch": "main", "revision": 12, @@ -188,11 +195,11 @@ "started": "2026-11-17T10:00:00Z", "readers": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:program" }, { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:tools" } ], @@ -220,11 +227,11 @@ "started": "2026-11-17T10:00:00Z", "readers": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:program" }, { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:tools" } ], @@ -259,11 +266,11 @@ "started": "2026-11-17T10:00:00Z", "readers": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:program" }, { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:tools" } ], @@ -283,14 +290,22 @@ }, "ended": [ { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:program" }, { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "artifact": "nats:tools" } ] } + }, + { + "name": "place asks a waiting pipeline ahead of its turn, with why", + "of": "verb:place.input", + "given": { + "pipeline": "main.3590", + "why": "the operator wants the fix out first" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 67dcaba9..cac7dd36 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -209,6 +209,7 @@ "step": { "type": "string", "enum": [ + "validate", "build", "lint", "unit", @@ -342,6 +343,7 @@ "step": { "type": "string", "enum": [ + "validate", "build", "lint", "unit", @@ -394,6 +396,7 @@ "step": { "type": "string", "enum": [ + "validate", "build", "lint", "unit", @@ -463,6 +466,39 @@ }, "class": "act" }, + { + "name": "place", + "description": "A waiting pipeline placed ahead of its turn, its steps asked now; written in the hand-act log (design 47 H §748, H-A-53).", + "input": { + "type": "object", + "properties": { + "pipeline": { + "type": "string", + "description": "the pipeline's key" + }, + "why": { + "type": "string", + "description": "why, written with the caller the runtime proves in the hand-act log" + } + }, + "required": [ + "pipeline", + "why" + ] + }, + "answer": { + "type": "object", + "properties": { + "pipeline": { + "$ref": "#/defs/Pipeline" + } + }, + "required": [ + "pipeline" + ] + }, + "class": "act" + }, { "name": "ask-again", "description": "A declined approval step asked again (ADR 0666 section 10). Written in the hand-act log.", @@ -587,7 +623,7 @@ "events": [ { "name": "pipeline-started", - "subject": "pipeline-started...", + "subject": "pipeline-started..", "body": { "$ref": "#/defs/PipelineStarted" }, @@ -598,7 +634,7 @@ }, { "name": "pipeline-ended", - "subject": "pipeline-ended...", + "subject": "pipeline-ended..", "body": { "$ref": "#/defs/PipelineEnded" }, @@ -607,20 +643,9 @@ "max-mib": 192 } }, - { - "name": "group-ended", - "subject": "group-ended..", - "body": { - "$ref": "#/defs/GroupEnded" - }, - "keep": { - "max-age-days": 90, - "max-mib": 64 - } - }, { "name": "run-started", - "subject": "run-started...", + "subject": "run-started...", "body": { "$ref": "#/defs/RunStarted" }, @@ -631,7 +656,7 @@ }, { "name": "step-started", - "subject": "step-started...", + "subject": "step-started...", "body": { "$ref": "#/defs/StepEvent" }, @@ -642,7 +667,7 @@ }, { "name": "step-ended", - "subject": "step-ended...", + "subject": "step-ended...", "body": { "$ref": "#/defs/StepEvent" }, @@ -653,7 +678,7 @@ }, { "name": "wait-held", - "subject": "wait-held...", + "subject": "wait-held..", "body": { "$ref": "#/defs/Wait" }, @@ -664,7 +689,7 @@ }, { "name": "wait-ended", - "subject": "wait-ended...", + "subject": "wait-ended..", "body": { "$ref": "#/defs/Wait" }, @@ -701,14 +726,44 @@ "name": "pipelines", "template": "state", "history": 1, - "description": "one key per pipeline, written by compare-and-set; kept in the runner's old state section (ADR 0666 section 4)", + "description": "one key per pipeline, one per take-in, written by compare-and-set on its absence (design 47 H §746, §747)", "key-forms": [ { - "key": "..", + "key": ".", "value": { "$ref": "#/defs/Pipeline" }, - "description": "a pipeline" + "description": "a take-in's pipeline" + }, + { + "key": "..published..", + "value": { + "$ref": "#/defs/Pipeline" + }, + "description": "a pipeline a package's publish started, its movers the package's kind-1 dependents the publishing pipeline does not move" + } + ] + }, + { + "name": "queue", + "template": "state", + "history": 1, + "description": "the pipelines waiting their turn under pipelines-at-once, the lowest sequence read first by key order (design 47 H §748, H-A-36, H-A-72)", + "key-forms": [ + { + "key": "queue.next", + "value": { + "type": "integer", + "description": "the runner's counter: the sequence the next waiting pipeline gets, written by compare-and-set" + }, + "description": "the queue's counter" + }, + { + "key": "waiting.", + "value": { + "$ref": "#/defs/Waiting" + }, + "description": "a waiting pipeline, its sequence 20 digits" } ] }, @@ -875,9 +930,14 @@ "StepResult": { "type": "object", "properties": { + "module": { + "type": "string", + "description": "the mover the step is of (design 47 H-A-35)" + }, "step": { "type": "string", "enum": [ + "validate", "build", "lint", "unit", @@ -1041,10 +1101,7 @@ "properties": { "pipeline": { "type": "string", - "description": "the pipeline's key, .., a branch escaped as a key's name is" - }, - "module": { - "type": "string" + "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" }, "branch": { "type": "string", @@ -1058,36 +1115,37 @@ "type": "integer", "description": "the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)" }, + "call": { + "type": "string", + "description": "the merge call whose source revision the take-in took in (design 47 H §746)" + }, + "movers": { + "type": "array", + "items": { + "$ref": "#/defs/Mover" + }, + "description": "the modules the pipeline moves, its take-in's entries (design 47 H §746)" + }, + "seq": { + "type": "integer", + "description": "for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748)" + }, "end-count": { "type": "integer", "description": "how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)" }, - "commit": { - "type": "string", - "description": "the commit the module's entry was last changed at" - }, - "group": { - "type": "string", - "description": "the gathered group, when the pipeline is its" - }, "run": { "type": "string", "description": "the run on request's id, for a pipeline of a run; such a pipeline delivers nothing" }, - "fingerprint": { - "type": "string", - "description": "the module's build-input fingerprint at the commit" - }, "v": { "type": "integer", "description": "the layout version" }, - "repository": { - "type": "string" - }, "outcome": { "type": "string", "enum": [ + "waiting", "running", "passed", "failed", @@ -1105,20 +1163,7 @@ "items": { "$ref": "#/defs/StepResult" }, - "description": "every step, approval last" - }, - "tests": { - "$ref": "#/defs/TestCounts" - }, - "over-budget": { - "type": "boolean", - "description": "yes when the module is over its test budget (design 47 G section 419)" - }, - "widens": { - "type": "array", - "items": { - "$ref": "#/defs/Widening" - } + "description": "every mover's steps, each naming its mover, approval last" }, "started": { "type": "string", @@ -1128,10 +1173,6 @@ "type": "string", "format": "date-time" }, - "version": { - "type": "string", - "description": "the version package-published names, for a pipeline the runner started from a publication or from outdated; none for any other (design 47 G 550)" - }, "unlogged": { "type": "array", "items": { @@ -1144,11 +1185,12 @@ "description": "for a pipeline a package's publish started, that publish (A-202)" } }, - "description": "one pipeline as the runner keeps it in its state pipelines, by compare-and-set (design 47 *The runner's kept data*)", + "description": "one pipeline of one take-in, its movers the take-in's entries, as the runner keeps it in its state pipelines by compare-and-set (design 47 H §746)", "required": [ - "module", + "pipeline", "branch", - "commit", + "source", + "movers", "outcome", "steps" ] @@ -1158,49 +1200,39 @@ "properties": { "pipeline": { "type": "string", - "description": "the pipeline's key, .., a branch escaped as a key's name is" - }, - "module": { - "type": "string" + "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" }, "branch": { "type": "string", "description": "the watched branch, or the branch of a run on request" }, - "revision": { - "type": "integer", - "description": "the catalog graph revision of the branch the pipeline runs for" - }, "source": { "type": "integer", "description": "the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)" }, + "call": { + "type": "string", + "description": "the merge call whose source revision the take-in took in (design 47 H §746)" + }, + "revision": { + "type": "integer", + "description": "the catalog graph revision of the branch the pipeline runs for" + }, "end-count": { "type": "integer", "description": "how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)" }, - "commit": { - "type": "string", - "description": "the commit the module's entry was last changed at" - }, - "group": { - "type": "string", - "description": "the gathered group, when the pipeline is its" - }, "run": { "type": "string", "description": "the run on request's id, for a pipeline of a run; such a pipeline delivers nothing" }, - "fingerprint": { - "type": "string", - "description": "the module's build-input fingerprint at the commit" - }, "v": { "type": "integer" }, "outcome": { "type": "string", "enum": [ + "waiting", "running", "passed", "failed", @@ -1212,24 +1244,12 @@ "why": { "type": "string" }, - "steps": { + "movers": { "type": "array", "items": { - "$ref": "#/defs/StepResult" - } - }, - "tests": { - "$ref": "#/defs/TestCounts" - }, - "over-budget": { - "type": "boolean", - "description": "yes when the module is over its test budget (500 unit or 50 integration tests; design 47 G section 419)" - }, - "widens": { - "type": "array", - "items": { - "$ref": "#/defs/Widening" - } + "$ref": "#/defs/MoverEnded" + }, + "description": "per mover its fingerprint, released version, step results and tier, in the delivery order (design 47 H §746, H-A-2)" }, "started": { "type": "string", @@ -1240,15 +1260,14 @@ "format": "date-time" } }, - "description": "a pipeline's end with every step's result, its test counts, the source revision and widens (design 47 *Health and going back*); the assigner writes a want only from one whose every required step passed", + "description": "a pipeline's end, said once, with per mover its released version, step results and tier (design 47 H §746); the assigner writes wants only from a passed one", "required": [ "v", "pipeline", - "module", "branch", - "commit", + "source", "outcome", - "steps" + "movers" ] }, "PipelineStarted": { @@ -1256,78 +1275,38 @@ "properties": { "pipeline": { "type": "string", - "description": "the pipeline's key, .., a branch escaped as a key's name is" - }, - "module": { - "type": "string" + "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" }, "branch": { "type": "string", "description": "the watched branch, or the branch of a run on request" }, - "revision": { - "type": "integer", - "description": "the catalog graph revision of the branch the pipeline runs for" - }, "source": { "type": "integer", "description": "the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)" }, - "commit": { + "call": { "type": "string", - "description": "the commit the module's entry was last changed at" + "description": "the merge call whose source revision the take-in took in (design 47 H §746)" }, - "group": { - "type": "string", - "description": "the gathered group, when the pipeline is its" + "revision": { + "type": "integer", + "description": "the catalog graph revision of the branch the pipeline runs for" + }, + "movers": { + "type": "array", + "items": { + "$ref": "#/defs/Mover" + }, + "description": "the pipeline's movers" }, "run": { "type": "string", "description": "the run on request's id, for a pipeline of a run; such a pipeline delivers nothing" }, - "fingerprint": { - "type": "string", - "description": "the module's build-input fingerprint at the commit" - }, "v": { "type": "integer" }, - "steps": { - "type": "array", - "items": { - "type": "object", - "properties": { - "step": { - "type": "string", - "enum": [ - "build", - "lint", - "unit", - "integration", - "composition", - "review", - "approval" - ] - }, - "artifact": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "required", - "optional", - "bypass" - ] - } - }, - "required": [ - "step", - "status" - ] - }, - "description": "the steps the policy gives it" - }, "at": { "type": "string", "format": "date-time" @@ -1337,67 +1316,13 @@ "description": "for a pipeline a package's publish started, that publish (A-202)" } }, - "description": "a pipeline's start", + "description": "a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52)", "required": [ "v", "pipeline", - "module", "branch", - "commit" - ] - }, - "GroupEnded": { - "type": "object", - "properties": { - "v": { - "type": "integer" - }, - "group": { - "type": "string" - }, - "branch": { - "type": "string" - }, - "revision": { - "type": "integer" - }, - "source": { - "type": "integer", - "description": "the group's one source revision of the watched branch" - }, - "outcome": { - "type": "string", - "enum": [ - "running", - "passed", - "failed", - "refused", - "superseded", - "cancelled" - ] - }, - "why": { - "type": "string" - }, - "pipelines": { - "type": "array", - "items": { - "$ref": "#/defs/PipelineEnded" - }, - "description": "every member module's pipeline, each ended" - }, - "ended": { - "type": "string", - "format": "date-time" - } - }, - "description": "a group's one pipeline's end on a watched branch, said once every member's modules have ended; a group's wants are written on it alone (ADR 0666 section 9)", - "required": [ - "v", - "group", - "branch", - "outcome", - "pipelines" + "source", + "movers" ] }, "Member": { @@ -1457,7 +1382,7 @@ "properties": { "pipeline": { "type": "string", - "description": "the pipeline's key, .., a branch escaped as a key's name is" + "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" }, "module": { "type": "string" @@ -1478,10 +1403,6 @@ "type": "string", "description": "the commit the module's entry was last changed at" }, - "group": { - "type": "string", - "description": "the gathered group, when the pipeline is its" - }, "run": { "type": "string", "description": "the run on request's id, for a pipeline of a run; such a pipeline delivers nothing" @@ -1516,10 +1437,11 @@ "properties": { "pipeline": { "type": "string", - "description": "the pipeline's key, .., a branch escaped as a key's name is" + "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" }, "module": { - "type": "string" + "type": "string", + "description": "for a step's wait, the mover whose step waits (design 47 H-A-72)" }, "branch": { "type": "string", @@ -1537,10 +1459,6 @@ "type": "string", "description": "the commit the module's entry was last changed at" }, - "group": { - "type": "string", - "description": "the gathered group, when the pipeline is its" - }, "run": { "type": "string", "description": "the run on request's id, for a pipeline of a run; such a pipeline delivers nothing" @@ -1555,15 +1473,17 @@ "step": { "type": "string", "enum": [ + "validate", "build", "lint", "unit", "integration", "composition", "review", - "approval" + "approval", + "pipeline" ], - "description": "a pipeline step a wait inside a pipeline is in" + "description": "the pipeline step a wait is in, or pipeline for a pipeline waiting its turn (design 47 H §748)" }, "artifact": { "type": "string" @@ -1573,7 +1493,8 @@ "enum": [ "person", "build node", - "revision view" + "revision view", + "pipelines-at-once" ], "description": "what the step waits on (design 47 *Health and going back*)" }, @@ -1601,11 +1522,10 @@ "description": "the run the step waits on, where the runner knows it: a test step's run key and ask (design 47 G §731, A-469v)" } }, - "description": "a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283)", + "description": "a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283); said on . (design 47 H-A-72)", "required": [ "v", "pipeline", - "module", "branch", "step", "on", @@ -1835,6 +1755,101 @@ "level", "digest" ] + }, + "Mover": { + "type": "object", + "properties": { + "module": { + "type": "string" + }, + "commit": { + "type": "string", + "description": "the commit the module's entry was last changed at" + }, + "fingerprint": { + "type": "string", + "description": "the module's build-input fingerprint at the commit" + }, + "repository": { + "type": "string" + }, + "tier": { + "type": "integer", + "description": "the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H §746)" + }, + "version": { + "type": "string", + "description": "the version released for the mover in this pipeline (version-released), absent until one is (design 47 H-A-52)" + }, + "widens": { + "type": "array", + "items": { + "$ref": "#/defs/Widening" + } + }, + "tests": { + "$ref": "#/defs/TestCounts" + }, + "over-budget": { + "type": "boolean", + "description": "yes when the module is over its test budget (design 47 G section 419)" + } + }, + "description": "one module a pipeline moves: an entry of its take-in.taken, with what the pipeline found of it (design 47 H §746, H-A-35, H-A-72)", + "required": [ + "module", + "commit", + "fingerprint", + "repository", + "tier" + ] + }, + "MoverEnded": { + "type": "object", + "properties": { + "module": { + "type": "string" + }, + "fingerprint": { + "type": "string", + "description": "the module's build-input fingerprint the pipeline ran at" + }, + "version": { + "type": "string", + "description": "the version released for the mover, absent when none was released" + }, + "steps": { + "type": "array", + "items": { + "$ref": "#/defs/StepResult" + }, + "description": "the mover's step results, each naming its module (design 47 H-A-72)" + }, + "tier": { + "type": "integer", + "description": "the mover's tier in the delivery order, from 1 (ADR 0666 section 14)" + } + }, + "description": "one mover at its pipeline's end (design 47 H §746)", + "required": [ + "module", + "fingerprint", + "steps", + "tier" + ] + }, + "Waiting": { + "type": "object", + "properties": { + "pipeline": { + "type": "string", + "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" + } + }, + "description": "a pipeline waiting its turn under pipelines-at-once (design 47 H §748, H-A-72)", + "required": [ + "pipeline" + ] } } } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index e0b467c5..316dcf10 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -16,6 +16,7 @@ export declare const verbs: { readonly rerun: "rerun"; readonly accept: "accept"; readonly cancel: "cancel"; + readonly place: "place"; readonly askAgain: "ask-again"; readonly testRuns: "test-runs"; readonly testRunsDrop: "test-runs-drop"; @@ -24,7 +25,6 @@ export declare const verbs: { export declare const events: { readonly pipelineStarted: "pipeline-started"; readonly pipelineEnded: "pipeline-ended"; - readonly groupEnded: "group-ended"; readonly runStarted: "run-started"; readonly stepStarted: "step-started"; readonly stepEnded: "step-ended"; @@ -39,51 +39,45 @@ export declare const family: { readonly name: "mesh-pipeline-runner.events"; rea export declare const pipelineStartedStream: "SEAT_mesh-pipeline-runner_pipeline-started"; -export declare function pipelineStartedSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function pipelineStartedSubject(branch: string, source: string): string; -export declare const pipelineStartedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*.*"; +export declare const pipelineStartedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*"; export declare const pipelineEndedStream: "SEAT_mesh-pipeline-runner_pipeline-ended"; -export declare function pipelineEndedSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function pipelineEndedSubject(branch: string, source: string): string; -export declare const pipelineEndedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*.*"; - -export declare const groupEndedStream: "SEAT_mesh-pipeline-runner_group-ended"; - -export declare function groupEndedSubject(branch: string, group: string): string; - -export declare const groupEndedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.group-ended.*.*"; +export declare const pipelineEndedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*"; export declare const runStartedStream: "SEAT_mesh-pipeline-runner_run-started"; -export declare function runStartedSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function runStartedSubject(module: string, branch: string, commit: string): string; export declare const runStartedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.run-started.*.*.*"; export declare const stepStartedStream: "SEAT_mesh-pipeline-runner_step-started"; -export declare function stepStartedSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function stepStartedSubject(module: string, branch: string, commit: string): string; export declare const stepStartedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.step-started.*.*.*"; export declare const stepEndedStream: "SEAT_mesh-pipeline-runner_step-ended"; -export declare function stepEndedSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function stepEndedSubject(module: string, branch: string, commit: string): string; export declare const stepEndedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.step-ended.*.*.*"; export declare const waitHeldStream: "SEAT_mesh-pipeline-runner_wait-held"; -export declare function waitHeldSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function waitHeldSubject(branch: string, source: string): string; -export declare const waitHeldSubjectAll: "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*.*"; +export declare const waitHeldSubjectAll: "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*"; export declare const waitEndedStream: "SEAT_mesh-pipeline-runner_wait-ended"; -export declare function waitEndedSubject(module: string, branch: string, commitOrGroup: string): string; +export declare function waitEndedSubject(branch: string, source: string): string; -export declare const waitEndedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*.*"; +export declare const waitEndedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*"; export declare const fillingSubject: "mesh.seat.mesh-pipeline-runner.event.filling"; @@ -93,16 +87,35 @@ export declare const roomSubject: "mesh.seat.mesh-pipeline-runner.event.room"; export declare const states: { readonly pipelines: "pipelines"; + readonly queue: "queue"; readonly kept: "kept"; readonly stepLog: "step-log"; readonly stepOutputs: "step-outputs"; }; -/** The key of one value of the state pipelines under the form "..". */ -export declare function pipelinesByBranchRevisionModuleKey(branch: string, revision: string, module: string): string; +/** The key of one value of the state pipelines under the form ".". */ +export declare function pipelinesByBranchSourceKey(branch: string, source: string): string; -/** The parts of a key of the form "..", or undefined for a key of another form. */ -export declare function parsePipelinesByBranchRevisionModuleKey(_key: string): { branch: string; revision: string; module: string } | undefined; +/** The parts of a key of the form ".", or undefined for a key of another form. */ +export declare function parsePipelinesByBranchSourceKey(_key: string): { branch: string; source: string } | undefined; + +/** The key of one value of the state pipelines under the form "..published..". */ +export declare function pipelinesByBranchSourcePublishedPackageVersionKey(branch: string, source: string, packagePart: string, version: string): string; + +/** The parts of a key of the form "..published..", or undefined for a key of another form. */ +export declare function parsePipelinesByBranchSourcePublishedPackageVersionKey(_key: string): { branch: string; source: string; packagePart: string; version: string } | undefined; + +/** The key of one value of the state queue under the form "queue.next". */ +export declare function queueByQueueNextKey(): string; + +/** The parts of a key of the form "queue.next", or undefined for a key of another form. */ +export declare function parseQueueByQueueNextKey(_key: string): { } | undefined; + +/** The key of one value of the state queue under the form "waiting.". */ +export declare function queueByWaitingSequenceKey(sequence: string): string; + +/** The parts of a key of the form "waiting.", or undefined for a key of another form. */ +export declare function parseQueueByWaitingSequenceKey(_key: string): { sequence: string } | undefined; /** The key of one value of the state kept under the form ".". */ export declare function keptByLevelDigestKey(level: string, digest: string): string; @@ -140,21 +153,6 @@ export interface Fill { "store": string; } -/** a group's one pipeline's end on a watched branch, said once every member's modules have ended; a group's wants are written on it alone (ADR 0666 section 9) */ -export interface GroupEnded { - "branch": string; - "ended"?: string; - "group": string; - "outcome": "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; - /** every member module's pipeline, each ended */ - "pipelines": PipelineEnded[]; - "revision"?: number; - /** the group's one source revision of the watched branch */ - "source"?: number; - "v": number; - "why"?: string; -} - /** a package's passing result the runner keeps, by the digest of what its tests read (ADR 0666 section 8) */ export interface KeptResult { /** sha256: of what the package's tests read */ @@ -191,101 +189,107 @@ export interface Member { "module": string; } -/** one pipeline as the runner keeps it in its state pipelines, by compare-and-set (design 47 *The runner's kept data*) */ +/** one module a pipeline moves: an entry of its take-in.taken, with what the pipeline found of it (design 47 H §746, H-A-35, H-A-72) */ +export interface Mover { + /** the commit the module's entry was last changed at */ + "commit": string; + /** the module's build-input fingerprint at the commit */ + "fingerprint": string; + "module": string; + /** yes when the module is over its test budget (design 47 G section 419) */ + "over-budget"?: boolean; + "repository": string; + "tests"?: TestCounts; + /** the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H §746) */ + "tier": number; + /** the version released for the mover in this pipeline (version-released), absent until one is (design 47 H-A-52) */ + "version"?: string; + "widens"?: Widening[]; +} + +/** one mover at its pipeline's end (design 47 H §746) */ +export interface MoverEnded { + /** the module's build-input fingerprint the pipeline ran at */ + "fingerprint": string; + "module": string; + /** the mover's step results, each naming its module (design 47 H-A-72) */ + "steps": StepResult[]; + /** the mover's tier in the delivery order, from 1 (ADR 0666 section 14) */ + "tier": number; + /** the version released for the mover, absent when none was released */ + "version"?: string; +} + +/** one pipeline of one take-in, its movers the take-in's entries, as the runner keeps it in its state pipelines by compare-and-set (design 47 H §746) */ export interface Pipeline { /** the watched branch, or the branch of a run on request */ "branch": string; - /** the commit the module's entry was last changed at */ - "commit": string; + /** the merge call whose source revision the take-in took in (design 47 H §746) */ + "call"?: string; /** how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325) */ "end-count"?: number; "ended"?: string; - /** the module's build-input fingerprint at the commit */ - "fingerprint"?: string; - /** the gathered group, when the pipeline is its */ - "group"?: string; - "module": string; - "outcome": "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; - /** yes when the module is over its test budget (design 47 G section 419) */ - "over-budget"?: boolean; - /** the pipeline's key, .., a branch escaped as a key's name is */ - "pipeline"?: string; + /** the modules the pipeline moves, its take-in's entries (design 47 H §746) */ + "movers": Mover[]; + "outcome": "waiting" | "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; + /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ + "pipeline": string; /** for a pipeline a package's publish started, that publish (A-202) */ "published"?: Published; - "repository"?: string; /** the catalog graph revision of the branch the pipeline runs for */ "revision"?: number; /** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */ "run"?: string; + /** for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748) */ + "seq"?: number; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ - "source"?: number; + "source": number; "started"?: string; - /** every step, approval last */ + /** every mover's steps, each naming its mover, approval last */ "steps": StepResult[]; - "tests"?: TestCounts; /** the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606) */ "unlogged"?: LogEntry[]; /** the layout version */ "v"?: number; - /** the version package-published names, for a pipeline the runner started from a publication or from outdated; none for any other (design 47 G 550) */ - "version"?: string; /** for a pipeline that did not pass, the steps that held it */ "why"?: string; - "widens"?: Widening[]; } -/** a pipeline's end with every step's result, its test counts, the source revision and widens (design 47 *Health and going back*); the assigner writes a want only from one whose every required step passed */ +/** a pipeline's end, said once, with per mover its released version, step results and tier (design 47 H §746); the assigner writes wants only from a passed one */ export interface PipelineEnded { /** the watched branch, or the branch of a run on request */ "branch": string; - /** the commit the module's entry was last changed at */ - "commit": string; + /** the merge call whose source revision the take-in took in (design 47 H §746) */ + "call"?: string; /** how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325) */ "end-count"?: number; "ended"?: string; - /** the module's build-input fingerprint at the commit */ - "fingerprint"?: string; - /** the gathered group, when the pipeline is its */ - "group"?: string; - "module": string; - "outcome": "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; - /** yes when the module is over its test budget (500 unit or 50 integration tests; design 47 G section 419) */ - "over-budget"?: boolean; - /** the pipeline's key, .., a branch escaped as a key's name is */ + /** per mover its fingerprint, released version, step results and tier, in the delivery order (design 47 H §746, H-A-2) */ + "movers": MoverEnded[]; + "outcome": "waiting" | "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; + /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ "pipeline": string; /** the catalog graph revision of the branch the pipeline runs for */ "revision"?: number; /** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */ "run"?: string; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ - "source"?: number; + "source": number; "started"?: string; - "steps": StepResult[]; - "tests"?: TestCounts; "v": number; "why"?: string; - "widens"?: Widening[]; } -export interface PipelineStartedStepsItem { - "artifact"?: string; - "status": "required" | "optional" | "bypass"; - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; -} - -/** a pipeline's start */ +/** a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52) */ export interface PipelineStarted { "at"?: string; /** the watched branch, or the branch of a run on request */ "branch": string; - /** the commit the module's entry was last changed at */ - "commit": string; - /** the module's build-input fingerprint at the commit */ - "fingerprint"?: string; - /** the gathered group, when the pipeline is its */ - "group"?: string; - "module": string; - /** the pipeline's key, .., a branch escaped as a key's name is */ + /** the merge call whose source revision the take-in took in (design 47 H §746) */ + "call"?: string; + /** the pipeline's movers */ + "movers": Mover[]; + /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ "pipeline": string; /** for a pipeline a package's publish started, that publish (A-202) */ "published"?: Published; @@ -294,9 +298,7 @@ export interface PipelineStarted { /** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */ "run"?: string; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ - "source"?: number; - /** the steps the policy gives it */ - "steps"?: PipelineStartedStepsItem[]; + "source": number; "v": number; } @@ -347,10 +349,8 @@ export interface StepEvent { "commit": string; /** the module's build-input fingerprint at the commit */ "fingerprint"?: string; - /** the gathered group, when the pipeline is its */ - "group"?: string; "module": string; - /** the pipeline's key, .., a branch escaped as a key's name is */ + /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ "pipeline": string; "result": StepResult; /** the catalog graph revision of the branch the pipeline runs for */ @@ -376,6 +376,8 @@ export interface StepResult { "ended"?: string; /** the artifact's build-input fingerprint the step ran at */ "fingerprint"?: string; + /** the mover the step is of (design 47 H-A-35) */ + "module"?: string; /** the node whose holder ended it */ "node"?: string; /** for a waiting step, who or what it waits on: a person, a build node, the revision view */ @@ -393,7 +395,7 @@ export interface StepResult { "started"?: string; /** the step's status in the module's policy */ "status": "required" | "optional" | "bypass"; - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; + "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; "tests"?: TestCounts; /** what the outcome rests on: the part not heard, the seat with no holder, what a waiting step waits on */ "why"?: string; @@ -455,7 +457,7 @@ export interface ToolchainUsed { "version": string; } -/** a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283) */ +/** a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283); said on . (design 47 H-A-72) */ export interface Wait { "artifact"?: string; /** the step's own ask, where it has one (design 47 G §731) */ @@ -466,14 +468,13 @@ export interface Wait { "commit"?: string; /** the module's build-input fingerprint at the commit */ "fingerprint"?: string; - /** the gathered group, when the pipeline is its */ - "group"?: string; /** for its end, how it ended: answered, ran, superseded */ "how"?: string; - "module": string; + /** for a step's wait, the mover whose step waits (design 47 H-A-72) */ + "module"?: string; /** what the step waits on (design 47 *Health and going back*) */ - "on": "person" | "build node" | "revision view"; - /** the pipeline's key, .., a branch escaped as a key's name is */ + "on": "person" | "build node" | "revision view" | "pipelines-at-once"; + /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ "pipeline": string; /** the catalog graph revision of the branch the pipeline runs for */ "revision"?: number; @@ -484,13 +485,19 @@ export interface Wait { "since": string; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ "source"?: number; - /** a pipeline step a wait inside a pipeline is in */ - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; + /** the pipeline step a wait is in, or pipeline for a pipeline waiting its turn (design 47 H §748) */ + "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval" | "pipeline"; "v": number; /** for a wait on a person, who: the operator, a reviewer */ "who"?: string; } +/** a pipeline waiting its turn under pipelines-at-once (design 47 H §748, H-A-72) */ +export interface Waiting { + /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ + "pipeline": string; +} + /** a part serving a step the change alters, or an acting rule, a grant or a credential it widens, computed by the running runner (ADR 0666 section 23) */ export interface Widening { /** the part, rule, grant or credential */ @@ -570,7 +577,7 @@ export interface WhyCarriedInput { "artifact"?: string; /** the pipeline's key */ "pipeline": string; - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; + "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; } /** is what why-carried answers. */ @@ -613,7 +620,7 @@ export interface RerunInput { "artifact"?: string; /** the pipeline's key */ "pipeline": string; - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; + "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; /** why, written with the caller the runtime proves in the hand-act log */ "why": string; } @@ -629,7 +636,7 @@ export interface AcceptInput { "artifact"?: string; /** the pipeline's key */ "pipeline": string; - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; + "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; /** why, written with the caller the runtime proves in the hand-act log */ "why": string; } @@ -652,6 +659,19 @@ export interface CancelAnswer { "pipeline": Pipeline; } +/** is what place takes. */ +export interface PlaceInput { + /** the pipeline's key */ + "pipeline": string; + /** why, written with the caller the runtime proves in the hand-act log */ + "why": string; +} + +/** is what place answers. */ +export interface PlaceAnswer { + "pipeline": Pipeline; +} + /** is what ask-again takes. */ export interface AskAgainInput { /** the pipeline's key */ @@ -702,9 +722,6 @@ export type PipelineStartedEvent = PipelineStarted; /** is the body of the event pipeline-ended. */ export type PipelineEndedEvent = PipelineEnded; -/** is the body of the event group-ended. */ -export type GroupEndedEvent = GroupEnded; - /** is the body of the event run-started. */ export type RunStartedEvent = RunStarted; @@ -729,8 +746,17 @@ export type FullEvent = Fill; /** is the body of the event room. */ export type RoomEvent = Fill; -/** is one value of the state pipelines under the key ... */ -export type PipelinesByBranchRevisionModuleValue = Pipeline; +/** is one value of the state pipelines under the key .. */ +export type PipelinesByBranchSourceValue = Pipeline; + +/** is one value of the state pipelines under the key ..published... */ +export type PipelinesByBranchSourcePublishedPackageVersionValue = Pipeline; + +/** is one value of the state queue under the key queue.next. */ +export type QueueByQueueNextValue = number; + +/** is one value of the state queue under the key waiting.. */ +export type QueueByWaitingSequenceValue = Waiting; /** is one value of the state kept under the key .. */ export type KeptByLevelDigestValue = KeptResult; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js index ac1575aa..935bf4c9 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js @@ -16,6 +16,7 @@ export const verbs = { rerun: "rerun", accept: "accept", cancel: "cancel", + place: "place", askAgain: "ask-again", testRuns: "test-runs", testRunsDrop: "test-runs-drop", @@ -24,7 +25,6 @@ export const verbs = { export const events = { pipelineStarted: "pipeline-started", pipelineEnded: "pipeline-ended", - groupEnded: "group-ended", runStarted: "run-started", stepStarted: "step-started", stepEnded: "step-ended", @@ -39,67 +39,59 @@ export const family = { name: "mesh-pipeline-runner.events", maxAgeDays: 7 }; export const pipelineStartedStream = "SEAT_mesh-pipeline-runner_pipeline-started"; -export function pipelineStartedSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.pipeline-started." + module + "." + branch + "." + commitOrGroup; +export function pipelineStartedSubject(branch, source) { + return "mesh.seat.mesh-pipeline-runner.event.pipeline-started." + branch + "." + source; } -export const pipelineStartedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*.*"; +export const pipelineStartedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*"; export const pipelineEndedStream = "SEAT_mesh-pipeline-runner_pipeline-ended"; -export function pipelineEndedSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.pipeline-ended." + module + "." + branch + "." + commitOrGroup; +export function pipelineEndedSubject(branch, source) { + return "mesh.seat.mesh-pipeline-runner.event.pipeline-ended." + branch + "." + source; } -export const pipelineEndedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*.*"; - -export const groupEndedStream = "SEAT_mesh-pipeline-runner_group-ended"; - -export function groupEndedSubject(branch, group) { - return "mesh.seat.mesh-pipeline-runner.event.group-ended." + branch + "." + group; -} - -export const groupEndedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.group-ended.*.*"; +export const pipelineEndedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*"; export const runStartedStream = "SEAT_mesh-pipeline-runner_run-started"; -export function runStartedSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.run-started." + module + "." + branch + "." + commitOrGroup; +export function runStartedSubject(module, branch, commit) { + return "mesh.seat.mesh-pipeline-runner.event.run-started." + module + "." + branch + "." + commit; } export const runStartedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.run-started.*.*.*"; export const stepStartedStream = "SEAT_mesh-pipeline-runner_step-started"; -export function stepStartedSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.step-started." + module + "." + branch + "." + commitOrGroup; +export function stepStartedSubject(module, branch, commit) { + return "mesh.seat.mesh-pipeline-runner.event.step-started." + module + "." + branch + "." + commit; } export const stepStartedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.step-started.*.*.*"; export const stepEndedStream = "SEAT_mesh-pipeline-runner_step-ended"; -export function stepEndedSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.step-ended." + module + "." + branch + "." + commitOrGroup; +export function stepEndedSubject(module, branch, commit) { + return "mesh.seat.mesh-pipeline-runner.event.step-ended." + module + "." + branch + "." + commit; } export const stepEndedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.step-ended.*.*.*"; export const waitHeldStream = "SEAT_mesh-pipeline-runner_wait-held"; -export function waitHeldSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.wait-held." + module + "." + branch + "." + commitOrGroup; +export function waitHeldSubject(branch, source) { + return "mesh.seat.mesh-pipeline-runner.event.wait-held." + branch + "." + source; } -export const waitHeldSubjectAll = "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*.*"; +export const waitHeldSubjectAll = "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*"; export const waitEndedStream = "SEAT_mesh-pipeline-runner_wait-ended"; -export function waitEndedSubject(module, branch, commitOrGroup) { - return "mesh.seat.mesh-pipeline-runner.event.wait-ended." + module + "." + branch + "." + commitOrGroup; +export function waitEndedSubject(branch, source) { + return "mesh.seat.mesh-pipeline-runner.event.wait-ended." + branch + "." + source; } -export const waitEndedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*.*"; +export const waitEndedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*"; export const fillingSubject = "mesh.seat.mesh-pipeline-runner.event.filling"; @@ -109,32 +101,87 @@ export const roomSubject = "mesh.seat.mesh-pipeline-runner.event.room"; export const states = { pipelines: "pipelines", + queue: "queue", kept: "kept", stepLog: "step-log", stepOutputs: "step-outputs", }; -/** The key of one value of the state pipelines under the form "..". */ -export function pipelinesByBranchRevisionModuleKey(branch, revision, module) { - return branch + "." + revision + "." + module; +/** The key of one value of the state pipelines under the form ".". */ +export function pipelinesByBranchSourceKey(branch, source) { + return branch + "." + source; } -/** The parts of a key of the form "..", or undefined for a key of another form. */ -export function parsePipelinesByBranchRevisionModuleKey(_key) { +/** The parts of a key of the form ".", or undefined for a key of another form. */ +export function parsePipelinesByBranchSourceKey(_key) { let _rest = _key; const _at0 = _rest.indexOf("."); if (_at0 <= 0) return undefined; const branch = _rest.slice(0, _at0); _rest = _rest.slice(_at0 + 1); - const _at2 = _rest.indexOf("."); - if (_at2 <= 0) return undefined; - const revision = _rest.slice(0, _at2); - _rest = _rest.slice(_at2 + 1); if (_rest === "") return undefined; - const module = _rest; + const source = _rest; _rest = ""; if (_rest !== "") return undefined; - return { branch, revision, module }; + return { branch, source }; +} + +/** The key of one value of the state pipelines under the form "..published..". */ +export function pipelinesByBranchSourcePublishedPackageVersionKey(branch, source, packagePart, version) { + return branch + "." + source + ".published." + packagePart + "." + version; +} + +/** The parts of a key of the form "..published..", or undefined for a key of another form. */ +export function parsePipelinesByBranchSourcePublishedPackageVersionKey(_key) { + let _rest = _key; + const _at0 = _rest.indexOf("."); + if (_at0 <= 0) return undefined; + const branch = _rest.slice(0, _at0); + _rest = _rest.slice(_at0 + 1); + const _at2 = _rest.indexOf(".published."); + if (_at2 <= 0) return undefined; + const source = _rest.slice(0, _at2); + _rest = _rest.slice(_at2 + 11); + const _at4 = _rest.indexOf("."); + if (_at4 <= 0) return undefined; + const packagePart = _rest.slice(0, _at4); + _rest = _rest.slice(_at4 + 1); + if (_rest === "") return undefined; + const version = _rest; + _rest = ""; + if (_rest !== "") return undefined; + return { branch, source, packagePart, version }; +} + +/** The key of one value of the state queue under the form "queue.next". */ +export function queueByQueueNextKey() { + return "queue.next"; +} + +/** The parts of a key of the form "queue.next", or undefined for a key of another form. */ +export function parseQueueByQueueNextKey(_key) { + let _rest = _key; + if (!_rest.startsWith("queue.next")) return undefined; + _rest = _rest.slice(10); + if (_rest !== "") return undefined; + return { }; +} + +/** The key of one value of the state queue under the form "waiting.". */ +export function queueByWaitingSequenceKey(sequence) { + return "waiting." + sequence; +} + +/** The parts of a key of the form "waiting.", or undefined for a key of another form. */ +export function parseQueueByWaitingSequenceKey(_key) { + let _rest = _key; + if (!_rest.startsWith("waiting.")) return undefined; + _rest = _rest.slice(8); + if (_rest === "") return undefined; + const sequence = _rest; + _rest = ""; + if (_rest !== "") return undefined; + return { sequence }; } /** The key of one value of the state kept under the form ".". */ -- 2.54.0 From 4599d2e60ff8ff7bdf1ceeb7975fd144de970f38 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:05:15 +0100 Subject: [PATCH 011/104] C-W: the seat mesh-wants: a want by version, pipeline and rank; pipeline-wanted; validate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A module want names its fingerprint and released version with the pipeline (.) and rank (its tier, from 1) it was written from, neither for a placement's build; parts, rule, newest, kept-on and composed go, and the client checks a rank with its pipeline instead of a composition and a rule. The node's own want is unchanged. The accepted step and its end take validate beside composition. wanted gains pipeline; pipeline-wanted.. says a pipeline's wants once at their end, running or tier-late with the movers and machines not running. version-delivered goes. Builds: design 47 H §745, §750, §751, §764 (the assigner: version-delivered, the digests in a want); lead answers H-A-37, H-A-51, H-A-56, H-A-72 (6), H-A-75 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/clients/meshwantsclient/wants.go | 54 ++---- .../go/clients/meshwantsclient/wants_test.go | 42 ++-- .../go/seats/meshwants/contract.go | 104 ++++++---- .../go/seats/meshwants/contract_test.go | 16 +- .../seats/mesh-wants/fixtures/events.json | 54 ++++-- .../seats/mesh-wants/fixtures/states.json | 18 +- .../seats/mesh-wants/fixtures/verbs.json | 17 +- .../seats/mesh-wants/seat.json | 183 ++++++++++-------- .../ts/seats/meshwants/index.d.ts | 75 +++---- .../ts/seats/meshwants/index.js | 14 +- 10 files changed, 315 insertions(+), 262 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go index ea5a8dff..700a2eb3 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go @@ -17,8 +17,8 @@ import ( // The three values of the state wants, in the seat's types. type ( - // Want is a node's want for a module: the fingerprint it should run and the digest of the one composition it allows, - // or Removed, or Self when the node composes it itself; Newest and Rule name what holds the node back. + // Want is a node's want for a module: the build it should run by its fingerprint and released version, with the + // pipeline and the rank it was written from (design 47 H §750), or Removed. Want = seat.WantsByWantNodeModuleValue // NodeWant is a node's own want: the digest of the node's own composition it may apply. NodeWant = seat.WantsByWantNodeNodeValue @@ -26,7 +26,8 @@ type ( Held = seat.WantsByHeldModuleFingerprintValue ) -// The rules of ADR 0429 §6 and ADR 0539 clause 6, by number, as a want or a difference names the one that holds a node back. +// The rules of ADR 0429 §6 and ADR 0539 clause 6, by number, as a difference names the one that held a node back; a want +// names none (design 47 H §750). const ( RuleBuildDone = 1 // the build of F is done RuleNotHeld = 2 // F is not held @@ -39,10 +40,6 @@ const ( RuleProvisions = 8 ) -// ruleRead is the highest rule a reader takes (novox/hq ADR 0614 §2, §4): 9 and 10 are kept for the verb wait and the -// capability hold of a later release. -const ruleRead = 10 - // The answers a want carries to a failed backup before an apply (ADR 0539 clause 16). const ( // BackupAgain is the answer to back the module up again before the apply. @@ -107,13 +104,6 @@ func checkDigest(digest, of string) error { return nil } -func checkRule(rule int64, of string) error { - if rule < RuleBuildDone || rule > ruleRead { - return fmt.Errorf("wants: %s names the rule %d, which is not one of 1 to %d", of, rule, ruleRead) - } - return nil -} - // WantKey is the key, in the state wants, of a node's want for a module: `want..`. A module named `node` is // refused, since `want..node` is the node's own key. func WantKey(node, module string) (string, error) { @@ -183,31 +173,24 @@ func ParseHeldKey(key string) (module, fingerprint string, err error) { func checkWant(w Want) error { if w.Removed { - if w.Fp != "" || w.Composed != "" || w.Newest != "" || w.Rule != 0 || w.Backup != "" || w.Put || w.Hold || w.Self || w.Yes != "" || w.Release != "" { - return fmt.Errorf("wants: a removed want names no fingerprint, composition, rule, backup answer or put") + if w.Fp != "" || w.Backup != "" || w.Put || w.Hold || w.Self || w.Yes != "" || w.Release != "" || w.Pipeline != "" || w.Rank != 0 { + return fmt.Errorf("wants: a removed want names no fingerprint, pipeline, backup answer or put") } return nil } if w.Hold && !w.Put { return fmt.Errorf("wants: only a put holds a want") } - if w.Put && (w.Newest != "" || w.Rule != 0) { - return fmt.Errorf("wants: a put's want is held back by no rule") - } if err := checkFingerprint(w.Fp, "a want's fingerprint"); err != nil { return err } - // A node the catalogue places composes its own modules (ADR 0547 §2): its want is Self and names the build alone. Any - // other want names the one composition it allows (ADR 0539 clause 1). + // The rank is the mover's tier in the pipeline the want was written from, from 1; a placement's build names neither + // (design 47 H §750, H-A-37). switch { - case w.Self && w.Composed != "": - return fmt.Errorf("wants: the want of %s says the node composes it, and names a composition", w.Fp) - case !w.Self && w.Composed == "": - return fmt.Errorf("wants: the want of %s names no composition: a want names the digest of the one composition it allows (ADR 0539 clause 1), unless the node composes it itself", w.Fp) - case w.Composed != "": - if err := checkDigest(w.Composed, "a want's composition digest"); err != nil { - return err - } + case w.Rank < 0 || w.Rank > 0 && w.Pipeline == "": + return fmt.Errorf("wants: the want of %s names the rank %d and no pipeline it is a tier of", w.Fp, w.Rank) + case w.Pipeline != "" && w.Rank == 0: + return fmt.Errorf("wants: the want of %s names the pipeline %s and no rank in it", w.Fp, w.Pipeline) } if w.Yes != "" { if err := checkDigest(w.Yes, "the digest a want's yes allows"); err != nil { @@ -224,23 +207,14 @@ func checkWant(w Want) error { if w.Revert != "" && w.Revert != RevertLive { return fmt.Errorf("wants: the revert answer %q is not %s", w.Revert, RevertLive) } - if w.Newest == "" && w.Rule == 0 { - return nil - } - if err := checkFingerprint(w.Newest, "a want's newest fingerprint"); err != nil { - return err - } - if w.Newest == w.Fp { - return fmt.Errorf("wants: a want at its newest fingerprint names no rule holding it back") - } - return checkRule(w.Rule, "a want held back") + return nil } // CheckWant refuses a want the codec refuses. func CheckWant(w Want) error { return checkWant(w) } // EncodeWant is w as JSON at the kept values' version; it refuses a fingerprint not of the new form, a removed want naming -// one, and a want that names no composition unless the node composes it itself. +// one, and a rank without its pipeline or a pipeline without its rank. func EncodeWant(w Want) ([]byte, error) { if err := checkWant(w); err != nil { return nil, err diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go index c12a9c14..76038e62 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go @@ -37,13 +37,12 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { w Want golden string }{ - "composed": {Want{Fp: a, Composed: c, Words: "w"}, `{"v":1,"fp":"` + a + `","composed":"` + c + `","words":"w"}`}, - "held back": {Want{Fp: a, Self: true, Newest: b, Rule: RuleGrant, Backup: BackupAgain, Words: "held"}, `{"v":1,"fp":"` + a + `","newest":"` + b + `","rule":6,"backup":"again","words":"held","self":true}`}, - "put": {Want{Fp: a, Self: true, Put: true, Hold: true, Yes: d, Release: "r1"}, `{"v":1,"fp":"` + a + `","put":true,"hold":true,"yes":"` + d + `","release":"r1","self":true}`}, - "revert": {Want{Fp: a, Self: true, Revert: RevertLive, Words: "live"}, `{"v":1,"fp":"` + a + `","revert":"live","words":"live","self":true}`}, - "removed": {Want{Removed: true, Words: "gone"}, `{"v":1,"removed":true,"words":"gone"}`}, - "released": {Want{Fp: a, Composed: c, Version: "0.1.15", Parts: map[string]string{"mesh-sdk:go": d}}, `{"v":1,"fp":"` + a + `","composed":"` + c + `","version":"0.1.15","parts":{"mesh-sdk:go":"` + d + `"}}`}, - "kept": {Want{Fp: a, Composed: c, Parts: map[string]string{"x:image": d}, KeptOn: "n1"}, `{"v":1,"fp":"` + a + `","composed":"` + c + `","parts":{"x:image":"` + d + `"},"kept-on":"n1"}`}, + "from a pipeline": {Want{Fp: a, Version: "0.1.15", Pipeline: "main.3589", Rank: 2, Words: "w"}, `{"v":1,"fp":"` + a + `","version":"0.1.15","pipeline":"main.3589","rank":2,"words":"w"}`}, + "backup answer": {Want{Fp: a, Self: true, Backup: BackupAgain, Words: "again"}, `{"v":1,"fp":"` + a + `","backup":"again","words":"again","self":true}`}, + "put": {Want{Fp: a, Self: true, Put: true, Hold: true, Yes: d, Release: "r1"}, `{"v":1,"fp":"` + a + `","put":true,"hold":true,"yes":"` + d + `","release":"r1","self":true}`}, + "revert": {Want{Fp: a, Self: true, Revert: RevertLive, Words: "live"}, `{"v":1,"fp":"` + a + `","revert":"live","words":"live","self":true}`}, + "removed": {Want{Removed: true, Words: "gone"}, `{"v":1,"removed":true,"words":"gone"}`}, + "a placement's build": {Want{Fp: a, Version: "0.1.14"}, `{"v":1,"fp":"` + a + `","version":"0.1.14"}`}, } { t.Run(name, func(t *testing.T) { raw, err := EncodeWant(row.w) @@ -60,26 +59,25 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { }) t.Run("refused", func(t *testing.T) { for name, w := range map[string]Want{ - "old fingerprint": {Fp: "src1:abc", Composed: c}, - "no composition": {Fp: a}, - "self and composition": {Fp: a, Self: true, Composed: c}, - "hold without put": {Fp: a, Self: true, Hold: true}, - "put held back": {Fp: a, Self: true, Put: true, Newest: b, Rule: RuleStep}, - "removed names a rule": {Removed: true, Rule: 1}, - "release without yes": {Fp: a, Self: true, Release: "r"}, - "backup answer unknown": {Fp: a, Self: true, Backup: "later"}, - "revert answer unknown": {Fp: a, Self: true, Revert: "hold"}, - "newest equals fp": {Fp: a, Self: true, Newest: a, Rule: RuleStep}, - "rule 11": {Fp: a, Self: true, Newest: b, Rule: 11}, - "newest without a rule": {Fp: a, Self: true, Newest: b}, - "composition not sha256": {Fp: a, Composed: "sha256:xyz"}, + "old fingerprint": {Fp: "src1:abc"}, + "hold without put": {Fp: a, Self: true, Hold: true}, + "rank without pipeline": {Fp: a, Rank: 1}, + "pipeline without rank": {Fp: a, Pipeline: "main.3589"}, + "rank below 1": {Fp: a, Pipeline: "main.3589", Rank: -1}, + "removed names a pipeline": {Removed: true, Pipeline: "main.3589", Rank: 1}, + "release without yes": {Fp: a, Self: true, Release: "r"}, + "backup answer unknown": {Fp: a, Self: true, Backup: "later"}, + "revert answer unknown": {Fp: a, Self: true, Revert: "hold"}, } { if _, err := EncodeWant(w); err == nil { t.Errorf("%s: written", name) } } - if _, err := EncodeWant(Want{Fp: a, Self: true, Newest: b, Rule: 10}); err != nil { - t.Errorf("rule 10 is read: %v", err) + // design 47 H §750, H-A-37: a want names no digest, rule or newest; the earlier fields are refused. + for _, old := range []string{`"composed":"` + c + `"`, `"parts":{"x:image":"` + d + `"}`, `"rule":3`, `"newest":"` + b + `"`, `"kept-on":"n1"`} { + if _, err := DecodeWant([]byte(`{"v":1,"fp":"` + a + `",` + old + `}`)); err == nil { + t.Errorf("a want naming %s is read", old) + } } if _, err := DecodeWant([]byte(`{"fp":"` + a + `","self":true}`)); !errors.Is(err, keys.ErrUnknownVersion) { t.Errorf("no version: %v", err) diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go index d68a4315..98ca9b80 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go @@ -34,13 +34,13 @@ const ( EventAssignmentRevision = "assignment-revision" EventDifference = "difference" EventWanted = "wanted" + EventPipelineWanted = "pipeline-wanted" EventWaitHeld = "wait-held" EventWaitEnded = "wait-ended" EventFilling = "filling" EventFull = "full" EventRoom = "room" EventStepEnded = "step-ended" - EventVersionDelivered = "version-delivered" EventStepProgress = "step-progress" ) @@ -51,7 +51,7 @@ func Verbs() []string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventPolicyChanged, EventAssignmentRevision, EventDifference, EventWanted, EventWaitHeld, EventWaitEnded, EventFilling, EventFull, EventRoom, EventStepEnded, EventVersionDelivered, EventStepProgress} + return []string{EventPolicyChanged, EventAssignmentRevision, EventDifference, EventWanted, EventPipelineWanted, EventWaitHeld, EventWaitEnded, EventFilling, EventFull, EventRoom, EventStepEnded, EventStepProgress} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -80,6 +80,17 @@ func SubjectWanted(node, module string) string { // SubjectWantedAll hears every wanted. const SubjectWantedAll = "mesh.seat.mesh-wants.event.wanted.*.*" +// StreamPipelineWanted is the stream pipeline-wanted is kept in. +const StreamPipelineWanted = "SEAT_mesh-wants_pipeline-wanted" + +// SubjectPipelineWanted is where pipeline-wanted is published, on mesh.seat.mesh-wants.event.pipeline-wanted... +func SubjectPipelineWanted(branch, source string) string { + return "mesh.seat.mesh-wants.event.pipeline-wanted." + branch + "." + source +} + +// SubjectPipelineWantedAll hears every pipeline-wanted. +const SubjectPipelineWantedAll = "mesh.seat.mesh-wants.event.pipeline-wanted.*.*" + // SubjectWaitHeld is where wait-held is published. const SubjectWaitHeld = "mesh.seat.mesh-wants.event.wait-held" @@ -104,12 +115,6 @@ func SubjectStepEnded(node string) string { return "mesh.seat.mesh-wants.event.s // SubjectStepEndedAll hears every step-ended. const SubjectStepEndedAll = "mesh.seat.mesh-wants.event.step-ended.*" -// StreamVersionDelivered is the stream version-delivered is kept in. -const StreamVersionDelivered = "SEAT_mesh-wants_version-delivered" - -// SubjectVersionDelivered is where version-delivered is published. -const SubjectVersionDelivered = "mesh.seat.mesh-wants.event.version-delivered" - // SubjectStepProgress is where step-progress is published, on mesh.seat.mesh-wants.event.step-progress.. func SubjectStepProgress(node string) string { return "mesh.seat.mesh-wants.event.step-progress." + node @@ -982,6 +987,30 @@ type NodeEntryRef struct { Node string `json:"node"` } +// NotRunning is a mover of a late tier and the placing machines it does not run on. +type NotRunning struct { + Machines []string `json:"machines"` + Module string `json:"module"` +} + +// PipelineWanted is a pipeline's wants written to the end, said once: running when every tier's movers run on every present placing machine, tier-late when a tier passed tier-bound (design 47 H §751, H-A-56, H-A-72, H-A-75). +type PipelineWanted struct { + Branch string `json:"branch"` + // for tier-late, the late tier's movers not running and the machines they do not run on + NotRunning []NotRunning `json:"not-running,omitempty"` + Outcome string `json:"outcome"` + // the runner's pipeline key, ., a branch escaped as a key's name is (design 47 H §746) + Pipeline string `json:"pipeline"` + Source int64 `json:"source"` + V int64 `json:"v"` +} + +// The values of PipelineWanted's outcome. +const ( + PipelineWantedOutcomeRunning = "running" + PipelineWantedOutcomeTierLate = "tier-late" +) + // SharedAskedBy is the step that asked the run, for a test step reading another's run. type SharedAskedBy struct { // its artifact, : @@ -1002,7 +1031,7 @@ type Shared struct { Run string `json:"run"` } -// StepEnded is the composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at. +// StepEnded is a validate or composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at. type StepEnded struct { // for a rerun, the caller the runtime proved By string `json:"by,omitempty"` @@ -1018,7 +1047,7 @@ type StepEnded struct { Outcome string `json:"outcome"` Pipeline string `json:"pipeline"` Rerun bool `json:"rerun,omitempty"` - // why it failed or could not run: the two modules owning one path, the part not heard + // why it failed or could not run: each manifest problem, the cycle the revision makes, the two modules owning one path, the part not heard (design 47 H §745) Said string `json:"said,omitempty"` // per machine composed, the composition run the step read, its ask and so where its verdict was taken (design 47 G §723, §729) Shared []Shared `json:"shared,omitempty"` @@ -1040,10 +1069,11 @@ const ( // The values of StepEnded's step. const ( + StepEndedStepValidate = "validate" StepEndedStepComposition = "composition" ) -// StepRun is the composition step of one module's pipeline (design 47 *Pipeline steps and the policy*, *The pipeline makes the check*): the assigner composes each machine's declaration at the change's heads with the composer built from them, in the build seat's sandbox, and refuses a change in which two modules own one path. +// StepRun is a pipeline step of one mover the assigner serves (design 47 H §745, G §22): validate, the manifest validator built from the take-in's heads run over the revision's manifests, before composition, each machine's declaration composed at the change's heads with the composer built from them, both in the build seat's sandbox. type StepRun struct { // the watched branch, or the branch of a run on request Branch string `json:"branch"` @@ -1054,7 +1084,7 @@ type StepRun struct { // the module's build-input fingerprint at the commit Fingerprint string `json:"fingerprint"` Module string `json:"module"` - // the runner's pipeline key, .., a branch escaped as a key's name is + // the runner's pipeline key, ., a branch escaped as a key's name is (design 47 H §746) Pipeline string `json:"pipeline"` // the step is asked again by the runner's rerun Rerun bool `json:"rerun,omitempty"` @@ -1069,6 +1099,7 @@ type StepRun struct { // The values of StepRun's step. const ( + StepRunStepValidate = "validate" StepRunStepComposition = "composition" ) @@ -1279,6 +1310,8 @@ type WantedEvent struct { Fp string `json:"fp"` Module string `json:"module"` Node string `json:"node"` + // the pipeline whose passed end the want was written from, its key .; absent for a placement's build (design 47 H-A-56) + Pipeline string `json:"pipeline,omitempty"` // true when the assigner removes the want of that node and module (the node left, or the module was unplaced); fp is then the fingerprint last wanted there (design 47 G section 693) Removed bool `json:"removed,omitempty"` Revision int64 `json:"revision"` @@ -1286,6 +1319,9 @@ type WantedEvent struct { V int64 `json:"v"` } +// PipelineWantedEvent is the body of the event pipeline-wanted. +type PipelineWantedEvent = PipelineWanted + // WaitHeldEvent is the body of the event wait-held. type WaitHeldEvent = Wait @@ -1304,20 +1340,6 @@ type RoomEvent = Fill // StepEndedEvent is the body of the event step-ended. type StepEndedEvent = StepEnded -// VersionDeliveredEvent is the body of the event version-delivered. -type VersionDeliveredEvent struct { - At *time.Time `json:"at,omitempty"` - // the machines away when it was said - Away []string `json:"away,omitempty"` - // the module - Module string `json:"module"` - // the digest of each of its parts, by `:` - Parts map[string]string `json:"parts"` - V int64 `json:"v"` - // MAJOR.MINOR.PATCH - Version string `json:"version"` -} - // StepProgressEvent is the body of the event step-progress. type StepProgressEvent struct { Ask string `json:"ask"` @@ -1339,25 +1361,21 @@ const ( // WantsByWantNodeModuleValue is one value of the state wants under the key want... type WantsByWantNodeModuleValue struct { // again or skip - Backup string `json:"backup,omitempty"` - Composed string `json:"composed,omitempty"` - Fp string `json:"fp,omitempty"` - Hold bool `json:"hold,omitempty"` - // for a kept build, the build node that keeps it, from the builder's build.ended; the node-engine fetches the build through that node's seat verb kept-artifact, and a want with none from the store (design 47 G section 526) - KeptOn string `json:"kept-on,omitempty"` - Newest string `json:"newest,omitempty"` - // the digest of each of the module's parts, by `:`; the node-engine fetches and checks each part by it (design 47 G section 379) - Parts map[string]string `json:"parts,omitempty"` - Put bool `json:"put,omitempty"` - Release string `json:"release,omitempty"` - Removed bool `json:"removed,omitempty"` + Backup string `json:"backup,omitempty"` + Fp string `json:"fp,omitempty"` + Hold bool `json:"hold,omitempty"` + // the pipeline whose passed end released the version, its key .; absent for a placement's build (design 47 H §750, H-A-37) + Pipeline string `json:"pipeline,omitempty"` + Put bool `json:"put,omitempty"` + // the mover's tier in that pipeline's delivery order, from 1; the node-engine applies one pipeline's wants by it; absent with pipeline (design 47 H §750, §771, H-A-37) + Rank int64 `json:"rank,omitempty"` + Release string `json:"release,omitempty"` + Removed bool `json:"removed,omitempty"` // live: the operator's answer to a held revert, to start the reverted build on the live data as it is, with nothing restored (design 47 G section 710) Revert string `json:"revert,omitempty"` - // the rule that holds the node back, 1 to 10 - Rule int64 `json:"rule,omitempty"` - Self bool `json:"self,omitempty"` - V int64 `json:"v,omitempty"` - // the module's released version, for people; none for a build of another watched branch (design 47 G section 379) + Self bool `json:"self,omitempty"` + V int64 `json:"v,omitempty"` + // the version released at the build the want names: the newest released on the placement's branch whose pipeline passed, or the placement's build's (design 47 H §750) Version string `json:"version,omitempty"` Words string `json:"words,omitempty"` Yes string `json:"yes,omitempty"` diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go index 9ed6c320..a090ff0d 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go @@ -25,10 +25,14 @@ func TestFixtures(t *testing.T) { }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.assignment-revision$")}, {name: "a difference worked out", subject: "mesh.seat.mesh-wants.event.difference", given: "{\"changes\":1,\"from\":40,\"nodes\":[\"n1\"],\"source\":3589,\"to\":41,\"v\":1}", wire: "{\"changes\":1,\"from\":40,\"nodes\":[\"n1\"],\"source\":3589,\"to\":41,\"v\":1}", decode: func(b []byte) (any, error) { var v DifferenceEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.difference$")}, - {name: "an entry wanted from a trunk revision", subject: "mesh.seat.mesh-wants.event.wanted.n1.xclip", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"revision\":40,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"revision\":40,\"source\":3589,\"v\":1}", + {name: "an entry wanted from a passed pipeline, naming it", subject: "mesh.seat.mesh-wants.event.wanted.n1.xclip", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"pipeline\":\"main.3589\",\"revision\":40,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"pipeline\":\"main.3589\",\"revision\":40,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v WantedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wanted\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a want removed, its node left or its module unplaced", subject: "mesh.seat.mesh-wants.event.wanted.n1.xclip", given: "{\"at\":\"2026-11-09T19:05:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"removed\":true,\"revision\":41,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:05:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"removed\":true,\"revision\":41,\"v\":1}", decode: func(b []byte) (any, error) { var v WantedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wanted\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a pipeline's wants all run", subject: "mesh.seat.mesh-wants.event.pipeline-wanted.main.3589", given: "{\"branch\":\"main\",\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"source\":3589,\"v\":1}", + decode: func(b []byte) (any, error) { var v PipelineWantedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.pipeline-wanted\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a pipeline's tier late, naming the movers and machines not running", subject: "mesh.seat.mesh-wants.event.pipeline-wanted.main.3590", given: "{\"branch\":\"main\",\"not-running\":[{\"machines\":[\"anchor\",\"laptop\"],\"module\":\"nats\"}],\"outcome\":\"tier-late\",\"pipeline\":\"main.3590\",\"source\":3590,\"v\":1}", wire: "{\"branch\":\"main\",\"not-running\":[{\"machines\":[\"anchor\",\"laptop\"],\"module\":\"nats\"}],\"outcome\":\"tier-late\",\"pipeline\":\"main.3590\",\"source\":3590,\"v\":1}", + decode: func(b []byte) (any, error) { var v PipelineWantedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.pipeline-wanted\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a composing wait held with its bound", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"30m\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}", wire: "{\"bound\":\"30m\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}", decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-held$")}, {name: "a wait ended, released by hand", subject: "mesh.seat.mesh-wants.event.wait-ended", given: "{\"bound\":\"30m\",\"by\":\"lead@workstation: the node is away\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"how\":\"released\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}", wire: "{\"bound\":\"30m\",\"by\":\"lead@workstation: the node is away\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"how\":\"released\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}", @@ -43,8 +47,6 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "the composition step failed, two modules owning one path", subject: "mesh.seat.mesh-wants.event.step-ended.laptop", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6b\",\"module\":\"nats\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats and xclip both own /etc/nats.conf on anchor\",\"step\":\"composition\",\"v\":1}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6b\",\"module\":\"nats\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats and xclip both own /etc/nats.conf on anchor\",\"step\":\"composition\",\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-ended\\.[^.*> ]+$")}, - {name: "a version delivered with the machines away", subject: "mesh.seat.mesh-wants.event.version-delivered", given: "{\"away\":[\"laptop\"],\"module\":\"mesh-sdk\",\"parts\":{\"mesh-sdk:go\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"away\":[\"laptop\"],\"module\":\"mesh-sdk\",\"parts\":{\"mesh-sdk:go\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}", - decode: func(b []byte) (any, error) { var v VersionDeliveredEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.version-delivered$")}, {name: "a composition step's progress", subject: "mesh.seat.mesh-wants.event.step-progress.anchor", given: "{\"ask\":\"a1b2\",\"asker\":\"assigner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"build\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"assigner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"build\"}", decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-progress\\.[^.*> ]+$")}, {name: "a put without hold waits, counted from its start", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"put\"}", wire: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"put\"}", @@ -63,13 +65,13 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "C1/AC1 a composition step's progress, naming the runs it waits on", subject: "mesh.seat.mesh-wants.event.step-progress.anchor", given: "{\"ask\":\"a1b2\",\"asker\":\"assigner\",\"at\":\"2026-11-17T10:01:00Z\",\"phase\":\"run\",\"shared\":[{\"ask\":\"r1a2b3\",\"machine\":\"anchor\",\"run\":\"main.12.anchor\"}]}", wire: "{\"ask\":\"a1b2\",\"asker\":\"assigner\",\"at\":\"2026-11-17T10:01:00Z\",\"phase\":\"run\",\"shared\":[{\"ask\":\"r1a2b3\",\"machine\":\"anchor\",\"run\":\"main.12.anchor\"}]}", decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-progress\\.[^.*> ]+$")}, - {name: "a want", subject: "", given: "{\"fp\":\"ab12\",\"rule\":3,\"v\":1}", wire: "{\"fp\":\"ab12\",\"rule\":3,\"v\":1}", + {name: "a want written from a passed pipeline, its version and rank", subject: "", given: "{\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"pipeline\":\"main.3589\",\"rank\":2,\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"pipeline\":\"main.3589\",\"rank\":2,\"v\":1,\"version\":\"0.1.15\"}", decode: func(b []byte) (any, error) { var v WantsByWantNodeModuleValue err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a want for a kept build, naming the node that keeps it", subject: "", given: "{\"fp\":\"ab12\",\"kept-on\":\"n1\",\"parts\":{\"x:image\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"fp\":\"ab12\",\"kept-on\":\"n1\",\"parts\":{\"x:image\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}", + {name: "a want of a placement's build, no pipeline and no rank", subject: "", given: "{\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"v\":1,\"version\":\"0.1.14\"}", wire: "{\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"v\":1,\"version\":\"0.1.14\"}", decode: func(b []byte) (any, error) { var v WantsByWantNodeModuleValue err := json.Unmarshal(b, &v) @@ -139,7 +141,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v DifferenceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "difference refuses a changed fingerprint with no difference, by name", subject: "", given: "{\"changes\":[],\"from\":40,\"refused\":[{\"module\":\"xclip\",\"why\":\"its fingerprint changed and its difference is empty\"}],\"to\":41}", wire: "{\"changes\":[],\"from\":40,\"refused\":[{\"module\":\"xclip\",\"why\":\"its fingerprint changed and its difference is empty\"}],\"to\":41}", decode: func(b []byte) (any, error) { var v DifferenceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a composition step asked by the runner", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", + {name: "a composition step asked by the runner", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", + decode: func(b []byte) (any, error) { var v StepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.accept\\.step$")}, + {name: "a validate step asked by the runner, before the mover's composition", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"validate\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"validate\"}", decode: func(b []byte) (any, error) { var v StepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.accept\\.step$")}, {name: "input asks a composition step's input by digest", subject: "", given: "{\"call\":\"0123456789abcdef0123456789abcdef\",\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", wire: "{\"call\":\"0123456789abcdef0123456789abcdef\",\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/events.json index 6cdc780f..feeace4e 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/events.json @@ -34,7 +34,7 @@ } }, { - "name": "an entry wanted from a trunk revision", + "name": "an entry wanted from a passed pipeline, naming it", "of": "event:wanted", "subject": "mesh.seat.mesh-wants.event.wanted.n1.xclip", "given": { @@ -44,7 +44,8 @@ "fp": "src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56", "revision": 40, "source": 3589, - "at": "2026-11-09T19:00:00Z" + "at": "2026-11-09T19:00:00Z", + "pipeline": "main.3589" } }, { @@ -61,6 +62,39 @@ "at": "2026-11-09T19:05:00Z" } }, + { + "name": "a pipeline's wants all run", + "of": "event:pipeline-wanted", + "subject": "mesh.seat.mesh-wants.event.pipeline-wanted.main.3589", + "given": { + "v": 1, + "pipeline": "main.3589", + "branch": "main", + "source": 3589, + "outcome": "running" + } + }, + { + "name": "a pipeline's tier late, naming the movers and machines not running", + "of": "event:pipeline-wanted", + "subject": "mesh.seat.mesh-wants.event.pipeline-wanted.main.3590", + "given": { + "v": 1, + "pipeline": "main.3590", + "branch": "main", + "source": 3590, + "outcome": "tier-late", + "not-running": [ + { + "module": "nats", + "machines": [ + "anchor", + "laptop" + ] + } + ] + } + }, { "name": "a composing wait held with its bound", "of": "event:wait-held", @@ -165,22 +199,6 @@ "said": "nats and xclip both own /etc/nats.conf on anchor" } }, - { - "name": "a version delivered with the machines away", - "of": "event:version-delivered", - "subject": "mesh.seat.mesh-wants.event.version-delivered", - "given": { - "v": 1, - "module": "mesh-sdk", - "version": "0.1.15", - "parts": { - "mesh-sdk:go": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" - }, - "away": [ - "laptop" - ] - } - }, { "name": "a composition step's progress", "of": "event:step-progress", diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/states.json index af8fd946..d5e7b03e 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/states.json @@ -1,24 +1,22 @@ [ { - "name": "a want", + "name": "a want written from a passed pipeline, its version and rank", "of": "state:wants/want..", "given": { "v": 1, - "fp": "ab12", - "rule": 3 + "fp": "src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56", + "version": "0.1.15", + "pipeline": "main.3589", + "rank": 2 } }, { - "name": "a want for a kept build, naming the node that keeps it", + "name": "a want of a placement's build, no pipeline and no rank", "of": "state:wants/want..", "given": { "v": 1, - "fp": "ab12", - "version": "0.1.15", - "parts": { - "x:image": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" - }, - "kept-on": "n1" + "fp": "src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56", + "version": "0.1.14" } }, { diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json index df3caf96..cbeb2d7f 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json @@ -150,7 +150,7 @@ "of": "accept:step", "subject": "mesh.seat.mesh-wants.accept.step", "given": { - "pipeline": "main.12.nats", + "pipeline": "main.3589", "step": "composition", "module": "nats", "branch": "main", @@ -160,6 +160,21 @@ "fingerprint": "fp-0123" } }, + { + "name": "a validate step asked by the runner, before the mover's composition", + "of": "accept:step", + "subject": "mesh.seat.mesh-wants.accept.step", + "given": { + "pipeline": "main.3589", + "step": "validate", + "module": "nats", + "branch": "main", + "commit": "0123456789abcdef0123456789abcdef01234567", + "revision": 12, + "source": 3589, + "fingerprint": "fp-0123" + } + }, { "name": "input asks a composition step's input by digest", "of": "verb:input.input", diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json index 597df58f..09488de3 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json @@ -54,7 +54,7 @@ }, { "name": "revision", - "description": "The assignment half of the revision view (ADR 0656 \u00a76): one assignment graph revision, named by its own number and naming its inputs, with its entries' digests; the trunk's newest when none is named, or a candidate's for its group and heads. Reads only.", + "description": "The assignment half of the revision view (ADR 0656 §6): one assignment graph revision, named by its own number and naming its inputs, with its entries' digests; the trunk's newest when none is named, or a candidate's for its group and heads. Reads only.", "input": { "type": "object", "properties": { @@ -201,7 +201,7 @@ { "name": "compositions", "class": "read", - "description": "Each composition run the assigner keeps (design 47 G \u00a7728): its program, input digest, ask, readers, outcome and verdict, and the state's fill against its cap; with candidate or machine, only those.", + "description": "Each composition run the assigner keeps (design 47 G §728): its program, input digest, ask, readers, outcome and verdict, and the state's fill against its cap; with candidate or machine, only those.", "input": { "type": "object", "properties": { @@ -236,7 +236,7 @@ { "name": "compositions-drop", "class": "act", - "description": "Drop one composition run by hand (design 47 G \u00a7728): the act and why are written in the hand-act log first, then the run's ask is dropped, each reader ended could not run naming the drop, and the key deleted.", + "description": "Drop one composition run by hand (design 47 G §728): the act and why are written in the hand-act log first, then the run's ask is dropped, each reader ended could not run naming the drop, and the key deleted.", "input": { "type": "object", "properties": { @@ -404,6 +404,10 @@ "fp": { "type": "string" }, + "pipeline": { + "type": "string", + "description": "the pipeline whose passed end the want was written from, its key .; absent for a placement's build (design 47 H-A-56)" + }, "revision": { "type": "integer" }, @@ -428,6 +432,17 @@ ] } }, + { + "name": "pipeline-wanted", + "subject": "pipeline-wanted..", + "keep": { + "max-age-days": 30, + "max-mib": 64 + }, + "body": { + "$ref": "#/defs/PipelineWanted" + } + }, { "name": "wait-held", "body": { @@ -469,54 +484,6 @@ "max-mib": 32 } }, - { - "name": "version-delivered", - "keep": { - "max-age-days": 90, - "max-mib": 64 - }, - "body": { - "type": "object", - "description": "a version delivered to every present machine that places it, and healthy (design 47 G section 376)", - "properties": { - "v": { - "type": "integer" - }, - "module": { - "type": "string", - "description": "the module" - }, - "version": { - "type": "string", - "description": "MAJOR.MINOR.PATCH" - }, - "parts": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "the digest of each of its parts, by `:`" - }, - "away": { - "type": "array", - "items": { - "type": "string" - }, - "description": "the machines away when it was said" - }, - "at": { - "type": "string", - "format": "date-time" - } - }, - "required": [ - "v", - "module", - "version", - "parts" - ] - } - }, { "name": "step-progress", "subject": "step-progress.", @@ -548,7 +515,7 @@ "items": { "$ref": "#/defs/Shared" }, - "description": "the composition runs the step waits on, by machine, each with its ask (design 47 G \u00a7723, \u00a7729)" + "description": "the composition runs the step waits on, by machine, each with its ask (design 47 G §723, §729)" } }, "required": [ @@ -574,7 +541,7 @@ "key": "want..", "value": { "type": "object", - "description": "a node's want for a module", + "description": "a node's want for a module: the build it should run by its fingerprint and released version, with the pipeline and rank it was written from (design 47 H §750)", "properties": { "v": { "type": "integer" @@ -582,19 +549,9 @@ "fp": { "type": "string" }, - "composed": { - "type": "string" - }, "removed": { "type": "boolean" }, - "newest": { - "type": "string" - }, - "rule": { - "type": "integer", - "description": "the rule that holds the node back, 1 to 10" - }, "backup": { "type": "string", "description": "again or skip", @@ -630,18 +587,16 @@ }, "version": { "type": "string", - "description": "the module's released version, for people; none for a build of another watched branch (design 47 G section 379)" + "description": "the version released at the build the want names: the newest released on the placement's branch whose pipeline passed, or the placement's build's (design 47 H §750)" }, - "parts": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "the digest of each of the module's parts, by `:`; the node-engine fetches and checks each part by it (design 47 G section 379)" - }, - "kept-on": { + "pipeline": { "type": "string", - "description": "for a kept build, the build node that keeps it, from the builder's build.ended; the node-engine fetches the build through that node's seat verb kept-artifact, and a want with none from the store (design 47 G section 526)" + "description": "the pipeline whose passed end released the version, its key .; absent for a placement's build (design 47 H §750, H-A-37)" + }, + "rank": { + "type": "integer", + "minimum": 1, + "description": "the mover's tier in that pipeline's delivery order, from 1; the node-engine applies one pipeline's wants by it; absent with pipeline (design 47 H §750, §771, H-A-37)" } } }, @@ -1220,7 +1175,7 @@ "$ref": "#/defs/NodeEntryRef" } }, - "description": "the order as a view: each tier the changes whose acting parts acted in the tiers before it (ADR 0603 \u00a76 as ADR 0656 changes it)" + "description": "the order as a view: each tier the changes whose acting parts acted in the tiers before it (ADR 0603 §6 as ADR 0656 changes it)" }, "refused": { "type": "array", @@ -1371,15 +1326,16 @@ }, "StepRun": { "type": "object", - "description": "the composition step of one module's pipeline (design 47 *Pipeline steps and the policy*, *The pipeline makes the check*): the assigner composes each machine's declaration at the change's heads with the composer built from them, in the build seat's sandbox, and refuses a change in which two modules own one path", + "description": "a pipeline step of one mover the assigner serves (design 47 H §745, G §22): validate, the manifest validator built from the take-in's heads run over the revision's manifests, before composition, each machine's declaration composed at the change's heads with the composer built from them, both in the build seat's sandbox", "properties": { "pipeline": { "type": "string", - "description": "the runner's pipeline key, .., a branch escaped as a key's name is" + "description": "the runner's pipeline key, ., a branch escaped as a key's name is (design 47 H §746)" }, "step": { "type": "string", "enum": [ + "validate", "composition" ] }, @@ -1430,7 +1386,7 @@ }, "StepEnded": { "type": "object", - "description": "the composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at", + "description": "a validate or composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at", "properties": { "v": { "type": "integer", @@ -1446,6 +1402,7 @@ "step": { "type": "string", "enum": [ + "validate", "composition" ] }, @@ -1474,7 +1431,7 @@ }, "said": { "type": "string", - "description": "why it failed or could not run: the two modules owning one path, the part not heard" + "description": "why it failed or could not run: each manifest problem, the cycle the revision makes, the two modules owning one path, the part not heard (design 47 H §745)" }, "warnings": { "type": "array", @@ -1503,7 +1460,7 @@ "items": { "$ref": "#/defs/Shared" }, - "description": "per machine composed, the composition run the step read, its ask and so where its verdict was taken (design 47 G \u00a7723, \u00a7729)" + "description": "per machine composed, the composition run the step read, its ask and so where its verdict was taken (design 47 G §723, §729)" } }, "required": [ @@ -1561,7 +1518,7 @@ }, "Shared": { "type": "object", - "description": "a run whose result a step took or waits on, asked once for every step that reads it (design 47 G \u00a7729, A-469t): for a composition step one per machine composed, `run` the `composition-runs` key and `ask` its run ask's id; for a test step one with no machine, `run` the `test-runs` key, `ask` its build seat ask's id and `asked-by` the step that asked the run, left out for that step itself", + "description": "a run whose result a step took or waits on, asked once for every step that reads it (design 47 G §729, A-469t): for a composition step one per machine composed, `run` the `composition-runs` key and `ask` its run ask's id; for a test step one with no machine, `run` the `test-runs` key, `ask` its build seat ask's id and `asked-by` the step that asked the run, left out for that step itself", "properties": { "machine": { "type": "string", @@ -1601,7 +1558,7 @@ }, "CompositionReader": { "type": "object", - "description": "a composition step reading a composition run: its step, as the runner asked it, with its ask's id (design 47 G \u00a7719, A-468)", + "description": "a composition step reading a composition run: its step, as the runner asked it, with its ask's id (design 47 G §719, A-468)", "properties": { "id": { "type": "string", @@ -1670,7 +1627,7 @@ }, "CompositionRun": { "type": "object", - "description": "one composition run of a candidate and a machine, a key of the assigner's state composition-runs (design 47 G \u00a7719, \u00a7728; A-469u)", + "description": "one composition run of a candidate and a machine, a key of the assigner's state composition-runs (design 47 G §719, §728; A-469u)", "properties": { "key": { "type": "string", @@ -1739,7 +1696,7 @@ }, "verdict": { "type": "object", - "description": "that machine's composer verdict (design 47 G \u00a7721)" + "description": "that machine's composer verdict (design 47 G §721)" } }, "required": [ @@ -1747,6 +1704,66 @@ "candidate", "machine" ] + }, + "PipelineWanted": { + "type": "object", + "description": "a pipeline's wants written to the end, said once: running when every tier's movers run on every present placing machine, tier-late when a tier passed tier-bound (design 47 H §751, H-A-56, H-A-72, H-A-75)", + "properties": { + "v": { + "type": "integer" + }, + "pipeline": { + "type": "string", + "description": "the runner's pipeline key, ., a branch escaped as a key's name is (design 47 H §746)" + }, + "branch": { + "type": "string" + }, + "source": { + "type": "integer" + }, + "outcome": { + "type": "string", + "enum": [ + "running", + "tier-late" + ] + }, + "not-running": { + "type": "array", + "items": { + "$ref": "#/defs/NotRunning" + }, + "description": "for tier-late, the late tier's movers not running and the machines they do not run on" + } + }, + "required": [ + "v", + "pipeline", + "branch", + "source", + "outcome" + ] + }, + "NotRunning": { + "type": "object", + "description": "a mover of a late tier and the placing machines it does not run on", + "properties": { + "module": { + "type": "string" + }, + "machines": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + } + }, + "required": [ + "module", + "machines" + ] } }, "acts": [ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts index 6e043fcf..c8112c2e 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts @@ -24,13 +24,13 @@ export declare const events: { readonly assignmentRevision: "assignment-revision"; readonly difference: "difference"; readonly wanted: "wanted"; + readonly pipelineWanted: "pipeline-wanted"; readonly waitHeld: "wait-held"; readonly waitEnded: "wait-ended"; readonly filling: "filling"; readonly full: "full"; readonly room: "room"; readonly stepEnded: "step-ended"; - readonly versionDelivered: "version-delivered"; readonly stepProgress: "step-progress"; }; @@ -48,6 +48,12 @@ export declare function wantedSubject(node: string, module: string): string; export declare const wantedSubjectAll: "mesh.seat.mesh-wants.event.wanted.*.*"; +export declare const pipelineWantedStream: "SEAT_mesh-wants_pipeline-wanted"; + +export declare function pipelineWantedSubject(branch: string, source: string): string; + +export declare const pipelineWantedSubjectAll: "mesh.seat.mesh-wants.event.pipeline-wanted.*.*"; + export declare const waitHeldSubject: "mesh.seat.mesh-wants.event.wait-held"; export declare const waitEndedSubject: "mesh.seat.mesh-wants.event.wait-ended"; @@ -64,10 +70,6 @@ export declare function stepEndedSubject(node: string): string; export declare const stepEndedSubjectAll: "mesh.seat.mesh-wants.event.step-ended.*"; -export declare const versionDeliveredStream: "SEAT_mesh-wants_version-delivered"; - -export declare const versionDeliveredSubject: "mesh.seat.mesh-wants.event.version-delivered"; - export declare function stepProgressSubject(node: string): string; export declare const stepProgressSubjectAll: "mesh.seat.mesh-wants.event.step-progress.*"; @@ -396,6 +398,24 @@ export interface NodeEntryRef { "node": string; } +/** a mover of a late tier and the placing machines it does not run on */ +export interface NotRunning { + "machines": string[]; + "module": string; +} + +/** a pipeline's wants written to the end, said once: running when every tier's movers run on every present placing machine, tier-late when a tier passed tier-bound (design 47 H §751, H-A-56, H-A-72, H-A-75) */ +export interface PipelineWanted { + "branch": string; + /** for tier-late, the late tier's movers not running and the machines they do not run on */ + "not-running"?: NotRunning[]; + "outcome": "running" | "tier-late"; + /** the runner's pipeline key, ., a branch escaped as a key's name is (design 47 H §746) */ + "pipeline": string; + "source": number; + "v": number; +} + /** the step that asked the run, for a test step reading another's run */ export interface SharedAskedBy { /** its artifact, : */ @@ -416,7 +436,7 @@ export interface Shared { "run": string; } -/** the composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at */ +/** a validate or composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at */ export interface StepEnded { /** for a rerun, the caller the runtime proved */ "by"?: string; @@ -432,19 +452,19 @@ export interface StepEnded { "outcome": "passed" | "failed" | "nothing to run" | "could not run"; "pipeline": string; "rerun"?: boolean; - /** why it failed or could not run: the two modules owning one path, the part not heard */ + /** why it failed or could not run: each manifest problem, the cycle the revision makes, the two modules owning one path, the part not heard (design 47 H §745) */ "said"?: string; /** per machine composed, the composition run the step read, its ask and so where its verdict was taken (design 47 G §723, §729) */ "shared"?: Shared[]; "started"?: string; - "step": "composition"; + "step": "validate" | "composition"; /** the layout version */ "v"?: number; /** a node asleep, passed with a warning (ADR 0593 section 9) */ "warnings"?: string[]; } -/** the composition step of one module's pipeline (design 47 *Pipeline steps and the policy*, *The pipeline makes the check*): the assigner composes each machine's declaration at the change's heads with the composer built from them, in the build seat's sandbox, and refuses a change in which two modules own one path */ +/** a pipeline step of one mover the assigner serves (design 47 H §745, G §22): validate, the manifest validator built from the take-in's heads run over the revision's manifests, before composition, each machine's declaration composed at the change's heads with the composer built from them, both in the build seat's sandbox */ export interface StepRun { /** the watched branch, or the branch of a run on request */ "branch": string; @@ -455,7 +475,7 @@ export interface StepRun { /** the module's build-input fingerprint at the commit */ "fingerprint": string; "module": string; - /** the runner's pipeline key, .., a branch escaped as a key's name is */ + /** the runner's pipeline key, ., a branch escaped as a key's name is (design 47 H §746) */ "pipeline": string; /** the step is asked again by the runner's rerun */ "rerun"?: boolean; @@ -465,7 +485,7 @@ export interface StepRun { "run"?: string; /** the source revision of the watched branch; absent for a run on request */ "source"?: number; - "step": "composition"; + "step": "validate" | "composition"; } /** a step's wait the assigner holds: placing, wanting or composing until an acting part's new version runs; the builder's toolchain wait is of this type too, with step build (design 47 G section 702) */ @@ -652,6 +672,8 @@ export interface WantedEvent { "fp": string; "module": string; "node": string; + /** the pipeline whose passed end the want was written from, its key .; absent for a placement's build (design 47 H-A-56) */ + "pipeline"?: string; /** true when the assigner removes the want of that node and module (the node left, or the module was unplaced); fp is then the fingerprint last wanted there (design 47 G section 693) */ "removed"?: boolean; "revision": number; @@ -659,6 +681,9 @@ export interface WantedEvent { "v": number; } +/** is the body of the event pipeline-wanted. */ +export type PipelineWantedEvent = PipelineWanted; + /** is the body of the event wait-held. */ export type WaitHeldEvent = Wait; @@ -677,20 +702,6 @@ export type RoomEvent = Fill; /** is the body of the event step-ended. */ export type StepEndedEvent = StepEnded; -/** is the body of the event version-delivered. */ -export interface VersionDeliveredEvent { - "at"?: string; - /** the machines away when it was said */ - "away"?: string[]; - /** the module */ - "module": string; - /** the digest of each of its parts, by `:` */ - "parts": Record; - "v": number; - /** MAJOR.MINOR.PATCH */ - "version": string; -} - /** is the body of the event step-progress. */ export interface StepProgressEvent { "ask": string; @@ -705,24 +716,20 @@ export interface StepProgressEvent { export interface WantsByWantNodeModuleValue { /** again or skip */ "backup"?: "again" | "skip"; - "composed"?: string; "fp"?: string; "hold"?: boolean; - /** for a kept build, the build node that keeps it, from the builder's build.ended; the node-engine fetches the build through that node's seat verb kept-artifact, and a want with none from the store (design 47 G section 526) */ - "kept-on"?: string; - "newest"?: string; - /** the digest of each of the module's parts, by `:`; the node-engine fetches and checks each part by it (design 47 G section 379) */ - "parts"?: Record; + /** the pipeline whose passed end released the version, its key .; absent for a placement's build (design 47 H §750, H-A-37) */ + "pipeline"?: string; "put"?: boolean; + /** the mover's tier in that pipeline's delivery order, from 1; the node-engine applies one pipeline's wants by it; absent with pipeline (design 47 H §750, §771, H-A-37) */ + "rank"?: number; "release"?: string; "removed"?: boolean; /** live: the operator's answer to a held revert, to start the reverted build on the live data as it is, with nothing restored (design 47 G section 710) */ "revert"?: "live"; - /** the rule that holds the node back, 1 to 10 */ - "rule"?: number; "self"?: boolean; "v"?: number; - /** the module's released version, for people; none for a build of another watched branch (design 47 G section 379) */ + /** the version released at the build the want names: the newest released on the placement's branch whose pipeline passed, or the placement's build's (design 47 H §750) */ "version"?: string; "words"?: string; "yes"?: string; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js index 391640d1..a544df9a 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js @@ -24,13 +24,13 @@ export const events = { assignmentRevision: "assignment-revision", difference: "difference", wanted: "wanted", + pipelineWanted: "pipeline-wanted", waitHeld: "wait-held", waitEnded: "wait-ended", filling: "filling", full: "full", room: "room", stepEnded: "step-ended", - versionDelivered: "version-delivered", stepProgress: "step-progress", }; @@ -50,6 +50,14 @@ export function wantedSubject(node, module) { export const wantedSubjectAll = "mesh.seat.mesh-wants.event.wanted.*.*"; +export const pipelineWantedStream = "SEAT_mesh-wants_pipeline-wanted"; + +export function pipelineWantedSubject(branch, source) { + return "mesh.seat.mesh-wants.event.pipeline-wanted." + branch + "." + source; +} + +export const pipelineWantedSubjectAll = "mesh.seat.mesh-wants.event.pipeline-wanted.*.*"; + export const waitHeldSubject = "mesh.seat.mesh-wants.event.wait-held"; export const waitEndedSubject = "mesh.seat.mesh-wants.event.wait-ended"; @@ -68,10 +76,6 @@ export function stepEndedSubject(node) { export const stepEndedSubjectAll = "mesh.seat.mesh-wants.event.step-ended.*"; -export const versionDeliveredStream = "SEAT_mesh-wants_version-delivered"; - -export const versionDeliveredSubject = "mesh.seat.mesh-wants.event.version-delivered"; - export function stepProgressSubject(node) { return "mesh.seat.mesh-wants.event.step-progress." + node; } -- 2.54.0 From 83d454217fb3343f7b68132cf5e1aff78423be5b Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:09:01 +0100 Subject: [PATCH 012/104] steprun: the asker judgement goes; every asker's kind is taken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The step runner no longer reads the seat list for the callers a build seat's definition lists, refuses an asker it does not name, or gives an ask back until the list says: Puller.Callers, CallersFromDefinitions, SeatListCallers and the seat list reader's start go, since no seat definition names callers and every account may call every verb. The step is still keyed under the asker its subject names, and main's subject still takes only a build, a run and the checker's check and recheck. mesh-delivery-sdk builds again against mesh-sdk without seatdef callers. Builds: design 47 H §752, §764 (every seat contract: the callers lists); lead answers H-A-41, H-A-66, H-A-71 (3) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- modules/mesh-delivery-sdk/steprun/askers.go | 156 ++---------------- .../mesh-delivery-sdk/steprun/askers_test.go | 86 ++-------- modules/mesh-delivery-sdk/steprun/pull.go | 8 +- 3 files changed, 24 insertions(+), 226 deletions(-) diff --git a/modules/mesh-delivery-sdk/steprun/askers.go b/modules/mesh-delivery-sdk/steprun/askers.go index 2f8caa64..76eaf2a0 100644 --- a/modules/mesh-delivery-sdk/steprun/askers.go +++ b/modules/mesh-delivery-sdk/steprun/askers.go @@ -3,22 +3,15 @@ package steprun import ( "encoding/json" "fmt" - "slices" - "strings" - "sync/atomic" - "time" buildrun "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildrun" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/seatdef" - "git.novox.be/novox/mesh-sdk/go/seatlist" ) -// **A holder refuses a kind its asker may not ask** (design 47 G §543, A-163, A-170). An ask rides -// `mesh.seat..accept..`, the asker the asking seat's own name, and its kind stays in its body. The -// holder takes the asker from the subject and checks the kind against the callers the seat's definition lists for it (read -// from the seat list); on main's subject, which names no asker, it takes only a build and a run. +// **A holder takes every asker's kind** (design 47 H §752, H-A-41: every account may call every verb; the asker judgement +// goes). An ask rides `mesh.seat..accept..`, the asker the asking seat's own name, and its kind stays in +// its body; the holder keys the step under that asker (design 47 G §481). On main's subject, which names no asker, it takes +// only a build and a run (design 47 G §543, A-184). // KindOf is the word the seat definition gives an ask's kind: run for a run or a compose, else the ask's own kind. func KindOf(ask sdkstep.StepAsk) string { @@ -28,67 +21,24 @@ func KindOf(ask sdkstep.StepAsk) string { return ask.Kind } -// CallersFromDefinitions is a Puller.Callers: the seats the definition of language's build seat lists as callers of an -// accepted kind, from the seat list's definitions (seatlist.Reader.Definitions). found is false when the definition or the -// kind is not held yet. A caller entry is `seat:`. -func CallersFromDefinitions(language string, definitions func() map[string]seatdef.Definition) func(kind string) (callers []string, found bool) { - return func(kind string) ([]string, bool) { - seat, err := sdkstep.BuildSeat(language) - if err != nil { - return nil, false - } - def, ok := definitions()[seat] - if !ok { - return nil, false - } - var out []string - found := false - for _, m := range def.Accepts { - if m.Name != kind { - continue - } - found = true - if m.Callers != nil { - for _, e := range m.Callers.List { - if name, ok := strings.CutPrefix(e, "seat:"); ok { - out = append(out, name) - } - } - } - } - return out, found - } -} - -// askerRefusal is why an ask must not be taken from its subject's asker: "" when it may be, and judged false when the seat -// list does not say yet (the ask is given back, not refused). -func (p *Puller) askerRefusal(msg *Pulled, ask sdkstep.StepAsk) (why string, judged bool) { +// askerRefusal is why an ask must not be taken from its subject: "" when it may be. Any named asker may ask any kind. +func (p *Puller) askerRefusal(msg *Pulled, ask sdkstep.StepAsk) (why string) { if msg.Subject == "" { - return "", true // a source that gives no subject (a test's) + return "" // a source that gives no subject (a test's) } _, _, asker, err := sdkstep.ParseAskSubjectBy(msg.Subject) if err != nil { - return fmt.Sprintf("the ask came on %s, which is no accept subject of this seat", msg.Subject), true + return fmt.Sprintf("the ask came on %s, which is no accept subject of this seat", msg.Subject) } kind := KindOf(ask) if asker == "" { // Main's subject takes a build, a run and, until it goes, the checker's check and recheck (design 47 G A-184, §543). if (ask.Build != nil && ask.Kind == sdkstep.AskDelivery) || kind == "run" || kind == sdkstep.AskCheck || kind == sdkstep.AskRecheck { - return "", true + return "" } - return fmt.Sprintf("the kind %s is not taken on main's subject, which takes only a build, a run and the checker's check and recheck (asker: none named)", kind), true + return fmt.Sprintf("the kind %s is not taken on main's subject, which takes only a build, a run and the checker's check and recheck (asker: none named)", kind) } - if p.Callers == nil { - return "", true - } - callers, found := p.Callers(kind) - if !found { - return "", false - } - if !slices.Contains(callers, asker) { - return fmt.Sprintf("the kind %s is not one %s may ask: its callers are %s", kind, asker, strings.Join(callers, ", ")), true - } - return "", true + return "" } // refuseAsker ends an ask whose asker may not ask its kind: its step key says failed with the reason, naming the kind and the @@ -143,87 +93,3 @@ func PriorRuns(get func(key string) (json.RawMessage, error)) func(string) int { return s.Run } } - -// giveBack hands an ask back to be judged again a little later, once the seat list says more. Why it cannot be judged is -// said once per change by the callers (SeatListCallers), not once per ask. -func (p *Puller) giveBack(msg *Pulled, ask sdkstep.StepAsk) { - if msg.NakAfter != nil && msg.NakAfter(DefaultPullWait) == nil { - return - } - _ = msg.Nak() -} - -// Seat list start retries: the first wait and its cap (a failed start is tried again, 1s doubling to 1 minute). -const ( - seatListRetryFirst = time.Second - seatListRetryMax = time.Minute -) - -// startSeatList tries start until it succeeds: each failure is said with its next try, the success once. wait is the -// pause a test replaces; the reader is returned once started (design 47 G §543, A-163, lead-47 2026-11-15: the reader's -// start is retried). -func startSeatList(start func() (*seatlist.Reader, error), wait func(time.Duration), logf func(format string, args ...any)) *seatlist.Reader { - if logf == nil { - logf = func(string, ...any) {} - } - delay := seatListRetryFirst - for { - r, err := start() - if err == nil { - logf("the seat list is followed") - return r - } - logf("following the seat list: %v; the asks are given back, the next try in %s", err, delay) - wait(delay) - delay = min(delay*2, seatListRetryMax) - } -} - -// SeatListCallers is a Puller.Callers that follows the seat list: it starts the reader once the runtime serves -// (seatlist.Start through the runtime's own way in) and answers from its definitions, found false until it has read them. -// A reader that cannot start is said and tried again with backoff while the asks are given back (design 47 G §543, A-163); -// why an ask is given back (reader not started, definition of the seat not held, kind not in it) is said once per change. -func SeatListCallers(language string, logf func(format string, args ...any)) func(kind string) ([]string, bool) { - var reader atomic.Pointer[seatlist.Reader] - go func() { - <-stdio.Served() - reader.Store(startSeatList(func() (*seatlist.Reader, error) { - return seatlist.Start(seatlist.Config{Bus: seatlist.StdioBus(), Bootstrap: seatlist.Bootstrapped()}) - }, time.Sleep, logf)) - }() - return callersOf(language, reader.Load, logf) -} - -// callersOf answers from the reader once started, saying once per change why a kind is not found. -func callersOf(language string, reader func() *seatlist.Reader, logf func(format string, args ...any)) func(kind string) ([]string, bool) { - var said atomic.Value // the last reason said - say := func(why string) { - if prev, _ := said.Swap(why).(string); prev != why && logf != nil { - logf("the asks are given back: %s", why) - } - } - return func(kind string) ([]string, bool) { - r := reader() - if r == nil { - say("the seat list reader is not started yet") - return nil, false - } - defs := r.Definitions() - seat, err := sdkstep.BuildSeat(language) - if err != nil { - say("the build seat of " + language + " is unknown: " + err.Error()) - return nil, false - } - if _, ok := defs[seat]; !ok { - say("the seat list holds no definition of the seat " + seat) - return nil, false - } - callers, found := CallersFromDefinitions(language, func() map[string]seatdef.Definition { return defs })(kind) - if !found { - say("the definition of " + seat + " does not accept the kind " + kind) - } else { - said.Store("") - } - return callers, found - } -} diff --git a/modules/mesh-delivery-sdk/steprun/askers_test.go b/modules/mesh-delivery-sdk/steprun/askers_test.go index eac24966..1057c63e 100644 --- a/modules/mesh-delivery-sdk/steprun/askers_test.go +++ b/modules/mesh-delivery-sdk/steprun/askers_test.go @@ -2,45 +2,34 @@ package steprun import ( "context" - "fmt" "strings" "testing" "time" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-sdk/go/seatdef" - "git.novox.be/novox/mesh-sdk/go/seatlist" ) -func callersFor(table map[string][]string) func(string) ([]string, bool) { - return func(kind string) ([]string, bool) { c, ok := table[kind]; return c, ok } -} - -// Design 47 G §543 (BG2, BG3, A-163, A-170): an ask whose kind its asker, the last token of its subject, is no caller of is -// answered error naming the kind and the asker and ended failed; a step on main's subject is refused as well (its check and recheck -// taken, A-184); one the -// seat list does not judge yet is given back. -func TestPullRefusesAKindItsAskerMayNotAsk(t *testing.T) { +// Design 47 H §752, H-A-41: every account may ask every kind, so an ask of any asker its subject names runs, keyed under +// that asker, and none is given back to be judged; a step on main's subject, which names no asker, is refused (design 47 G +// §543, A-184: main's subject takes a build, a run and the checker's check and recheck). +func TestPullTakesEveryAskersKind(t *testing.T) { step := testAsk(sdkstep.AskStep) step.Check = nil step.Step = &sdkstep.StepRun{Pipeline: "p", Step: sdkstep.StepUnit, Module: "m", Artifact: "m:a", Commit: "0123456789abcdef0123456789abcdef01234567", Fingerprint: "fp", Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: "0123456789abcdef0123456789abcdef01234567"}} build := testAsk(sdkstep.AskDelivery) - table := map[string][]string{"step": {"mesh-pipeline-runner"}, "delivery": {"mesh-builds"}} for _, c := range []struct { name, subject string ask sdkstep.StepAsk - callers func(string) ([]string, bool) - want string // "" runs it, "refused" refuses it, "back" gives it back + want string // "" runs it, "refused" refuses it }{ - {"the indexer's step", "mesh.seat.node-build-go.accept.check.mesh-catalog", step, callersFor(table), "refused"}, - {"the runner's step", "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner", step, callersFor(table), ""}, - {"a step on main's subject", "mesh.seat.node-build-go.accept.check", step, callersFor(table), "refused"}, - {"a build on main's subject", "mesh.seat.node-build-go.accept.delivery", build, callersFor(table), ""}, + {"the indexer's step", "mesh.seat.node-build-go.accept.check.mesh-catalog", step, ""}, + {"the runner's step", "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner", step, ""}, + {"a step on main's subject", "mesh.seat.node-build-go.accept.check", step, "refused"}, + {"a build on main's subject", "mesh.seat.node-build-go.accept.delivery", build, ""}, // A-184: until main's subject goes, it also takes the checker's check and recheck asks. - {"the checker's check on main's subject", "mesh.seat.node-build-go.accept.check", testAsk(sdkstep.AskCheck), callersFor(table), ""}, - {"the checker's recheck on main's subject", "mesh.seat.node-build-go.accept.recheck", testAsk(sdkstep.AskRecheck), callersFor(table), ""}, - {"a kind the seat list does not hold", "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner", step, callersFor(nil), "back"}, + {"the checker's check on main's subject", "mesh.seat.node-build-go.accept.check", testAsk(sdkstep.AskCheck), ""}, + {"the checker's recheck on main's subject", "mesh.seat.node-build-go.accept.recheck", testAsk(sdkstep.AskRecheck), ""}, } { t.Run(c.name, func(t *testing.T) { src, st, sy := NewFakeAsks(), newSteps(), &sayer{} @@ -52,7 +41,7 @@ func TestPullRefusesAKindItsAskerMayNotAsk(t *testing.T) { src.PublishWithSubject(queue, raw, c.subject) _, _, asker, _ := sdkstep.ParseAskSubjectBy(c.subject) ran := make(chan struct{}, 1) - p := &Puller{Source: src, Language: sdkstep.AskGo, Node: "shanks", Put: st.put, Capacity: func() int { return 1 }, Callers: c.callers, + p := &Puller{Source: src, Language: sdkstep.AskGo, Node: "shanks", Put: st.put, Capacity: func() int { return 1 }, PullWait: 5 * time.Millisecond, Heartbeat: time.Hour, Say: sy.say, ProgressEvery: time.Hour, Run: func(context.Context, sdkstep.StepAsk) (any, error) { ran <- struct{}{}; return nil, nil }} ctx, cancel := context.WithCancel(context.Background()) @@ -79,58 +68,7 @@ func TestPullRefusesAKindItsAskerMayNotAsk(t *testing.T) { t.Fatal("a refused ask ran") default: } - case "back": - waitFor(t, "the ask given back", func() bool { src.mu.Lock(); defer src.mu.Unlock(); return len(src.Delayed) > 0 }) } }) } } - -func TestCallersFromDefinitionsReadsTheSeatsCallers(t *testing.T) { - def := seatdef.Definition{Seat: "node-build-go", Accepts: []seatdef.Message{ - {Name: "step", Callers: &seatdef.Callers{List: []string{"seat:mesh-pipeline-runner"}}}}} - callers := CallersFromDefinitions(sdkstep.AskGo, func() map[string]seatdef.Definition { return map[string]seatdef.Definition{"node-build-go": def} }) - if got, ok := callers("step"); !ok || len(got) != 1 || got[0] != "mesh-pipeline-runner" { - t.Fatalf("callers of step = %v, %v", got, ok) - } - if _, ok := callers("run"); ok { - t.Fatal("a kind the definition does not list is found") - } -} - -func TestStartSeatListRetriesWithBackoffAndSaysIt(t *testing.T) { - var lines []string - var waits []time.Duration - tries := 0 - start := func() (*seatlist.Reader, error) { - tries++ - if tries <= 8 { - return nil, fmt.Errorf("binding the consumer: context deadline exceeded") - } - return &seatlist.Reader{}, nil - } - r := startSeatList(start, func(d time.Duration) { waits = append(waits, d) }, func(f string, a ...any) { lines = append(lines, fmt.Sprintf(f, a...)) }) - if r == nil || tries != 9 || len(waits) != 8 { - t.Fatalf("reader %v tries %d waits %v", r, tries, waits) - } - if waits[0] != time.Second || waits[1] != 2*time.Second || waits[7] != time.Minute { - t.Fatalf("waits = %v, want 1s doubling to 1m", waits) - } - if len(lines) != 9 || !strings.Contains(lines[0], "next try in 1s") || lines[8] != "the seat list is followed" { - t.Fatalf("lines = %q", lines) - } -} - -func TestCallersOfSaysWhyOncePerChange(t *testing.T) { - var lines []string - var r *seatlist.Reader - c := callersOf(sdkstep.AskGo, func() *seatlist.Reader { return r }, func(f string, a ...any) { lines = append(lines, fmt.Sprintf(f, a...)) }) - for range 3 { - if _, ok := c("step"); ok { - t.Fatal("found without a reader") - } - } - if len(lines) != 1 || !strings.Contains(lines[0], "not started yet") { - t.Fatalf("lines = %q", lines) - } -} diff --git a/modules/mesh-delivery-sdk/steprun/pull.go b/modules/mesh-delivery-sdk/steprun/pull.go index d753a92b..72ef627d 100644 --- a/modules/mesh-delivery-sdk/steprun/pull.go +++ b/modules/mesh-delivery-sdk/steprun/pull.go @@ -87,9 +87,6 @@ type Puller struct { // as the object named object, which the key and a run's step-ended name and the seat's verb `output` answers (A-254); a // holder keeps it in the object store its manifest requires. Nil keeps none: such an answer ends the ask failed, saying so. KeepOutput func(object string, body []byte) error - // Callers says which seats the build seat's definition lists as callers of an accepted kind (CallersFromDefinitions); - // found is false while the seat list holds no such kind. Nil checks no named asker (design 47 G §543, A-163). - Callers func(kind string) (callers []string, found bool) // Prior says how many runs of the ask under a step key started before (the Run of the step the key holds, PriorRuns; 0 for // none), so the poison rule and the transport fault's run count only runs that started, never an ask given back before it // ran. Nil counts the bus's deliveries (a test's). @@ -710,10 +707,7 @@ func (p *Puller) take(ctx context.Context, msg *Pulled) { p.endUnrun(msg, ask, key, step, prior) return } - if why, judged := p.askerRefusal(msg, ask); !judged { - p.giveBack(msg, ask) - return - } else if why != "" { + if why := p.askerRefusal(msg, ask); why != "" { p.refuseAsker(msg, ask, why) return } -- 2.54.0 From f9fa0ec2b217969c5e7a3bfff2bac8b24f848f54 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:09:23 +0100 Subject: [PATCH 013/104] C-W: a want awaiting its hand placement is held MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The assigner holds the want of a node whose node-engine does not state want:version in the want's hold field, its words awaits-hand-placement; the client takes that hold beside a put's and refuses a hold with other words. Builds: design 47 H §772; lead answer H-A-73 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/clients/meshwantsclient/wants.go | 8 ++++++-- .../go/clients/meshwantsclient/wants_test.go | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go index 700a2eb3..5d7f8e6b 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go @@ -52,6 +52,10 @@ const ( // nothing restored (design 47 G §710). const RevertLive = seat.WantsByWantNodeModuleValueRevertLive +// HoldAwaitsHandPlacement is the words of a want the assigner holds for a node whose node-engine does not state +// want:version: it awaits its hand placement (design 47 H §772, H-A-73). Beside a put it is the one held want. +const HoldAwaitsHandPlacement = "awaits-hand-placement" + // NodeWord is the last part of a node's own key. const NodeWord = "node" @@ -178,8 +182,8 @@ func checkWant(w Want) error { } return nil } - if w.Hold && !w.Put { - return fmt.Errorf("wants: only a put holds a want") + if w.Hold && !w.Put && w.Words != HoldAwaitsHandPlacement { + return fmt.Errorf("wants: only a put, or a want awaiting its hand placement (%s), holds a want", HoldAwaitsHandPlacement) } if err := checkFingerprint(w.Fp, "a want's fingerprint"); err != nil { return err diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go index 76038e62..c967aace 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go @@ -43,6 +43,8 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { "revert": {Want{Fp: a, Self: true, Revert: RevertLive, Words: "live"}, `{"v":1,"fp":"` + a + `","revert":"live","words":"live","self":true}`}, "removed": {Want{Removed: true, Words: "gone"}, `{"v":1,"removed":true,"words":"gone"}`}, "a placement's build": {Want{Fp: a, Version: "0.1.14"}, `{"v":1,"fp":"` + a + `","version":"0.1.14"}`}, + // design 47 H §772, H-A-73: a node whose node-engine reads no want by version is held, awaiting its hand placement. + "awaits its hand placement": {Want{Fp: a, Version: "0.1.15", Pipeline: "main.3589", Rank: 1, Hold: true, Words: HoldAwaitsHandPlacement}, `{"v":1,"fp":"` + a + `","version":"0.1.15","pipeline":"main.3589","rank":1,"hold":true,"words":"awaits-hand-placement"}`}, } { t.Run(name, func(t *testing.T) { raw, err := EncodeWant(row.w) @@ -61,6 +63,7 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { for name, w := range map[string]Want{ "old fingerprint": {Fp: "src1:abc"}, "hold without put": {Fp: a, Self: true, Hold: true}, + "hold with other words": {Fp: a, Hold: true, Words: "awaits"}, "rank without pipeline": {Fp: a, Rank: 1}, "pipeline without rank": {Fp: a, Pipeline: "main.3589"}, "rank below 1": {Fp: a, Pipeline: "main.3589", Rank: -1}, -- 2.54.0 From 630c099972e1acb7b1282353615eb51573f2097d Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:13:15 +0100 Subject: [PATCH 014/104] B1: the forge bridge's one message, head-moved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit forgemsg holds one message per move of a watched branch's head: head-moved with repository, branch, head, before and start, on forge....head-moved, refusing a head equal to the one held and any field it does not have (trees, base). The messages pull, merged, pushed, refused and open, their trees, inputs, group and members, and the group's end forge.group.merged go; owed.ended stays. Builds: design 47 H §739, §764 (the forge bridge: merged, pushed, base, the group's end); lead answers H-A-27, H-A-48 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../forgemsg/forge.go | 459 ++++-------------- .../forgemsg/forge_test.go | 215 ++------ .../forgemsg/go.mod | 7 - .../forgemsg/group.go | 80 --- 4 files changed, 136 insertions(+), 625 deletions(-) delete mode 100644 modules/mesh-delivery-forge-bridge/forgemsg/group.go diff --git a/modules/mesh-delivery-forge-bridge/forgemsg/forge.go b/modules/mesh-delivery-forge-bridge/forgemsg/forge.go index 027a891c..eff0989a 100644 --- a/modules/mesh-delivery-forge-bridge/forgemsg/forge.go +++ b/modules/mesh-delivery-forge-bridge/forgemsg/forge.go @@ -1,18 +1,16 @@ -// Package forgemsg is the forge bridge's contract on its own stream `forge` (novox/hq ADR 0633 §4): its messages (Forge, -// one per pull request, merge, refusal or list of open pull requests) and a delivery group's end (ForgeGroupEnd). The -// forge bridge writes them; the indexer and the gate read them. It is the forge bridge's own package: one module owns -// these types, so they live with it and not in mesh-sdk (the operator, 2026-11-04). +// Package forgemsg is the forge bridge's contract on its own stream `forge` (novox/hq ADR 0633 §4): its one message per +// move of a watched branch's head (HeadMoved, design 47 H §739) and an owed act's outcome (OwedEnded). The forge bridge +// writes them; the gate reads them. It is the forge bridge's own package: one module owns these types, so they live with +// it and not in mesh-sdk (the operator, 2026-11-04). package forgemsg import ( + "bytes" "encoding/json" "fmt" - "reflect" "regexp" "strings" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "git.novox.be/novox/mesh-sdk/go/keys" ) @@ -22,33 +20,89 @@ const Version = keys.Version // ForgeStream is the forge bridge's stream as its manifest declares it; the broker derives the real names. const ForgeStream = "forge" -// The kinds of forge message, the last part of a forge event's name. -const ( - ForgePull = "pull" - ForgeMerged = "merged" - // ForgePushed is a move of a watched branch the forge names no pull request's merge for (design 47 G §509): an - // admitted push, taken in as a merged message is. - ForgePushed = "pushed" - ForgeRefused = "refused" - ForgeOpen = "open" -) +// HeadMovedKind is the last part of a head-moved message's name. +const HeadMovedKind = "head-moved" -// OpenPull names an open pull request into the trunk: the repository as `/` and the number. -type OpenPull struct { +// HeadMoved is the bridge's one message per move of a watched branch's head (design 47 H §739): the repository as +// `/`, the branch, the head the bridge read through git.branch, the head it held for that branch before +// (empty the first time) and Start, true when said at the bridge's start. It names no pull request and no tree. +type HeadMoved struct { + V int `json:"v"` Repository string `json:"repository"` - Number int `json:"number"` + Branch string `json:"branch"` + Head string `json:"head"` + Before string `json:"before,omitempty"` + Start bool `json:"start,omitempty"` } -// OpenEvent is the name of an open message: `forge.open`. It names no repository: it says every open pull request of -// every repository the forge bridge reads (novox/hq ADR 0443 §5). -func OpenEvent() string { return "forge." + ForgeOpen } +// HeadMovedEvent is the name of a head-moved message: `forge....head-moved`, the branch +// escaped as a key's name is, so a branch holding a dot is one token (design 47 H H-A-27). +func HeadMovedEvent(repository, branch string) (string, error) { + if err := checkRepository(repository); err != nil { + return "", err + } + if branch == "" { + return "", fmt.Errorf("delivery: a head-moved message names no branch") + } + owner, name, _ := strings.Cut(repository, "/") + return "forge." + owner + "." + name + "." + keys.EscapeName(branch) + "." + HeadMovedKind, nil +} -// The actions of a pull message. -const ( - PullOpened = "opened" - PullUpdated = "updated" - PullClosed = "closed" -) +// HeadMovedEvents is the filter of every head-moved message's name. +func HeadMovedEvents() string { return "forge.*.*.*." + HeadMovedKind } + +// ParseHeadMovedEvent is the inverse of HeadMovedEvent. +func ParseHeadMovedEvent(event string) (repository, branch string, err error) { + parts := strings.Split(event, ".") + if len(parts) != 5 || parts[0] != "forge" || parts[4] != HeadMovedKind { + return "", "", fmt.Errorf("delivery: %q is not a head-moved message, forge....%s", event, HeadMovedKind) + } + repository = parts[1] + "/" + parts[2] + if err := checkRepository(repository); err != nil { + return "", "", fmt.Errorf("delivery: %q: %w", event, err) + } + if branch, err = keys.UnescapeName(parts[3]); err != nil || branch == "" { + return "", "", fmt.Errorf("delivery: %q: the branch part %q is no escaped name: %v", event, parts[3], err) + } + return repository, branch, nil +} + +func (h HeadMoved) check() error { + if err := checkRepository(h.Repository); err != nil { + return err + } + switch { + case h.Branch == "": + return fmt.Errorf("delivery: the head-moved of %s names no branch", h.Repository) + case h.Head == "": + return fmt.Errorf("delivery: the head-moved of %s %s names no head", h.Repository, h.Branch) + case h.Head == h.Before: + return fmt.Errorf("delivery: the head-moved of %s %s names the head it held, %s: a head equal to the one held writes nothing", h.Repository, h.Branch, h.Head) + } + return nil +} + +// EncodeHeadMoved is h as JSON at Version; it refuses what check refuses. +func EncodeHeadMoved(h HeadMoved) ([]byte, error) { + if err := h.check(); err != nil { + return nil, err + } + h.V = Version + return json.Marshal(h) +} + +// DecodeHeadMoved reads a head-moved message; it refuses an unknown version, a field the message does not have (a tree +// or a base among them) and what EncodeHeadMoved refuses. +func DecodeHeadMoved(data []byte) (HeadMoved, error) { + var h HeadMoved + if err := decode(data, &h); err != nil { + return HeadMoved{}, err + } + if err := h.check(); err != nil { + return HeadMoved{}, err + } + return h, nil +} // checkRepository refuses a repository that is not `/`: exactly one slash, each part a valid name. func checkRepository(repository string) error { @@ -62,346 +116,13 @@ func checkRepository(repository string) error { if err := checkName("repository name", name); err != nil { return fmt.Errorf("delivery: the repository %q: %w", repository, err) } - if strings.Contains(owner, "/") { - return fmt.Errorf("delivery: the repository %q is not /, with exactly one slash", repository) - } return nil } -func checkForgeKind(kind string) error { - switch kind { - case ForgePull, ForgeMerged, ForgePushed, ForgeRefused, ForgeOpen: - return nil - } - return fmt.Errorf("delivery: the forge kind %q is not pull, merged, pushed, refused or open", kind) -} +var nameOK = regexp.MustCompile(`^[-_=a-zA-Z0-9]+$`) -// ForgeEvent is the name of a forge message of the given kind: `forge...`. -func ForgeEvent(repository, kind string) (string, error) { - if err := checkForgeKind(kind); err != nil { - return "", err - } - if kind == ForgeOpen { - return "", fmt.Errorf("delivery: an open message names no repository, its event is %s", OpenEvent()) - } - if err := checkRepository(repository); err != nil { - return "", err - } - owner, name, _ := strings.Cut(repository, "/") - return "forge." + owner + "." + name + "." + kind, nil -} - -// ParseForgeEvent is the inverse of ForgeEvent. -func ParseForgeEvent(event string) (repository, kind string, err error) { - if event == OpenEvent() { - return "", ForgeOpen, nil - } - parts := strings.Split(event, ".") - if len(parts) != 4 || parts[0] != "forge" { - return "", "", fmt.Errorf("delivery: %q is not a forge event, forge...", event) - } - repository = parts[1] + "/" + parts[2] - if _, err := ForgeEvent(repository, parts[3]); err != nil { - return "", "", fmt.Errorf("delivery: %q is not a forge event: %w", event, err) - } - return repository, parts[3], nil -} - -// Forge is a message of the forge bridge's stream, trimmed to repository, branch, pull request and head. A pull -// message says Action; a merged message carries the merge commit, the tree of every directory holding a -// module.json and the repository's root tree; a refused message names the owed act it answers and the forge's own -// words. A pull message may also carry the module directories its head changes (Dirs, in the order the forge said) and -// DirsKnown, true when the forge could say them: known and empty is DirsKnown with no Dirs, not known is neither -// (the forge's module_dirs and module_dirs_said, mesh-catalog modules/gitea/trunk.ts). Other messages carry neither. -type Forge struct { - V int `json:"v"` - Kind string `json:"kind"` - Repository string `json:"repository"` - // Branch is a pull or merged message's pull request branch, and a pushed message's branch pushed. - Branch string `json:"branch,omitempty"` - // Base is the watched branch a merged message's commit landed on (design 47 G §714). - Base string `json:"base,omitempty"` - Number int `json:"number,omitempty"` - // Head is a pull or merged message's pull request head commit, and a pushed message's new head of its branch (A-236). - Head string `json:"head,omitempty"` - // Before is a pushed message's head of its branch before, as the forge bridge last wrote it (A-236), empty for none. - Before string `json:"before,omitempty"` - Action string `json:"action,omitempty"` - Dirs []string `json:"dirs,omitempty"` - DirsKnown bool `json:"dirs-known,omitempty"` - Merge string `json:"merge,omitempty"` - Trees map[string]string `json:"trees,omitempty"` - Root string `json:"root,omitempty"` - // Manifests are the module.json bytes, exact, of each module directory: of the merge's trees on a merged message, - // of Dirs at the head on a pull message. Locks are, of each such directory, its lock files' hex sha256 by path - // relative to it (novox/hq ADR 0465 clause 1). Older writers send neither. - Manifests map[string]string `json:"manifests,omitempty"` - Locks map[string]map[string]string `json:"locks,omitempty"` - // Needs are, of each such directory whose manifest names templates, the reader capabilities of the module whole: - // its manifest's and its templates' text's at the same commit (catalogue.ModuleNeeds; novox/hq ADR 0632 §2). The - // indexer takes them over the manifest's own; a directory absent, or an older writer, has the manifest's alone. - Needs map[string][]string `json:"needs,omitempty"` - // Paths are, of each module directory whose manifest names paths on every artifact, each named path's git object - // id at the same commit as its manifest, by path relative to the directory (novox/hq ADR 0499 clause 3). The - // indexer names the paths; a message without them gives such a module none. Older writers send none. - Paths map[string]map[string]string `json:"paths,omitempty"` - // Packages are, of each module directory, the mesh packages its lock file names (MeshPackagesOf; novox/hq ADR 0573 - // §2): the indexer keeps them in the module's inputs and takes each one's latest published version into its - // fingerprint. Absent for a directory that uses none, and from an older writer. - Packages map[string][]string `json:"packages,omitempty"` - Act string `json:"act,omitempty"` - Words string `json:"words,omitempty"` - Open []OpenPull `json:"open,omitempty"` - // RetiredAssignments is the assignments files a bridge before ADR 0567 carried (ADR 0549 §2, ADR 0559 §2): assignments is - // the seat mesh-module-assigner's state now and no repository holds it (ADR 0567 §11), so a message carrying them is - // refused, loudly, rather than read with them dropped. - RetiredAssignments json.RawMessage `json:"assignments,omitempty"` - RetiredRead bool `json:"assignments-read,omitempty"` - // Predefined is the catalogue's predefined.json, exact, at the merge commit of a merged message (novox/hq ADR 0565 - // §2): what the indexer keeps as its state `predefined`. PredefinedRead says the bridge read the merge and it holds - // no predefined.json. Carried on a merged message only; an older bridge sends neither, and the indexer keeps what it - // held. - Predefined json.RawMessage `json:"predefined,omitempty"` - PredefinedRead bool `json:"predefined-read,omitempty"` - // Group is the delivery group a merged message's pull request was merged in, and Members every approved member of - // that group with its approved head, this one included (novox/hq ADR 0633 §4): the forge bridge sets both from the - // seat mesh-delivery's verb groups, and the indexer gathers the group's merges until the group's end (ForgeGroupEnd). A merge - // with no group carries neither, and an older bridge sends neither; an older reader ignores both. - Group string `json:"group,omitempty"` - Members []meshdeliveryclient.Head `json:"members,omitempty"` -} - -// checkGroup refuses a group on anything but a merged message, a group without its members or members without a -// group, a member that is not a repository's pull request at a head, a member named twice, and members that leave out -// the message's own pull request. -func (f Forge) checkGroup() error { - if f.Group == "" && len(f.Members) == 0 { - return nil - } - if f.Kind != ForgeMerged { - return fmt.Errorf("delivery: only a merged message names its delivery group, not a %s message", f.Kind) - } - if f.Group == "" || len(f.Members) == 0 { - return fmt.Errorf("delivery: a merged message names its group and the group's members together, or neither") - } - self := false - seen := map[string]bool{} - for _, m := range f.Members { - if err := checkRepository(m.Repository); err != nil { - return err - } - if m.Number <= 0 || m.Head == "" { - return fmt.Errorf("delivery: the member %s of the group %q needs its pull request number and head", m.Repository, f.Group) - } - k := fmt.Sprintf("%s#%d", m.Repository, m.Number) - if seen[k] { - return fmt.Errorf("delivery: the group %q names its member %s twice", f.Group, k) - } - seen[k] = true - self = self || (trunk.SameRepository(m.Repository, f.Repository) && m.Number == f.Number) - } - if !self { - return fmt.Errorf("delivery: the members of the group %q leave out the merged pull request %s#%d", f.Group, f.Repository, f.Number) - } - return nil -} - -// checkPredefined refuses the predefined list on anything but a merged message, a list that is not one JSON object, and -// a list said both present and absent. -func (f Forge) checkPredefined() error { - if len(f.Predefined) == 0 && !f.PredefinedRead { - return nil - } - if f.Kind != ForgeMerged && f.Kind != ForgePushed { - return fmt.Errorf("delivery: only a merged or pushed message carries the predefined list, not a %s message", f.Kind) - } - if len(f.Predefined) > 0 && f.PredefinedRead { - return fmt.Errorf("delivery: a merged message carries the predefined list and says the merge holds none (predefined-read)") - } - var list map[string]json.RawMessage - if len(f.Predefined) > 0 && json.Unmarshal(f.Predefined, &list) != nil { - return fmt.Errorf("delivery: the predefined list a merged message carries is not one JSON object") - } - return nil -} - -func (f Forge) check() error { - if err := checkForgeKind(f.Kind); err != nil { - return err - } - if f.Kind == ForgeOpen { - return f.checkOpen() - } - if len(f.Open) > 0 { - return fmt.Errorf("delivery: only an open message names open pull requests") - } - if len(f.RetiredAssignments) > 0 || f.RetiredRead { - return fmt.Errorf("delivery: a forge message carries assignments files, which no repository holds since ADR 0567: " + - "assignments is the seat mesh-module-assigner's state") - } - if err := f.checkPredefined(); err != nil { - return err - } - if err := f.checkGroup(); err != nil { - return err - } - if err := checkRepository(f.Repository); err != nil { - return err - } - switch f.Kind { - case ForgePull: - if f.Number <= 0 { - return fmt.Errorf("delivery: a pull message needs its pull request number") - } - if f.Head == "" { - return fmt.Errorf("delivery: a pull message needs its head") - } - switch f.Action { - case PullOpened, PullUpdated, PullClosed: - default: - return fmt.Errorf("delivery: the pull action %q is not opened, updated or closed", f.Action) - } - if len(f.Dirs) > 0 && !f.DirsKnown { - return fmt.Errorf("delivery: a pull message with module directories must say it knows them (dirs-known)") - } - dirs := map[string]bool{} - for _, d := range f.Dirs { - dirs[d] = true - } - if err := f.checkInputs(func(d string) bool { return dirs[d] }, "its module directories"); err != nil { - return err - } - case ForgeMerged, ForgePushed: - if len(f.Dirs) > 0 || f.DirsKnown { - return fmt.Errorf("delivery: a %s message carries no module directories", f.Kind) - } - if f.Kind == ForgeMerged && f.Number <= 0 { - return fmt.Errorf("delivery: a merged message needs its pull request number") - } - if f.Kind == ForgePushed && (f.Number != 0 || f.Merge != "" || f.Base != "") { - return fmt.Errorf("delivery: a pushed message names no pull request, merge commit or base: its branch is the one pushed") - } - if f.Kind == ForgePushed && f.Branch == "" { - return fmt.Errorf("delivery: a pushed message needs its branch") - } - if f.Head == "" { - return fmt.Errorf("delivery: a %s message needs its head", f.Kind) - } - if f.Kind == ForgeMerged && f.Merge == "" { - return fmt.Errorf("delivery: a merged message needs its merge commit") - } - if f.Root == "" { - return fmt.Errorf("delivery: a %s message needs the repository's root tree", f.Kind) - } - // No trees is a merge that leaves the repository with no module.json anywhere (a documents repository, or one - // whose last module was removed): it is written all the same, so the indexer takes the merge in and drops the - // repository's modules (novox/hq issue 1126). An older writer always sent at least one tree, so none is unambiguous; - // such a message carries no manifests, locks or paths (checkInputs below: each names a directory of its trees). - for dir, tree := range f.Trees { - if tree == "" { - return fmt.Errorf("delivery: a merged message's tree of the directory %q is empty", dir) - } - } - if err := f.checkInputs(func(d string) bool { _, ok := f.Trees[d]; return ok }, "its trees"); err != nil { - return err - } - case ForgeRefused: - if len(f.Dirs) > 0 || f.DirsKnown { - return fmt.Errorf("delivery: a refused message carries no module directories") - } - if len(f.Manifests) > 0 || len(f.Locks) > 0 || len(f.Paths) > 0 { - return fmt.Errorf("delivery: a refused message carries no manifests, lock hashes or named paths") - } - if f.Act == "" { - return fmt.Errorf("delivery: a refused message needs the act it answers") - } - if f.Words == "" { - return fmt.Errorf("delivery: a refused message needs the forge's words") - } - } - return nil -} - -// checkInputs refuses a manifest or a lock hash of a directory that known does not know (of is what it knows them -// by), an empty manifest and an empty lock path or hash, naming the directory. -func (f Forge) checkInputs(known func(dir string) bool, of string) error { - for dir, m := range f.Manifests { - if !known(dir) { - return fmt.Errorf("delivery: the manifest of the directory %q is not of %s", dir, of) - } - if m == "" { - return fmt.Errorf("delivery: the manifest of the directory %q is empty", dir) - } - } - for dir, locks := range f.Locks { - if !known(dir) { - return fmt.Errorf("delivery: the lock hashes of the directory %q are not of %s", dir, of) - } - for path, hash := range locks { - if path == "" || hash == "" { - return fmt.Errorf("delivery: the lock %q of the directory %q has an empty path or hash", path, dir) - } - } - } - for dir, paths := range f.Paths { - if !known(dir) { - return fmt.Errorf("delivery: the named paths of the directory %q are not of %s", dir, of) - } - for path, object := range paths { - if path == "" || object == "" { - return fmt.Errorf("delivery: the named path %q of the directory %q has an empty path or object", path, dir) - } - } - } - return nil -} - -// checkOpen refuses an open message that names a repository, a branch, a head or anything of the other kinds, or -// an open pull request that is not `/` and a number. -func (f Forge) checkOpen() error { - if f.Repository != "" || f.Branch != "" || f.Number != 0 || f.Head != "" || f.Action != "" || len(f.Dirs) > 0 || f.DirsKnown || - f.Merge != "" || len(f.Trees) > 0 || len(f.Manifests) > 0 || len(f.Locks) > 0 || len(f.Paths) > 0 || f.Root != "" || f.Act != "" || f.Words != "" || f.Group != "" || len(f.Members) > 0 { - return fmt.Errorf("delivery: an open message carries only the open pull requests it names") - } - for _, p := range f.Open { - if err := checkRepository(p.Repository); err != nil { - return err - } - if p.Number <= 0 { - return fmt.Errorf("delivery: the open pull request of %s has no number", p.Repository) - } - } - return nil -} - -// EncodeForge is f as JSON at Version; it refuses a message missing what its kind needs. -func EncodeForge(f Forge) ([]byte, error) { - if err := f.check(); err != nil { - return nil, err - } - f.V = Version - return json.Marshal(f) -} - -// DecodeForge reads a forge message; it refuses an unknown version (ErrUnknownVersion) and what EncodeForge refuses. -func DecodeForge(data []byte) (Forge, error) { - var f Forge - if err := decode(data, &f); err != nil { - return Forge{}, err - } - if err := f.check(); err != nil { - return Forge{}, err - } - return f, nil -} - -// SameForge says whether two forge messages are the same value. -func SameForge(a, b Forge) bool { return reflect.DeepEqual(a, b) } - -var nameOK = regexp.MustCompile(`^[-/_=a-zA-Z0-9]+$`) - -// checkName refuses a name that is empty or holds a dot, a wildcard, whitespace or a character a bus key refuses -// (mesh-sdk delivery's rule for a name). +// checkName refuses a name that is empty or holds a dot, a slash, a wildcard, whitespace or a character a bus key +// refuses (mesh-sdk delivery's rule for a name). func checkName(kind, name string) error { if name == "" { return fmt.Errorf("delivery: the %s name is empty", kind) @@ -412,8 +133,8 @@ func checkName(kind, name string) error { return nil } -// decode reads a value of Version, refusing another or none with keys.ErrUnknownVersion, as mesh-sdk delivery's -// values are read. +// decode reads a value of Version, refusing another or none with keys.ErrUnknownVersion, and a field the value's type +// does not have. func decode(data []byte, into any) error { var probe struct { V *int `json:"v"` @@ -427,7 +148,9 @@ func decode(data []byte, into any) error { if *probe.V != Version { return fmt.Errorf("%w: the value is version %d, this reader reads %d", keys.ErrUnknownVersion, *probe.V, Version) } - if err := json.Unmarshal(data, into); err != nil { + dec := json.NewDecoder(bytes.NewReader(data)) + dec.DisallowUnknownFields() + if err := dec.Decode(into); err != nil { return fmt.Errorf("delivery: value does not fit its shape: %w", err) } return nil diff --git a/modules/mesh-delivery-forge-bridge/forgemsg/forge_test.go b/modules/mesh-delivery-forge-bridge/forgemsg/forge_test.go index c31695e5..1a4c6548 100644 --- a/modules/mesh-delivery-forge-bridge/forgemsg/forge_test.go +++ b/modules/mesh-delivery-forge-bridge/forgemsg/forge_test.go @@ -1,206 +1,81 @@ package forgemsg import ( - "encoding/json" "errors" "strings" "testing" "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" "git.novox.be/novox/mesh-sdk/go/keys" ) -const oddManifest = "{\n\t\"module\": \"a\",\n \"z\": 1, \"a\": [ \"x\",\"y\" ],\n \"why\": \"é — & \\n\"\n}\n\n" - -func sampleForges() []Forge { - return []Forge{ - {Kind: ForgePull, Repository: "novox/mesh-sdk", Branch: "feat/x", Number: 36, Head: "aaaa", Action: "opened"}, - {Kind: ForgeMerged, Repository: "novox/mesh-sdk", Number: 36, Head: "aaaa", Merge: "cccc", - Trees: map[string]string{"modules/a": "t1"}, Root: "t0"}, - {Kind: ForgeRefused, Repository: "novox/mesh-sdk", Act: "novox/mesh-sdk.36.aaaa.view", Words: "403 forbidden"}, - {Kind: ForgeOpen, Open: []OpenPull{{Repository: "novox/mesh-sdk", Number: 36}, {Repository: "novox/mesh-control", Number: 7}}}, - // 1585/T1: a group member's merged message names its group and every approved member (ADR 0633 §4). - {Kind: ForgeMerged, Repository: "novox/mesh-sdk", Number: 37, Head: "dddd", Merge: "eeee", Root: "t0", - Group: "feat/take-in", Members: []meshdeliveryclient.Head{{Repository: "novox/mesh-sdk", Number: 37, Head: "dddd"}, {Repository: "novox/mesh-delivery", Number: 9, Head: "ffff"}}}, - // design 47 G §509, §714, A-236: a merged message names the watched branch it landed on; a pushed one its branch, new - // head and head before. - {Kind: ForgeMerged, Repository: "novox/mesh-sdk", Number: 38, Branch: "feat/y", Head: "aaaa", Merge: "bbbb", Base: "beta", Root: "t0"}, - {Kind: ForgePushed, Repository: "novox/mesh-sdk", Branch: "beta", Head: "cccc", Before: "bbbb", Root: "t0", Trees: map[string]string{"modules/a": "t1"}}, - } -} - -func mergedWithInputs() Forge { - return Forge{Kind: ForgeMerged, Repository: "novox/mesh-sdk", Number: 36, Head: "aaaa", Merge: "cccc", Root: "t0", - Trees: map[string]string{"a": "t1", "b": "t2"}, - Manifests: map[string]string{"a": oddManifest}, - Locks: map[string]map[string]string{"a": {"go.sum": strings.Repeat("ab", 32)}}} -} - -// TestForge holds the forge bridge's contract, moved whole from mesh-sdk go/delivery with its tests (1200/AC1, AC3, -// AC4; 1279/AC5; 1442/AC1-AC4; 1585/T1). +// design 47 H §739, H-A-27: the bridge's one message, head-moved, on forge....head-moved, +// with repository, branch, head, before and start; a message naming trees, a base or another field is refused. func TestForge(t *testing.T) { t.Run("events", func(t *testing.T) { - ev, err := ForgeEvent("novox/mesh-sdk", ForgeMerged) - if err != nil || ev != "forge.novox.mesh-sdk.merged" { - t.Fatalf("forge event = %q, %v", ev, err) + ev, err := HeadMovedEvent("novox/mesh-sdk", "release.1") + if err != nil || ev != "forge.novox.mesh-sdk.release=2e1.head-moved" { + t.Fatalf("event %q, %v", ev, err) } - if repo, kind, err := ParseForgeEvent(ev); err != nil || repo != "novox/mesh-sdk" || kind != ForgeMerged { - t.Fatalf("parse forge event = %q %q %v", repo, kind, err) + if repo, branch, err := ParseHeadMovedEvent(ev); err != nil || repo != "novox/mesh-sdk" || branch != "release.1" { + t.Fatalf("parse %q: %s %s %v", ev, repo, branch, err) } - for _, bad := range []struct{ repo, kind string }{ - {"", "pull"}, {"novox", "pull"}, {"a/b/c", "pull"}, {"/b", "pull"}, {"a/", "pull"}, - {"a.b/c", "pull"}, {"a/b c", "pull"}, {"a/b", "closed"}, {"a/b", ""}, {"a/b", ForgeOpen}, - } { - if _, err := ForgeEvent(bad.repo, bad.kind); err == nil { - t.Errorf("forge event %q %q accepted", bad.repo, bad.kind) + if all := HeadMovedEvents(); all != "forge.*.*.*.head-moved" { + t.Fatalf("every head-moved is %q", all) + } + for _, bad := range []string{"forge.novox.mesh-sdk.merged", "forge.novox.mesh-sdk.main.merged", "forge.open", + "forge.novox.mesh-sdk.ma=zz.head-moved", "owed.ended", "forge.novox.mesh-sdk.main.x.head-moved"} { + if _, _, err := ParseHeadMovedEvent(bad); err == nil { + t.Errorf("%q parsed", bad) } } - for _, bad := range []string{"", "forge.a.b", "forge.a.b.closed", "x.a.b.pull", "forge.a.b.pull.x", "forge..b.pull", ForgeGroupEndEvent} { - if _, _, err := ParseForgeEvent(bad); err == nil { - t.Errorf("parse forge event %q accepted", bad) + for _, repo := range []string{"mesh-sdk", "a/b/c", "a./b"} { + if _, err := HeadMovedEvent(repo, "main"); err == nil { + t.Errorf("repository %q named", repo) } } - if repo, kind, err := ParseForgeEvent(OpenEvent()); OpenEvent() != "forge.open" || err != nil || repo != "" || kind != ForgeOpen { - t.Errorf("open event %q = %q %q %v", OpenEvent(), repo, kind, err) - } }) t.Run("round trip", func(t *testing.T) { - fs := append(sampleForges(), mergedWithInputs()) - for _, f := range fs { - data, err := EncodeForge(f) - if err != nil { - t.Fatalf("%s: %v", f.Kind, err) - } - var probe map[string]any - if err := json.Unmarshal(data, &probe); err != nil || probe["v"] != float64(1) { - t.Fatalf("%s: json %s does not carry v:1", f.Kind, data) - } - f.V = Version - if got, err := DecodeForge(data); err != nil || !SameForge(got, f) { - t.Errorf("forge %s round trip: %+v %v", f.Kind, got, err) - } - } - // An empty list is an open message too: nothing is open. - if data, err := EncodeForge(Forge{Kind: ForgeOpen, Open: []OpenPull{}}); err != nil { - t.Errorf("empty open: %v", err) - } else if f, err := DecodeForge(data); err != nil || f.Kind != ForgeOpen || len(f.Open) != 0 { - t.Errorf("empty open round trip: %+v %v", f, err) - } - ge := ForgeGroupEnd{Group: "feat/take-in", Members: []GroupMerge{{Repository: "novox/mesh-sdk", Number: 37, Merge: "eeee"}}} - data, err := EncodeForgeGroupEnd(ge) - ge.V = Version - if got, err2 := DecodeForgeGroupEnd(data); err != nil || err2 != nil || !SameForgeGroupEnd(got, ge) { - t.Errorf("group end round trip: %+v %v %v", got, err, err2) - } - // An older bridge's message reads, and is written back byte for byte. - old := `{"v":1,"kind":"merged","repository":"novox/mesh-sdk","number":36,"head":"aaaa","merge":"cccc","trees":{"a":"t1"},"root":"t0"}` - if f, err := DecodeForge([]byte(old)); err != nil || f.Manifests != nil { - t.Fatalf("%+v, %v", f, err) - } else if data, err := EncodeForge(f); err != nil || string(data) != old { - t.Errorf("%s, %v, want exactly %s", data, err, old) - } - // A merge leaving the repository with no module.json is a message too (issue 1126). - f := sampleForges()[1] - f.Trees = nil - if data, err := EncodeForge(f); err != nil { - t.Errorf("a merged message with no trees is refused: %v", err) - } else if got, err := DecodeForge(data); err != nil || len(got.Trees) != 0 { - t.Errorf("a merged message with no trees comes back as %+v, %v", got, err) - } - for name, dec := range map[string]func([]byte) error{ - "forge": func(b []byte) error { _, err := DecodeForge(b); return err }, - "group end": func(b []byte) error { _, err := DecodeForgeGroupEnd(b); return err }, + for _, h := range []HeadMoved{ + {Repository: "novox/mesh-sdk", Branch: "main", Head: "cccc", Before: "bbbb"}, + {Repository: "novox/mesh-sdk", Branch: "feat/x", Head: "aaaa", Start: true}, // the first time: no head held } { - for _, in := range []string{`{"group":"g"}`, `{"v":2,"group":"g"}`} { - if err := dec([]byte(in)); !errors.Is(err, keys.ErrUnknownVersion) { - t.Errorf("%s decode of %s = %v, want keys.ErrUnknownVersion", name, in, err) - } + raw, err := EncodeHeadMoved(h) + if err != nil { + t.Fatal(err) + } + back, err := DecodeHeadMoved(raw) + h.V = Version + if err != nil || back != h { + t.Fatalf("read back %+v, %v; want %+v", back, err, h) } } }) t.Run("refused", func(t *testing.T) { - at := func(i int, mut func(*Forge)) Forge { f := sampleForges()[i]; mut(&f); return f } - in := func(mut func(*Forge)) Forge { f := mergedWithInputs(); mut(&f); return f } - pullIn := func(mut func(*Forge)) Forge { - f := Forge{Kind: ForgePull, Repository: "novox/mesh-sdk", Number: 1, Head: "h", Action: PullOpened, - Dirs: []string{"a"}, DirsKnown: true, Manifests: map[string]string{"a": oddManifest}, - Locks: map[string]map[string]string{"a": {"go.sum": strings.Repeat("0", 64)}}} - mut(&f) - return f - } - for _, c := range []struct { - name, want string - f Forge - }{ - {"merged without merge commit", "merge", at(1, func(f *Forge) { f.Merge = "" })}, - {"merged without root", "root", at(1, func(f *Forge) { f.Root = "" })}, - {"merged with a manifest and no trees", "modules/a", at(1, func(f *Forge) { f.Trees = nil; f.Manifests = map[string]string{"modules/a": "{}"} })}, - {"merged with an empty tree", "modules/a", at(1, func(f *Forge) { f.Trees = map[string]string{"modules/a": ""} })}, - {"pull with an unknown action", "reopened", at(0, func(f *Forge) { f.Action = "reopened" })}, - {"pull without head", "head", at(0, func(f *Forge) { f.Head = "" })}, - {"refused without words", "words", at(2, func(f *Forge) { f.Words = "" })}, - {"refused without act", "act", at(2, func(f *Forge) { f.Act = "" })}, - {"unknown kind", "closed", Forge{Kind: "closed", Repository: "a/b"}}, - {"bad repository", "nope", Forge{Kind: ForgePull, Repository: "nope", Number: 1, Head: "h", Action: "opened"}}, - {"open with a repository", "only the open", Forge{Kind: ForgeOpen, Repository: "a/b", Open: []OpenPull{{Repository: "a/b", Number: 1}}}}, - {"open with a bad entry", "", Forge{Kind: ForgeOpen, Open: []OpenPull{{Repository: "a", Number: 1}}}}, - {"open with a zero number", "no number", Forge{Kind: ForgeOpen, Open: []OpenPull{{Repository: "a/b"}}}}, - {"pull naming open pull requests", "only an open message", Forge{Kind: ForgePull, Repository: "a/b", Number: 1, Head: "h", Action: "updated", Open: []OpenPull{{Repository: "a/b", Number: 1}}}}, - {"manifest outside trees", `"zz"`, in(func(f *Forge) { f.Manifests["zz"] = "{}" })}, - {"locks outside trees", `"yy"`, in(func(f *Forge) { f.Locks["yy"] = map[string]string{"go.sum": "h"} })}, - {"empty manifest", `"b"`, in(func(f *Forge) { f.Manifests["b"] = "" })}, - {"empty lock hash", `"a"`, in(func(f *Forge) { f.Locks["a"]["go.sum"] = "" })}, - {"named paths outside trees", `"other"`, in(func(f *Forge) { f.Paths = map[string]map[string]string{"other": {"src": "o"}} })}, - {"a named path with no object", `"src"`, in(func(f *Forge) { f.Paths = map[string]map[string]string{"a": {"src": ""}} })}, - {"assignments files", "mesh-module-assigner", in(func(f *Forge) { f.RetiredAssignments = []byte(`{"anchor":"{}"}`) })}, - {"assignments read", "mesh-module-assigner", in(func(f *Forge) { f.RetiredRead = true })}, - {"predefined not an object", "one JSON object", in(func(f *Forge) { f.Predefined = []byte(`["domain"]`) })}, - {"predefined both", "says the merge holds none", in(func(f *Forge) { f.Predefined = []byte(`{}`); f.PredefinedRead = true })}, - {"pull with the predefined list", "only a merged or pushed message", Forge{Kind: ForgePull, Repository: "novox/mesh-sdk", Number: 1, Head: "h", Action: PullOpened, PredefinedRead: true}}, - {"pull manifest outside dirs", `"b"`, pullIn(func(f *Forge) { f.Manifests["b"] = "{}" })}, - {"pull locks outside dirs", `"c"`, pullIn(func(f *Forge) { f.Locks["c"] = map[string]string{"go.sum": "h"} })}, - {"refused with manifests", "no manifests", Forge{Kind: ForgeRefused, Repository: "a/b", Act: "x", Words: "no", Manifests: map[string]string{"a": "{}"}}}, - {"open with locks", "only the open", Forge{Kind: ForgeOpen, Locks: map[string]map[string]string{"a": {"go.sum": "h"}}}}, - // 1585/T1: a group only on a merged message, with its members, the message's own pull request among them. - {"pull with a group", "only a merged message names its delivery group", at(0, func(f *Forge) { - f.Group, f.Members = "g", []meshdeliveryclient.Head{{Repository: "novox/mesh-sdk", Number: 36, Head: "aaaa"}} - })}, - {"merged with a group and no members", "together", at(4, func(f *Forge) { f.Members = nil })}, - {"merged with members and no group", "together", at(4, func(f *Forge) { f.Group = "" })}, - {"merged with members leaving itself out", "leave out", at(4, func(f *Forge) { f.Members = f.Members[1:] })}, - {"merged with a member twice", "twice", at(4, func(f *Forge) { f.Members = append(f.Members, f.Members[0]) })}, - {"open with a group", "only the open pull requests", Forge{Kind: ForgeOpen, Group: "g"}}, - // design 47 G §509, A-236: a pushed message names its branch and no pull request, merge commit or base. - {"pushed with a pull request", "names no pull request", Forge{Kind: ForgePushed, Repository: "a/b", Branch: "beta", Head: "h", Root: "r", Number: 3}}, - {"pushed with no branch", "needs its branch", Forge{Kind: ForgePushed, Repository: "a/b", Head: "h", Root: "r"}}, + for name, h := range map[string]HeadMoved{ + "no repository": {Branch: "main", Head: "a"}, + "no branch": {Repository: "novox/x", Head: "a"}, + "no head": {Repository: "novox/x", Branch: "main"}, + "head not moved": {Repository: "novox/x", Branch: "main", Head: "a", Before: "a"}, + "repository form": {Repository: "x", Branch: "main", Head: "a"}, } { - if _, err := EncodeForge(c.f); err == nil || !strings.Contains(err.Error(), c.want) { - t.Errorf("%s: %v, want a refusal naming %q", c.name, err, c.want) + if _, err := EncodeHeadMoved(h); err == nil { + t.Errorf("%s: written", name) } } - // A member's repository in another case still names the merged pull request (10c91fba). - f := sampleForges()[4] - f.Members[0].Repository = "Novox/Mesh-SDK" - if _, err := EncodeForge(f); err != nil { - t.Errorf("a member in another case: %v", err) - } - for _, c := range []struct { - name, want string - e ForgeGroupEnd - }{ - {"group end without members", "no member", ForgeGroupEnd{Group: "g"}}, - {"group end without a group", "names its group", ForgeGroupEnd{Members: []GroupMerge{{Repository: "a/b", Number: 1, Merge: "m"}}}}, - {"group end with a member without its merge", "merge commit", ForgeGroupEnd{Group: "g", Members: []GroupMerge{{Repository: "a/b", Number: 1}}}}, - {"group end with a member twice", "twice", ForgeGroupEnd{Group: "g", Members: []GroupMerge{{Repository: "a/b", Number: 1, Merge: "m"}, {Repository: "a/b", Number: 1, Merge: "m"}}}}, + for name, raw := range map[string]string{ + "trees": `{"v":1,"repository":"novox/x","branch":"main","head":"a","trees":{"m":"t"}}`, + "base": `{"v":1,"repository":"novox/x","branch":"main","head":"a","base":"main"}`, + "merged": `{"v":1,"kind":"merged","repository":"novox/x","number":3,"head":"a","merge":"b"}`, + "no version": `{"repository":"novox/x","branch":"main","head":"a"}`, } { - if _, err := EncodeForgeGroupEnd(c.e); err == nil || !strings.Contains(err.Error(), c.want) { - t.Errorf("%s: %v, want a refusal naming %q", c.name, err, c.want) + if _, err := DecodeHeadMoved([]byte(raw)); err == nil { + t.Errorf("%s: read", name) + } else if name == "no version" && !errors.Is(err, keys.ErrUnknownVersion) { + t.Errorf("no version: %v", err) } } }) - // Design 47 G §164: an owed act's outcome names its seat, its id, one outcome and words for every outcome but - // performed; an act the bridge cannot decode may name no id. t.Run("owed ended", func(t *testing.T) { at := time.Date(2026, 11, 9, 20, 0, 0, 0, time.UTC) ok := OwedEnded{Of: "mesh-delivery", ID: "g1.view.1", Outcome: OwedPerformed, At: at} diff --git a/modules/mesh-delivery-forge-bridge/forgemsg/go.mod b/modules/mesh-delivery-forge-bridge/forgemsg/go.mod index ddbc1c3e..58077783 100644 --- a/modules/mesh-delivery-forge-bridge/forgemsg/go.mod +++ b/modules/mesh-delivery-forge-bridge/forgemsg/go.mod @@ -3,10 +3,3 @@ module git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forge go 1.26.0 require git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 - -require ( - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk v0.0.0-00010101000000-000000000000 -) - -require git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery v0.0.0-00010101000000-000000000000 // indirect diff --git a/modules/mesh-delivery-forge-bridge/forgemsg/group.go b/modules/mesh-delivery-forge-bridge/forgemsg/group.go deleted file mode 100644 index 527c3b7f..00000000 --- a/modules/mesh-delivery-forge-bridge/forgemsg/group.go +++ /dev/null @@ -1,80 +0,0 @@ -package forgemsg - -import ( - "encoding/json" - "fmt" - "reflect" -) - -// ForgeGroupEndEvent is the name of a delivery group's end on the forge bridge's stream (novox/hq ADR 0633 §4): the -// bridge publishes it once every approved member of the group is merged, after the last member's merged message. It -// has three parts, so no repository's forge event (`forge...`) is ever this name. -const ForgeGroupEndEvent = "forge.group.merged" - -// GroupMerge is one merged member of a delivery group: the repository as `/`, its pull request and the -// merge commit the forge made of it. -type GroupMerge struct { - Repository string `json:"repository"` - Number int `json:"number"` - Merge string `json:"merge"` -} - -// ForgeGroupEnd is the body of ForgeGroupEndEvent: the group and every member merged in it on its base, with its merge commit. -// The indexer takes the members it holds in as one source revision once it hears it (ADR 0633 §4). -type ForgeGroupEnd struct { - V int `json:"v"` - Group string `json:"group"` - // Base is the watched branch the members merged into: a group's end is said once per base (design 47 G §715). - Base string `json:"base,omitempty"` - Members []GroupMerge `json:"members"` -} - -func (e ForgeGroupEnd) check() error { - if e.Group == "" { - return fmt.Errorf("delivery: a group's end names its group") - } - if len(e.Members) == 0 { - return fmt.Errorf("delivery: the end of the group %q names no member merged in it", e.Group) - } - seen := map[string]bool{} - for _, m := range e.Members { - if err := checkRepository(m.Repository); err != nil { - return err - } - if m.Number <= 0 || m.Merge == "" { - return fmt.Errorf("delivery: the member %s of the group %q's end needs its pull request number and merge commit", m.Repository, e.Group) - } - k := fmt.Sprintf("%s#%d", m.Repository, m.Number) - if seen[k] { - return fmt.Errorf("delivery: the end of the group %q names its member %s twice", e.Group, k) - } - seen[k] = true - } - return nil -} - -// EncodeForgeGroupEnd is e as JSON at Version; it refuses an end with no group or no member, and a member without its -// pull request or merge commit. -func EncodeForgeGroupEnd(e ForgeGroupEnd) ([]byte, error) { - if err := e.check(); err != nil { - return nil, err - } - e.V = Version - return json.Marshal(e) -} - -// DecodeForgeGroupEnd reads a group's end; it refuses an unknown version (ErrUnknownVersion) and what -// EncodeForgeGroupEnd refuses. -func DecodeForgeGroupEnd(data []byte) (ForgeGroupEnd, error) { - var e ForgeGroupEnd - if err := decode(data, &e); err != nil { - return ForgeGroupEnd{}, err - } - if err := e.check(); err != nil { - return ForgeGroupEnd{}, err - } - return e, nil -} - -// SameForgeGroupEnd says whether two group ends are the same value. -func SameForgeGroupEnd(a, b ForgeGroupEnd) bool { return reflect.DeepEqual(a, b) } -- 2.54.0 From b75dcc947c667f2e84e4cc73bad4492d9f2b33bc Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:15:15 +0100 Subject: [PATCH 015/104] C1b: the seat mesh-catalog keeps no state verdicts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the validation gone from the take-in, the state verdicts, its value and the client's helpers over it (VerdictsKey, TakeVerdict, VerdictWhy, ModuleVerdict, the codec) leave the seat's contract; a module's own verdict field keeps its three states. Builds: design 47 H §745, §764 (the indexer: the validation at the take-in); lead answer H-A-79 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../clients/meshcatalogclient/catalog_test.go | 63 +++---- .../go/clients/meshcatalogclient/verdict.go | 158 +----------------- .../go/seats/meshcatalog/contract.go | 46 ----- .../go/seats/meshcatalog/contract_test.go | 2 - .../seats/mesh-catalog/fixtures/states.json | 13 -- .../seats/mesh-catalog/seat.json | 58 ------- .../ts/seats/meshcatalog/index.d.ts | 21 --- .../ts/seats/meshcatalog/index.js | 16 -- 8 files changed, 22 insertions(+), 355 deletions(-) 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"; -- 2.54.0 From 87e9084e15a3a6121080420c4c94c2fd1f7ce06e Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:21:43 +0100 Subject: [PATCH 016/104] C-R2: the runner's pipelines key a run on request; a mover keeps its heard publishes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat mesh-pipeline-runner's state pipelines gains the key form .run., one pipeline per run on request, its movers the named commits' modules (it delivers nothing). Its Mover gains published, the artifact references whose package-published (or, on a kind-3 edge, whose build step's passed end) the runner heard at the pipeline's branch and source, kept with the pipeline so a dependency's wait survives a restart. A fixture of the new key form with a mover naming one heard publish proves both. Builds: design 47 H §746; lead answers H-A-83 (1) (hq ae7fc40a), H-A-84 (hq main 0631f43f+) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshpipelinerunner/contract.go | 45 +++++++++- .../seats/meshpipelinerunner/contract_test.go | 6 ++ .../mesh-pipeline-runner/fixtures/states.json | 86 +++++++++++++++++++ .../seats/mesh-pipeline-runner/seat.json | 16 +++- .../ts/seats/meshpipelinerunner/index.d.ts | 13 ++- .../ts/seats/meshpipelinerunner/index.js | 19 ++++ 6 files changed, 181 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 9b5b3f87..96e4131c 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -239,6 +239,42 @@ func DecodePipelinesByBranchSourcePublishedPackageVersionValue(raw []byte) (Pipe return v, nil } +// PipelinesByBranchRunRunKey is the key of one value of the state pipelines under the form ".run.". +func PipelinesByBranchRunRunKey(branch, run string) string { return branch + ".run." + run } + +// ParsePipelinesByBranchRunRunKey reads the parts of a key of the form ".run.", in the order of the form; the last result is false for a key of another form. +func ParsePipelinesByBranchRunRunKey(key string) (string, string, bool) { + rest := key + v0, after0, found0 := strings.Cut(rest, ".run.") + if !found0 || v0 == "" { + return "", "", false + } + rest = after0 + if rest == "" { + return "", "", false + } + v2 := rest + rest = "" + if rest != "" { + return "", "", false + } + return v0, v2, true +} + +// DecodePipelinesByBranchRunRunValue reads one value of the state pipelines under the form ".run.", refusing a field PipelinesByBranchRunRunValue does not know and any text after the value. +func DecodePipelinesByBranchRunRunValue(raw []byte) (PipelinesByBranchRunRunValue, error) { + var v PipelinesByBranchRunRunValue + 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 +} + // QueueByQueueNextKey is the key of one value of the state queue under the form "queue.next". func QueueByQueueNextKey() string { return "queue.next" } @@ -511,7 +547,9 @@ type Mover struct { Fingerprint string `json:"fingerprint"` Module string `json:"module"` // yes when the module is over its test budget (design 47 G section 419) - OverBudget bool `json:"over-budget,omitempty"` + OverBudget bool `json:"over-budget,omitempty"` + // the artifact references, :, of the mover's dependencies whose package-published (and, for a kind-3 edge, whose build step's passed end) was heard at the pipeline's branch and source, written with the pipeline by compare-and-set; absent when none (H-A-84) + Published []string `json:"published,omitempty"` Repository string `json:"repository"` Tests *TestCounts `json:"tests,omitempty"` // the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H §746) @@ -546,7 +584,7 @@ type Pipeline struct { // the modules the pipeline moves, its take-in's entries (design 47 H §746) Movers []Mover `json:"movers"` Outcome string `json:"outcome"` - // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) + // the pipeline's key, ., ..published.. for a pipeline a publish started, or .run. for a run on request; a branch escaped as a key's name is (design 47 H §746, §747; H-A-83) Pipeline string `json:"pipeline"` // for a pipeline a package's publish started, that publish (A-202) Published *Published `json:"published,omitempty"` @@ -1212,6 +1250,9 @@ type PipelinesByBranchSourceValue = Pipeline // PipelinesByBranchSourcePublishedPackageVersionValue is one value of the state pipelines under the key ..published... type PipelinesByBranchSourcePublishedPackageVersionValue = Pipeline +// PipelinesByBranchRunRunValue is one value of the state pipelines under the key .run.. +type PipelinesByBranchRunRunValue = Pipeline + // QueueByQueueNextValue is one value of the state queue under the key queue.next. type QueueByQueueNextValue = int64 diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index d00cc41c..d4d39dba 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -71,6 +71,12 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, + {name: "a run on request's pipeline, its mover waiting with one dependency's publish heard", subject: "", given: "{\"branch\":\"feat-x\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"published\":[\"mesh-sdk:go\"],\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"feat-x.run.r42\",\"revision\":12,\"run\":\"r42\",\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"feat-x\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"published\":[\"mesh-sdk:go\"],\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"feat-x.run.r42\",\"revision\":12,\"run\":\"r42\",\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", + decode: func(b []byte) (any, error) { + var v PipelinesByBranchRunRunValue + err := json.Unmarshal(b, &v) + return v, err + }, subjectIs: nil}, {name: "run asks one member at a commit", subject: "", given: "{\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}]}", wire: "{\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}]}", decode: func(b []byte) (any, error) { var v RunInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "run answers its id and pipelines", subject: "", given: "{\"pipelines\":[\"feature~2f1966-x.0.nats\"],\"run\":\"run-m2kx9a\"}", wire: "{\"pipelines\":[\"feature~2f1966-x.0.nats\"],\"run\":\"run-m2kx9a\"}", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json index 4fc96cdc..18285de8 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json @@ -214,5 +214,91 @@ } ] } + }, + { + "name": "a run on request's pipeline, its mover waiting with one dependency's publish heard", + "of": "state:pipelines/.run.", + "given": { + "pipeline": "feat-x.run.r42", + "branch": "feat-x", + "revision": 12, + "source": 3589, + "end-count": 1, + "v": 1, + "outcome": "passed", + "steps": [ + { + "step": "lint", + "artifact": "nats:program", + "status": "required", + "outcome": "passed", + "fingerprint": "fp-0123", + "seat": "node-build-go", + "node": "anchor", + "ask": "m2kx9a1b3c4d5e", + "module": "nats" + }, + { + "step": "unit", + "artifact": "nats:program", + "status": "required", + "outcome": "carried", + "fingerprint": "fp-0123", + "carried-from": "main.3588", + "tests": { + "unit": 42 + }, + "module": "nats" + }, + { + "step": "integration", + "artifact": "nats:program", + "status": "optional", + "outcome": "failed", + "why": "TestTheBusWhole failed", + "fingerprint": "fp-0123", + "seat": "node-build-go", + "node": "home-server", + "tests": { + "integration": 3 + }, + "module": "nats" + }, + { + "step": "composition", + "status": "required", + "outcome": "passed", + "seat": "mesh-wants", + "module": "nats" + }, + { + "step": "review", + "status": "bypass", + "outcome": "bypassed", + "module": "nats" + }, + { + "step": "approval", + "status": "required", + "outcome": "passed", + "module": "nats" + } + ], + "started": "2026-11-10T10:00:00Z", + "ended": "2026-11-10T10:20:00Z", + "movers": [ + { + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0123", + "repository": "mesh-networking", + "tier": 1, + "published": [ + "mesh-sdk:go" + ] + } + ], + "run": "r42" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index cac7dd36..68879ae5 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -741,6 +741,13 @@ "$ref": "#/defs/Pipeline" }, "description": "a pipeline a package's publish started, its movers the package's kind-1 dependents the publishing pipeline does not move" + }, + { + "key": ".run.", + "value": { + "$ref": "#/defs/Pipeline" + }, + "description": "a run on request's pipeline, one per run, its movers the named commits' modules; it delivers nothing (H-A-83)" } ] }, @@ -1101,7 +1108,7 @@ "properties": { "pipeline": { "type": "string", - "description": "the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)" + "description": "the pipeline's key, ., ..published.. for a pipeline a publish started, or .run. for a run on request; a branch escaped as a key's name is (design 47 H §746, §747; H-A-83)" }, "branch": { "type": "string", @@ -1781,6 +1788,13 @@ "type": "string", "description": "the version released for the mover in this pipeline (version-released), absent until one is (design 47 H-A-52)" }, + "published": { + "type": "array", + "items": { + "type": "string" + }, + "description": "the artifact references, :, of the mover's dependencies whose package-published (and, for a kind-3 edge, whose build step's passed end) was heard at the pipeline's branch and source, written with the pipeline by compare-and-set; absent when none (H-A-84)" + }, "widens": { "type": "array", "items": { diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 316dcf10..ec8bf096 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -105,6 +105,12 @@ export declare function pipelinesByBranchSourcePublishedPackageVersionKey(branch /** The parts of a key of the form "..published..", or undefined for a key of another form. */ export declare function parsePipelinesByBranchSourcePublishedPackageVersionKey(_key: string): { branch: string; source: string; packagePart: string; version: string } | undefined; +/** The key of one value of the state pipelines under the form ".run.". */ +export declare function pipelinesByBranchRunRunKey(branch: string, run: string): string; + +/** The parts of a key of the form ".run.", or undefined for a key of another form. */ +export declare function parsePipelinesByBranchRunRunKey(_key: string): { branch: string; run: string } | undefined; + /** The key of one value of the state queue under the form "queue.next". */ export declare function queueByQueueNextKey(): string; @@ -198,6 +204,8 @@ export interface Mover { "module": string; /** yes when the module is over its test budget (design 47 G section 419) */ "over-budget"?: boolean; + /** the artifact references, :, of the mover's dependencies whose package-published (and, for a kind-3 edge, whose build step's passed end) was heard at the pipeline's branch and source, written with the pipeline by compare-and-set; absent when none (H-A-84) */ + "published"?: string[]; "repository": string; "tests"?: TestCounts; /** the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H §746) */ @@ -232,7 +240,7 @@ export interface Pipeline { /** the modules the pipeline moves, its take-in's entries (design 47 H §746) */ "movers": Mover[]; "outcome": "waiting" | "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; - /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ + /** the pipeline's key, ., ..published.. for a pipeline a publish started, or .run. for a run on request; a branch escaped as a key's name is (design 47 H §746, §747; H-A-83) */ "pipeline": string; /** for a pipeline a package's publish started, that publish (A-202) */ "published"?: Published; @@ -752,6 +760,9 @@ export type PipelinesByBranchSourceValue = Pipeline; /** is one value of the state pipelines under the key ..published... */ export type PipelinesByBranchSourcePublishedPackageVersionValue = Pipeline; +/** is one value of the state pipelines under the key .run.. */ +export type PipelinesByBranchRunRunValue = Pipeline; + /** is one value of the state queue under the key queue.next. */ export type QueueByQueueNextValue = number; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js index 935bf4c9..e8e03364 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js @@ -153,6 +153,25 @@ export function parsePipelinesByBranchSourcePublishedPackageVersionKey(_key) { return { branch, source, packagePart, version }; } +/** The key of one value of the state pipelines under the form ".run.". */ +export function pipelinesByBranchRunRunKey(branch, run) { + return branch + ".run." + run; +} + +/** The parts of a key of the form ".run.", or undefined for a key of another form. */ +export function parsePipelinesByBranchRunRunKey(_key) { + let _rest = _key; + const _at0 = _rest.indexOf(".run."); + if (_at0 <= 0) return undefined; + const branch = _rest.slice(0, _at0); + _rest = _rest.slice(_at0 + 5); + if (_rest === "") return undefined; + const run = _rest; + _rest = ""; + if (_rest !== "") return undefined; + return { branch, run }; +} + /** The key of one value of the state queue under the form "queue.next". */ export function queueByQueueNextKey() { return "queue.next"; -- 2.54.0 From 3560362330b131be721101ee612aa5967dc4e1ad Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:27:41 +0100 Subject: [PATCH 017/104] C-W2: a step the assigner serves names its asker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat mesh-wants' StepRun gains asker, the seat name of the part asking the step (the runner writes mesh-pipeline-runner), so the assigner names a step's progress with it. Optional in the definition: the line names its writer, not that a step without it is refused. Both accept:step fixtures carry it; the generated fixture test fails without the field. Builds: design 47 H §745; lead answer H-A-88 (hq 2c6c7c03), H-A-41 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../mesh-delivery-contracts/go/seats/meshwants/contract.go | 2 ++ .../go/seats/meshwants/contract_test.go | 4 ++-- .../seats/mesh-wants/fixtures/verbs.json | 6 ++++-- modules/mesh-delivery-contracts/seats/mesh-wants/seat.json | 4 ++++ .../mesh-delivery-contracts/ts/seats/meshwants/index.d.ts | 2 ++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go index 98ca9b80..9ef9156c 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go @@ -1075,6 +1075,8 @@ const ( // StepRun is a pipeline step of one mover the assigner serves (design 47 H §745, G §22): validate, the manifest validator built from the take-in's heads run over the revision's manifests, before composition, each machine's declaration composed at the change's heads with the composer built from them, both in the build seat's sandbox. type StepRun struct { + // the seat name of the part asking the step, mesh-pipeline-runner for the runner; the assigner names the step's progress with it (design 47 H-A-88, H-A-41) + Asker string `json:"asker,omitempty"` // the watched branch, or the branch of a run on request Branch string `json:"branch"` // for a rerun, the caller the runtime proved diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go index a090ff0d..daeed530 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go @@ -141,9 +141,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v DifferenceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "difference refuses a changed fingerprint with no difference, by name", subject: "", given: "{\"changes\":[],\"from\":40,\"refused\":[{\"module\":\"xclip\",\"why\":\"its fingerprint changed and its difference is empty\"}],\"to\":41}", wire: "{\"changes\":[],\"from\":40,\"refused\":[{\"module\":\"xclip\",\"why\":\"its fingerprint changed and its difference is empty\"}],\"to\":41}", decode: func(b []byte) (any, error) { var v DifferenceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a composition step asked by the runner", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", + {name: "a composition step asked by the runner", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"asker\":\"mesh-pipeline-runner\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", wire: "{\"asker\":\"mesh-pipeline-runner\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", decode: func(b []byte) (any, error) { var v StepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.accept\\.step$")}, - {name: "a validate step asked by the runner, before the mover's composition", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"validate\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"validate\"}", + {name: "a validate step asked by the runner, before the mover's composition", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"asker\":\"mesh-pipeline-runner\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"validate\"}", wire: "{\"asker\":\"mesh-pipeline-runner\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step\":\"validate\"}", decode: func(b []byte) (any, error) { var v StepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.accept\\.step$")}, {name: "input asks a composition step's input by digest", subject: "", given: "{\"call\":\"0123456789abcdef0123456789abcdef\",\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", wire: "{\"call\":\"0123456789abcdef0123456789abcdef\",\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json index cbeb2d7f..2c09da7a 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json @@ -157,7 +157,8 @@ "commit": "0123456789abcdef0123456789abcdef01234567", "revision": 12, "source": 3589, - "fingerprint": "fp-0123" + "fingerprint": "fp-0123", + "asker": "mesh-pipeline-runner" } }, { @@ -172,7 +173,8 @@ "commit": "0123456789abcdef0123456789abcdef01234567", "revision": 12, "source": 3589, - "fingerprint": "fp-0123" + "fingerprint": "fp-0123", + "asker": "mesh-pipeline-runner" } }, { diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json index 09488de3..11f475d6 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json @@ -1362,6 +1362,10 @@ "type": "string", "description": "the module's build-input fingerprint at the commit" }, + "asker": { + "type": "string", + "description": "the seat name of the part asking the step, mesh-pipeline-runner for the runner; the assigner names the step's progress with it (design 47 H-A-88, H-A-41)" + }, "run": { "type": "string", "description": "the run on request's id: its composition writes no want (ADR 0666 section 18)" diff --git a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts index c8112c2e..5e250410 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts @@ -466,6 +466,8 @@ export interface StepEnded { /** a pipeline step of one mover the assigner serves (design 47 H §745, G §22): validate, the manifest validator built from the take-in's heads run over the revision's manifests, before composition, each machine's declaration composed at the change's heads with the composer built from them, both in the build seat's sandbox */ export interface StepRun { + /** the seat name of the part asking the step, mesh-pipeline-runner for the runner; the assigner names the step's progress with it (design 47 H-A-88, H-A-41) */ + "asker"?: string; /** the watched branch, or the branch of a run on request */ "branch": string; /** for a rerun, the caller the runtime proved */ -- 2.54.0 From 7ac48fd8824ef639d13a967c9b23ea09c39d4323 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:31:04 +0100 Subject: [PATCH 018/104] B2, B3: the forge bridge says head-moved and carries the one model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit B2: on every branch-moved of a watched branch, and at its start for every watched branch's head, the bridge reads the head through the seat git's verb branch, as a kept call that waits on the holder's return while the branch is watched, and writes one head-moved (repository, branch, head, before the head held in its state heads, start) on its stream forge; a head equal to the one held writes nothing. It reads no pull request, no tree, no file and no protection: the merged and pushed messages, their inputs and the state inputs, the call of git.pull, the finding branch-unprotected with its held finding writer, and the ten-second redelivery go. A move whose head cannot be read is left unacknowledged for the bus to deliver again. B3: the pull-message path (Convert, the open pull requests at start and reconnect, the forge-delete message), the groups (internal/groups' group part, forge.group.merged, end-asks, bridge_groups, bridge_group_end_again), bridge_merged_message with the forge-made reader, the checker's owed and the merge act of a switched key (with the switch's bookkeeping read) go, with their consumes, invokes, states and requires. The gate's owed path stays (H-A-71), its catch-up from the gate's verb groups gone with that verb. The two meet in main.go and the package compiles only with both, as it did not since B1. The unit suites pass; the whole test (integration) is rewritten in B4. Builds: design 47 H §739, §764 (the forge bridge; the branch protection); lead answers H-A-23, H-A-27, H-A-48, H-A-71 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../mesh-delivery-forge-bridge-tools/main.go | 187 +----- .../main_test.go | 241 +------- .../mesh-delivery-forge-bridge-tools/owed.go | 2 +- .../mesh-delivery-forge-bridge/bound_test.go | 2 +- .../cmd/mesh-delivery-forge-bridge/call.go | 12 - .../mesh-delivery-forge-bridge/findings.go | 111 ---- .../mesh-delivery-forge-bridge/gate_test.go | 127 +--- .../mesh-delivery-forge-bridge/groupask.go | 67 --- .../cmd/mesh-delivery-forge-bridge/groups.go | 148 ----- .../mesh-delivery-forge-bridge/groups_test.go | 125 ---- .../cmd/mesh-delivery-forge-bridge/held.go | 16 +- .../cmd/mesh-delivery-forge-bridge/kept.go | 79 --- .../cmd/mesh-delivery-forge-bridge/main.go | 172 +----- .../mesh-delivery-forge-bridge/main_test.go | 388 ++++-------- .../cmd/mesh-delivery-forge-bridge/moves.go | 88 ++- .../mesh-delivery-forge-bridge/names_test.go | 6 +- .../cmd/mesh-delivery-forge-bridge/open.go | 143 ----- .../mesh-delivery-forge-bridge/open_test.go | 295 ---------- .../cmd/mesh-delivery-forge-bridge/owed.go | 88 +-- .../forgemsg/owed.go | 3 +- .../internal/bridge/bridge.go | 556 +----------------- .../internal/bridge/bridge_test.go | 423 ------------- .../internal/bridge/call.go | 59 -- .../internal/bridge/files_test.go | 412 ------------- .../internal/bridge/forgemade.go | 46 -- .../internal/bridge/kept.go | 64 -- .../internal/bridge/moved.go | 59 +- .../internal/bridge/moved_test.go | 74 +-- .../internal/bridge/owed.go | 39 +- .../internal/bridge/owed_test.go | 12 +- .../internal/bridge/paths_test.go | 36 -- .../internal/groups/groups.go | 301 ---------- .../internal/groups/owedask.go | 4 +- .../internal/groups/read_test.go | 49 -- .../manifest_test.go | 60 +- .../mesh-delivery-forge-bridge/module.json | 33 -- 36 files changed, 337 insertions(+), 4190 deletions(-) delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/findings.go delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groupask.go delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups.go delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups_test.go delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/kept.go delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open.go delete mode 100644 modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open_test.go delete mode 100644 modules/mesh-delivery-forge-bridge/internal/bridge/files_test.go delete mode 100644 modules/mesh-delivery-forge-bridge/internal/bridge/forgemade.go delete mode 100644 modules/mesh-delivery-forge-bridge/internal/bridge/kept.go delete mode 100644 modules/mesh-delivery-forge-bridge/internal/bridge/paths_test.go delete mode 100644 modules/mesh-delivery-forge-bridge/internal/groups/groups.go delete mode 100644 modules/mesh-delivery-forge-bridge/internal/groups/read_test.go diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go index 1add275e..9b246454 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go @@ -1,8 +1,8 @@ -// Command mesh-delivery-forge-bridge-tools serves the forge bridge's tools (novox/hq ADR 0633 §4, issue 1585; design 51): -// the runtime launches it for a call. bridge_tags reads a package's git tags through the seat git's verb tags, for the -// builder's floor. bridge_groups reads the delivery groups the gate holds and what the bridge kept of their ends; -// bridge_group_end_again writes an ask into the bridge's state end-asks and waits for the bridge's answer there, since the -// bridge is the other program and serves no request subject (ADR 0437 §4). +// Command mesh-delivery-forge-bridge-tools serves the forge bridge's tools (design 51; design 47 *What the gate owes the +// forge*): the runtime launches it for a call. bridge_tags reads a package's git tags through the seat git's verb tags, +// for the builder's floor; bridge_owed, bridge_owed_again and bridge_owed_drop write an ask into the bridge's state +// owed-asks and wait for the bridge's answer there, since the bridge is the other program and serves no request subject +// (ADR 0437 §4). package main import ( @@ -15,28 +15,14 @@ import ( "time" "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - "mesh-delivery-forge-bridge/internal/bridge" "mesh-delivery-forge-bridge/internal/groups" ) -// Tool names. -const ( - GroupsTool = "bridge_groups" - EndAgainTool = "bridge_group_end_again" - // MergedTool answers the merged message of a merge on request (issue 1585). - MergedTool = "bridge_merged_message" -) - -// asker writes an end-asks value and waits for the bridge's answer to it. -type asker func(key string, value []byte) (groups.EndAsk, error) - -// Tools are the bridge's tools: groupsRead reads the seat mesh-delivery's groups with what the bridge kept of them. -func Tools(ask asker, now func() time.Time, groupsRead func() ([]groups.Row, []string, error), merged func(repository, merge string, number int) (json.RawMessage, error), forge bridge.Caller) []stdio.Tool { +// Tools are the bridge's reading tools: forge calls the seat git. +func Tools(forge bridge.Caller) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } return []stdio.Tool{ {Name: bridge.TagsTool, @@ -49,150 +35,6 @@ func Tools(ask asker, now func() time.Time, groupsRead func() ([]groups.Row, []s Run: func(args map[string]any) (any, error) { return bridge.Tags(context.Background(), forge, str(args, "repository"), str(args, "prefix")) }}, - {Name: MergedTool, - Description: "The merged message of one merge, asked again (issue 1585): the message the bridge wrote on its stream FORGE when the " + - "pull request was merged into the trunk, built the same way from the forge (the merge commit's trees and the manifests " + - "and lock files of its module directories), the pull request's number, branch and head from the seat git's verb pull, and " + - "for a delivery group's member its group and members from the seat mesh-delivery's verb groups. For the indexer, which asks it when it takes in a held merge it does not hold in memory (a restart, a new " + - "build), and the ask-again a lost message lacked. About 0.5 MB for a repository of many modules. Answers {message} " + - "with the forge message whole, or why it cannot: the forge gives no merged pull request with that commit, or a seat did not answer. " + - "A merge made on the forge (a recovery merge, the operator's own) is read the same way.", - Input: map[string]any{"type": "object", "required": []string{"repository", "merge"}, "properties": map[string]any{ - "repository": map[string]any{"type": "string", "description": "the repository, owner/name, as the forge names it"}, - "merge": map[string]any{"type": "string", "description": "the merge commit, 40 hex digits"}, - "number": map[string]any{"type": "integer", "description": "the pull request's number, when known: the bridge reads that pull request and checks its merge commit"}}}, - Run: func(args map[string]any) (any, error) { - number, _ := args["number"].(float64) - raw, err := merged(str(args, "repository"), str(args, "merge"), int(number)) - if err != nil { - return nil, err - } - return map[string]any{"message": raw}, nil - }}, - {Name: GroupsTool, - Description: "The delivery groups the seat mesh-delivery's verb groups answers (more than one member), each with its members' delivery " + - "state and whether each merged message is written on the forge stream (with the merge commit it named), and whether the " + - "group's end (forge.group.merged) is written: ended, or open with why (gathered, or every message written and its end " + - "not written yet). An open group with every member's message written is " + - "what bridge_group_end_again says the end of. Each group names its last end ask (who, why, when) and the bridge's " + - "answer to it, from the state end-asks. A group's name narrows it to that group; open lists only open ones.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "group": map[string]any{"type": "string", "description": "only this group, by its id (its branch)"}, - "open": map[string]any{"type": "boolean", "description": "only the groups whose end is not written"}}}, - Run: func(args map[string]any) (any, error) { - rows, unread, err := groupsRead() - if err != nil { - return nil, err - } - only, _ := args["open"].(bool) - group := str(args, "group") - kept := rows[:0] - for _, r := range rows { - if (group != "" && r.Group != group) || (only && !r.Open) { - continue - } - kept = append(kept, r) - } - return map[string]any{"groups": kept, "unread": unread}, nil - }}, - {Name: EndAgainTool, - Description: "Say a delivery group's end (forge.group.merged) again, by hand, for a group whose end the indexer did not take " + - "in (a group bridge_groups names as merged with its end not written, or one the indexer waits for). The bridge " + - "writes it again from the seat mesh-delivery's groups, with the time appended to the message id so the stream does not drop it as " + - "a duplicate; the indexer takes an end for a group it already took in without changing anything. Refused while " + - "a member's merged message is not written. Answers whether it was written.", - Input: map[string]any{"type": "object", "required": []string{"group", "base"}, "properties": map[string]any{ - "group": map[string]any{"type": "string", "description": "the group, by its id (its branch)"}, - "base": map[string]any{"type": "string", "description": "the watched branch its members merged into, whose end is said again"}, - "why": map[string]any{"type": "string", "description": "why its end is said again, in plain words"}}}, - Run: func(args map[string]any) (any, error) { - key, value, err := groups.NewEndAsk(str(args, "group"), str(args, "base"), str(args, "why"), stdio.CallerOf(args), now()) - if err != nil { - return nil, err - } - a, err := ask(key, value) - if err != nil { - return nil, err - } - return map[string]any{"group": a.Group, "base": a.Base, "written": a.Written, "answer": a.Answer, "by": a.By, "why": a.Why}, nil - }}, - } -} - -// MergedOf is the merged message of the merge of repository at commit merge, as the bridge writes it: the pull request's -// number, branch and head through the seat git's verb pull (by number when given, else by the merge commit; a merge made -// on the forge is read the same way), the rest from the forge through trees and files (bridge.MergedMessage), and, for a -// member of a delivery group the seat mesh-delivery names (of), the group and its members as the process sets them. -func MergedOf(groupOf func(id string) ([]seat.Group, error), repository, merge string, number int, trees bridge.Trees, files bridge.Files, forge bridge.Caller) (json.RawMessage, error) { - owner, repo, ok := strings.Cut(repository, "/") - if !ok || owner == "" || repo == "" { - return nil, fmt.Errorf("%q is not owner/name", repository) - } - fp, err := bridge.ForgeMade(context.Background(), forge, owner, repo, number, merge) - if err != nil { - return nil, fmt.Errorf("the forge gives no merged pull request of %s with the commit %s: %w", repository, merge, err) - } - msg, err := bridge.MergedMessage(owner, repo, fp.Number, fp.Branch, fp.Head, merge, fp.Base, trees, files) - if err != nil { - return nil, fmt.Errorf("the merged message of %s at %s cannot be built: %w", repository, merge, err) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - return nil, err - } - of, err := groupOf(f.Branch) // the one group the pull request's branch names, never the whole list - if err != nil { - return nil, err - } - if g, ok := groups.Named(of, f.Branch, f.Repository, f.Number); ok { - f.Group, f.Members = g.ID, groups.MembersOf(g) - } - return forgemsg.EncodeForge(f) -} - -// read is the groups the seat mesh-delivery answers with what the bridge kept of them: the merged messages written and -// their ends in performed, and the last ask of each in end-asks with the bridge's answer. -func read(of []seat.Group, performed, asks stdio.KeptState) ([]groups.Row, []string, error) { - pkeys, err := performed.Keys() - if err != nil { - return nil, nil, fmt.Errorf("the bridge's performed state cannot be listed: %w", err) - } - published, ended := map[string]string{}, map[string]string{} - for _, k := range pkeys { - into := ended - switch { - case strings.HasPrefix(k, "published."): - into = published - case !strings.HasPrefix(k, "groups."): - continue - } - if e, err := performed.Get(k); err == nil && e != nil { - into[k] = strings.TrimSpace(string(e.Value)) - } - } - akeys, err := asks.Keys() - if err != nil { - return nil, nil, fmt.Errorf("the bridge's state %s cannot be listed: %w", groups.EndAsksState, err) - } - askRaws := map[string][]byte{} - for _, k := range akeys { - if e, err := asks.Get(k); err == nil && e != nil { - askRaws[k] = e.Value - } - } - rows, unread := groups.Rows(of, published, ended, askRaws) - return rows, unread, nil -} - -// askEnd writes the end-asks value at key and waits at most bound for the bridge's answer. -func askEnd(s stdio.KeptState, module string, bound time.Duration) asker { - wait := askState(s, groups.EndAsksBucket(module), bound, func(v []byte) bool { a, err := groups.DecodeEndAsk(v); return err == nil && a.Done() }) - return func(key string, value []byte) (groups.EndAsk, error) { - v, err := wait(key, value) - if err != nil { - return groups.EndAsk{}, err - } - return groups.DecodeEndAsk(v) } } @@ -252,19 +94,8 @@ func askCaller(_ context.Context, key string, body any) (json.RawMessage, error) func main() { // The module the runtime serves these tools as: the bridge's, whose states they ask (design 47 G A-296). served := os.Getenv(stdio.ServedAs) - performed, asks := stdio.State(groups.PerformedState), stdio.State(groups.EndAsksState) - tools := Tools(askEnd(asks, served, 25*time.Second), time.Now, - func() ([]groups.Row, []string, error) { - of, err := groups.ReadAll(context.Background(), askCaller) - if err != nil { - return nil, nil, err - } - return read(of, performed, asks) - }, - func(repository, merge string, number int) (json.RawMessage, error) { - ctx := context.Background() - return MergedOf(func(id string) ([]seat.Group, error) { return groups.ReadGroup(ctx, askCaller, id) }, repository, merge, number, bridge.TreesVia(ctx, askCaller), bridge.FilesVia(ctx, askCaller), askCaller) - }, askCaller) + performed := stdio.State(groups.PerformedState) + tools := Tools(askCaller) owedAsks := stdio.State(groups.OwedAsksState) recorder := meshhandactsclient.Recorder{Ask: stdio.Ask} tools = append(tools, OwedTools(askState(owedAsks, groups.OwedAsksBucket(served), 25*time.Second, func(v []byte) bool { diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go index 7d0523ee..ce28c7ed 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go @@ -1,226 +1,21 @@ package main import ( - "bytes" - "context" "encoding/json" "errors" - "strings" "testing" "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - "mesh-delivery-forge-bridge/internal/bridge" - - "mesh-delivery-forge-bridge/internal/gitfixture" "mesh-delivery-forge-bridge/internal/groups" ) -// 1585/T18, T19 (ADR 0633 §4), acceptance 49: bridge_groups names each group the seat mesh-delivery's verb groups answers -// with its members' state and whether its end is written (open or ended, with why), narrowed by group and by open; -// bridge_group_end_again writes an ask naming the group, who asked and why, and answers what the bridge answered. -func TestTheBridgeToolsReadTheGroupsAndAskTheEndAgain(t *testing.T) { - h1, h2 := strings.Repeat("1", 40), strings.Repeat("2", 40) - c1, c2 := strings.Repeat("c", 40), strings.Repeat("d", 40) - grp := func(id string, a, b int, stateB string) seat.Group { - return seat.Group{ID: id, State: "merging", Members: []seat.Member{{Repository: "novox/a", Number: int64(a), Head: h1, State: "merged", Base: "main"}, - {Repository: "novox/b", Number: int64(b), Head: h2, State: stateB, Base: "main"}}} - } - of := []seat.Group{grp("ended", 1, 2, "merged"), grp("ready", 3, 4, "merged"), grp("gathered", 5, 6, "merging"), - {ID: "solo", Members: []seat.Member{{Repository: "novox/a", Number: 7, Head: h1}}}, grp("", 8, 9, "merged")} - published := map[string]string{} - for _, n := range []int{1, 3, 5} { - published[groups.PublishedKey("novox/a", n)] = c1 - } - for _, n := range []int{2, 4} { - published[groups.PublishedKey("novox/b", n)] = c2 - } - // The state end-asks keeps the last ask of the group ready, answered, and one that does not read. - answeredAsk, _ := json.Marshal(groups.EndAsk{V: 1, Group: "ready", Base: "main", Why: "lost", By: "lead@shanks", At: time.Date(2026, 11, 4, 22, 0, 0, 0, time.UTC), - Written: true, Answer: "the end of the group is written again", Answered: time.Date(2026, 11, 4, 22, 0, 1, 0, time.UTC)}) - asks := map[string][]byte{"ready.main": answeredAsk, "gathered.main": []byte("{")} - var asked groups.EndAsk - var askedKey string - ask := func(key string, value []byte) (groups.EndAsk, error) { - askedKey = key - a, err := groups.DecodeEndAsk(value) - a.Written, a.Answer, a.Answered = true, "the end of the group is written again", time.Now() - asked = a - return a, err - } - tools := Tools(ask, func() time.Time { return time.Date(2026, 11, 4, 23, 0, 0, 0, time.UTC) }, - func() ([]groups.Row, []string, error) { - rows, unread := groups.Rows(of, published, map[string]string{"groups.ended.main": c2}, asks) - return rows, unread, nil - }, nil, nil) - call := func(name string, args map[string]any) any { - for _, tl := range tools { - if tl.Name == name { - out, err := tl.Run(args) - if err != nil { - t.Fatalf("%s: %v", name, err) - } - return out - } - } - t.Fatalf("no tool %s", name) - return nil - } - rowsOf := func(args map[string]any) map[string]groups.Row { - raw, _ := json.Marshal(call(GroupsTool, args)) - var out struct { - Groups []groups.Row `json:"groups"` - Unread []string `json:"unread"` - } - if err := json.Unmarshal(raw, &out); err != nil { - t.Fatal(err) - } - m := map[string]groups.Row{} - for _, r := range out.Groups { - m[r.Group] = r - } - if len(args) == 0 && strings.Join(out.Unread, ", ") != "a group with no id, end-asks.gathered.main" { - t.Errorf("unread = %v, want the group with no id and end-asks.gathered", out.Unread) - } - return m - } - all := rowsOf(map[string]any{}) - if len(all) != 3 || !all["ended"].Ended || all["ended"].EndedWith != c2 { - t.Fatalf("groups = %+v", all) - } - if r := all["ready"]; !r.Open || !strings.Contains(r.Words, "bridge_group_end_again") || !r.Members[1].Published || r.Members[1].Commit != c2 { - t.Errorf("ready = %+v, want open and published with its merge commit, its end the thing to say", r) - } - if a := all["ready"].LastEndAsk; a == nil || a.By != "lead@shanks" || a.Why != "lost" || !a.Written || a.Answer == "" || all["ended"].LastEndAsk != nil { - t.Errorf("ready's last end ask = %+v, ended's %+v: want ready's ask and its answer, none for ended", a, all["ended"].LastEndAsk) - } - if r := all["gathered"]; !r.Open || !strings.Contains(r.Words, "gathered") || r.Members[1].State != "merging" || r.Members[1].Published { - t.Errorf("gathered = %+v", r) - } - if open := rowsOf(map[string]any{"open": true}); len(open) != 2 || open["ended"].Group != "" { - t.Errorf("open = %+v, want ready and gathered", open) - } - if one := rowsOf(map[string]any{"group": "ready"}); len(one) != 1 { - t.Errorf("group ready = %+v", one) - } - out := call(EndAgainTool, map[string]any{"group": "ready", "base": "main", "why": "the indexer never took it in"}).(map[string]any) - if askedKey != "ready.main" || asked.Group != "ready" || asked.Base != "main" || asked.Why != "the indexer never took it in" || out["written"] != true { - t.Errorf("the ask %q %+v, answered %v", askedKey, asked, out) - } - for _, tl := range tools { - if tl.Name == EndAgainTool { - if _, err := tl.Run(map[string]any{}); err == nil { - t.Error("an ask naming no group was taken") - } - if _, err := tl.Run(map[string]any{"group": "ready"}); err == nil { - t.Error("an ask naming no base was taken") - } - } - } - - // §715: a group with members on two bases is two rows, one per base, each with its own members and key. - split := seat.Group{ID: "feat/s", State: "merging", Members: []seat.Member{{Repository: "novox/a", Number: 11, Base: "beta"}, {Repository: "novox/b", Number: 12, Base: "main"}, {Repository: "novox/c", Number: 13, Base: "beta"}}} - if rows, unread := groups.Rows([]seat.Group{split}, nil, nil, nil); len(unread) != 0 || len(rows) != 2 || rows[0].Base != "beta" || len(rows[0].Members) != 2 || rows[1].Base != "main" || len(rows[1].Members) != 1 || rows[0].Key == rows[1].Key { - t.Errorf("rows of a group on two bases = %+v unread %v", rows, unread) - } - - // 1585: bridge_merged_message answers the merged message as the bridge publishes it: for a lone pull request the same bytes - // the event gives through Convert, for a member of a delivery group those with its group and members set as the process - // sets them; a merge the gate does not hold, or a forge that does not answer, is said. - t.Run("bridge_merged_message answers the merged message as published", func(t *testing.T) { - h1, h2 := strings.Repeat("1", 40), strings.Repeat("2", 40) - c1, c2 := strings.Repeat("c", 40), strings.Repeat("d", 40) - trees := func(owner, repo, sha string) (string, map[string]string, error) { - return "root-" + sha[:4], map[string]string{"": "r", "modules/a": "ta-" + sha[:4]}, nil - } - files := func(owner, repo, path, ref string) ([]byte, error) { - if strings.HasSuffix(path, "module.json") { - return []byte(`{"module":"a"}`), nil - } - return nil, bridge.ErrNotFound - } - published := func(repo string, number int, head, branch, merge string) forgemsg.Forge { - msg, err := bridge.MergedMessage("novox", repo, number, branch, head, merge, "main", trees, files) - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - return f - } - // The seat mesh-delivery's groups: feat/g of novox/a#9 and novox/b#7; a lone pull request is in none. - of := []seat.Group{{ID: "fix/x", Members: []seat.Member{{Repository: "novox/a", Number: 9, Head: h2}, {Repository: "novox/b", Number: 7, Head: h1}}}} - for _, c := range []struct { - name string - of []seat.Group - repository string - merge string - number int - api bridge.Caller - want forgemsg.Forge - fail string - }{ - {name: "a lone pull request, by number", repository: "novox/a", merge: c2, number: 9, - api: forgeAnswers(t, 9, "", "merged", "fix/x", h2, c2, "main"), want: published("a", 9, h2, "fix/x", c2)}, - {name: "a lone pull request, by the merge commit", repository: "novox/a", merge: c2, - api: forgeAnswers(t, 0, c2, "merged", "fix/x", h2, c2, "main"), want: published("a", 9, h2, "fix/x", c2)}, - {name: "a member of a group", of: of, repository: "novox/a", merge: c2, - api: forgeAnswers(t, 0, c2, "merged", "fix/x", h2, c2, "main"), want: func() forgemsg.Forge { - f := published("a", 9, h2, "fix/x", c2) - f.Group, f.Members = "fix/x", []meshdeliveryclient.Head{{Repository: "novox/a", Number: 9, Head: h2}, {Repository: "novox/b", Number: 7, Head: h1}} - return f - }()}, - {name: "a forge pull request merged at another commit", repository: "novox/a", merge: c2, number: 9, - api: forgeAnswers(t, 9, "", "merged", "fix/x", h2, c1, "main"), fail: "not at " + c2}, - {name: "a forge pull request not merged", repository: "novox/a", merge: c2, number: 9, - api: forgeAnswers(t, 9, "", "open", "fix/x", h2, "", "main"), fail: "not merged"}, - // design 47 G §714: no filter to the trunk alone; the merged message names the branch it was merged into. - {name: "a forge pull request merged into another branch", repository: "novox/a", merge: c2, number: 9, - api: forgeAnswers(t, 9, "", "merged", "fix/x", h2, c2, "dev"), want: func() forgemsg.Forge { - f := published("a", 9, h2, "fix/x", c2) - f.Base = "dev" - return f - }()}, - {name: "a forge pull request with no head branch", repository: "novox/a", merge: c2, number: 9, - api: forgeAnswers(t, 9, "", "merged", "", h2, c2, "main"), fail: "no head branch"}, - {name: "a seat answer that says an error", repository: "novox/a", merge: c2, number: 9, - api: answering(gitfixture.Given(t, "pull answers an error, never none", "verb:pull.answer")), fail: "holds no pull request"}, - {name: "a seat answer with no pull request", repository: "novox/a", merge: c2, number: 9, - api: answering(json.RawMessage(`{}`)), fail: "carries nothing"}, - {name: "a forge that does not answer", repository: "novox/a", merge: c2, - api: func(context.Context, string, any) (json.RawMessage, error) { - return nil, errors.New("the forge is down") - }, fail: "the forge is down"}, - } { - t.Run(c.name, func(t *testing.T) { - raw, err := MergedOf(func(string) ([]seat.Group, error) { return c.of, nil }, c.repository, c.merge, c.number, trees, files, c.api) - if c.fail != "" { - if err == nil || !strings.Contains(err.Error(), c.fail) { - t.Fatalf("err %v, want %q", err, c.fail) - } - return - } - want, _ := forgemsg.EncodeForge(c.want) - if err != nil || !bytes.Equal(raw, want) { - t.Fatalf("err %v, answer\n%s\nwant the published message\n%s", err, raw, want) - } - }) - } - if _, err := MergedOf(func(string) ([]seat.Group, error) { return nil, nil }, "novox/a", c2, 9, func(string, string, string) (string, map[string]string, error) { - return "", nil, errors.New("the forge does not answer") - }, files, forgeAnswers(t, 9, "", "merged", "fix/x", h2, c2, "main")); err == nil || !strings.Contains(err.Error(), "does not answer") { - t.Errorf("a forge that does not answer: %v", err) - } - }) - - // Design 47 *What the gate owes the forge*: bridge_owed reads performed and asks the backlog; bridge_owed_again asks the - // act again; bridge_owed_drop writes the hand-act log first and drops nothing it could not record. +// Design 47 *What the gate owes the forge*: bridge_owed reads what the bridge performed and its consumer's backlog, +// bridge_owed_again and bridge_owed_drop write an ask and answer what the bridge answered, a drop naming why and +// recorded as a hand act first. +func TestTheBridgeTools(t *testing.T) { t.Run("the owed tools", func(t *testing.T) { at := time.Date(2026, 11, 9, 21, 0, 0, 0, time.UTC) var asked []groups.OwedAsk @@ -236,7 +31,7 @@ func TestTheBridgeToolsReadTheGroupsAndAskTheEndAgain(t *testing.T) { } return json.Marshal(a) } - rows := []OwedRow{{Of: seat.Seat, ID: "a", Outcome: forgemsg.OwedPerformed, At: at}, {Of: "mesh-delivery-checker", ID: "b", Outcome: forgemsg.OwedRefused, At: at}} + rows := []OwedRow{{Of: seat.Seat, ID: "a", Outcome: forgemsg.OwedPerformed, At: at}} var recorded []string recordErr := error(nil) record := func(what, why string) error { recorded = append(recorded, what+": "+why); return recordErr } @@ -269,29 +64,3 @@ func TestTheBridgeToolsReadTheGroupsAndAskTheEndAgain(t *testing.T) { } }) } - -// forgeAnswers is the seat git's verb pull for one pull request, asked by number (when number is given) or by the merge -// commit asked: the seat's own fixture with that pull request's state, branch, head, merge commit and base; any other -// ask is refused as the seat refuses it. -func forgeAnswers(t *testing.T, number int, byMerge, state, branch, head, merge, base string) bridge.Caller { - t.Helper() - var a git.PullAnswer - if err := json.Unmarshal(gitfixture.Given(t, "pull answers", "verb:pull.answer"), &a); err != nil || a.Pull == nil { - t.Fatalf("the seat's pull fixture: %v", err) - } - p := *a.Pull - p.Repository, p.Number, p.State, p.Branch, p.Head, p.MergeCommit, p.Base = "novox/a", 9, state, branch, head, merge, base - answer, _ := json.Marshal(git.PullAnswer{Pull: &p}) - return func(_ context.Context, key string, body any) (json.RawMessage, error) { - in, ok := body.(git.PullInput) - if key != "seat:git.pull" || !ok || in.Repository != "novox/a" || int(in.Number) != number || in.MergeCommit != byMerge { - return json.RawMessage(`{"error":"the forge holds no such pull request"}`), nil - } - return answer, nil - } -} - -// answering is a seat that answers raw to every ask. -func answering(raw json.RawMessage) bridge.Caller { - return func(context.Context, string, any) (json.RawMessage, error) { return raw, nil } -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/owed.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/owed.go index 2c7459b0..c615f25d 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/owed.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/owed.go @@ -53,7 +53,7 @@ func performedRows(s stdio.KeptState) ([]OwedRow, error) { func OwedTools(ask func(key string, value []byte) ([]byte, error), performed func() ([]OwedRow, error), record func(what, why string) error, now func() time.Time) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } act := map[string]any{ - "of": map[string]any{"type": "string", "description": "the seat that said the act: mesh-delivery (the gate) or mesh-delivery-checker"}, + "of": map[string]any{"type": "string", "description": "the seat that said the act: mesh-delivery (the gate)"}, "id": map[string]any{"type": "string", "description": "the act's id, as owed and owed.ended say it"}} asked := func(kind string, args map[string]any) (groups.OwedAsk, error) { key, value, err := groups.NewOwedAsk(kind, str(args, "of"), str(args, "id"), str(args, "why"), stdio.CallerOf(args), now()) diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/bound_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/bound_test.go index 5f9791f5..d521d33a 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/bound_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/bound_test.go @@ -47,7 +47,7 @@ func performedIsOpenedByItsBinding(t *testing.T) { f := &seatFake{} o, pub, kept := newOwing(f) o.waits = binding.Waiting - gate := gitfixture.Seat(t, seat.Seat, "events", "owed is said, a merge", "event:owed")[0] + gate := gitfixture.Seat(t, seat.Seat, "events", "owed is said, a status", "event:owed")[0] if _, err := o.heard(context.Background(), seat.Seat, gate); err == nil || len(f.calls) != 0 || len(pub.data) != 0 || len(kept) != 0 { t.Errorf("unbound: %v, called %v, said %d; want the act left unperformed and unsaid", err, f.calls, len(pub.data)) } diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/call.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/call.go index fae52344..41bb218b 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/call.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/call.go @@ -9,8 +9,6 @@ import ( "time" "github.com/nats-io/nats.go" - - "mesh-delivery-forge-bridge/internal/bridge" ) // callTimeout bounds a call to a tool (mesh-sdk go/process/call.go CallTimeout). @@ -82,13 +80,3 @@ func callSubjects(key, token string) (called, fallback string, err error) { } return "mesh.mod." + module + ".call." + tool + "." + token, "mesh.mod." + module + ".tool." + tool, nil } - -// treesVia asks the forge for a commit's trees through call. -func treesVia(ctx context.Context, call caller) bridge.Trees { - return bridge.TreesVia(ctx, bridge.Caller(call)) -} - -// filesVia asks the forge for a file through call. A file the forge says is not there is bridge.ErrNotFound. -func filesVia(ctx context.Context, call caller) bridge.Files { - return bridge.FilesVia(ctx, bridge.Caller(call)) -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/findings.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/findings.go deleted file mode 100644 index 6db37c04..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/findings.go +++ /dev/null @@ -1,111 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "time" - - "github.com/nats-io/nats.go/jetstream" - - condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" - stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The bridge's finding branch-unprotected (design 47 G §17, §387, §529): on every move of a watched branch the bridge reads the -// branch's protection again; a branch whose protection was removed starts nothing and is said as this finding, naming the -// branch, which the condition keeper raises and clears once the protection is back. The findings state is a `requires` -// entry opened by its binding (§577), written through mesh-sdk's held finding writer (§689). -const ( - // findingsLocal is the local name of the state findings in the manifest's `requires`. - findingsLocal = "findings" - // kindBranchUnprotected is the finding's kind. - kindBranchUnprotected = "branch-unprotected" - // findingScope is the finding's scope (design 47 G A-251). - findingScope = "merge" -) - -// findingWriter is the bridge's finding writer: mesh-sdk's held writer of the seat mesh-conditions' generated finding. -type findingWriter interface { - Write(ctx context.Context, f condseat.Finding) error - Clear(ctx context.Context, scope, id, kind, why string) error - Held() []condseat.Finding -} - -// findingState is the state findings, a bound bucket, as the held writer's state. -type findingState struct{ b *boundBucket } - -const findingStateTimeout = 10 * time.Second - -func (s findingState) Get(key string) (*stdio.StateEntry, error) { - ctx, cancel := context.WithTimeout(context.Background(), findingStateTimeout) - defer cancel() - e, err := s.b.Get(ctx, key) - if errors.Is(err, jetstream.ErrKeyNotFound) { - return nil, nil - } - if err != nil { - return nil, err - } - return &stdio.StateEntry{Key: key, Value: json.RawMessage(e.Value()), Revision: e.Revision()}, nil -} - -func (s findingState) Put(key string, value any) (uint64, error) { - data, err := json.Marshal(value) - if err != nil { - return 0, err - } - ctx, cancel := context.WithTimeout(context.Background(), findingStateTimeout) - defer cancel() - return s.b.Put(ctx, key, data) -} - -func (s findingState) Delete(key string) error { - ctx, cancel := context.WithTimeout(context.Background(), findingStateTimeout) - defer cancel() - return s.b.Delete(ctx, key) -} - -func (s findingState) Keys() ([]string, error) { - ctx, cancel := context.WithTimeout(context.Background(), findingStateTimeout) - defer cancel() - return s.b.Keys(ctx) -} - -// unprotectedID is the finding's id: `//` escaped as a key's part (A-251): a bus key holds no `~`, and EscapeName keeps `/`. -func unprotectedID(repository, branch string) string { - return keys.EscapeName(repository + "/" + branch) -} - -// protection says what a read of a watched branch's protection means for its finding: a branch not protected is written as -// the finding branch-unprotected (the writer says it only when it is new or changed), a protected one clears it when it is held. -func (mv *mover) protection(ctx context.Context, repository, branch string, protected bool, head string) { - if mv.findings == nil { - return - } - id := unprotectedID(repository, branch) - if protected { - for _, f := range mv.findings.Held() { - if f.Scope == findingScope && f.ID == id && f.Kind == kindBranchUnprotected { - if err := mv.findings.Clear(ctx, findingScope, id, kindBranchUnprotected, "the protection of "+branch+" is back"); err != nil { - mv.logger.Printf("%s of %s: the finding %s is not cleared: %v", branch, repository, kindBranchUnprotected, err) - } - } - } - return - } - now := time.Now() - if mv.now != nil { - now = mv.now() - } - now = now.UTC() - err := mv.findings.Write(ctx, condseat.Finding{Scope: findingScope, ID: id, Kind: kindBranchUnprotected, Severity: condseat.FindingSeverityWarning, - Headline: "the branch " + branch + " of " + repository + " is not protected", - Summary: fmt.Sprintf("the branch %s of %s moved to %s while its protection is removed: no delivering pipeline starts for it until the protection is back", branch, repository, head), - Source: "git.branch", Observer: forgeBridgeModule(), At: now, Subject: condseat.Subject{Scope: findingScope, ID: id}}) - if err != nil { - mv.logger.Printf("%s of %s: the finding %s is not written: %v", branch, repository, kindBranchUnprotected, err) - } -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go index 20c20e48..db0c6332 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go @@ -10,9 +10,7 @@ import ( "testing" "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" "mesh-delivery-forge-bridge/internal/gitfixture" @@ -61,13 +59,14 @@ func newOwing(f *seatFake) (*owing, *fakePub, memPerformed) { } // Design 47 *What the gate owes the forge*: an owed act is the seat git's verb under its id, its outcome said as -// owed.ended on the stream forge before it is kept in performed, an act it cannot read said undecodable; and at its start -// the bridge performs from the seat's groups every act said and not answered. +// owed.ended on the stream forge before it is kept in performed, an act it cannot read said undecodable (a merge among +// them: the bridge performs no merge, design 47 H §764). func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { t.Run("the names are the manifest's", theNamesAreTheManifests) t.Run("performed is opened by its binding", performedIsOpenedByItsBinding) gate := func(name string) []byte { return gitfixture.Seat(t, seat.Seat, "events", name, "event:owed")[0] } answer := func(verb, name string) json.RawMessage { return gitfixture.Given(t, name, "verb:"+verb+".answer") } + statusOK := map[string]json.RawMessage{"seat:git.status": answer("status", "status answers")} for _, c := range []struct { name, of string data []byte @@ -78,19 +77,16 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { kept bool err string }{ - {"a merge performed", seat.Seat, gate("owed is said, a merge"), - map[string]json.RawMessage{"seat:git.merge-pull": answer("merge-pull", "merge-pull answers")}, nil, - "seat:git.merge-pull", forgemsg.OwedPerformed, true, ""}, + {"a status performed", seat.Seat, gate("owed is said, a status"), statusOK, nil, "seat:git.status", forgemsg.OwedPerformed, true, ""}, {"a status refused", seat.Seat, gate("owed is said, a status"), map[string]json.RawMessage{"seat:git.status": answer("status", "status answers an error, never none")}, nil, "seat:git.status", forgemsg.OwedRefused, true, ""}, - {"the checker's status not answered", checker.Seat, gitfixture.Seat(t, checker.Seat, "events", "owed is said", "event:owed")[0], - nil, nil, "seat:git.status", forgemsg.OwedCouldNotBePerformed, true, ""}, + {"a status not answered", seat.Seat, gate("owed is said, a status"), nil, nil, "seat:git.status", forgemsg.OwedCouldNotBePerformed, true, ""}, + {"a merge, which the bridge does not perform", seat.Seat, gate("owed is said, a merge"), nil, nil, "", forgemsg.OwedUndecodable, true, ""}, {"an act it cannot read", seat.Seat, []byte(`{`), nil, nil, "", forgemsg.OwedUndecodable, false, ""}, - {"a seat that says no owed act", "mesh-wants", gate("owed is said, a merge"), nil, nil, "", forgemsg.OwedUndecodable, false, ""}, - {"the stream forge refusing the outcome", seat.Seat, gate("owed is said, a merge"), - map[string]json.RawMessage{"seat:git.merge-pull": answer("merge-pull", "merge-pull answers")}, errors.New("no responders"), - "seat:git.merge-pull", "", false, "could not be said"}, + {"a seat that says no owed act", "mesh-delivery-checker", gate("owed is said, a status"), nil, nil, "", forgemsg.OwedUndecodable, false, ""}, + {"the stream forge refusing the outcome", seat.Seat, gate("owed is said, a status"), statusOK, errors.New("no responders"), + "seat:git.status", "", false, "could not be said"}, } { f := &seatFake{answers: c.answers} o, pub, kept := newOwing(f) @@ -122,51 +118,10 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { } } - // Design 47 *The switch carries what is owed*: an act the gate switched from its old state is performed only when the old - // bridge's own bookkeeping does not name its key at its revision or later; one it names is said performed, not done. - t.Run("a switched act the old bridge performed", func(t *testing.T) { - var owed map[string]any - if err := json.Unmarshal(gate("owed is said, a merge"), &owed); err != nil { - t.Fatal(err) - } - id, err := meshdeliveryclient.SwitchedActID(meshdeliveryclient.SwitchedMerges, "feat~x", 7) - if err != nil { - t.Fatal(err) - } - owed["id"] = id - data, _ := json.Marshal(owed) - for _, c := range []struct { - name string - kept string // the old bridge's merges.feat~x, "" for none - called bool - }{ - {"kept at its revision", "7", false}, - {"kept at a later revision", "9", false}, - {"kept at an earlier revision", "6", true}, - {"not kept", "", true}, - } { - f := &seatFake{answers: map[string]json.RawMessage{"seat:git.merge-pull": answer("merge-pull", "merge-pull answers")}} - o, pub, kept := newOwing(f) - if c.kept != "" { - kept["merges.feat~x"] = []byte(c.kept) - } - if _, err := o.heard(context.Background(), seat.Seat, data); err != nil || len(pub.data) != 1 { - t.Fatalf("%s: %v, said %d", c.name, err, len(pub.data)) - } - e, _ := forgemsg.DecodeOwedEnded(pub.data[0]) - if (len(f.calls) == 1) != c.called || e.Outcome != forgemsg.OwedPerformed || e.ID != id { - t.Errorf("%s: called %v, said %+v; want called %v and performed", c.name, f.calls, e, c.called) - } - if _, ok := kept[performedKey(seat.Seat, id)]; !ok { - t.Errorf("%s: the outcome is not kept under the act's id", c.name) - } - } - }) - t.Run("heard from a seat's stream owed", func(t *testing.T) { - f := &seatFake{answers: map[string]json.RawMessage{"seat:git.merge-pull": answer("merge-pull", "merge-pull answers")}} + f := &seatFake{answers: statusOK} o, pub, _ := newOwing(f) - m := &fakeMsg{subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", data: gate("owed is said, a merge")} + m := &fakeMsg{subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", data: gate("owed is said, a status")} o.hear(context.Background(), seat.Seat, m) again := &fakeMsg{subject: m.subject, data: m.data} o.hear(context.Background(), seat.Seat, again) @@ -175,7 +130,11 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { m.acked, again.acked, f.calls, len(pub.data)) } pub.err = errors.New("no responders") - lost := &fakeMsg{subject: m.subject, data: gate("owed is said, a status")} + var other map[string]any + _ = json.Unmarshal(gate("owed is said, a status"), &other) + other["id"] = "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/other" + otherData, _ := json.Marshal(other) + lost := &fakeMsg{subject: m.subject, data: otherData} o.hear(context.Background(), seat.Seat, lost) if lost.acked != 0 || len(lost.nak) != 1 { t.Errorf("an outcome not said: acked %d, nak %v; want it heard again", lost.acked, lost.nak) @@ -183,12 +142,10 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { }) t.Run("asked again, dropped, and its backlog read by hand", func(t *testing.T) { - groupsAnswer := gitfixture.Seat(t, seat.Seat, "verbs", "groups answers a group with its members and acts", "verb:groups.answer")[0] - f := &seatFake{answers: map[string]json.RawMessage{"seat:git.merge-pull": answer("merge-pull", "merge-pull answers"), - "seat:mesh-delivery.groups": groupsAnswer, "seat:git.status": answer("status", "status answers")}} + f := &seatFake{answers: statusOK} o, pub, kept := newOwing(f) - merge := "merge.feat=47-G.0123456789ab.novox/mesh-sdk#178" - if _, err := o.heard(context.Background(), seat.Seat, gate("owed is said, a merge")); err != nil { + status := "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate" + if _, err := o.heard(context.Background(), seat.Seat, gate("owed is said, a status")); err != nil { t.Fatal(err) } backlog := func(context.Context) []groups.Backlog { return []groups.Backlog{{Stream: seat.StreamOwed, Waiting: 2}} } @@ -198,12 +155,10 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { calls, said int outcome, answers string }{ - {"again, from performed", groups.OwedAsk{Kind: groups.OwedAgain, Of: seat.Seat, ID: merge}, 2, 2, forgemsg.OwedPerformed, "performed"}, - // The fixture's status is in the groups only: the bridge never heard it. - {"again, from the groups", groups.OwedAsk{Kind: groups.OwedAgain, Of: seat.Seat, ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate"}, 4, 3, forgemsg.OwedPerformed, "performed"}, - {"dropped", groups.OwedAsk{Kind: groups.OwedDrop, Of: seat.Seat, ID: merge, Why: "merged by hand", By: "lead@shanks"}, 4, 4, forgemsg.OwedDropped, "merged by hand"}, - {"again, an act nobody holds", groups.OwedAsk{Kind: groups.OwedAgain, Of: checker.Seat, ID: "x"}, 4, 4, "", "checker says"}, - {"the backlog", groups.OwedAsk{Kind: groups.OwedBacklog}, 4, 4, "", "backlog"}, + {"again, from performed", groups.OwedAsk{Kind: groups.OwedAgain, Of: seat.Seat, ID: status}, 2, 2, forgemsg.OwedPerformed, "performed"}, + {"dropped", groups.OwedAsk{Kind: groups.OwedDrop, Of: seat.Seat, ID: status, Why: "set by hand", By: "lead@shanks"}, 2, 3, forgemsg.OwedDropped, "set by hand"}, + {"again, an act nobody holds", groups.OwedAsk{Kind: groups.OwedAgain, Of: seat.Seat, ID: "x"}, 2, 3, "", "holds no owed act"}, + {"the backlog", groups.OwedAsk{Kind: groups.OwedBacklog}, 2, 3, "", "backlog"}, } { a := o.answer(context.Background(), c.ask, backlog) if !a.Done() || a.Outcome != c.outcome || !strings.Contains(a.Answer, c.answers) || len(f.calls) != c.calls || len(pub.data) != c.said { @@ -214,42 +169,8 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { } } var p Performed - if err := json.Unmarshal(kept[performedKey(seat.Seat, merge)], &p); err != nil || p.Ended.Outcome != forgemsg.OwedDropped { + if err := json.Unmarshal(kept[performedKey(seat.Seat, status)], &p); err != nil || p.Ended.Outcome != forgemsg.OwedDropped { t.Errorf("performed after the drop: %+v %v", p, err) } }) - - t.Run("caught up from the groups", func(t *testing.T) { - groups := gitfixture.Seat(t, seat.Seat, "verbs", "groups answers a group with its members and acts", "verb:groups.answer")[0] - f := &seatFake{answers: map[string]json.RawMessage{"seat:mesh-delivery.groups": groups, - "seat:git.status": answer("status", "status answers")}} - o, pub, kept := newOwing(f) - // The fixture's merge has its outcome recorded; its status is said and unanswered. - if n, err := o.catchUp(context.Background()); err != nil || n != 1 || len(pub.data) != 1 || f.calls[1] != "seat:git.status" { - t.Fatalf("catch-up: %d %v, called %v; want the one unanswered status performed", n, err, f.calls) - } - if n, err := o.catchUp(context.Background()); err != nil || n != 0 || len(f.calls) != 3 { - t.Errorf("catch-up again: %d %v, called %v; want nothing performed that performed holds", n, err, f.calls) - } - if len(kept) != 1 { - t.Errorf("kept %v, want the status", kept) - } - // The seat answers a group it does not know with no groups, never an error (W11.10): nothing is performed and - // nothing fails; a groups the seat leaves unanswered is the catch-up's error. - none := gitfixture.Seat(t, seat.Seat, "verbs", "groups answers a group it does not know with no groups", "verb:groups.answer")[0] - for _, row := range []struct { - answer json.RawMessage - fails bool - }{{none, false}, {nil, true}} { - f := &seatFake{answers: map[string]json.RawMessage{}} - if row.answer != nil { - f.answers["seat:mesh-delivery.groups"] = row.answer - } - o, pub, _ := newOwing(f) - n, err := o.catchUp(context.Background()) - if (err != nil) != row.fails || n != 0 || len(pub.data) != 0 { - t.Errorf("catch-up from %s: %d performed, %v; want none performed, failing %v", row.answer, n, err, row.fails) - } - } - }) } diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groupask.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groupask.go deleted file mode 100644 index 88158e91..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groupask.go +++ /dev/null @@ -1,67 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "time" - - "github.com/nats-io/nats.go/jetstream" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - - "mesh-delivery-forge-bridge/internal/groups" -) - -// endAsked answers one value of the state end-asks (the tool bridge_group_end_again, ADR 0633 §4): a value not yet answered -// says the group's end again from the seat's groups, with the ask's time appended to the message id so the stream's duplicate -// window does not drop it, and is written back by compare-and-set at its revision with whether it was written. A value -// answered already (this bridge's own write) is left. -func (g *grouper) endAsked(ctx context.Context, kv jetstream.KeyValue, key string, rev uint64, value []byte) { - a, err := groups.DecodeEndAsk(value) - if err != nil { - g.logger.Printf("%s.%s holds what is not an end ask, left: %v", groups.EndAsksState, key, err) - return - } - if a.Done() { - return - } - a = g.answerEnd(ctx, a, time.Now()) - g.logger.Printf("the end of the group %q said again by %s (%s): %s", a.Group, a.By, a.Why, a.Answer) - data, err := json.Marshal(a) - if err != nil { - return - } - if _, err := kv.Update(ctx, key, data, rev); err != nil && !errors.Is(err, jetstream.ErrKeyExists) && !errors.Is(err, jetstream.ErrKeyRevisionMismatch) { - g.logger.Printf("%s.%s: the answer could not be written: %v", groups.EndAsksState, key, err) - } -} - -// answerEnd says the group's end again for an ask and returns the ask with its answer. -func (g *grouper) answerEnd(ctx context.Context, a groups.EndAsk, at time.Time) groups.EndAsk { - a.Answered = at.UTC() - if g.groups == nil { - a.Answer = "the bridge reads no groups" - return a - } - of, err := g.groups(ctx) - if err != nil { - a.Answer = "the groups cannot be read: " + err.Error() - return a - } - m, ok := seat.Group{}, false - for _, c := range of { - if c.ID == a.Group { - m, ok = c, true - } - } - switch { - case !ok || len(m.Members) < 2: - a.Answer = "the seat " + seat.Seat + " holds no group " + a.Group + " of more than one member" - case g.end(ctx, m, a.Base, groups.AgainStamp(a.At)): - a.Written, a.Answer = true, "the end of the group is written again" - default: - a.Answer = "the end on " + a.Base + " is not written: a member's merged message is not written, or FORGE refused it (the bridge's journal says which)" - } - return a -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups.go deleted file mode 100644 index e5aba649..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups.go +++ /dev/null @@ -1,148 +0,0 @@ -package main - -import ( - "context" - "log" - - "github.com/nats-io/nats.go/jetstream" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - - groupkeys "mesh-delivery-forge-bridge/internal/groups" -) - -// A delivery group's merges reach the indexer together (novox/hq ADR 0633 §4): the bridge sets the group on each -// member's merged message, from the seat mesh-delivery's verb groups (design 47 *A group's merges are taken in together*; -// it reads no state of the gate's), and once every member's merged message is written on FORGE it says the group's end, -// forge.group.merged, once, after the last of them. -// -// What it keeps of it is in its state performed: `published.` for each member's merged message written, its value -// the merge commit it named (the hash is the first 16 hex digits of the sha256 of `#`), and -// `groups.` once the group's end is written, its value the last member's merge commit. A group whose end is not -// written yet is open (bridge_groups reads them). A group gathers per watched branch: its end is said once per base, from -// the members whose base the seat says is that branch, and its key is `groups..` (design 47 G §715). - -// groupsRead is every delivery group the seat answers. -type groupsRead func(ctx context.Context) ([]seat.Group, error) - -// strs is performed as string values by key: the grouper's `published.` and `groups.` keys. -type strs interface { - Get(ctx context.Context, key string) (value string, found bool, err error) - Put(ctx context.Context, key, value string) error -} - -// grouper sets a member's group and says a group's end. -type grouper struct { - groups groupsRead - send func(ctx context.Context, subject string, data []byte, id string) error // writes on FORGE with the message id - done strs - logger *log.Logger -} - -// sendVia writes on FORGE through pub, with the message id. -func sendVia(pub publisher) func(context.Context, string, []byte, string) error { - return func(ctx context.Context, subject string, data []byte, id string) error { - _, err := pub.Publish(ctx, subject, data, jetstream.WithMsgID(id)) - return err - } -} - -// groupsVia reads the groups through the seat mesh-delivery's verb groups. -func groupsVia(call caller) groupsRead { - return func(ctx context.Context) ([]seat.Group, error) { return groupkeys.Read(ctx, call) } -} - -// groupOf is the group a merged message's branch names, when the seat names the message's pull request among its -// members and the group has more than one: a lone pull request is no group. -func (g *grouper) groupOf(ctx context.Context, f forgemsg.Forge) (seat.Group, bool) { - if g == nil || g.groups == nil || f.Branch == "" { - return seat.Group{}, false - } - of, err := g.groups(ctx) - if err != nil { - g.logger.Printf("%s#%d: the groups cannot be read, so its merged message names no group: %v", f.Repository, f.Number, err) - return seat.Group{}, false - } - return groupkeys.Named(of, f.Branch, f.Repository, f.Number) -} - -// member sets the group and its members on a merged message's body (ADR 0633 §4); any other body, and a merge of no -// group, is left as it is. -func (g *grouper) member(ctx context.Context, data []byte) ([]byte, forgemsg.Forge, bool) { - f, err := forgemsg.DecodeForge(data) - if err != nil || f.Kind != forgemsg.ForgeMerged { - return data, f, false - } - m, ok := g.groupOf(ctx, f) - if !ok { - return data, f, false - } - f.Group, f.Members = m.ID, groupkeys.MembersOf(m) - out, err := forgemsg.EncodeForge(f) - if err != nil { - g.logger.Printf("%s#%d: its merged message cannot name the group %q, written without: %v", f.Repository, f.Number, m.ID, err) - return data, f, false - } - return out, f, true -} - -// published keeps that a member's merged message is written, and says the group's end when it was the last. -func (g *grouper) published(ctx context.Context, f forgemsg.Forge) { - if err := g.done.Put(ctx, groupkeys.PublishedKey(f.Repository, f.Number), f.Merge); err != nil { - g.logger.Printf("%s#%d: that its merged message is written is not kept, so the group's end waits for bridge_group_end_again: %v", f.Repository, f.Number, err) - return - } - if m, ok := g.groupOf(ctx, f); ok { - g.end(ctx, m, f.Base, "") - } -} - -// end says the group's end (forge.group.merged) once every member's merged message is written, after the last of them; -// never on a refusal (ADR 0441 §3: a held group merges on from it), since a refused member's message is never written. It -// is written once per group and base: `groups..` in performed says it was. again says it is written again by hand -// (bridge_group_end_again), with the time appended to the message id, so the duplicate window does not drop it. -func (g *grouper) end(ctx context.Context, m seat.Group, base, again string) bool { - if len(m.Members) < 2 { - return false - } - onBase := groupkeys.OnBase(m, base) - if len(onBase) == 0 { - g.logger.Printf("the group %q has no member on %q, so no end is said on it", m.ID, base) - return false - } - key, err := groupkeys.Key(m.ID, base) - if err != nil { - g.logger.Printf("the group %q cannot be kept, so its end is not said: %v", m.ID, err) - return false - } - if again == "" { - if _, seen, err := g.done.Get(ctx, key); err == nil && seen { - return false - } - } - // The members in the group's order, which the gate merges them in (ADR 0441 §5), so the last commit names the end. - end := forgemsg.ForgeGroupEnd{Group: m.ID, Base: base} - for _, member := range onBase { - merge, ok, err := g.done.Get(ctx, groupkeys.PublishedKey(member.Repository, int(member.Number))) - if err != nil || !ok || merge == "" { - return false // its merged message is not written yet: said when it is (published) - } - end.Members = append(end.Members, forgemsg.GroupMerge{Repository: member.Repository, Number: int(member.Number), Merge: merge}) - } - data, err := forgemsg.EncodeForgeGroupEnd(end) - if err != nil { - g.logger.Printf("the end of the group %q cannot be written: %v", m.ID, err) - return false - } - last := end.Members[len(end.Members)-1].Merge - if err := g.send(ctx, forgeSubject(forgemsg.ForgeGroupEndEvent), data, groupkeys.EndID(m.ID, base, last, again)); err != nil { - g.logger.Printf("the end of the group %q is not written on FORGE, written by bridge_group_end_again: %v", m.ID, err) - return false - } - if err := g.done.Put(ctx, key, last); err != nil { - g.logger.Printf("the end of the group %q is written and not kept: the stream's duplicate window drops a second one: %v", m.ID, err) - } - g.logger.Printf("the end of the group %q on %q is written: %d members merged, the last %s", m.ID, base, len(end.Members), last) - return true -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups_test.go deleted file mode 100644 index ad922071..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/groups_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package main - -import ( - "bytes" - "context" - "errors" - "log" - "strings" - "testing" - "time" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - - groupkeys "mesh-delivery-forge-bridge/internal/groups" -) - -// idPub records the subjects, bodies and message ids it is handed. -type idPub struct { - subjects, ids []string - data [][]byte -} - -func (p *idPub) send(_ context.Context, subject string, data []byte, id string) error { - p.subjects, p.data, p.ids = append(p.subjects, subject), append(p.data, data), append(p.ids, id) - return nil -} - -// 1585/T16, T17, T19 (ADR 0633 §4), acceptance 49: a member's merged message names its group from the seat -// mesh-delivery's verb groups, the group's end is said once after the last member's merged message, and said again by hand. -func TestAGroupsMembersNameItAndItsEndIsSaidOnce(t *testing.T) { - ctx := context.Background() - h1, h2 := strings.Repeat("1", 40), strings.Repeat("2", 40) - c1, c2 := strings.Repeat("c", 40), strings.Repeat("d", 40) - group := seat.Group{ID: "feat/take-in", State: "merging", Members: []seat.Member{ - {Repository: "novox/mesh-sdk", Number: 37, Head: h1, State: "merged", Base: "beta"}, {Repository: "novox/mesh-delivery", Number: 9, Head: h2, State: "merging", Base: "beta"}, - {Repository: "novox/mesh-tools", Number: 5, Head: h2, State: "merging", Base: "main"}}} - var of []seat.Group - var read error - var logs bytes.Buffer - pub, done := &idPub{}, memStrs{} - g := &grouper{send: pub.send, done: done, logger: log.New(&logs, "", 0), - groups: func(context.Context) ([]seat.Group, error) { return of, read }} - mergedOf := func(repo string, number int, head, commit string) []byte { - data, err := forgemsg.EncodeForge(forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: repo, Branch: "feat/take-in", Base: "beta", Number: number, Head: head, Merge: commit, Root: "r"}) - if err != nil { - t.Fatal(err) - } - return data - } - // A lone pull request's merged message carries no group, and neither does one whose groups cannot be read. - of = []seat.Group{group, {ID: "solo", Members: []seat.Member{{Repository: "novox/hq", Number: 4, Head: h1}}}} - lone, _ := forgemsg.EncodeForge(forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: "novox/hq", Branch: "solo", Number: 4, Head: h1, Merge: c1, Root: "r"}) - if _, f, ok := g.member(ctx, lone); ok || f.Group != "" { - t.Errorf("a lone pull request names the group %q", f.Group) - } - read = errors.New("the seat did not answer") - if _, f, ok := g.member(ctx, mergedOf("novox/mesh-sdk", 37, h1, c1)); ok || f.Group != "" || !strings.Contains(logs.String(), "the seat did not answer") { - t.Errorf("a group read that failed names the group %q: %s", f.Group, logs.String()) - } - read = nil - // The first member: its message names the group and both members in the group's order; the group is not ended. - data, f, ok := g.member(ctx, mergedOf("novox/mesh-sdk", 37, h1, c1)) - if back, err := forgemsg.DecodeForge(data); !ok || err != nil || back.Group != "feat/take-in" || len(back.Members) != 3 || back.Members[0].Number != 37 { - t.Fatalf("a member's message: %+v %v", back, err) - } - g.published(ctx, f) - if len(pub.subjects) != 0 || done[groupkeys.PublishedKey("novox/mesh-sdk", 37)] != c1 { - t.Fatalf("after the first member: ends %v, performed %v", pub.subjects, done) - } - // The last member's merged message ends the group; a second merged message of it says no second end. - _, f, _ = g.member(ctx, mergedOf("novox/mesh-delivery", 9, h2, c2)) - g.published(ctx, f) - g.published(ctx, f) - if len(pub.subjects) != 1 || pub.subjects[0] != "mesh.stream.mesh-delivery-forge-bridge.event.forge.group.merged" || pub.ids[0] != "group-end.feat/take-in.beta."+c2 { - t.Fatalf("ends %v ids %v, want one forge.group.merged with id group-end.feat/take-in.beta.%s", pub.subjects, pub.ids, c2) - } - end, err := forgemsg.DecodeForgeGroupEnd(pub.data[0]) - if err != nil || end.Base != "beta" || len(end.Members) != 2 || end.Members[0].Merge != c1 || end.Members[1].Merge != c2 { - t.Errorf("the end = %+v %v, want the two members on beta in the group's order", end, err) - } - if key, _ := groupkeys.Key("feat/take-in", "beta"); done[key] != c2 { - t.Errorf("performed %v: want groups.feat~take-in kept with the last merge", done) - } - // §715: the member on main is on another base, and its merged message ends the group on main alone, once. - done[groupkeys.PublishedKey("novox/mesh-tools", 5)] = c1 - g.published(ctx, forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-tools", Branch: "feat/take-in", Base: "main", Number: 5, Merge: c1}) - g.published(ctx, forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-tools", Branch: "feat/take-in", Base: "main", Number: 5, Merge: c1}) - if mainEnd, err := forgemsg.DecodeForgeGroupEnd(pub.data[len(pub.data)-1]); len(pub.subjects) != 2 || err != nil || mainEnd.Base != "main" || len(mainEnd.Members) != 1 || mainEnd.Members[0].Number != 5 { - t.Errorf("ends %d, the last %+v %v: want one more end, on main, of the member on main alone", len(pub.subjects), mainEnd, err) - } - // 1585/T19: an ask to say a group's end again is answered from the seat's groups, with the ask's time on the message id; - // not written while a member's merged message is not written, with the reason; not for a group the seat does not hold, - // nor when the groups cannot be read. - ask := groupkeys.EndAsk{V: 1, Group: "feat/take-in", Base: "beta", By: "operator@shanks", Why: "the indexer never took it in", At: time.Date(2026, 11, 4, 23, 0, 0, 123, time.UTC)} - for _, tc := range []struct { - name string - of []seat.Group - read error - published bool - written bool - answer string - }{ - {"every message written: written again", []seat.Group{group}, nil, true, true, "written again"}, - {"a base no member is on", []seat.Group{{ID: group.ID, Members: []seat.Member{group.Members[2], {Repository: "novox/mesh-sdk", Number: 37, Base: "main"}}}}, nil, true, false, "not written"}, - {"a member's message not written", []seat.Group{group}, nil, false, false, "not written"}, - {"no such group at the seat", []seat.Group{{ID: "other", Members: group.Members}}, nil, true, false, "holds no group"}, - {"the groups cannot be read", nil, errors.New("no answer"), true, false, "cannot be read"}, - } { - pub, done := &idPub{}, memStrs{} - if tc.published { - done[groupkeys.PublishedKey("novox/mesh-sdk", 37)], done[groupkeys.PublishedKey("novox/mesh-delivery", 9)] = c1, c2 - done[groupkeys.PublishedKey("novox/mesh-tools", 5)] = c1 - } - g := &grouper{send: pub.send, done: done, logger: log.New(&bytes.Buffer{}, "", 0), - groups: func(context.Context) ([]seat.Group, error) { return tc.of, tc.read }} - got := g.answerEnd(ctx, ask, ask.At.Add(time.Second)) - if got.Written != tc.written || !strings.Contains(got.Answer, tc.answer) || !got.Done() || len(pub.ids) != map[bool]int{true: 1}[tc.written] { - t.Errorf("%s: %+v, ids %v", tc.name, got, pub.ids) - } - if tc.written && pub.ids[0] != groupkeys.EndID("feat/take-in", "beta", c2, groupkeys.AgainStamp(ask.At)) { - t.Errorf("%s: the id %s does not carry the ask's time", tc.name, pub.ids[0]) - } - } -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/held.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/held.go index f71b18f6..5ace2802 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/held.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/held.go @@ -3,14 +3,26 @@ package main import ( "context" "errors" + "time" "github.com/nats-io/nats.go/jetstream" ) // headsBucket is the module's state bucket heads, `_`, module its credential's (design 47 G A-296): the head -// last written on FORGE for each pull request (manifest state entry heads, novox/hq ADR 0443 §5). +// held for each watched branch, under `branch...` (design 47 H §739, A-236). func headsBucket(module string) string { return module + "_heads" } +// headStore is the state heads as the mover reads and writes it. +type headStore interface { + // Get is the head kept under the key; found is false when there is none. + Get(ctx context.Context, key string) (head string, found bool, err error) + Put(ctx context.Context, key, head string) error +} + +// handleDeadline bounds the handling of one heard message: its calls and every read and write of the state and the +// stream forge. +const handleDeadline = 30 * time.Second + // kvHeads is the bucket heads as the bridge's headStore. type kvHeads struct{ kv keptStore } @@ -29,5 +41,3 @@ func (s kvHeads) Put(ctx context.Context, key, head string) error { _, err := s.kv.PutString(ctx, key, head) return err } - -func (s kvHeads) Delete(ctx context.Context, key string) error { return s.kv.Delete(ctx, key) } diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/kept.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/kept.go deleted file mode 100644 index a084e5cc..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/kept.go +++ /dev/null @@ -1,79 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "log" - "regexp" - "sync" - "time" - - "github.com/nats-io/nats.go/jetstream" - - "mesh-delivery-forge-bridge/internal/bridge" -) - -// inputsBucket is the module's state bucket inputs (manifest state entry inputs): what the bridge read of a module -// directory, its manifest and lock-file hashes, by the directory's git tree hash, so a merge reads the forge only for the -// directories it changed (issue 1126; internal/bridge kept.go). A tree hash names its bytes, so a value is never stale; -// a merge adds a value only for each directory it changed (a few kilobytes each). -func inputsBucket(module string) string { return module + "_inputs" } - -// keptTimeout bounds one read or write of the bucket: the bucket is a saving, never a reason to fail a merge. -const keptTimeout = 2 * time.Second - -var treeHash = regexp.MustCompile(`^[0-9a-f]{40}$|^[0-9a-f]{64}$`) - -// kept is the bridge's Kept: in memory always, and in the bucket inputs when it is on the bus, so the first merge after a -// start reads only what changed too. A value the bucket cannot give or take is read from the forge, and said. -type kept struct { - kv jetstream.KeyValue // nil when the bucket is not on the bus - logger *log.Logger - mu sync.Mutex - mem map[string]bridge.Inputs -} - -func newKept(kv jetstream.KeyValue, logger *log.Logger) *kept { - return &kept{kv: kv, logger: logger, mem: map[string]bridge.Inputs{}} -} - -func (k *kept) Get(tree string) (bridge.Inputs, bool) { - k.mu.Lock() - in, ok := k.mem[tree] - k.mu.Unlock() - if ok || k.kv == nil || !treeHash.MatchString(tree) { - return in, ok - } - ctx, cancel := context.WithTimeout(context.Background(), keptTimeout) - defer cancel() - e, err := k.kv.Get(ctx, tree) - if err != nil { - return bridge.Inputs{}, false // not kept (or not readable): read from the forge - } - if err := json.Unmarshal(e.Value(), &in); err != nil || in.Manifest == "" { - k.logger.Printf("inputs.%s cannot be read, so its directory is read from the forge: %v", tree, err) - return bridge.Inputs{}, false - } - k.mu.Lock() - k.mem[tree] = in - k.mu.Unlock() - return in, true -} - -func (k *kept) Put(tree string, in bridge.Inputs) { - k.mu.Lock() - k.mem[tree] = in - k.mu.Unlock() - if k.kv == nil || !treeHash.MatchString(tree) { - return - } - data, err := json.Marshal(in) - if err != nil { - return - } - ctx, cancel := context.WithTimeout(context.Background(), keptTimeout) - defer cancel() - if _, err := k.kv.Put(ctx, tree, data); err != nil { - k.logger.Printf("inputs.%s is not kept, so the next merge reads its directory from the forge again: %v", tree, err) - } -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main.go index 815830d5..e832e94f 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main.go @@ -1,13 +1,12 @@ -// Command mesh-delivery-forge-bridge is delivery's forge bridge (novox/hq ADR 0437 §4, issue 1235): it hears the forge -// module's pull request events and writes each as a pull message on its stream FORGE. It runs beside today's -// mesh-delivery and merges nothing. It serves no request subject and holds no timer: every reaction is an event -// (ADR 0437 §8); a refused act is tried again only on the next event touching its meshdeliveryclient. +// Command mesh-delivery-forge-bridge is delivery's forge bridge: it says one message head-moved on its stream forge for +// every move of a watched branch's head, heard on the seat git's branch-moved and read at its start (novox/hq design 47 H +// §739), and performs what the gate owes the forge through the seat git, its outcome said as owed.ended. It serves no +// request subject and holds no timer: every reaction is an event (ADR 0437 §8). package main import ( "context" "encoding/json" - "errors" "fmt" "io" "log" @@ -23,12 +22,10 @@ import ( "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" - condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" mcseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/sourcebranches" "mesh-delivery-forge-bridge/internal/bridge" @@ -73,40 +70,6 @@ type publisher interface { Publish(ctx context.Context, subject string, payload []byte, opts ...jetstream.PublishOpt) (*jetstream.PubAck, error) } -// handle turns one pull request event into its message on FORGE and acknowledges it (bridge.Convert). An event it cannot -// read is terminated, never redelivered, and the log names its subject and why. A message it could not write stays -// unacknowledged: the server delivers it again (the server's ack wait is the only clock). -func handle(ctx context.Context, m delivered, pub publisher, files bridge.Files, watched bridge.Watching, logger *log.Logger) { - msg, err := bridge.Convert(m.Subject(), m.Data(), files, watched) - switch { - case errors.Is(err, bridge.ErrRetry): - logger.Printf("%v; heard again in %s", err, retryDelay) - _ = m.NakWithDelay(retryDelay) - return - case errors.Is(err, bridge.ErrNotHandled): - logger.Printf("%v; nothing written", err) - _ = m.Ack() - return - case err != nil: - logger.Printf("%v; the event is dropped", err) - _ = m.Term() - return - } - var opts []jetstream.PublishOpt - // The forge's event id makes a redelivery after a lost acknowledgement the same message to the stream. - if id := m.Headers().Get("x-event-id"); id != "" { - opts = append(opts, jetstream.WithMsgID(id)) - } - if _, err := pub.Publish(ctx, forgeSubject(msg.Event), msg.Data, opts...); err != nil { - logger.Printf("%s: %s could not be written on FORGE, left for redelivery: %v", m.Subject(), msg.Event, err) - return - } - if msg.Said != "" { - logger.Printf("%s: %s", m.Subject(), msg.Said) - } - _ = m.Ack() -} - // run is the program: it returns when ctx ends or the bus cannot be used. func run(ctx context.Context, getenv func(string) string, logOut io.Writer) error { logger := log.New(logOut, "mesh-delivery-forge-bridge: ", log.LstdFlags) @@ -115,91 +78,49 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return err } setForgeBridgeModule(cred.Module) // the bridge names its own states and stream from its credential's module (A-296, §428) - again := make(chan struct{}, 1) - conn, js, err := cred.Dial( - nats.ReconnectHandler(func(*nats.Conn) { - select { - case again <- struct{}{}: - default: - } - }), - ) + conn, js, err := cred.Dial() if err != nil { return err } defer conn.Close() - // What the forge holds open, said before any event is heard, and again at each reconnect (ADR 0429 §13). call := callerOn(conn, cred.User) - // No forge event is heard while the open pull requests are read and said (ADR 0443 §5): events and syncs take turns. - var turn sync.Mutex - kv, err := process.EssentialBucket(ctx, js, "bridge", headsBucket(cred.Module), "keep the heads it wrote on the forge stream") + kv, err := process.EssentialBucket(ctx, js, "bridge", headsBucket(cred.Module), "keep the head it holds for each watched branch") if err != nil { return err } heads := kvHeads{kv} - // Everything written on FORGE, an event's and a sync's, keeps the head in the bucket. - rec := &recorder{pub: js, heads: heads, logger: logger} // The branches the bridge watches (design 47 G §4, §507, §532): the registrations' first view and then // registration-changed; before the first registration, the gate's source's branches and its source-moved. Nothing is // written before both first views are held (ready). watched := &bridge.Watched{} - said := func(ctx context.Context) error { return syncOpen(ctx, call, rec, heads, watched, &turn, logger) } // The module's one pull of its durable consumer on the shared events stream is its event hub (below). hub := process.NewEventHub(logger.Printf) // The state performed is a `requires` entry: opened by its binding, asked of the seat mesh-broker's show at this start // as a kept call and again on its recreated and dropped (design 47 G §577). Until show answers, nothing owed is // performed and the bridge says it waits, naming the entry. - binding := process.NewBinding(brokerSeat, forgeBridgeModule(), keptCallOf(ctx, call), logger.Printf, performedLocal, findingsLocal, views.FindingEventsLocal) + binding := process.NewBinding(brokerSeat, forgeBridgeModule(), keptCallOf(ctx, call), logger.Printf, performedLocal) if err := binding.Register(hub); err != nil { return err } binding.Ask(performedLocal) - binding.Ask(findingsLocal) - binding.Ask(views.FindingEventsLocal) if w := binding.Waiting(); w != "" { logger.Printf("the bridge %s: nothing owed to the forge is performed until it is bound", w) } performedKV := &boundBucket{binding: binding, local: performedLocal, js: js} - // The bridge's one finding, branch-unprotected (design 47 G §17, §387): written through mesh-sdk's held finding writer into the - // state findings, a `requires` entry opened by its binding; a writer that cannot start (the entry is not bound, or the stream - // of its asks is not there yet) is said, and what it holds is stated at the next start. - findingsWriter, err := views.NewHeldWriter(views.WriterConfig[condseat.Finding, condseat.FindingCleared, condseat.FindingsStated, condseat.FindingsAskedEvent]{ - Module: cred.Module, State: findingState{&boundBucket{binding: binding, local: findingsLocal, js: js}}, Node: cred.Node, - Asked: condseat.SubjectFindingsAsked, JS: js, Conn: conn, Logf: logger.Printf, - // Its finding events under its binding finding-events (design 47 G A-274, §529). - Bindings: binding}) - if err != nil { - return fmt.Errorf("the bridge's finding writer cannot be made: %w", err) - } - defer findingsWriter.Close() - if err := findingsWriter.Start(ctx); err != nil { - logger.Printf("the finding writer cannot start, the finding branch-unprotected is stated at the next start: %v", err) - } - // What the gate and the checker owe the forge, performed through the seat git (design 47 *What the gate owes the forge*). + // What the gate owes the forge, performed through the seat git (design 47 *What the gate owes the forge*). owe := &owing{call: call, pub: js, performed: kvPerformed{performedKV}, waits: binding.Waiting, now: time.Now, logger: logger} - // A delivery group's member names its group, and its end is said once (ADR 0633 §4), from the seat mesh-delivery's groups. - groups := &grouper{groups: groupsVia(call), send: sendVia(js), done: kvHeads{performedKV}, logger: logger} - // A person says a group's end again with bridge_group_end_again, which writes the state end-asks (ADR 0633 §4): watched, and - // answered there; a state not there at this start is answered from the next start. - if kv := process.OptionalBucket(ctx, js, groupkeys.EndAsksBucket(forgeBridgeModule()), "bridge_group_end_again is not answered until the bridge starts again", logger.Printf); kv != nil { - go func() { - err := watch(ctx, kv, func(key string, rev uint64, value []byte) { groups.endAsked(ctx, kv, key, rev, value) }) - if err != nil && ctx.Err() == nil { - logger.Printf("the end asks are no longer watched, so bridge_group_end_again is not answered until the bridge starts again: %v", err) - } - }() - } keptCall := keptCallOf(ctx, call) reader := &views.ProcessReader{Module: forgeBridgeModule(), Call: keptCall, Logf: logger.Printf, Hub: hub} src := sourcebranches.New(sourcebranches.Call(keptCall)) var regs *meshcatalogclient.Registrations - var mv *mover + turn := &sync.Mutex{} + mv := &mover{call: call, pub: js, heads: heads, watched: watched, turn: turn, logger: logger} recompute := func() { if regs != nil { watched.Set(registeredOf(regs.All()), unescaped(src.Branches())) } } - started := make(chan struct{}) // closed once the watched branches are read and the open pull requests said + started := make(chan struct{}) // closed once the watched branches are read regs, _, err = meshcatalogclient.WireRegistrationsProcess(reader, keptCall, func(mcseat.Registration, bool) { recompute() select { @@ -216,32 +137,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return err } reader.Start(ctx, js, cred, nil) - // What a merge read of each module directory, by its tree (issue 1126): a merge reads only the directories it changed. - inputs := newKept(process.OptionalBucket(ctx, js, inputsBucket(cred.Module), "a merge's module directories are kept in memory only, so the first merge after a start reads every one", logger.Printf), logger) - mv = &mover{call: call, pub: rec, heads: heads, watched: watched, inputs: inputs, groups: groups, findings: findingsWriter, turn: &turn, logger: logger} - // The hub's handler of the forge's events, for every event its consumes filter lets through. Essential: the forge's - // events are what the bridge carries. The forge's events are the seat git's (novox/hq design 47 *The seat `git`*), - // whichever module holds it. - if err := hub.Handle("mesh.seat."+git.Seat+".event.>", func(m jetstream.Msg) { - select { - case <-started: - case <-ctx.Done(): - return - } - hear(&turn, func() { - // Bounded: the turn is held, and no sync or other event goes on without it. - hctx, cancel := context.WithTimeout(ctx, syncDeadline) - defer cancel() - handle(hctx, m, rec, filesVia(hctx, call), watched, logger) - }) - }); err != nil { - return err - } if err := hub.Start(ctx, js, cred); err != nil { - return fmt.Errorf("%w: the bridge hears no forge event without it, so it stops; where the bus refused it or did not answer, this module's consumes (made by the controller with its grant) have not reached the bus yet", err) + return fmt.Errorf("%w: the bridge hears no registration without it, so it stops; where the bus refused it or did not answer, this module's consumes (made by the controller with its grant) have not reached the bus yet", err) } defer hub.Stop() - // Every move of a branch, heard on the seat git's stream branch-moved through this module's durable there (§11), so a + // Every move of a branch, heard on the seat git's stream branch-moved through this module's durable there (§739), so a // move said while the bridge was stopped is heard at its start. Essential: every merge and push reaches the stream so. moves, err := cred.HearSeatEvents(ctx, js, git.StreamBranchMoved, func(m jetstream.Msg) { select { @@ -249,12 +149,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro case <-ctx.Done(): return } - hctx, cancel := context.WithTimeout(ctx, syncDeadline) - defer cancel() - mv.hear(hctx, m) + mv.hear(ctx, m) }, logger.Printf) if err != nil { - return fmt.Errorf("the seat git's branch-moved cannot be heard, so no merge or push reaches the forge stream: %w", err) + return fmt.Errorf("the seat git's branch-moved cannot be heard, so no move reaches the forge stream: %w", err) } defer moves.Stop() select { @@ -270,32 +168,25 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } } recompute() - if err := said(ctx); err != nil { - return err - } close(started) - // What the gate and the checker say they owe, each on its seat's own stream owed through this module's durable there - // (made from its consumes). A stream not there yet is said, and the bridge goes on: its other work does not wait on the - // gate, and what was said meanwhile is caught up from the groups at the next start. - for _, owner := range []struct{ of, kept string }{{seat.Seat, seat.StreamOwed}, {checker.Seat, checker.StreamOwed}} { - cc, err := cred.HearSeatEvents(ctx, js, owner.kept, func(m jetstream.Msg) { - hctx, cancel := context.WithTimeout(ctx, syncDeadline) - defer cancel() - owe.hear(hctx, owner.of, m) - }, logger.Printf) - if err != nil { - logger.Printf("nothing %s owes the forge is performed until the bridge starts again: %v", owner.of, err) - continue - } + // What the gate says it owes, on its seat's stream owed through this module's durable there (made from its consumes). + // A stream not there yet is said, and the bridge goes on: its other work does not wait on the gate. + if cc, err := cred.HearSeatEvents(ctx, js, seat.StreamOwed, func(m jetstream.Msg) { + hctx, cancel := context.WithTimeout(ctx, handleDeadline) + defer cancel() + owe.hear(hctx, seat.Seat, m) + }, logger.Printf); err != nil { + logger.Printf("nothing %s owes the forge is performed until the bridge starts again: %v", seat.Seat, err) + } else { defer cc.Stop() } - // A person performs an act again, drops one or reads the consumers' backlog with the tools bridge_owed_again, + // A person performs an act again, drops one or reads the consumer's backlog with the tools bridge_owed_again, // bridge_owed_drop and bridge_owed, which write the state owed-asks: watched, and answered there. if kv := process.OptionalBucket(ctx, js, groupkeys.OwedAsksBucket(forgeBridgeModule()), "bridge_owed_again, bridge_owed_drop and bridge_owed's backlog are not answered until the bridge starts again", logger.Printf); kv != nil { backlog := owedBacklog(js, cred, time.Now) go func() { err := watch(ctx, kv, func(key string, rev uint64, value []byte) { - hctx, cancel := context.WithTimeout(ctx, syncDeadline) + hctx, cancel := context.WithTimeout(ctx, handleDeadline) defer cancel() owe.asked(hctx, kv, key, rev, value, backlog) }) @@ -304,15 +195,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } }() } - // What was said while the bridge was away and is still unanswered, read from the seat (design 47 *The bridge catches up - // from the seat*). The gate comes after the bridge, so a seat that does not answer yet is said, and the bridge goes on. - if n, err := owe.catchUp(ctx); err != nil { - logger.Printf("nothing owed is caught up from the groups at this start, so an act said while the bridge was away waits for its saying again: %v", err) - } else if n > 0 { - logger.Printf("%d acts owed to the forge, said while the bridge was away, performed from the groups", n) - } - go onReconnect(ctx, again, said, logger) - // Each watched branch's head, read at the start (§11): a head missed while the bridge was stopped is written now. + // Each watched branch's head, read at the start and said with start true (§739): a head moved while the bridge was + // stopped is written now. mv.readHeads(ctx) <-ctx.Done() return nil diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main_test.go index 6efc180b..80475ec0 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/main_test.go @@ -5,29 +5,20 @@ import ( "context" "encoding/json" "errors" - "fmt" "log" - "slices" "strings" "sync" "testing" "time" - condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" - git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" - "git.novox.be/novox/mesh-sdk/go/process" - "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" "mesh-delivery-forge-bridge/internal/bridge" - "mesh-delivery-forge-bridge/internal/gitfixture" ) -const head = "0123456789abcdef0123456789abcdef01234567" - type fakeMsg struct { subject string data []byte @@ -37,7 +28,7 @@ type fakeMsg struct { func (f *fakeMsg) Subject() string { return f.subject } func (f *fakeMsg) Data() []byte { return f.data } -func (f *fakeMsg) Headers() nats.Header { return nats.Header{"X-Event-Id": {"ev-1"}} } +func (f *fakeMsg) Headers() nats.Header { return nats.Header{} } func (f *fakeMsg) Ack() error { f.acked++; return nil } func (f *fakeMsg) NakWithDelay(d time.Duration) error { f.nak = append(f.nak, d); return nil } func (f *fakeMsg) Term() error { f.termd++; return nil } @@ -56,302 +47,123 @@ func (p *fakePub) Publish(_ context.Context, subject string, payload []byte, _ . return &jetstream.PubAck{}, nil } -// body is the seat git's pull.updated (modules/mesh-delivery-contracts/seats/git), the head head_sha laid over it when given. -func body(m map[string]any) []byte { - e := map[string]any{"repository": "novox/mesh-delivery", "number": 12, "branch": "feat/x", "head": head, "base": "main", - "change": map[string]any{"paths": []string{"modules/a/x.go"}, "module-dirs": []string{"modules/a"}}} - if h, ok := m["head_sha"]; ok { - e["head"] = h - } - b, _ := json.Marshal(e) - return b -} +// memHeads is the state heads in memory. +type memHeads map[string]string -func TestReadableEventIsWrittenOnForgeAndAcked(t *testing.T) { // 1235/AC2 (unit part; the bus is the integration test) - t.Run("1945: a refused bucket is said, or stops the start naming its grant", func(t *testing.T) { - refusal := errors.New("nats: permissions violation for publish to $JS.API.STREAM.INFO.KV_x") - var said []string - if kv := process.OptionalBucket(context.Background(), refusingBus{refusal}, "x", "x is not heard", func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) }); kv != nil || len(said) != 1 || !strings.Contains(said[0], "permissions violation") { - t.Errorf("an optional bucket refused: %v, said %v", kv, said) - } - if _, err := process.EssentialBucket(context.Background(), refusingBus{refusal}, "bridge", "x", "work"); err == nil || !strings.Contains(err.Error(), "grant of x") { - t.Errorf("an essential bucket refused: %v, want its grant named", err) - } - }) - var logs bytes.Buffer - m, pub := &fakeMsg{subject: git.SubjectPullUpdated, data: body(nil)}, &fakePub{} - handle(context.Background(), m, pub, someFiles, watchesMain(), log.New(&logs, "", 0)) - if len(pub.subjects) != 1 || pub.subjects[0] != "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-delivery.pull" { - t.Fatalf("published on %v", pub.subjects) - } - f, err := forgemsg.DecodeForge(pub.data[0]) - if err != nil || f.Number != 12 || f.Branch != "feat/x" || f.Head != head || f.Action != "updated" || !f.DirsKnown { - t.Errorf("message %+v err %v", f, err) - } - if m.acked != 1 || m.termd != 0 { - t.Errorf("acked %d terminated %d", m.acked, m.termd) - } +func (m memHeads) Get(_ context.Context, key string) (string, bool, error) { + v, ok := m[key] + return v, ok, nil } +func (m memHeads) Put(_ context.Context, key, head string) error { m[key] = head; return nil } -func TestUnreadableEventIsTerminatedAndLogged(t *testing.T) { // 1235/AC5 - var logs bytes.Buffer - m, pub := &fakeMsg{subject: git.SubjectPullUpdated, data: body(map[string]any{"head_sha": "short"})}, &fakePub{} - handle(context.Background(), m, pub, someFiles, watchesMain(), log.New(&logs, "", 0)) - if len(pub.subjects) != 0 { - t.Errorf("a message was written: %v", pub.subjects) - } - if m.termd != 1 || m.acked != 0 { - t.Errorf("terminated %d acked %d, want terminated once", m.termd, m.acked) - } - if !strings.Contains(logs.String(), git.SubjectPullUpdated) || !strings.Contains(logs.String(), "head") { - t.Errorf("log %q names neither the subject nor why", logs.String()) - } - // 1235: an unwritten message is not acked (a failed write is redelivered by the server, not retried here); merged here - // from a test of its own, for the test budget. - logs.Reset() - m, pub = &fakeMsg{subject: git.SubjectPullUpdated, data: body(nil)}, &fakePub{err: errors.New("no stream")} - handle(context.Background(), m, pub, someFiles, watchesMain(), log.New(&logs, "", 0)) - if m.acked != 0 || m.termd != 0 { - t.Errorf("acked %d terminated %d, want neither", m.acked, m.termd) - } - if !strings.Contains(logs.String(), "no stream") { - t.Errorf("log %q", logs.String()) - } -} - -// watchesMain watches main of every repository, as the gate's source names it before the first registration. +// watchesMain watches main of novox/mesh-delivery, as its registration names it. func watchesMain() *bridge.Watched { w := &bridge.Watched{} - w.Set(nil, []string{"main"}) + w.Set([]bridge.Registered{{Origin: "novox/mesh-delivery", Branches: []string{"main"}}}, nil) return w } -// movedEvent is the seat git's branch-moved of main of novox/mesh-delivery, naming a head the bridge never takes. +// movedEvent is the seat git's branch-moved of a branch of novox/mesh-delivery, naming a head the bridge never takes. func movedEvent(branch string) []byte { b, _ := json.Marshal(map[string]any{"repository": "novox/mesh-delivery", "branch": branch, "head": strings.Repeat("f", 40)}) return b } -const landed = "89abcdef0123456789abcdef0123456789abcdef" +// forge answers the seat git's verb branch with the head it holds (an unprotected branch, ADR 0682 §13), and refuses +// every other verb; it records each key asked. +type forge struct { + head string + err error + asked []string +} -// moveCall answers the seat git as a forge whose main of novox/mesh-delivery is protected at landed, merged there by #12; -// trees answers trees, every other verb answers err. -func moveCall(trees json.RawMessage, err error, keys *[]string, args *[]any, mu *sync.Mutex) caller { - return func(_ context.Context, key string, body any) (json.RawMessage, error) { - mu.Lock() - *keys, *args = append(*keys, key), append(*args, body) - mu.Unlock() - switch key { - case "seat:git.branch": - return json.RawMessage(`{"repository":"novox/mesh-delivery","branch":"main","head":"` + landed + `","protected":true}`), nil - case "seat:git.pull": - return json.RawMessage(`{"pull":{"repository":"novox/mesh-delivery","number":12,"branch":"feat/x","head":"` + head + `","base":"main","state":"merged","merge-commit":"` + landed + `"}}`), nil - case "seat:git.trees": - if trees != nil { - return trees, nil +func (f *forge) call(_ context.Context, key string, _ any) (json.RawMessage, error) { + f.asked = append(f.asked, key) + if key != "seat:git.branch" { + return json.RawMessage(`{"error":"not asked of the bridge"}`), nil + } + if f.err != nil { + return nil, f.err + } + return json.RawMessage(`{"repository":"novox/mesh-delivery","branch":"main","head":"` + f.head + `","protected":false}`), nil +} + +// Design 47 H §739 (AC1, AC2, AC3 of B2): every move of a watched branch's head, and every watched head at the start, is +// one head-moved naming the head read through the seat git's verb branch and the head held before, start true only at +// the start; a head equal to the one held writes nothing; nothing but branch is asked (no pull, trees, files or +// protection), and an unprotected branch moves like any other. A move whose head cannot be read is left unacknowledged, +// never redelivered by a timer of the bridge's (H-A-48); one it cannot read is terminated, one not watched acknowledged. +func TestAMoveIsOneHeadMoved(t *testing.T) { + const h1, h2 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222" + f := &forge{head: h1} + pub, heads := &fakePub{}, memHeads{} + var logs bytes.Buffer + mv := &mover{call: f.call, pub: pub, heads: heads, watched: watchesMain(), turn: &sync.Mutex{}, logger: log.New(&logs, "", 0)} + said := func(i int) forgemsg.HeadMoved { + t.Helper() + h, err := forgemsg.DecodeHeadMoved(pub.data[i]) + if err != nil { + t.Fatalf("message %d: %v", i, err) + } + return h + } + subject := forgeSubject("forge.novox.mesh-delivery.main.head-moved") + for _, c := range []struct { + name string + head string + start bool + said int + before string + }{ + {"the first move", h1, false, 1, ""}, + {"the same head heard twice", h1, false, 1, ""}, + {"a later move", h2, false, 2, h1}, + {"a start with the head held", h2, true, 2, ""}, + } { + f.head = c.head + m := &fakeMsg{subject: "mesh.seat.git.event.branch-moved", data: movedEvent("main")} + if c.start { + mv.readHeads(context.Background()) + } else { + mv.hear(context.Background(), m) + if m.acked != 1 { + t.Errorf("%s: acked %d, want 1", c.name, m.acked) } } - return nil, err + if len(pub.data) != c.said { + t.Fatalf("%s: said %d, want %d", c.name, len(pub.data), c.said) + } + if h := said(c.said - 1); pub.subjects[c.said-1] != subject || h.Head != heads["branch.novox.mesh-delivery.main"] || (c.said > 1 && h.Before != h1) { + t.Errorf("%s: %s %+v, heads %v", c.name, pub.subjects[c.said-1], h, heads) + } + } + f.head = "3333333333333333333333333333333333333333" + mv.readHeads(context.Background()) + if len(pub.data) != 3 || !said(2).Start || said(2).Before != h2 { + t.Errorf("a start with a head moved meanwhile: said %d, %+v; want head-moved with start true and before the held head", len(pub.data), said(2)) + } + for _, k := range f.asked { + if k != "seat:git.branch" { + t.Errorf("asked %s; the bridge asks nothing but the seat git's branch", k) + } } -} -func newMover(call caller, pub publisher, heads headStore, logs *bytes.Buffer) *mover { - return &mover{call: call, pub: pub, heads: heads, watched: watchesMain(), turn: &sync.Mutex{}, logger: log.New(logs, "", 0)} -} - -func TestTreesRefusedLeavesTheEventForTenSecondsAndLogs(t *testing.T) { // 1236/AC3 - var logs bytes.Buffer - var keys []string - var args []any - var mu sync.Mutex - m, pub, heads := &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("main")}, &fakePub{}, newHeads() - newMover(moveCall(nil, errors.New("the tree listing of novox/mesh-delivery was cut"), &keys, &args, &mu), pub, heads, &logs).hear(context.Background(), m) - if len(pub.subjects) != 0 || heads.get("branch.novox.mesh-delivery.main") != "" { - t.Errorf("a message was written: %v", pub.subjects) - } - if m.acked != 0 || m.termd != 0 || len(m.nak) != 1 || m.nak[0] < 10*time.Second { - t.Errorf("acked %d terminated %d naks %v, want one nak of at least 10 s", m.acked, m.termd, m.nak) - } - for _, w := range []string{"novox/mesh-delivery", landed, "the tree listing of novox/mesh-delivery was cut"} { - if !strings.Contains(logs.String(), w) { - t.Errorf("log %q does not name %q", logs.String(), w) + for _, c := range []struct { + name string + data []byte + err error + acked, termd, said int + }{ + {"a branch not watched", movedEvent("feat/x"), nil, 1, 0, 0}, + {"an event it cannot read", []byte(`{"repository":"x"}`), nil, 0, 1, 0}, + {"a head the forge refuses", movedEvent("main"), errors.New("the forge says 502"), 0, 0, 0}, + } { + f.err, f.head = c.err, "4444444444444444444444444444444444444444" + n := len(pub.data) + m := &fakeMsg{data: c.data} + mv.hear(context.Background(), m) + if m.acked != c.acked || m.termd != c.termd || len(m.nak) != 0 || len(pub.data)-n != c.said { + t.Errorf("%s: acked %d, terminated %d, nak %v, said %d; want %d, %d, none, %d", c.name, m.acked, m.termd, m.nak, len(pub.data)-n, c.acked, c.termd, c.said) } } } - -// 1236/AC1; design 47 *The seat git* (verbs trees, file); design 47 G §11, §20, §509 (FB1, FB10): a move of a watched branch -// is taken by the seat's verb branch, never the event's head, written once as merged with its pull request and base, and -// its head kept, so the same move heard again writes nothing; a move of a branch not watched writes nothing. -func TestMergeCallsTheToolOnceAndWritesTheMergedMessage(t *testing.T) { - noCodeNamesTheBridgesOwnModule(t) - var logs bytes.Buffer - var keys []string - var args []any - var mu sync.Mutex // the files are asked for concurrently (issue 1458) - trees := gitfixture.Given(t, "trees answers", "verb:trees.answer") // root ddd…, "" ddd…, contracts eee… - call := moveCall(trees, nil, &keys, &args, &mu) - file := gitfixture.Given(t, "file answers", "verb:file.answer") - files := func(ctx context.Context, key string, body any) (json.RawMessage, error) { - if key == "seat:git.file" { // the manifests, 1448; the trees are what this test is about - mu.Lock() - keys = append(keys, key) - mu.Unlock() - return file, nil - } - return call(ctx, key, body) - } - m, pub, heads := &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("main")}, &fakePub{}, newHeads() - mv := newMover(files, pub, heads, &logs) - mv.hear(context.Background(), m) - if len(keys) < 3 || keys[0] != "seat:git.branch" || keys[1] != "seat:git.pull" || keys[2] != "seat:git.trees" || slices.Index(keys[3:], "seat:git.trees") >= 0 { - t.Fatalf("calls %v, want the branch, its pull, then the trees once", keys) - } - if got, _ := json.Marshal(args[2]); !sameJSON(got, []byte(`{"repository":"novox/mesh-delivery","commit":"`+landed+`"}`)) { - t.Errorf("arguments %s", got) - } - if len(pub.subjects) != 1 || pub.subjects[0] != "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-delivery.merged" { - t.Fatalf("published on %v", pub.subjects) - } - f, err := forgemsg.DecodeForge(pub.data[0]) - d, e := strings.Repeat("d", 40), strings.Repeat("e", 40) - if err != nil || f.Root != d || f.Trees[""] != d || f.Trees["contracts"] != e || f.Merge != landed || f.Base != "main" || f.Number != 12 || f.Branch != "feat/x" { - t.Errorf("message %+v err %v", f, err) - } - if m.acked != 1 || heads.get("branch.novox.mesh-delivery.main") != landed { - t.Errorf("acked %d, head kept %q", m.acked, heads.get("branch.novox.mesh-delivery.main")) - } - again, other := &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("main")}, &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("feat/x")} - mv.hear(context.Background(), again) - mv.hear(context.Background(), other) - if len(pub.subjects) != 1 || again.acked != 1 || other.acked != 1 { - t.Errorf("the same move again and a move of a branch not watched wrote %d messages (acked %d, %d), want none", len(pub.subjects)-1, again.acked, other.acked) - } -} - -func TestAnAnswerWithoutARootIsNotUsed(t *testing.T) { // 1236 (a shape the seat does not answer); design 47 *A failed read answers an error* - for _, raw := range []json.RawMessage{json.RawMessage(`{"trees":{"a":"t"}}`), json.RawMessage(`[1]`), - gitfixture.Given(t, "trees answers an error, never none", "verb:trees.answer")} { - call := func(context.Context, string, any) (json.RawMessage, error) { return raw, nil } - if _, _, err := treesVia(context.Background(), call)("o", "r", "s"); err == nil { - t.Errorf("the answer %s was taken", raw) - } - } -} - -func TestFilesViaAsksByOwnerRepoPathRefAndTakesTheContent(t *testing.T) { // 1448/AC4; design 47 *The seat git* (verb file) - var keys []string - var args []any - call := func(_ context.Context, key string, body any) (json.RawMessage, error) { - keys, args = append(keys, key), append(args, body) - return gitfixture.Given(t, "file answers", "verb:file.answer"), nil - } - got, err := filesVia(context.Background(), call)("novox", "mesh-contracts", "seats/index.json", strings.Repeat("a", 40)) - if err != nil || string(got) != `{"format":1,"seats":["mesh-broker"]}` { - t.Fatalf("got %q err %v", got, err) - } - if len(keys) != 1 || keys[0] != "seat:git.file" { - t.Fatalf("calls %v", keys) - } - want := gitfixture.Given(t, "file asks", "verb:file.input") - if b, _ := json.Marshal(args[0]); !sameJSON(b, want) { - t.Errorf("arguments %s, want the seat's %s", b, want) - } -} - -func TestFilesViaTellsNotFoundFromOtherErrorsAndOtherShapes(t *testing.T) { // 1448/AC3; design 47 *A failed read answers an error* - call := func(err error, raw json.RawMessage) caller { - return func(context.Context, string, any) (json.RawMessage, error) { return raw, err } - } - absent := gitfixture.All(t, "file answers", "verb:file.answer")[1] - if _, err := filesVia(context.Background(), call(nil, absent))("o", "r", "p", "s"); !errors.Is(err, bridge.ErrNotFound) { - t.Errorf("an absent file is %v, want ErrNotFound", err) - } - if _, err := filesVia(context.Background(), call(errors.New("nats: timeout"), nil))("o", "r", "p", "s"); err == nil || errors.Is(err, bridge.ErrNotFound) { - t.Errorf("a seat that does not answer is %v, want an error that is not ErrNotFound", err) - } - for _, raw := range []json.RawMessage{gitfixture.Given(t, "file answers an error, never none", "verb:file.answer"), json.RawMessage(`{}`), json.RawMessage(`[1]`), json.RawMessage(`{"path":"p"}`)} { - if _, err := filesVia(context.Background(), call(nil, raw))("o", "r", "p", "s"); err == nil || errors.Is(err, bridge.ErrNotFound) { - t.Errorf("the answer %s gave %v, want an error", raw, err) - } - } -} - -// sameJSON is whether two JSON texts say the same value. -func sameJSON(a, b []byte) bool { - var x, y any - if json.Unmarshal(a, &x) != nil || json.Unmarshal(b, &y) != nil { - return false - } - ax, _ := json.Marshal(x) - by, _ := json.Marshal(y) - return bytes.Equal(ax, by) -} - -// someFiles is a forge that has a module.json at every path and no other file, for the tests that are not about the files. -func someFiles(_, _, path, _ string) ([]byte, error) { - if strings.HasSuffix(path, "module.json") { - return []byte("{}"), nil - } - return nil, bridge.ErrNotFound -} - -// refusingBus refuses every bucket with err (issue 1945). -type refusingBus struct{ err error } - -func (r refusingBus) KeyValue(context.Context, string) (jetstream.KeyValue, error) { return nil, r.err } - -// fakeFindings is a finding writer that holds what it is given. -type fakeFindings struct { - held []condseat.Finding - cleared []string -} - -func (f *fakeFindings) Write(_ context.Context, w condseat.Finding) error { - f.held = append(f.held, w) - return nil -} -func (f *fakeFindings) Clear(_ context.Context, scope, id, kind, _ string) error { - f.cleared = append(f.cleared, scope+"."+id+"."+kind) - f.held = nil - return nil -} -func (f *fakeFindings) Held() []condseat.Finding { return f.held } - -// Design 47 G §17, A-251 (FB2): a move of a watched branch whose protection was removed writes nothing and says the finding -// branch-unprotected, scope merge, its id the owner, repository and branch escaped as a key; a move that finds the protection -// back clears it, and a protected branch with no finding held says nothing. -func TestAnUnprotectedBranchIsSaidAsAFindingAndClearedWhenItIsBack(t *testing.T) { - var logs bytes.Buffer - protected := false - call := func(_ context.Context, key string, _ any) (json.RawMessage, error) { - if key == "seat:git.branch" { - return json.RawMessage(fmt.Sprintf(`{"repository":"novox/mesh-delivery","branch":"beta","head":"%s","protected":%t}`, landed, protected)), nil - } - return nil, errors.New("not asked: " + key) - } - pub, heads, findings := &fakePub{}, newHeads(), &fakeFindings{} - mv := newMover(call, pub, heads, &logs) - mv.findings, mv.now = findings, func() time.Time { return time.Date(2026, 11, 12, 9, 0, 0, 0, time.UTC) } - mv.watched = &bridge.Watched{} - mv.watched.Set(nil, []string{"beta"}) - mv.hear(context.Background(), &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("beta")}) - if len(pub.subjects) != 0 || len(findings.held) != 1 { - t.Fatalf("written %v, findings %+v: want nothing written and one finding", pub.subjects, findings.held) - } - f := findings.held[0] - if f.Scope != "merge" || f.ID != "novox/mesh-delivery/beta" || f.Kind != "branch-unprotected" || f.Severity != "warning" || f.Observer != "mesh-delivery-forge-bridge" || - f.Subject.Scope != "merge" || f.Subject.ID != "novox/mesh-delivery/beta" || !strings.Contains(f.Summary, "beta") { - t.Errorf("the finding = %+v", f) - } - // The protection is back at a move whose head the bridge wrote already: the finding is cleared. - protected = true - heads.vals["branch.novox.mesh-delivery.beta"] = landed - mv.hear(context.Background(), &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("beta")}) - if len(findings.cleared) != 1 || findings.cleared[0] != "merge.novox/mesh-delivery/beta.branch-unprotected" || len(findings.held) != 0 { - t.Errorf("cleared %v held %+v, want the finding cleared", findings.cleared, findings.held) - } - mv.hear(context.Background(), &fakeMsg{subject: bridge.BranchMovedSubject, data: movedEvent("beta")}) - if len(findings.cleared) != 1 { - t.Errorf("cleared %v: a protected branch with no finding held clears nothing", findings.cleared) - } -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/moves.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/moves.go index 7d0d4bed..c482d444 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/moves.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/moves.go @@ -2,42 +2,38 @@ package main import ( "context" + "encoding/json" "errors" "fmt" "log" "strings" "sync" - "time" "github.com/nats-io/nats.go/jetstream" mcseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/keys" "mesh-delivery-forge-bridge/internal/bridge" ) -// mover writes the one message of each move of a watched branch (design 47 G §11, §509, §714): heard on the seat git's -// branch-moved through the bridge's durable on SEAT_git_branch-moved, the head read by the seat's verb branch, never the -// event's; merged with its pull request, or pushed; the head written kept in the state heads under the branch's key -// (A-236), so a move heard twice writes once and the next pushed says its head before. +// mover writes the one message of each move of a watched branch's head (design 47 H §739): heard on the seat git's +// branch-moved through the bridge's durable on SEAT_git_branch-moved, and at the start for every watched branch, the +// head read by the seat's verb branch, never the event's; head-moved with before the head held in the state heads under +// the branch's key (A-236), so a head heard twice writes once. It reads no pull request, no tree and no protection. type mover struct { call caller pub publisher heads headStore watched *bridge.Watched - inputs bridge.Kept - groups *grouper - // findings says the finding branch-unprotected (design 47 G §17, A-251); nil says none. - findings findingWriter - now func() time.Time - turn *sync.Mutex - logger *log.Logger + turn *sync.Mutex + logger *log.Logger } // hear takes one branch-moved: one it cannot read is terminated, one of a branch not watched is acknowledged with nothing -// written, one the forge could not say about is heard again. +// written. One whose head could not be read or written is left unacknowledged: the server delivers it again after its +// acknowledgement wait, the bridge holding no clock of its own (design 47 H-A-48). func (mv *mover) hear(ctx context.Context, m delivered) { moved, err := bridge.MovedOf(m.Data()) if err != nil { @@ -50,67 +46,61 @@ func (mv *mover) hear(ctx context.Context, m delivered) { return } mv.turn.Lock() - err = mv.move(ctx, moved) + err = mv.move(ctx, moved, false) mv.turn.Unlock() switch { case errors.Is(err, bridge.ErrUnreadable): mv.logger.Printf("%v; the event is dropped", err) _ = m.Term() case err != nil: - mv.logger.Printf("%v; heard again in %s", err, retryDelay) - _ = m.NakWithDelay(retryDelay) + mv.logger.Printf("%v; left unacknowledged, so the bus delivers it again", err) default: _ = m.Ack() } } -// move reads the branch's head and writes its message, unless that head is the one last written for it. -func (mv *mover) move(ctx context.Context, moved bridge.Moved) error { - b, err := bridge.ReadBranch(ctx, bridge.Caller(mv.call), moved) +// branchCall is the seat git's verb branch as a kept call (design 47 H-A-48): asked again through a timeout or no +// responders while the branch is still watched, so a read waits on the seat holder's return. +func (mv *mover) branchCall(moved bridge.Moved) bridge.Caller { + open := busretry.Open{Key: moved.HeadKey(), Logf: mv.logger.Printf, + Open: func(string) (bool, error) { return mv.watched.Watches(moved.Repository(), moved.Branch), nil }} + return func(ctx context.Context, key string, body any) (json.RawMessage, error) { + return busretry.DoKept("the call "+key, open, func() (json.RawMessage, error) { return mv.call(ctx, key, body) }, nil) + } +} + +// move reads the branch's head and writes its head-moved, unless that head is the one held for it. start says it is read +// at the bridge's start (or at a branch's adoption, which is its start). +func (mv *mover) move(ctx context.Context, moved bridge.Moved, start bool) error { + head, err := bridge.ReadHead(ctx, mv.branchCall(moved), moved) if err != nil { return fmt.Errorf("%s of %s: %w", moved.Branch, moved.Repository(), err) } - // The protection is read at every move, so a finding stands until a move finds it back (§17). - mv.protection(ctx, moved.Repository(), moved.Branch, b.Protected, b.Head) before, _, err := mv.heads.Get(ctx, moved.HeadKey()) if err != nil { - return fmt.Errorf("%s of %s: the head last written cannot be read: %w", moved.Branch, moved.Repository(), err) + return fmt.Errorf("%s of %s: the head held cannot be read: %w", moved.Branch, moved.Repository(), err) } - if before == b.Head { + if before == head { return nil } - if !b.Protected { - // A branch whose protection was removed starts nothing: nothing is written (§17, §509). - mv.logger.Printf("%s of %s moved to %s while it is not protected: nothing is written", moved.Branch, moved.Repository(), b.Head) - return nil - } - msg, err := bridge.MoveMessage(ctx, bridge.Caller(mv.call), moved, b.Head, before, treesVia(ctx, mv.call), filesVia(ctx, mv.call), mv.inputs) + msg, err := bridge.HeadMoved(moved, head, before, start) if err != nil { - return err - } - data, grouped := msg.Data, false - var member forgemsg.Forge - if mv.groups != nil { - data, member, grouped = mv.groups.member(ctx, msg.Data) + return fmt.Errorf("%w: %s of %s: %v", bridge.ErrUnreadable, moved.Branch, moved.Repository(), err) } // The branch's new head makes a write after a lost acknowledgement the same message to the stream. - id := "moved." + keys.EscapeName(moved.Repository()) + "." + keys.EscapeName(moved.Branch) + "." + b.Head - if _, err := mv.pub.Publish(ctx, forgeSubject(msg.Event), data, jetstream.WithMsgID(id)); err != nil { - return fmt.Errorf("%s could not be written on FORGE: %w", msg.Event, err) + id := "moved." + keys.EscapeName(moved.Repository()) + "." + keys.EscapeName(moved.Branch) + "." + head + if _, err := mv.pub.Publish(ctx, forgeSubject(msg.Event), msg.Data, jetstream.WithMsgID(id)); err != nil { + return fmt.Errorf("%s could not be written on the stream forge: %w", msg.Event, err) } - if grouped { - mv.groups.published(ctx, member) - } - if err := mv.heads.Put(ctx, moved.HeadKey(), b.Head); err != nil { - mv.logger.Printf("%s of %s: the head %s written is not kept, so the next move says the older head before: %v", moved.Branch, moved.Repository(), b.Head, err) - } - if msg.Said != "" { - mv.logger.Printf("%s", msg.Said) + if err := mv.heads.Put(ctx, moved.HeadKey(), head); err != nil { + mv.logger.Printf("%s of %s: the head %s written is not kept, so the next move says the older head before: %v", moved.Branch, moved.Repository(), head, err) } + mv.logger.Printf("%s", msg.Said) return nil } -// readHeads reads each watched branch's head (§11): a head missed while the bridge was stopped is written now. +// readHeads reads each watched branch's head and says it with start true (design 47 H §739): a head moved while the +// bridge was stopped is written now, one equal to the head held writes nothing. func (mv *mover) readHeads(ctx context.Context) { for _, repo := range mv.watched.Repositories() { owner, name, ok := strings.Cut(repo, "/") @@ -119,7 +109,7 @@ func (mv *mover) readHeads(ctx context.Context) { } for _, branch := range mv.watched.Branches(repo) { mv.turn.Lock() - err := mv.move(ctx, bridge.Moved{Owner: owner, Repo: name, Branch: branch}) + err := mv.move(ctx, bridge.Moved{Owner: owner, Repo: name, Branch: branch}, true) mv.turn.Unlock() if err != nil { mv.logger.Printf("the head of %s of %s is not read at this start, so a move missed meanwhile waits for its next move: %v", branch, repo, err) diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/names_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/names_test.go index d1e0bfff..76ca7b2f 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/names_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/names_test.go @@ -45,10 +45,10 @@ func theNamesAreTheManifests(t *testing.T) { } } // Design 47 G A-296: its own buckets are named from its credential's module, never a constant. - if headsBucket("n1-bridge") != "n1-bridge_heads" || inputsBucket("n1-bridge") != "n1-bridge_inputs" { - t.Errorf("the own buckets of n1-bridge are %s and %s", headsBucket("n1-bridge"), inputsBucket("n1-bridge")) + if headsBucket("n1-bridge") != "n1-bridge_heads" { + t.Errorf("the own bucket heads of n1-bridge is %s", headsBucket("n1-bridge")) } - for _, b := range []string{headsBucket(forgeBridgeModule()), inputsBucket(forgeBridgeModule())} { + for _, b := range []string{headsBucket(forgeBridgeModule())} { if !slices.Contains(own, b) { t.Errorf("the bridge keeps %s, its manifest's states are %v", b, own) } diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open.go deleted file mode 100644 index 826d5295..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open.go +++ /dev/null @@ -1,143 +0,0 @@ -package main - -import ( - "context" - "fmt" - "log" - "slices" - "sync" - "time" - - "github.com/nats-io/nats.go/jetstream" - - git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - - "mesh-delivery-forge-bridge/internal/bridge" -) - -// openPullsTool is the seat git's verb for every open pull request (novox/hq design 47 *The seat `git`*): no arguments, -// answers {pulls: [...]} or an error. -var openPullsTool = bridge.GitKey(git.VerbOpenPulls) - -// headStore is the bucket heads: the head last written on FORGE for each pull request, by bridge.Track's key -// (novox/hq ADR 0443 §5). -type headStore interface { - // Get is the head kept under the key; found is false when there is none. - Get(ctx context.Context, key string) (head string, found bool, err error) - Put(ctx context.Context, key, head string) error - Delete(ctx context.Context, key string) error -} - -// recorder writes to FORGE and keeps in the bucket what it wrote: a pull message keeps its head, a closed or merged one -// takes its pull request's key away. Every write of the program goes through it, an event's and a sync's alike. -type recorder struct { - pub publisher - heads headStore - logger *log.Logger -} - -func (r *recorder) Publish(ctx context.Context, subject string, payload []byte, opts ...jetstream.PublishOpt) (*jetstream.PubAck, error) { - ack, err := r.pub.Publish(ctx, subject, payload, opts...) - if err != nil { - return ack, err - } - f, derr := forgemsg.DecodeForge(payload) - if derr != nil { - return ack, nil - } - key, head, ok := bridge.Track(f) - if !ok { - return ack, nil - } - if head == "" { - err = r.heads.Delete(ctx, key) - } else { - err = r.heads.Put(ctx, key, head) - } - if err != nil { - return ack, fmt.Errorf("%s was written on FORGE but its head could not be kept in the bucket: %w", subject, err) - } - return ack, nil -} - -// syncDeadline bounds one sync: the call to the forge and every read and write of the bucket and of FORGE, because -// the sync holds the turn that stops the bridge hearing any event. -const syncDeadline = 30 * time.Second - -// hear runs one reaction to a forge event while no sync of the open pull requests is between reading the forge and -// writing the open message (novox/hq ADR 0443 §5): an event heard meanwhile waits, and is written after it, so a pull -// request opened after the read is added again by its own message and never dropped by the open message. -func hear(mu *sync.Mutex, react func()) { - mu.Lock() - defer mu.Unlock() - react() -} - -// syncOpen reads the open pull requests from the forge and writes a pull message for each whose head differs from the -// one kept in the bucket, then one open message naming every one it read, those whose head did not differ among them: -// what makes the indexer's candidates match the forge after a restart or a gap in the forge's events (ADR 0429 §13, -// ADR 0443 §5). pub keeps the bucket as it writes (recorder). It holds mu from before it reads the forge until the open -// message is written, so no event is heard between, and never past syncDeadline. A bucket that cannot be read is logged -// and every open pull request is written. An error names the call and the forge's words. -func syncOpen(ctx context.Context, call caller, pub publisher, heads headStore, watched bridge.Watching, mu *sync.Mutex, logger *log.Logger) error { - mu.Lock() - defer mu.Unlock() - ctx, cancel := context.WithTimeout(ctx, syncDeadline) - defer cancel() - raw, err := call(ctx, openPullsTool, git.OpenPullsInput{}) - if err != nil { - return fmt.Errorf("%s: %w", openPullsTool, err) - } - msgs, skipped, err := bridge.OpenPulls(raw, watched) - if err != nil { - return fmt.Errorf("%s: %w", openPullsTool, err) - } - open, err := bridge.OpenMessage(raw, watched) - if err != nil { - return fmt.Errorf("%s: %w", openPullsTool, err) - } - for _, s := range skipped { - logger.Printf("an open pull request is left out: %s", s) - } - var differing []bridge.Message - for _, m := range msgs { - f, err := forgemsg.DecodeForge(m.Data) - if err != nil { - differing = append(differing, m) - continue - } - key, head, _ := bridge.Track(f) - kept, found, err := heads.Get(ctx, key) - if err != nil { - logger.Printf("the heads kept could not be read, so every open pull request is written: %v", err) - differing = slices.Clone(msgs) - break - } - if !found || kept != head { - differing = append(differing, m) - } - } - for _, m := range append(differing, open) { - if _, err := pub.Publish(ctx, forgeSubject(m.Event), m.Data); err != nil { - return fmt.Errorf("the open pull request message %s could not be written on FORGE: %w", m.Event, err) - } - } - logger.Printf("%d pull messages and the open message written on FORGE", len(differing)) - return nil -} - -// onReconnect reads the open pull requests again each time the bus connection comes back, until ctx ends; a failure is -// logged and the bridge goes on (the next reconnect or event tries again). -func onReconnect(ctx context.Context, again <-chan struct{}, sync func(context.Context) error, logger *log.Logger) { - for { - select { - case <-ctx.Done(): - return - case <-again: - if err := sync(ctx); err != nil { - logger.Printf("after a reconnect: %v", err) - } - } - } -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open_test.go deleted file mode 100644 index a10a62f3..00000000 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/open_test.go +++ /dev/null @@ -1,295 +0,0 @@ -package main - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "log" - "strconv" - "strings" - "sync" - "testing" - "time" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" -) - -// openAnswer is the seat git's answer of open-pulls: two into the trunk, one into another branch. -func openAnswer() json.RawMessage { - entry := func(repo string, number int, base, branch, sha string) string { - return `{"pull":{"repository":"novox/` + repo + `","number":` + strconv.Itoa(number) + `,"base":"` + base + `","branch":"` + branch + - `","head":"` + sha + `","state":"open","url":"h"},"required":[],"checks":{}}` - } - return json.RawMessage(`{"pulls":[` + entry("mesh-delivery", 12, "main", "feat/x", head) + `,` + - entry("mesh-catalog", 300, "main", "feat/x", strings.Repeat("a", 40)) + `,` + entry("mesh-catalog", 301, "feat/y", "feat/z", strings.Repeat("b", 40)) + `]}`) -} - -func TestSyncOpenWritesOneUpdatedMessagePerOpenPull(t *testing.T) { // 1237/AC1, AC4 - var logs bytes.Buffer - pub := &fakePub{} - var keys []string - call := func(_ context.Context, key string, _ any) (json.RawMessage, error) { - keys = append(keys, key) - return openAnswer(), nil - } - if err := runSync(call, pub, newHeads(), &sync.Mutex{}, log.New(&logs, "", 0)); err != nil { - t.Fatal(err) - } - if len(keys) != 1 || keys[0] != "seat:git.open-pulls" { - t.Errorf("calls %v", keys) - } - if len(pub.subjects) != 3 { - t.Fatalf("%d messages written (%v), want two pull messages and the open message: the pull request into feat/y gets none", len(pub.subjects), pub.subjects) - } - want := []string{"mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-delivery.pull", "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-catalog.pull"} - for i, w := range want { - f, err := forgemsg.DecodeForge(pub.data[i]) - if pub.subjects[i] != w || err != nil || f.Action != "updated" || f.DirsKnown || f.Branch != "feat/x" { - t.Errorf("message %d on %s = %+v err %v", i, pub.subjects[i], f, err) - } - } -} - -// memHeads is the bucket heads in memory. -type memHeads struct { - mu sync.Mutex - vals map[string]string - getErr error -} - -func newHeads(kv ...string) *memHeads { - m := &memHeads{vals: map[string]string{}} - for i := 0; i+1 < len(kv); i += 2 { - m.vals[kv[i]] = kv[i+1] - } - return m -} - -func (m *memHeads) Get(_ context.Context, key string) (string, bool, error) { - m.mu.Lock() - defer m.mu.Unlock() - v, ok := m.vals[key] - return v, ok, m.getErr -} -func (m *memHeads) Put(_ context.Context, key, head string) error { - m.mu.Lock() - defer m.mu.Unlock() - m.vals[key] = head - return nil -} -func (m *memHeads) Delete(_ context.Context, key string) error { - m.mu.Lock() - defer m.mu.Unlock() - delete(m.vals, key) - return nil -} -func (m *memHeads) get(key string) string { m.mu.Lock(); defer m.mu.Unlock(); return m.vals[key] } - -// runSync runs syncOpen with the recorder the program writes through. -func runSync(call caller, pub publisher, heads headStore, mu *sync.Mutex, logger *log.Logger) error { - return syncOpen(context.Background(), call, &recorder{pub: pub, heads: heads, logger: logger}, heads, watchesMain(), mu, logger) -} - -// 1279/AC6: the sync writes a pull message only for a head that differs from what FORGE holds, then one open message -// naming every open pull request into trunk it read, those whose head did not differ among them. -func TestSyncOpenWritesPullsForNewHeadsThenOneOpenMessageNamingAll(t *testing.T) { // 1279/AC6 - pub := &fakePub{} - call := func(context.Context, string, any) (json.RawMessage, error) { return openAnswer(), nil } - heads := newHeads("novox.mesh-delivery.12", head) - var logs bytes.Buffer - if err := runSync(call, pub, heads, &sync.Mutex{}, log.New(&logs, "", 0)); err != nil { - t.Fatal(err) - } - if heads.get("novox.mesh-catalog.300") != strings.Repeat("a", 40) || heads.get("novox.mesh-delivery.12") != head { - t.Errorf("the bucket after the sync: %v, want the head written for mesh-catalog#300 kept beside the held one", heads.vals) - } - if len(pub.subjects) != 2 { - t.Fatalf("%d messages written (%v), want the one pull message that differs and the open message", len(pub.subjects), pub.subjects) - } - if pub.subjects[0] != "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-catalog.pull" { - t.Errorf("first message on %s, want mesh-catalog's pull message", pub.subjects[0]) - } - if pub.subjects[1] != "mesh.stream.mesh-delivery-forge-bridge.event.forge.open" { - t.Fatalf("last message on %s, want the open message after the pull messages", pub.subjects[1]) - } - f, err := forgemsg.DecodeForge(pub.data[1]) - want := []forgemsg.OpenPull{{Repository: "novox/mesh-catalog", Number: 300}, {Repository: "novox/mesh-delivery", Number: 12}} - if err != nil || len(f.Open) != 2 || f.Open[0] != want[0] || f.Open[1] != want[1] { - t.Errorf("open message = %+v err %v, want it to name %v, the pull request whose head did not differ among them", f, err, want) - } -} - -// The bucket cannot be read: every open pull request is written, as before, and the open message follows; the -// indexer's writes are idempotent, so the fault costs messages and no state. -func TestSyncOpenWritesAllWhenTheHeadsCannotBeRead(t *testing.T) { // 1279/AC6 - pub := &fakePub{} - call := func(context.Context, string, any) (json.RawMessage, error) { return openAnswer(), nil } - heads := newHeads("novox.mesh-delivery.12", head) - heads.getErr = errors.New("the bucket is gone") - var logs bytes.Buffer - if err := runSync(call, pub, heads, &sync.Mutex{}, log.New(&logs, "", 0)); err != nil { - t.Fatal(err) - } - if len(pub.subjects) != 3 || !strings.Contains(logs.String(), "the bucket is gone") { - t.Errorf("messages %v, log %q", pub.subjects, logs.String()) - } -} - -// What the bridge writes on FORGE it keeps in the bucket: a head by its pull message, nothing by a closed or merged one. -func TestWhatIsWrittenOnFORGEIsKeptInTheBucket(t *testing.T) { // 1279/AC6 - pub := &fakePub{} - heads := newHeads() - r := &recorder{pub: pub, heads: heads, logger: log.New(&bytes.Buffer{}, "", 0)} - write := func(f forgemsg.Forge) { - t.Helper() - ev, _ := forgemsg.ForgeEvent(f.Repository, f.Kind) - raw, err := forgemsg.EncodeForge(f) - if err != nil { - t.Fatal(err) - } - if _, err := r.Publish(context.Background(), forgeSubject(ev), raw); err != nil { - t.Fatal(err) - } - } - p := forgemsg.Forge{Kind: forgemsg.ForgePull, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, Action: forgemsg.PullUpdated} - write(p) - if heads.get("novox.mesh-delivery.12") != head { - t.Fatalf("bucket %v", heads.vals) - } - p.Action = forgemsg.PullClosed - write(p) - if _, kept := heads.vals["novox.mesh-delivery.12"]; kept { - t.Errorf("a closed pull request is still kept: %v", heads.vals) - } - p.Action = forgemsg.PullUpdated - write(p) - write(forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, Merge: "m", Root: "r", Trees: map[string]string{"": "t"}}) - if _, kept := heads.vals["novox.mesh-delivery.12"]; kept { - t.Errorf("a merged pull request is still kept: %v", heads.vals) - } - if len(pub.subjects) != 4 { - t.Errorf("%d messages written", len(pub.subjects)) - } -} - -// 1279/AC6: no forge event is heard between reading the forge and writing the open message. -func TestNoForgeEventIsHeardWhileTheOpenPullsAreSaid(t *testing.T) { // 1279/AC6 - pub := &lockedPub{} - reading := make(chan struct{}) - release := make(chan struct{}) - call := func(context.Context, string, any) (json.RawMessage, error) { - close(reading) - <-release - return openAnswer(), nil - } - var mu sync.Mutex - synced := make(chan error, 1) - go func() { - synced <- runSync(call, pub, newHeads(), &mu, log.New(&bytes.Buffer{}, "", 0)) - }() - <-reading - // An event arrives while the forge is being read. - heard := make(chan struct{}) - go func() { - hear(&mu, func() { _, _ = pub.Publish(context.Background(), "event", nil); close(heard) }) - }() - select { - case <-heard: - t.Fatal("an event was heard while the forge was read") - case <-time.After(100 * time.Millisecond): - } - close(release) - if err := <-synced; err != nil { - t.Fatal(err) - } - <-heard - got := pub.snapshot() - if len(got) != 4 || got[2] != "mesh.stream.mesh-delivery-forge-bridge.event.forge.open" || got[3] != "event" { - t.Errorf("order of writes: %v, want the event after the open message", got) - } -} - -type lockedPub struct { - mu sync.Mutex - subjects []string -} - -func (p *lockedPub) Publish(_ context.Context, subject string, _ []byte, _ ...jetstream.PublishOpt) (*jetstream.PubAck, error) { - p.mu.Lock() - defer p.mu.Unlock() - p.subjects = append(p.subjects, subject) - return &jetstream.PubAck{}, nil -} -func (p *lockedPub) snapshot() []string { - p.mu.Lock() - defer p.mu.Unlock() - return append([]string(nil), p.subjects...) -} - -func TestSyncOpenFailureNamesTheCallAndTheForgesWords(t *testing.T) { // 1237/AC3 - pub := &fakePub{} - call := func(context.Context, string, any) (json.RawMessage, error) { - return nil, errors.New("the forge said 502") - } - err := runSync(call, pub, newHeads(), &sync.Mutex{}, log.New(&bytes.Buffer{}, "", 0)) - if err == nil || !strings.Contains(err.Error(), "seat:git.open-pulls") || !strings.Contains(err.Error(), "the forge said 502") { - t.Errorf("err = %v", err) - } - if len(pub.subjects) != 0 { - t.Errorf("messages written: %v", pub.subjects) - } -} - -func TestReconnectReadsTheOpenPullsAgainAndFailureGoesOn(t *testing.T) { // 1237/AC2, AC3 - var logs lockedBuffer - ctx, cancel := context.WithCancel(context.Background()) - again := make(chan struct{}, 1) - done := make(chan struct{}) - var mu sync.Mutex - n := 0 - count := func() int { mu.Lock(); defer mu.Unlock(); return n } - read := func(context.Context) error { - mu.Lock() - defer mu.Unlock() - n++ - if n == 1 { - return errors.New("the forge said 502") - } - return nil - } - go func() { onReconnect(ctx, again, read, log.New(&logs, "", 0)); close(done) }() - again <- struct{}{} - waitFor(t, func() bool { return count() >= 1 }) - again <- struct{}{} // the first read failed; the bridge goes on and reads again at the next reconnect - waitFor(t, func() bool { return count() >= 2 }) - cancel() - <-done - if !strings.Contains(logs.String(), "the forge said 502") { - t.Errorf("log %q does not carry the forge's words", logs.String()) - } -} - -type lockedBuffer struct { - mu sync.Mutex - b bytes.Buffer -} - -func (l *lockedBuffer) Write(p []byte) (int, error) { - l.mu.Lock() - defer l.mu.Unlock() - return l.b.Write(p) -} -func (l *lockedBuffer) String() string { l.mu.Lock(); defer l.mu.Unlock(); return l.b.String() } - -func waitFor(t *testing.T, ok func() bool) { - t.Helper() - for deadline := time.Now().Add(5 * time.Second); time.Now().Before(deadline); time.Sleep(5 * time.Millisecond) { - if ok() { - return - } - } - t.Fatal("it did not happen within 5 s") -} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go index 0ff09c15..35008636 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go @@ -7,16 +7,12 @@ import ( "errors" "fmt" "log" - "strconv" - "strings" "time" "github.com/nats-io/nats.go/jetstream" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" "git.novox.be/novox/mesh-sdk/go/process" @@ -28,7 +24,7 @@ import ( // The state performed (manifest `requires`, the template state, opened by its binding: bound.go) keeps one key per owed act it // performed, the act's outcome and when, with the owed event as heard (novox/hq design 47 *What the gate owes the // forge*). It is a saving and a read, never what keeps an act from happening twice: every act is safe to repeat at the -// forge. The group ends' bookkeeping (`published.`, `groups.`, groups.go) is in it too, under the same 7 days. +// forge. // performedKey is the key of one act in performed: the seat that said it and its id, the id in unpadded base64url, since // an id may hold what a key may not (`#`, `/`). @@ -67,7 +63,7 @@ func (s kvPerformed) Put(ctx context.Context, key string, value []byte) error { return err } -// owing performs what the gate and the checker owe the forge (design 47 *What the gate owes the forge*): each owed act +// owing performs what the gate owes the forge (design 47 *What the gate owes the forge*): each owed act // through the seat git's verb under its id, its outcome said as owed.ended on the stream forge and then kept in // performed. It holds no timer. type owing struct { @@ -85,8 +81,6 @@ func readerOf(of string) (func([]byte) (bridge.OwedCall, error), error) { switch of { case seat.Seat: return bridge.GateOwed, nil - case checker.Seat: - return bridge.CheckerOwed, nil } return nil, fmt.Errorf("the seat %q says no owed act the bridge performs", of) } @@ -110,34 +104,9 @@ func (o *owing) heard(ctx context.Context, of string, data []byte) (forgemsg.Owe // said twice, or said again while its outcome was on its way: performed once, the outcome said once return forgemsg.OwedEnded{Of: c.Of, ID: c.ID}, nil } - if words, done := o.switchedDone(ctx, c.Of, c.ID); done { - // performed by the old bridge before the switch: said performed, never done twice - return o.end(ctx, forgemsg.OwedEnded{Of: c.Of, ID: c.ID, - Outcome: forgemsg.OwedPerformed, Words: words}, data) - } return o.perform(ctx, c, data) } -// switchedDone says whether a switched act (design 47 *The switch carries what is owed*: the gate's act of a key of its -// old state owed or merges, its id meshdeliveryclient.SwitchedActID) was performed by the old bridge: its own bookkeeping -// in performed, `.`, holds that key at the act's revision or a later one. Any other id, and bookkeeping that -// cannot be read, is not: the act is performed, which changes nothing at the forge. -func (o *owing) switchedDone(ctx context.Context, of, id string) (string, bool) { - state, key, rev, ok := meshdeliveryclient.ParseSwitchedActID(id) - if !ok || of != seat.Seat { - return "", false - } - kept, found, err := o.performed.Get(ctx, state+"."+key) - if err != nil || !found { - return "", false - } - at, err := strconv.ParseUint(strings.TrimSpace(string(kept)), 10, 64) - if err != nil || at < rev { - return "", false - } - return fmt.Sprintf("performed by the bridge before the switch: its %s.%s at revision %d", state, key, at), true -} - // hear is one message of a seat's stream owed: performed and acknowledged, or, when its outcome could not be said, // left to come again (design 47: the bridge stopped between an act and its owed.ended performs it again). func (o *owing) hear(ctx context.Context, of string, m delivered) { @@ -206,36 +175,7 @@ func (o *owing) held(ctx context.Context, of, id string) bool { return found } -// catchUp reads the seat mesh-delivery's groups and performs every act said there with no recorded outcome that -// performed does not hold either (design 47 *The bridge catches up from the seat*). It answers how many it performed. -func (o *owing) catchUp(ctx context.Context) (int, error) { - if w := o.waiting(); w != "" { - return 0, fmt.Errorf("the bridge %s", w) - } - of, err := groups.Read(ctx, o.call) - if err != nil { - return 0, err - } - n := 0 - for _, g := range of { - for _, act := range g.Acts { - if act.Outcome != "" || o.held(ctx, seat.Seat, act.Owed.ID) { - continue // answered, or performed and its outcome on its way to the gate - } - data, err := json.Marshal(act.Owed) - if err != nil { - return n, err - } - if _, err := o.heard(ctx, seat.Seat, data); err != nil { - return n, err - } - n++ - } - } - return n, nil -} - -// owedOf is the owed event of an act to perform again: as performed keeps it, else, for the gate's, as its groups say it. +// owedOf is the owed event of an act to perform again, as performed keeps it. func (o *owing) owedOf(ctx context.Context, of, id string) ([]byte, error) { v, found, err := o.performed.Get(ctx, performedKey(of, id)) if err != nil { @@ -247,25 +187,7 @@ func (o *owing) owedOf(ctx context.Context, of, id string) ([]byte, error) { return p.Owed, nil } } - if of != seat.Seat { - return nil, fmt.Errorf("the bridge holds no owed act %s of %s: the checker says its unanswered acts again at its start", id, of) - } - raw, err := o.call(ctx, "seat:"+seat.Seat+"."+seat.VerbGroups, seat.GroupsInput{All: seat.GroupsInputAllTrue}) - if err != nil { - return nil, fmt.Errorf("the seat %s's groups could not be read: %w", seat.Seat, err) - } - var a seat.GroupsAnswer - if err := json.Unmarshal(raw, &a); err != nil || a.Error != "" { - return nil, fmt.Errorf("the seat %s's groups do not answer: %v %s", seat.Seat, err, a.Error) - } - for _, g := range a.Groups { - for _, act := range g.Acts { - if act.Owed.ID == id { - return json.Marshal(act.Owed) - } - } - } - return nil, fmt.Errorf("neither the bridge nor the seat %s's groups hold an owed act %s", seat.Seat, id) + return nil, fmt.Errorf("the bridge holds no owed act %s of %s in its state performed", id, of) } // answer answers one owed ask: an act performed again now, whatever performed holds of it; an act dropped, said as @@ -330,7 +252,7 @@ func (o *owing) asked(ctx context.Context, kv jetstream.KeyValue, key string, re func owedBacklog(js jetstream.JetStream, cred process.Account, now func() time.Time) func(context.Context) []groups.Backlog { return func(ctx context.Context) []groups.Backlog { var out []groups.Backlog - for _, kept := range []string{seat.StreamOwed, checker.StreamOwed} { + for _, kept := range []string{seat.StreamOwed} { row := groups.Backlog{Stream: kept, Consumer: cred.EventConsumerName()} c, err := js.Consumer(ctx, row.Stream, row.Consumer) var info *jetstream.ConsumerInfo diff --git a/modules/mesh-delivery-forge-bridge/forgemsg/owed.go b/modules/mesh-delivery-forge-bridge/forgemsg/owed.go index b8400a36..e67e3bbe 100644 --- a/modules/mesh-delivery-forge-bridge/forgemsg/owed.go +++ b/modules/mesh-delivery-forge-bridge/forgemsg/owed.go @@ -27,8 +27,7 @@ const ( var OwedOutcomes = []string{OwedPerformed, OwedRefused, OwedCouldNotBePerformed, OwedUndecodable, OwedDropped} // OwedEnded is an owed act's outcome (design 47 G §164): the act's id and one outcome, with the words of any outcome -// but performed. Of is the seat that said the act (mesh-delivery for the gate's, mesh-delivery-checker for the -// checker's), so each hears its own ids (§164). An act the bridge cannot decode may name no id. +// but performed. Of is the seat that said the act (mesh-delivery for the gate's), so it hears its own ids (§164). An act the bridge cannot decode may name no id. type OwedEnded struct { V int `json:"v"` Of string `json:"of"` diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/bridge.go b/modules/mesh-delivery-forge-bridge/internal/bridge/bridge.go index 21648ba3..92ab3a1b 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/bridge.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/bridge.go @@ -1,65 +1,19 @@ -// Package bridge turns the seat git's pull request events into the messages the forge bridge writes on FORGE. +// Package bridge reads the seat git's branch-moved and the acts owed to the forge, and makes the messages the forge +// bridge writes on its stream forge: head-moved (design 47 H §739) and owed.ended. package bridge import ( - "crypto/sha256" - "encoding/hex" - "encoding/json" "errors" "fmt" - "maps" - "path" "regexp" - "slices" - "strconv" - "strings" - "sync" - - git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/keys" ) // ErrUnreadable is wrapped by every error that says an event cannot be turned into a message; it is never // redelivered. var ErrUnreadable = errors.New("unreadable event") -// ErrNotHandled says the event is one the bridge hears but writes nothing for (yet). -var ErrNotHandled = errors.New("event not handled") - -// ErrRetry says the event is readable but the forge could not be asked what the message needs; the event is to be -// heard again later. -var ErrRetry = errors.New("the forge could not say") - -// Watching says whether the bridge watches a branch of a repository (Watched; design 47 G §507, §532). -type Watching interface { - Watches(repository, branch string) bool -} - -// Trees asks the forge for the trees of a commit: the root tree and the tree of every directory holding a module.json -// (the root directory spelled ""), as the seat git's verb trees answers (issue 1234/AC4). -type Trees func(owner, repo, sha string) (root string, trees map[string]string, err error) - -// ErrNotFound says the forge has no file at that path and ref (the forge's "404", issue 1448). -var ErrNotFound = errors.New("the forge has no such file") - -// Files asks the forge for one file's bytes at a ref (a commit), as the seat git's verb file answers; a file the forge -// says is not there is ErrNotFound, any other failure any other error (issue 1448). -type Files func(owner, repo, path, ref string) ([]byte, error) - -// CatalogRepository is the catalogue, whose merged message carries its predefined list, and PredefinedFile that list's -// file at its root (novox/hq ADR 0565 §2, ADR 0348 §7). -const ( - CatalogRepository = "novox/mesh-catalog" - PredefinedFile = "predefined.json" -) - -// LockFiles are the lock files read beside a module's manifest, by name relative to its directory (novox/hq ADR 0465 -// clause 1: go.sum for a Go module, package-lock.json for a Node one). -var LockFiles = []string{"go.sum", "package-lock.json"} - -// Message is a message for FORGE: the event name (forge...) and its JSON body. +// Message is a message for the stream forge: the event name (forge....head-moved) and its +// JSON body. type Message struct { Event string Data []byte @@ -67,510 +21,8 @@ type Message struct { Said string } -// The subjects of the seat git's events the bridge writes pull messages for (novox/hq design 47 *The seat `git`*): the -// seat's holder says them on mesh.seat.git.event., whichever module holds it; the bridge names none. -const ( - UpdatedSubject = git.SubjectPullUpdated - ClosedSubject = git.SubjectPullClosed - MergedSubject = git.SubjectPullMerged - // DeletedSubject is the seat's forge.delete: a branch or a tag deleted (repository, ref, ref-type). Only the seat's - // holder may publish on the seat's subjects (novox/hq ADR 0363 §2), so no other module can end a branch's tagged - // versions. - DeletedSubject = git.SubjectForgeDelete -) - -// ForgeBranchDeleted is the kind of a branch-deleted message on FORGE (novox/hq design 51 *The forge bridge says a -// branch's end*): the builder removes the branch's tagged versions on it, as on a pull request's merged or closed. -// Every existing consumer of FORGE ignores a kind it does not know. -const ForgeBranchDeleted = "branch-deleted" - -// BranchDeleted is the body of a branch-deleted message. -type BranchDeleted struct { - V int `json:"v"` - Kind string `json:"kind"` - Repository string `json:"repository"` - Branch string `json:"branch"` - // Head is the commit the branch named when it was deleted, when the forge said it. - Head string `json:"head,omitempty"` -} - -// branchDeleted turns forge.delete into a branch-deleted message; a deleted tag is not handled. -func branchDeleted(subject string, data []byte, watched Watching) (Message, error) { - var e git.ForgeDeleteEvent - if err := json.Unmarshal(data, &e); err != nil { - return Message{}, unreadable(subject, "the body is not json: %v", err) - } - d := struct{ Owner, Repo, Ref, RefType string }{Ref: e.Ref, RefType: e.RefType} - d.Owner, d.Repo, _ = strings.Cut(e.Repository, "/") - if d.RefType != "branch" { - return Message{}, fmt.Errorf("%w: %s of a %s (%s)", ErrNotHandled, subject, d.RefType, d.Ref) - } - branch := strings.TrimPrefix(d.Ref, "refs/heads/") - switch { - case d.Owner == "" || d.Repo == "" || strings.ContainsAny(d.Owner+d.Repo, "./ *>"): - return Message{}, unreadable(subject, "no owner or repo a forge event can name (%q/%q)", d.Owner, d.Repo) - case branch == "": - return Message{}, unreadable(subject, "no branch") - case watched.Watches(d.Owner+"/"+d.Repo, branch): - return Message{}, fmt.Errorf("%w: %s of the watched branch %s", ErrNotHandled, subject, branch) - } - body, err := json.Marshal(BranchDeleted{V: keys.Version, Kind: ForgeBranchDeleted, Repository: d.Owner + "/" + d.Repo, Branch: branch}) - if err != nil { - return Message{}, unreadable(subject, "%v", err) - } - return Message{Event: "forge." + d.Owner + "." + d.Repo + "." + ForgeBranchDeleted, Data: body, - Said: fmt.Sprintf("branch %s of %s/%s deleted: its tagged versions end", branch, d.Owner, d.Repo)}, nil -} - var sha40 = regexp.MustCompile(`^[0-9a-f]{40}$`) -// pull is the part of the seat git's pull.updated, pull.merged and pull.closed the bridge reads: Head is the branch and -// HeadSHA the commit, Owner and Repo the repository's two halves. -type pull struct { - Owner, Repo string - Number int - Head, HeadSHA string - ModuleDirs []string - ModuleDirsSaid bool - Base string - MergeSHA string -} - -// pullOf reads one of the seat's pull events. The directories are the seat's word only when its change says them: an -// absent `module-dirs` is "could not be read", never "none". -func pullOf(data []byte) (pull, error) { - var e struct { - Repository string `json:"repository"` - Number int64 `json:"number"` - Branch string `json:"branch"` - Head string `json:"head"` - Base string `json:"base"` - MergeCommit string `json:"merge-commit"` - Change json.RawMessage `json:"change"` - } - if err := json.Unmarshal(data, &e); err != nil { - return pull{}, err - } - p := pull{Number: int(e.Number), Head: e.Branch, HeadSHA: e.Head, Base: e.Base, MergeSHA: e.MergeCommit} - p.Owner, p.Repo, _ = strings.Cut(e.Repository, "/") - if len(e.Change) > 0 && string(e.Change) != "null" { - var c map[string]json.RawMessage - if err := json.Unmarshal(e.Change, &c); err != nil { - return pull{}, fmt.Errorf("its change: %w", err) - } - if raw, said := c["module-dirs"]; said { - if err := json.Unmarshal(raw, &p.ModuleDirs); err != nil { - return pull{}, fmt.Errorf("its change's module-dirs: %w", err) - } - p.ModuleDirsSaid = true - } - } - return p, nil -} - func unreadable(subject, why string, args ...any) error { return fmt.Errorf("%w: %s: %s", ErrUnreadable, subject, fmt.Sprintf(why, args...)) } - -// Convert turns one pull request event of the seat git, by its bus subject and body, into a message. An event it cannot -// read is an ErrUnreadable error naming the subject and why; an event it writes nothing for is ErrNotHandled. A pull -// request into a branch the bridge does not watch is no candidate: written closed. A merge into a watched branch writes -// nothing here: its merged message is the move's, heard on branch-moved (MoveMessage; design 47 G §509, §714); a merge -// into another branch is a closed pull message, as the pull request left its group. A forge that cannot say is ErrRetry. -func Convert(subject string, data []byte, files Files, watched Watching) (Message, error) { - var action string - switch subject { - case UpdatedSubject: - action = forgemsg.PullUpdated - case ClosedSubject, MergedSubject: - action = forgemsg.PullClosed - case DeletedSubject: - return branchDeleted(subject, data, watched) - default: - return Message{}, fmt.Errorf("%w: %s", ErrNotHandled, subject) - } - p, err := pullOf(data) - if err != nil { - return Message{}, unreadable(subject, "the body is not the seat's json: %v", err) - } - switch { - case p.Owner == "" || p.Repo == "" || strings.Contains(p.Repo, "/"): - return Message{}, unreadable(subject, "no owner or repo") - case p.Number <= 0: - return Message{}, unreadable(subject, "no pull request number") - case !sha40.MatchString(p.HeadSHA): - return Message{}, unreadable(subject, "the head %q is not 40 hex digits", p.HeadSHA) - case p.Head == "": - return Message{}, unreadable(subject, "no branch") - } - into := p.Base != "" && watched.Watches(p.Owner+"/"+p.Repo, p.Base) - if subject == MergedSubject && into { - return Message{}, fmt.Errorf("%w: %s of %s/%s#%d into the watched branch %s: its merged message is written from the branch's move", ErrNotHandled, subject, p.Owner, p.Repo, p.Number, p.Base) - } - said := "" - if action == forgemsg.PullUpdated && p.Base != "" && !into { - // A pull request into a branch no registration watches is no candidate, as it is none at the start (OpenPulls) and at - // its merge. It is written closed, so a candidate an older head made is taken out, and said (issue 1422). - action = forgemsg.PullClosed - said = fmt.Sprintf("%s/%s#%d at %s is into %s, which is not watched: written closed, so it is no candidate", - p.Owner, p.Repo, p.Number, p.HeadSHA[:12], p.Base) - } - f := forgemsg.Forge{Kind: forgemsg.ForgePull, Repository: p.Owner + "/" + p.Repo, Branch: p.Head, Number: p.Number, - Head: p.HeadSHA, Action: action} - // The directories are the forge's word only when it said it could read them (module_dirs_said). - if action == forgemsg.PullUpdated && p.ModuleDirsSaid { - f.Dirs, f.DirsKnown = p.ModuleDirs, true - var err error - if f.Manifests, f.Locks, f.Needs, _, err = inputsRead(p.Owner, p.Repo, p.HeadSHA, p.ModuleDirs, files); err != nil { - return Message{}, fmt.Errorf("%w: %s: the manifests of %s/%s at the head %s: %v", ErrRetry, subject, p.Owner, p.Repo, p.HeadSHA, err) - } - } - event, err := forgemsg.ForgeEvent(f.Repository, forgemsg.ForgePull) - if err != nil { - return Message{}, unreadable(subject, "%v", err) - } - body, err := forgemsg.EncodeForge(f) - if err != nil { - return Message{}, unreadable(subject, "%v", err) - } - return Message{Event: event, Data: body, Said: said}, nil -} - -// MaxReadsInFlight is how many files of the forge inputsOf asks for at once. A merge into a repository of many -// modules (131 in the catalogue) reads three files for each, one after another inside the bound of a handled event -// (30 s) that leaves about 76 ms a call; eight at once keeps the forge's load small and the read well inside the bound -// (issue 1458). -const MaxReadsInFlight = 8 - -// read is one file asked for: the path in the directory dir, and whether it is the module's manifest. -type read struct { - dir, path string - manifest bool - asked bool - raw []byte - err error -} - -// inputsOf reads, at ref, the module.json of each directory (the root spelled "") and the lock files beside it -// (LockFiles): the manifests as the forge answered them and the lock files' hex sha256 by name. A manifest the forge -// does not have is an error, since the directory was said to hold one; a lock file it does not have is left out; any other -// failure is an error (issue 1448). -// -// The files are asked for with at most MaxReadsInFlight calls at once (issue 1458). The result does not depend on the -// order the calls finish in, and the error is that of the first failing file in the order of dirs and LockFiles. After -// a failure no further file is asked for, and inputsOf returns only when every call it started has returned. -func inputsOf(owner, repo, ref string, dirs []string, files Files) (manifests map[string]string, locks map[string]map[string]string, err error) { - manifests, locks, _, _, err = inputsRead(owner, repo, ref, dirs, files) - return manifests, locks, err -} - -// inputsRead is inputsOf, and also answers, on a failure too, the directories whose manifest and lock files were all -// read, with their manifests and lock hashes: a merge keeps them by their tree, so its next try reads only the rest -// (issue 1126). It reads no mesh package a go.sum names: the indexer alone computes what a fingerprint takes (novox/hq -// ADR 0593 §2), so the message's Packages stay empty. Of a directory whose manifest names templates it reads each -// template too, in a second round, and answers the module's needs whole (catalogue.ModuleNeeds; novox/hq ADR 0632 §2): -// a template's text can need a reading its manifest does not. A template the forge does not have is no need (the judge -// refuses the manifest by name); any other failure to read one is the directory's, as a lock file's is. -func inputsRead(owner, repo, ref string, dirs []string, files Files) (manifests map[string]string, locks map[string]map[string]string, needs map[string][]string, whole []string, err error) { - at := func(dir, name string) string { - if dir == "" { - return name - } - return dir + "/" + name - } - var reads []*read - for _, dir := range dirs { - reads = append(reads, &read{dir: dir, path: at(dir, "module.json"), manifest: true}) - for _, name := range LockFiles { - reads = append(reads, &read{dir: dir, path: at(dir, name)}) - } - } - fetch(owner, repo, ref, reads, files) - manifests = map[string]string{} - locks = map[string]map[string]string{} - broken := map[string]bool{} // a directory with a file not read (failed, or never asked after a failure) - failed := func(r *read) bool { - switch { - case r.err != nil && (r.manifest || !errors.Is(r.err, ErrNotFound)): - broken[r.dir] = true - if err == nil { - err = fmt.Errorf("%s: %w", r.path, r.err) - } - case r.err == nil && r.raw == nil && !r.asked: - broken[r.dir] = true - default: - return false - } - return true - } - for _, r := range reads { - switch { - case failed(r): - case r.err != nil: // a lock file the forge does not have - case r.manifest: - manifests[r.dir] = string(r.raw) - default: - sum := sha256.Sum256(r.raw) - if locks[r.dir] == nil { - locks[r.dir] = map[string]string{} - } - locks[r.dir][path.Base(r.path)] = hex.EncodeToString(sum[:]) - } - } - var templates []*read - if err == nil { - for _, dir := range dirs { - for _, t := range templatePaths(manifests[dir]) { - templates = append(templates, &read{dir: dir, path: at(dir, t)}) - } - } - fetch(owner, repo, ref, templates, files) - } - texts := map[string]map[string]string{} - for _, r := range templates { - if failed(r) || r.err != nil { - continue - } - if texts[r.dir] == nil { - texts[r.dir] = map[string]string{} - } - texts[r.dir][strings.TrimPrefix(r.path, at(r.dir, ""))] = string(r.raw) - } - needs = map[string][]string{} - for _, dir := range dirs { - if raw, ok := manifests[dir]; ok && !broken[dir] && len(templatePaths(raw)) > 0 { - needs[dir], _ = catalogue.ModuleNeeds([]byte(raw), texts[dir]) - } - } - for _, dir := range dirs { - if !broken[dir] { - whole = append(whole, dir) - } - } - if err != nil { - for dir := range broken { - delete(manifests, dir) - delete(locks, dir) - delete(needs, dir) - } - return manifests, locks, needs, whole, err - } - if len(manifests) == 0 { - manifests = nil - } - if len(locks) == 0 { - locks = nil - } - if len(needs) == 0 { - needs = nil - } - return manifests, locks, needs, whole, nil -} - -// templatePaths is the templates a manifest names (catalogue.TemplatePaths), none for one that does not decode. -func templatePaths(raw string) []string { - if raw == "" { - return nil - } - m, err := catalogue.Decode([]byte(raw)) - if err != nil { - return nil - } - return catalogue.TemplatePaths(m) -} - -// fetch asks the forge for each of reads at ref, at most MaxReadsInFlight at once; after a failure (a manifest, or a -// file the forge has and could not give) no further file is asked for, and it returns once every call it started has. -func fetch(owner, repo, ref string, reads []*read, files Files) { - var ( - wg sync.WaitGroup - mu sync.Mutex - failed bool - slots = make(chan struct{}, MaxReadsInFlight) - ) - for _, r := range reads { - slots <- struct{}{} - mu.Lock() - stop := failed - mu.Unlock() - if stop { - <-slots - break - } - r.asked = true - wg.Add(1) - go func(r *read) { - defer func() { <-slots; wg.Done() }() - r.raw, r.err = files(owner, repo, r.path, ref) - if r.err != nil && (r.manifest || !errors.Is(r.err, ErrNotFound)) { - mu.Lock() - failed = true - mu.Unlock() - } - }(r) - } - wg.Wait() -} - -// landed is the message of a commit that landed on a watched branch, merged or pushed (f says which and what names it): -// the trees of the commit, asked once, and the take-in inputs of every module directory at it (design 47 G §509, A-236). -func landed(what string, f forgemsg.Forge, commit string, trees Trees, files Files, kept Kept) (Message, error) { - if !sha40.MatchString(commit) { - return Message{}, unreadable(what, "the commit %q is not 40 hex digits", commit) - } - repository := f.Repository - owner, repo, _ := strings.Cut(repository, "/") - root, dirs, err := trees(owner, repo, commit) - if err != nil { - return Message{}, fmt.Errorf("%w: %s: the trees of %s at %s: %v", ErrRetry, what, repository, commit, err) - } - names := make([]string, 0, len(dirs)) - for dir := range dirs { - names = append(names, dir) - } - slices.Sort(names) - manifests, locks, needs, toRead := keptInputs(names, dirs, kept) - read, readLocks, readNeeds, whole, err := inputsRead(owner, repo, commit, toRead, files) - if err != nil { - keep(whole, dirs, read, readLocks, readNeeds, kept) // what was read whole is not asked again at the next try - return Message{}, fmt.Errorf("%w: %s: the manifests of %s at %s (%d of %d module directories read from the forge, the others kept by their tree): %v", ErrRetry, what, repository, commit, len(toRead), len(names), err) - } - keep(toRead, dirs, read, readLocks, readNeeds, kept) - maps.Copy(manifests, read) - maps.Copy(locks, readLocks) - maps.Copy(needs, readNeeds) - if len(manifests) == 0 { - manifests = nil - } - if len(locks) == 0 { - locks = nil - } - if len(needs) == 0 { - needs = nil - } - event, err := forgemsg.ForgeEvent(repository, f.Kind) - if err != nil { - return Message{}, unreadable(what, "%v", err) - } - f.Root, f.Trees, f.Manifests, f.Locks, f.Needs = root, dirs, manifests, locks, needs - if repository == CatalogRepository { - // The catalogue's predefined list at the commit (novox/hq ADR 0565 §2): the indexer keeps it for mesh-config. - raw, err := files(owner, repo, PredefinedFile, commit) - switch { - case errors.Is(err, ErrNotFound): - f.PredefinedRead = true - case err != nil: - return Message{}, fmt.Errorf("%w: %s: %s of %s at %s: %v", ErrRetry, what, PredefinedFile, repository, commit, err) - default: - f.Predefined = json.RawMessage(raw) - } - } - body, err := forgemsg.EncodeForge(f) - if err != nil { - return Message{}, unreadable(what, "%v", err) - } - msg := Message{Event: event, Data: body} - if len(dirs) == 0 { - msg.Said = fmt.Sprintf("%s at %s holds no module.json: a %s message with no module directories", repository, commit, f.Kind) - } - return msg, nil -} - -// openPulls reads the seat git's answer of open-pulls: an answer saying an error is the error, never none open. -func openPulls(answer []byte) ([]pull, error) { - var a git.OpenPullsAnswer - if err := json.Unmarshal(answer, &a); err != nil { - return nil, fmt.Errorf("the seat git's answer of open-pulls is not its contract's: %v", err) - } - if a.Error != "" { - return nil, fmt.Errorf("the seat git refused open-pulls: %s", a.Error) - } - var said map[string]json.RawMessage - if _ = json.Unmarshal(answer, &said); said["pulls"] == nil || string(said["pulls"]) == "null" { - // None open is `pulls: []`; an answer naming no list would drop every candidate on a holder's fault. - return nil, fmt.Errorf("open-pulls: %w", errNoAnswer) - } - out := make([]pull, 0, len(a.Pulls)) - for _, o := range a.Pulls { - p := pull{Number: int(o.Pull.Number), Head: o.Pull.Branch, HeadSHA: o.Pull.Head, Base: o.Pull.Base} - p.Owner, p.Repo, _ = strings.Cut(o.Pull.Repository, "/") - out = append(out, p) - } - return out, nil -} - -// OpenPulls turns the seat git's answer of open-pulls into one pull message per open pull request into -// a watched branch, action updated and its directories not known (the forge's answer does not say them). A pull request into -// another branch gets none. An entry that cannot be read is named in skipped and gets none; an answer that is not -// the contract's, or that says an error, is an error. -func OpenPulls(answer []byte, watched Watching) (msgs []Message, skipped []string, err error) { - pulls, err := openPulls(answer) - if err != nil { - return nil, nil, err - } - for _, p := range pulls { - if !watched.Watches(p.Owner+"/"+p.Repo, p.Base) { - continue - } - name := fmt.Sprintf("%s/%s#%d", p.Owner, p.Repo, p.Number) - if p.Owner == "" || p.Repo == "" || p.Number <= 0 || p.Head == "" || !sha40.MatchString(p.HeadSHA) { - skipped = append(skipped, name+": it names no owner, repo, number, branch or 40-hex head") - continue - } - f := forgemsg.Forge{Kind: forgemsg.ForgePull, Repository: p.Owner + "/" + p.Repo, Branch: p.Head, Number: p.Number, - Head: p.HeadSHA, Action: forgemsg.PullUpdated} - event, err := forgemsg.ForgeEvent(f.Repository, forgemsg.ForgePull) - var body []byte - if err == nil { - body, err = forgemsg.EncodeForge(f) - } - if err != nil { - skipped = append(skipped, name+": "+err.Error()) - continue - } - msgs = append(msgs, Message{Event: event, Data: body}) - } - return msgs, skipped, nil -} - -// Track says what a message the bridge wrote changes in the head it keeps for each pull request (the bucket heads, -// novox/hq ADR 0443 §5): the key `..`, and the head to keep under it, or "" to take the key away -// (a closed pull request, a merged one). ok is false for a message that keeps no head. -func Track(f forgemsg.Forge) (key, head string, ok bool) { - key = strings.ReplaceAll(f.Repository, "/", ".") + "." + strconv.Itoa(f.Number) - switch { - case f.Kind == forgemsg.ForgePull && f.Action != forgemsg.PullClosed: - return key, f.Head, true - case f.Kind == forgemsg.ForgePull || f.Kind == forgemsg.ForgeMerged: - return key, "", true - } - return "", "", false -} - -// OpenMessage turns the seat git's answer of open-pulls into the open message: every open pull request into a watched branch, by -// repository and number, whether its head reads or not and whether FORGE holds it or not, in repository and number -// order. A pull request into another branch is not named. An answer that names none is a message too: nothing is open. -func OpenMessage(answer []byte, watched Watching) (Message, error) { - pulls, err := openPulls(answer) - if err != nil { - return Message{}, err - } - open := []forgemsg.OpenPull{} - for _, p := range pulls { - if !watched.Watches(p.Owner+"/"+p.Repo, p.Base) || p.Owner == "" || p.Repo == "" || p.Number <= 0 { - continue - } - open = append(open, forgemsg.OpenPull{Repository: p.Owner + "/" + p.Repo, Number: p.Number}) - } - slices.SortFunc(open, func(a, b forgemsg.OpenPull) int { - if c := strings.Compare(a.Repository, b.Repository); c != 0 { - return c - } - return a.Number - b.Number - }) - body, err := forgemsg.EncodeForge(forgemsg.Forge{Kind: forgemsg.ForgeOpen, Open: open}) - if err != nil { - return Message{}, fmt.Errorf("the open pull requests cannot be said: %w", err) - } - return Message{Event: forgemsg.OpenEvent(), Data: body}, nil -} diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/bridge_test.go b/modules/mesh-delivery-forge-bridge/internal/bridge/bridge_test.go index dc0aaa35..23b12b42 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/bridge_test.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/bridge_test.go @@ -7,420 +7,9 @@ import ( "strings" "testing" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - "git.novox.be/novox/mesh-sdk/go/keys" - "mesh-delivery-forge-bridge/internal/gitfixture" ) -const head = "0123456789abcdef0123456789abcdef01234567" - -// updated is the body of the seat git's pull.updated (modules/mesh-delivery-contracts/seats/git): the pull request, its base's head and its -// change. extra names the parts a test changes by their short names (owner, repo, number, head for the branch, -// head_sha for the commit, base, module_dirs, module_dirs_said), a nil value leaving the part out (seatPull). -func updated(extra map[string]any) []byte { - return seatPull(map[string]any{"base_sha": "ffffffffffffffffffffffffffffffffffffffff", - "paths": []string{"modules/a/x.go"}, "module_dirs": []string{"modules/a"}, "module_dirs_said": true}, extra) -} - -// closed is the body of the seat git's pull.closed. -func closed() []byte { return seatPull(nil, nil) } - -// seatPull is a pull event of the seat git: the pull request novox/mesh-delivery#12 of feat/x at head into main, with -// the parts of base and extra laid over it by their short names, a nil value leaving the part out. module_dirs is said -// in the change only when module_dirs_said is true: its absence is "could not be read". -func seatPull(base, extra map[string]any) []byte { - m := map[string]any{"owner": "novox", "repo": "mesh-delivery", "number": 12, "title": "A change", "head": "feat/x", - "head_sha": head, "base": "main", "html_url": "https://forge.example/novox/mesh-delivery/pulls/12"} - for _, over := range []map[string]any{base, extra} { - for k, v := range over { - if v == nil { - delete(m, k) - } else { - m[k] = v - } - } - } - e := map[string]any{} - owner, _ := m["owner"].(string) - repo, _ := m["repo"].(string) - if owner != "" || repo != "" { - e["repository"] = owner + "/" + repo - } - for short, name := range map[string]string{"number": "number", "title": "title", "head": "branch", "head_sha": "head", - "base": "base", "html_url": "url", "merge_commit_sha": "merge-commit", "base_sha": "base-head", "merged_at": "merged-at"} { - if v, ok := m[short]; ok { - e[name] = v - } - } - if paths, ok := m["paths"]; ok { - c := map[string]any{"paths": paths} - if m["module_dirs_said"] == true && m["module_dirs"] != nil { - c["module-dirs"] = m["module_dirs"] - } - e["change"] = c - } - b, _ := json.Marshal(e) - return b -} - -const updatedSubject = "mesh.seat.git.event.pull-updated" -const closedSubject = "mesh.seat.git.event.pull-closed" - -func TestUpdatedBecomesAPullMessage(t *testing.T) { // 1235/AC2 (the conversion; the bus is the integration test) - msg, err := Convert(updatedSubject, updated(nil), anyFiles, watchesMain) - if err != nil { - t.Fatal(err) - } - if msg.Event != "forge.novox.mesh-delivery.pull" { - t.Errorf("event = %q", msg.Event) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - want := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgePull, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, - Head: head, Action: forgemsg.PullUpdated, Dirs: []string{"modules/a"}, DirsKnown: true, Manifests: map[string]string{"modules/a": "{}"}} - if !forgemsg.SameForge(f, want) { - t.Errorf("message = %+v, want %+v", f, want) - } - - // 1235/AC3, merged into this test for the test budget: dirs not said are not known. - msg, err = Convert(updatedSubject, updated(map[string]any{"module_dirs": nil, "module_dirs_said": nil}), anyFiles, watchesMain) - if err != nil { - t.Fatal(err) - } - f, _ = forgemsg.DecodeForge(msg.Data) - if f.DirsKnown || len(f.Dirs) != 0 { - t.Errorf("dirs = %v known = %v, want not known", f.Dirs, f.DirsKnown) - } - // Said and empty is known and empty, not unknown. - msg, err = Convert(updatedSubject, updated(map[string]any{"module_dirs": []string{}, "module_dirs_said": true}), anyFiles, watchesMain) - if err != nil { - t.Fatal(err) - } - f, _ = forgemsg.DecodeForge(msg.Data) - if !f.DirsKnown || len(f.Dirs) != 0 { - t.Errorf("dirs = %v known = %v, want known and empty", f.Dirs, f.DirsKnown) - } - // Dirs listed without the forge saying it could read them are not trusted. - msg, err = Convert(updatedSubject, updated(map[string]any{"module_dirs_said": nil}), anyFiles, watchesMain) - if err != nil { - t.Fatal(err) - } - if f, _ = forgemsg.DecodeForge(msg.Data); f.DirsKnown || len(f.Dirs) != 0 { - t.Errorf("dirs %v known %v without module_dirs_said", f.Dirs, f.DirsKnown) - } -} - -func TestClosedBecomesAClosedPullMessage(t *testing.T) { // 1235/AC4 - msg, err := Convert(closedSubject, closed(), anyFiles, watchesMain) - if err != nil { - t.Fatal(err) - } - if msg.Event != "forge.novox.mesh-delivery.pull" { - t.Errorf("event = %q", msg.Event) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - want := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgePull, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, - Head: head, Action: forgemsg.PullClosed} - if !forgemsg.SameForge(f, want) { - t.Errorf("message = %+v, want %+v", f, want) - } - // Issue 1422; design 47 G §507: a head pushed to a pull request into a base no registration watches is written closed, - // read nothing for, and said; one into a watched branch is no closed message, and an event naming no base is written as before. - msg, err = Convert(updatedSubject, updated(map[string]any{"base": "nox-mesh"}), nil, watchesMain) - if err != nil { - t.Fatal(err) - } - if f, err = forgemsg.DecodeForge(msg.Data); err != nil || !forgemsg.SameForge(f, want) || !strings.Contains(msg.Said, "is into nox-mesh, which is not watched") { - t.Errorf("an update into nox-mesh is %+v (%v), said %q; want it closed and said", f, err, msg.Said) - } - for _, base := range []any{"main", nil} { - msg, err = Convert(updatedSubject, updated(map[string]any{"base": base}), anyFiles, watchesMain) - if f, _ = forgemsg.DecodeForge(msg.Data); err != nil || f.Action != forgemsg.PullUpdated || msg.Said != "" { - t.Errorf("an update with base %v is %+v (%v), said %q; want it updated", base, f, err, msg.Said) - } - } -} - -func TestUnreadableEventsWriteNothing(t *testing.T) { // 1235/AC5 - for name, c := range map[string]struct { - subject string - data []byte - why string - }{ - "no owner": {updatedSubject, updated(map[string]any{"owner": nil}), "owner"}, - "no repo": {updatedSubject, updated(map[string]any{"repo": nil}), "repo"}, - "no number": {updatedSubject, updated(map[string]any{"number": nil}), "number"}, - "number zero": {updatedSubject, updated(map[string]any{"number": 0}), "number"}, - "short head": {updatedSubject, updated(map[string]any{"head_sha": "abc123"}), "head"}, - "head not hex": {updatedSubject, updated(map[string]any{"head_sha": strings.Repeat("g", 40)}), "head"}, - "upper-case head": {updatedSubject, updated(map[string]any{"head_sha": strings.ToUpper(head)}), "head"}, - "no branch": {updatedSubject, updated(map[string]any{"head": nil}), "branch"}, - "not json": {updatedSubject, []byte("{"), "json"}, - "closed no head": {closedSubject, mustDrop(closed(), "head"), "head"}, - "closed no repo": {closedSubject, mustDrop(closed(), "repository"), "repo"}, - } { - msg, err := Convert(c.subject, c.data, anyFiles, watchesMain) - if err == nil { - t.Errorf("%s: a message %q was made", name, msg.Event) - continue - } - if !errors.Is(err, ErrUnreadable) { - t.Errorf("%s: error %v is not ErrUnreadable", name, err) - } - if !strings.Contains(err.Error(), c.why) || !strings.Contains(err.Error(), c.subject) { - t.Errorf("%s: error %q names neither its subject nor %q", name, err, c.why) - } - if msg.Data != nil { - t.Errorf("%s: data was made", name) - } - } -} - -func mustDrop(body []byte, key string) []byte { - var m map[string]any - _ = json.Unmarshal(body, &m) - delete(m, key) - b, _ := json.Marshal(m) - return b -} - -func TestOtherSubjectsAreNotHandled(t *testing.T) { // 1235, 1236 - for _, s := range []string{"mesh.seat.git.event.something.else", "mesh.mod.gitea.event.pull.updated", "mesh.mod.other.event.forge.delete"} { - if _, err := Convert(s, updated(nil), anyFiles, watchesMain); !errors.Is(err, ErrNotHandled) { - t.Errorf("%s: err = %v, want ErrNotHandled", s, err) - } - } - // The seat's forge.delete of a branch is a branch-deleted message (DLV-FB1, design 51); of a tag or the - // trunk it is not handled, and a body naming no repository is unreadable. - del := func(refType, ref string) []byte { - b, _ := json.Marshal(map[string]any{"repository": "novox/mesh-sdk", "ref": ref, "ref-type": refType, "sender": "jochen"}) - return b - } - msg, err := Convert(DeletedSubject, del("branch", "feat/x"), anyFiles, watchesMain) - var bd BranchDeleted - if err != nil || msg.Event != "forge.novox.mesh-sdk.branch-deleted" || json.Unmarshal(msg.Data, &bd) != nil || - bd.Kind != ForgeBranchDeleted || bd.Repository != "novox/mesh-sdk" || bd.Branch != "feat/x" || bd.Head != "" || msg.Said == "" { - t.Errorf("forge.delete of a branch = %+v (%s), %v", msg, msg.Data, err) - } - for _, c := range []struct{ refType, ref string }{{"tag", "go/v0.1.13"}, {"branch", "main"}} { - if _, err := Convert(DeletedSubject, del(c.refType, c.ref), anyFiles, watchesMain); !errors.Is(err, ErrNotHandled) { - t.Errorf("forge.delete of %s %s: err = %v, want ErrNotHandled", c.refType, c.ref, err) - } - } - if _, err := Convert(DeletedSubject, []byte(`{"ref":"x","ref-type":"branch"}`), anyFiles, watchesMain); !errors.Is(err, ErrUnreadable) { - t.Errorf("forge.delete naming no repository: err = %v, want ErrUnreadable", err) - } - // 1236: a merged event without a full merge commit is unreadable, and the forge is not asked. - var calls []call - _, err = convertMerged(mergedBody(map[string]any{"merge_commit_sha": "abc"}), treesOf(&calls, "r0", map[string]string{"a": "t"}, nil), anyFiles, nil) - if !errors.Is(err, ErrUnreadable) || len(calls) != 0 { - t.Errorf("merged without a merge commit: err = %v calls = %v", err, calls) - } -} - -const merge = "89abcdef0123456789abcdef0123456789abcdef" - -// mergedBody is the seat git's pull.merged, extra by the short names seatPull reads. -func mergedBody(extra map[string]any) []byte { - return seatPull(map[string]any{"merge_commit_sha": merge, "merged_at": "2026-10-19T12:00:00Z", - "paths": []string{"modules/a/x.go"}, "module_dirs": []string{"modules/a"}, "module_dirs_said": true}, extra) -} - -const mergedSubject = "mesh.seat.git.event.pull-merged" - -type call struct{ owner, repo, sha string } - -// treesOf answers as gitea_commit_trees does (issue 1234/AC4: root, and the directory to tree hash, the root spelled ""). -func treesOf(calls *[]call, root string, trees map[string]string, err error) Trees { - return func(owner, repo, sha string) (string, map[string]string, error) { - *calls = append(*calls, call{owner, repo, sha}) - return root, trees, err - } -} - -func TestMergeIntoMainBecomesAMergedMessage(t *testing.T) { // 1236/AC1 - var calls []call - answer := map[string]string{"modules/a": "t1", "modules/b": "t2"} - msg, err := convertMerged(mergedBody(nil), treesOf(&calls, "r0", answer, nil), anyFiles, nil) - if err != nil { - t.Fatal(err) - } - if msg.Event != "forge.novox.mesh-delivery.merged" { - t.Errorf("event = %q", msg.Event) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - want := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, - Head: head, Merge: merge, Base: "main", Root: "r0", Trees: answer, Manifests: map[string]string{"modules/a": "{}", "modules/b": "{}"}} - if !forgemsg.SameForge(f, want) { - t.Errorf("message = %+v, want %+v", f, want) - } - if len(calls) != 1 || calls[0] != (call{"novox", "mesh-delivery", merge}) { - t.Errorf("the tool was called %v, want once with novox, mesh-delivery and the merge commit", calls) - } -} - -// 1236/AC2; design 47 G §509, §714: a pull request merged into a branch no registration watches is a closed pull, and one -// merged into a watched branch writes nothing here: its one message is its branch's move (MoveMessage). -func TestMergeIntoAnotherBranchIsAClosedPull(t *testing.T) { - var calls []call - if _, err := Convert(mergedSubject, mergedBody(nil), anyFiles, watchesMain); !errors.Is(err, ErrNotHandled) { - t.Errorf("a merge into the watched main: %v, want nothing written (ErrNotHandled)", err) - } - msg, err := Convert(mergedSubject, mergedBody(map[string]any{"base": "feat/y"}), anyFiles, watchesMain) - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - want := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgePull, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, - Head: head, Action: forgemsg.PullClosed} - if msg.Event != "forge.novox.mesh-delivery.pull" || !forgemsg.SameForge(f, want) { - t.Errorf("event %q message %+v, want a closed pull message", msg.Event, f) - } - if len(calls) != 0 { - t.Errorf("the tool was called for a merge into another branch: %v", calls) - } -} - -func TestTreesRefusedWritesNothingAndSaysWhy(t *testing.T) { // 1236/AC3 (the conversion; the delay is in main_test) - var calls []call - msg, err := convertMerged(mergedBody(nil), treesOf(&calls, "", nil, errors.New("the listing for novox/mesh-delivery was cut")), anyFiles, nil) - if !errors.Is(err, ErrRetry) || msg.Data != nil { - t.Fatalf("err = %v data = %s, want ErrRetry and no message", err, msg.Data) - } - for _, w := range []string{"novox/mesh-delivery", merge, "the listing for novox/mesh-delivery was cut"} { - if !strings.Contains(err.Error(), w) { - t.Errorf("error %q does not name %q", err, w) - } - } -} - -// 1126 (note 94): a merge that leaves no module.json anywhere (hq, or a repository whose last module was removed) is a merged -// message with no trees, so the indexer takes it in and the repository's reach is not held for ever. -func TestNoModuleJSONAnywhereWritesAMergedMessageWithNoTrees(t *testing.T) { - var calls []call - msg, err := convertMerged(mergedBody(nil), treesOf(&calls, "r0", map[string]string{}, nil), anyFiles, nil) - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(msg.Data) - want := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, - Head: head, Merge: merge, Base: "main", Root: "r0"} - if err != nil || msg.Event != "forge.novox.mesh-delivery.merged" || !forgemsg.SameForge(f, want) || !strings.Contains(msg.Said, "no module.json") { - t.Errorf("event %q message %+v said %q, %v; want a merged message with no trees", msg.Event, f, msg.Said, err) - } -} - -// openAnswer is the seat git's answer of open-pulls. -func openAnswer(pulls ...map[string]any) []byte { - b, _ := json.Marshal(map[string]any{"pulls": pulls}) - return b -} - -func openEntry(repo string, number int, base, branch, sha string) map[string]any { - return map[string]any{"pull": map[string]any{"repository": "novox/" + repo, "number": number, "base": base, "branch": branch, "head": sha, - "state": "open", "url": "https://forge.example/x"}, "required": []string{"mesh/check"}, "checks": map[string]any{}} -} - -func TestOpenPullsAreUpdatedPullMessagesWithUnknownDirs(t *testing.T) { // 1237/AC1 - h2 := strings.Repeat("a", 40) - msgs, skipped, err := OpenPulls(openAnswer(openEntry("mesh-delivery", 12, "main", "feat/x", head), openEntry("mesh-catalog", 300, "main", "feat/x", h2)), watchesMain) - if err != nil || len(skipped) != 0 || len(msgs) != 2 { - t.Fatalf("msgs %d skipped %v err %v", len(msgs), skipped, err) - } - for i, want := range []forgemsg.Forge{ - {V: keys.Version, Kind: forgemsg.ForgePull, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, Action: forgemsg.PullUpdated}, - {V: keys.Version, Kind: forgemsg.ForgePull, Repository: "novox/mesh-catalog", Branch: "feat/x", Number: 300, Head: h2, Action: forgemsg.PullUpdated}, - } { - f, err := forgemsg.DecodeForge(msgs[i].Data) - if err != nil || !forgemsg.SameForge(f, want) { - t.Errorf("message %d = %+v err %v, want %+v", i, f, err, want) - } - if f.DirsKnown { - t.Errorf("message %d says its directories are known", i) - } - } - if msgs[0].Event != "forge.novox.mesh-delivery.pull" || msgs[1].Event != "forge.novox.mesh-catalog.pull" { - t.Errorf("events %q %q", msgs[0].Event, msgs[1].Event) - } -} - -func TestOpenPullsUnreadableEntryIsNamedAndTheRestGo(t *testing.T) { // 1237, 1237/AC4 - // 1237/AC4: an open pull request into another branch gets no message. - if msgs, skipped, err := OpenPulls(openAnswer(openEntry("mesh-delivery", 12, "feat/y", "feat/x", head)), watchesMain); err != nil || len(msgs) != 0 || len(skipped) != 0 { - t.Errorf("into another branch: msgs %d skipped %v err %v, want none", len(msgs), skipped, err) - } - msgs, skipped, err := OpenPulls(openAnswer(openEntry("a", 1, "main", "b", "short"), openEntry("mesh-delivery", 12, "main", "feat/x", head)), watchesMain) - if err != nil || len(msgs) != 1 || len(skipped) != 1 || !strings.Contains(skipped[0], "novox/a#1") { - t.Errorf("msgs %d skipped %v err %v", len(msgs), skipped, err) - } - for _, bad := range []string{`{"pulls":null}`, `{}`, `[]`, `x`, string(gitFixture(t, "open-pulls answers an error, never none", "verb:open-pulls.answer"))} { - if _, _, err := OpenPulls([]byte(bad), watchesMain); err == nil { - t.Errorf("%s was taken as an answer", bad) - } - } -} - -func TestOpenMessageNamesEveryOpenPullIntoTheTrunk(t *testing.T) { // 1279/AC6 - h2 := strings.Repeat("a", 40) - answer := openAnswer(openEntry("mesh-delivery", 12, "main", "feat/x", head), openEntry("mesh-catalog", 300, "main", "feat/x", h2), - openEntry("mesh-catalog", 301, "feat/y", "feat/z", h2), openEntry("a", 1, "main", "b", "short")) - m, err := OpenMessage(answer, watchesMain) - if err != nil || m.Event != "forge.open" { - t.Fatalf("message %+v err %v", m, err) - } - f, err := forgemsg.DecodeForge(m.Data) - // Every one into the trunk, whether its head reads or not (it is open); none into another branch; in a fixed order. - want := []forgemsg.OpenPull{{Repository: "novox/a", Number: 1}, {Repository: "novox/mesh-catalog", Number: 300}, {Repository: "novox/mesh-delivery", Number: 12}} - if err != nil || f.Kind != forgemsg.ForgeOpen || len(f.Open) != 3 || f.Open[0] != want[0] || f.Open[1] != want[1] || f.Open[2] != want[2] { - t.Errorf("open message = %+v err %v, want %v", f, err, want) - } - // Nothing open is a message too: the indexer then drops every candidate. - m, err = OpenMessage([]byte(`{"pulls":[]}`), watchesMain) - if f, derr := forgemsg.DecodeForge(m.Data); err != nil || derr != nil || f.Kind != forgemsg.ForgeOpen || len(f.Open) != 0 { - t.Errorf("empty answer: %+v %v %v", f, err, derr) - } - for _, bad := range []string{`{"pulls":null}`, `{}`, `x`, `{"error":"the forge answered 502","pulls":[]}`} { - if _, err := OpenMessage([]byte(bad), watchesMain); err == nil { - t.Errorf("%s was taken as an answer", bad) - } - } -} - -func TestTrackSaysWhichHeadOfWhichPullRequestWasWritten(t *testing.T) { // 1279/AC6 - pullMsg := func(action string) forgemsg.Forge { - return forgemsg.Forge{Kind: forgemsg.ForgePull, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, Action: action} - } - for _, a := range []string{forgemsg.PullOpened, forgemsg.PullUpdated} { - if key, h, ok := Track(pullMsg(a)); key != "novox.mesh-delivery.12" || h != head || !ok { - t.Errorf("%s: Track = %q %q %v, want the head kept under a bucket key", a, key, h, ok) - } - } - // A closed pull request and a merged one are no longer kept: their key goes. - if key, h, ok := Track(pullMsg(forgemsg.PullClosed)); key != "novox.mesh-delivery.12" || h != "" || !ok { - t.Errorf("closed: Track = %q %q %v", key, h, ok) - } - merged := forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, Merge: "m", Root: "r", Trees: map[string]string{"": "t"}} - if key, h, ok := Track(merged); key != "novox.mesh-delivery.12" || h != "" || !ok { - t.Errorf("merged: Track = %q %q %v", key, h, ok) - } - // The open message and the rest hold no head. - if _, _, ok := Track(forgemsg.Forge{Kind: forgemsg.ForgeOpen}); ok { - t.Error("an open message was tracked") - } -} - // gitFixture is one answer of the seat git's fixtures, by its name and what it is of. func gitFixture(t *testing.T, name, of string) json.RawMessage { t.Helper() @@ -505,15 +94,3 @@ func watchedOf(branches ...string) *Watched { w.Set(nil, branches) return w } - -// convertMerged is the merged message of a pull.merged body as the move of its base writes it (landed, MoveMessage), so the -// tests of what a merge reads keep their bodies. -func convertMerged(data []byte, trees Trees, files Files, kept Kept) (Message, error) { - p, err := pullOf(data) - if err != nil { - return Message{}, unreadable(MergedSubject, "%v", err) - } - f := forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: p.Owner + "/" + p.Repo, Branch: p.Head, Number: p.Number, - Head: p.HeadSHA, Merge: p.MergeSHA, Base: p.Base} - return landed(MergedSubject, f, p.MergeSHA, trees, files, kept) -} diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/call.go b/modules/mesh-delivery-forge-bridge/internal/bridge/call.go index 4c51d447..3d209816 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/call.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/call.go @@ -3,12 +3,10 @@ package bridge import ( "context" "encoding/json" - "errors" "fmt" "strings" git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" ) // Caller calls a seat's verb by its manifest key (`seat:.`) with a JSON body and returns its answer: the @@ -44,63 +42,6 @@ func askGit[A any](ctx context.Context, call Caller, verb string, in any) (A, er // repository is `/`, as the seat names a repository. func repository(owner, repo string) string { return owner + "/" + repo } -// TreesVia asks the seat `git` for a commit's trees (verb trees). -func TreesVia(ctx context.Context, call Caller) Trees { - return func(owner, repo, sha string) (string, map[string]string, error) { - a, err := askGit[git.TreesAnswer](ctx, call, git.VerbTrees, git.TreesInput{Repository: repository(owner, repo), Commit: sha}) - if err != nil { - return "", nil, err - } - if a.Root == "" { - return "", nil, fmt.Errorf("the seat git's trees of %s at %s name no root tree", repository(owner, repo), sha) - } - return a.Root, a.Trees, nil - } -} - -// FilesVia asks the seat `git` for one file at a ref (verb file). A file the seat says is absent is ErrNotFound; an -// answer that says neither absent nor content is an error, never an empty file. -func FilesVia(ctx context.Context, call Caller) Files { - return func(owner, repo, path, ref string) ([]byte, error) { - raw, err := call(ctx, GitKey(git.VerbFile), git.FileInput{Repository: repository(owner, repo), Path: path, Ref: ref}) - if err != nil { - return nil, fmt.Errorf("the seat git did not answer file: %w", err) - } - var a struct { - git.FileAnswer - Content *string `json:"content"` - } - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf("the seat git's answer of file is not its contract's: %w", err) - } - switch { - case a.Error != "": - return nil, fmt.Errorf("the seat git refused file %s at %s: %s", path, ref, a.Error) - case a.Absent: - return nil, fmt.Errorf("%w: %s at %s in %s", ErrNotFound, path, ref, repository(owner, repo)) - case a.Content == nil: - return nil, fmt.Errorf("the seat git's file %s at %s says neither its content nor that it is absent", path, ref) - } - return []byte(*a.Content), nil - } -} - -// errNoAnswer is a read whose answer carries nothing the contract says it must. -var errNoAnswer = errors.New("the seat git's answer carries nothing") - -// MergedMessage is the merged message of a merge into the branch base, asked again: built as the bridge builds the one -// it writes on FORGE for the branch's move (MoveMessage), from the pull request's owner, repository, number, branch, head, -// merge commit and base, which the seat git's verb pull answers. It reads the forge for every module directory (no kept -// inputs). -func MergedMessage(owner, repo string, number int, branch, head, merge, base string, trees Trees, files Files) (Message, error) { - if number <= 0 || branch == "" || base == "" || !sha40.MatchString(head) { - return Message{}, unreadable("bridge_merged_message", "%s#%d names no branch, base or 40-hex head", repository(owner, repo), number) - } - f := forgemsg.Forge{Kind: forgemsg.ForgeMerged, Repository: repository(owner, repo), Branch: branch, Number: number, Head: head, - Merge: merge, Base: base} - return landed(repository(owner, repo)+"#"+fmt.Sprint(number), f, merge, trees, files, nil) -} - // splitRepository is a `/` cut in two, refusing anything else. func splitRepository(repository string) (string, string, error) { owner, name, ok := strings.Cut(strings.TrimSpace(repository), "/") diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/files_test.go b/modules/mesh-delivery-forge-bridge/internal/bridge/files_test.go deleted file mode 100644 index 09b4418e..00000000 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/files_test.go +++ /dev/null @@ -1,412 +0,0 @@ -package bridge - -import ( - "crypto/sha256" - "encoding/hex" - "errors" - "fmt" - "os" - "reflect" - "slices" - "sort" - "strings" - "sync" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" -) - -// The bytes the forge answers in these tests are two real files of this repository, read from the working tree: the -// module.json and the go.sum of modules/mesh-delivery-forge-bridge (two directories up). The forge's own answer shape -// is mesh-catalog modules/gitea tools/index.ts gitea_get_file; the bridge sees only the bytes (issue 1448). -func real(t *testing.T, name string) []byte { - t.Helper() - b, err := os.ReadFile("../../" + name) - if err != nil { - t.Fatal(err) - } - return b -} - -func hexSum(b []byte) string { s := sha256.Sum256(b); return hex.EncodeToString(s[:]) } - -type fileCall struct{ owner, repo, path, ref string } - -// forgeFiles answers as the forge does for a path: its bytes, ErrNotFound for a path in none, the error in errs. -type forgeFiles struct { - have map[string][]byte - errs map[string]error - mu sync.Mutex - calls []fileCall -} - -func (f *forgeFiles) get(owner, repo, path, ref string) ([]byte, error) { - f.mu.Lock() - f.calls = append(f.calls, fileCall{owner, repo, path, ref}) - f.mu.Unlock() - if err, ok := f.errs[path]; ok { - return nil, err - } - if b, ok := f.have[path]; ok { - return b, nil - } - return nil, ErrNotFound -} - -// anyFiles is a forge that has a module.json at every path and no lock file, for tests that are not about the files. -func anyFiles(owner, repo, path, ref string) ([]byte, error) { - if strings.HasSuffix(path, "module.json") { - return []byte("{}"), nil - } - return nil, ErrNotFound -} - -func TestMergedCarriesManifestsAndLocks(t *testing.T) { // 1448/AC1 - manifest, sum := real(t, "module.json"), real(t, "go.sum") - forge := &forgeFiles{have: map[string][]byte{"modules/a/module.json": manifest, "modules/a/go.sum": sum, "modules/b/module.json": []byte(`{"module":"b"}`)}} - var calls []call - msg, err := convertMerged(mergedBody(nil), treesOf(&calls, "r0", map[string]string{"modules/a": "t1", "modules/b": "t2"}, nil), forge.get, nil) - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - if want := map[string]string{"modules/a": string(manifest), "modules/b": `{"module":"b"}`}; !reflect.DeepEqual(f.Manifests, want) { - t.Errorf("manifests = %v", f.Manifests) - } - if want := map[string]map[string]string{"modules/a": {"go.sum": hexSum(sum)}}; !reflect.DeepEqual(f.Locks, want) { - t.Errorf("locks = %v, want %v", f.Locks, want) - } - // ADR 0593 §2 (D6): the bridge reads no mesh package; only the indexer computes what a fingerprint takes. - if len(f.Packages) != 0 || strings.Contains(string(msg.Data), `"packages"`) { - t.Errorf("the merged message carries packages: %v", f.Packages) - } - // ADR 0567: assignments is the seat mesh-module-assigner's: a merge of the catalogue carries no assignments file and asks the - // forge for none. - forge.calls = nil - msg, err = convertMerged(mergedBody(map[string]any{"repo": "mesh-catalog"}), treesOf(&calls, "r0", map[string]string{"modules/a": "t1"}, nil), forge.get, nil) - if err != nil { - t.Fatal(err) - } - if f, err = forgemsg.DecodeForge(msg.Data); err != nil { - t.Fatal(err) - } - if len(f.RetiredAssignments) > 0 || f.RetiredRead || strings.Contains(string(msg.Data), `"assignments`) { - t.Errorf("a merge of the catalogue carries assignments: %s", msg.Data) - } - for _, c := range forge.calls { - if strings.HasPrefix(c.path, "assignments") { - t.Errorf("the forge was asked for %s", c.path) - } - } - // 1953/D1 (ADR 0565 §2): the catalogue's merged message carries its predefined.json at the merge, or says it holds - // none; another repository's asks the forge for none. - if !f.PredefinedRead || len(f.Predefined) != 0 { - t.Errorf("a merge of the catalogue with no predefined.json does not say so: %s", msg.Data) - } - forge.have[PredefinedFile] = []byte(`{"font-size":{"type":"integer","value":13}}`) - msg, _ = convertMerged(mergedBody(map[string]any{"repo": "mesh-catalog"}), treesOf(&calls, "r0", map[string]string{"modules/a": "t1"}, nil), forge.get, nil) - if f, err = forgemsg.DecodeForge(msg.Data); err != nil || string(f.Predefined) != string(forge.have[PredefinedFile]) || f.PredefinedRead { - t.Errorf("predefined = %s (%v)", f.Predefined, err) - } - forge.calls = nil - msg, _ = convertMerged(mergedBody(nil), treesOf(&calls, "r0", map[string]string{"modules/a": "t1"}, nil), forge.get, nil) - for _, c := range forge.calls { - if c.path == PredefinedFile { - t.Errorf("another repository's merge asked for %s", c.path) - } - } - forge.errs = map[string]error{PredefinedFile: errors.New("forge down")} - if _, err := convertMerged(mergedBody(map[string]any{"repo": "mesh-catalog"}), treesOf(&calls, "r0", map[string]string{"modules/a": "t1"}, nil), forge.get, nil); !errors.Is(err, ErrRetry) { - t.Errorf("a forge that cannot say is %v, want a retry", err) - } - // ADR 0632 §2: of a manifest naming a template, the template is read at the merge and the module's needs carried - // whole: docker's daemon file names the image seat's reach while its manifest stays the same. A manifest naming - // none carries no needs; a template the forge does not have is no need, and no retry. - forge.errs = nil - forge.have["modules/d/module.json"] = []byte(`{"module":"d","version":"1","resources":[{"id":"daemon","type":"file",` + - `"path":"/etc/d.json","template":"files/daemon.json"},{"id":"gone","type":"file","path":"/etc/g","template":"files/gone"}]}`) - forge.have["modules/d/files/daemon.json"] = []byte(`{"registry":"${seat:container-image-registry:reach}"}`) - msg, err = convertMerged(mergedBody(nil), treesOf(&calls, "r0", map[string]string{"modules/b": "t2", "modules/d": "t4"}, nil), forge.get, nil) - if err != nil { - t.Fatal(err) - } - if f, err = forgemsg.DecodeForge(msg.Data); err != nil || len(f.Needs) != 1 || !slices.Contains(f.Needs["modules/d"], "form:seat-reach") { - t.Errorf("needs = %v (%v), want modules/d's alone, with form:seat-reach from its template", f.Needs, err) - } - // Issue 1126: a merge reads the forge only for the module directories whose tree changed. - t.Run("a merge reads only the directories whose tree changed", mergeReadsOnlyChangedDirs) -} - -func TestPullWithKnownDirsCarriesTheSameAtTheHead(t *testing.T) { // 1448/AC2 - manifest := real(t, "module.json") - forge := &forgeFiles{have: map[string][]byte{"modules/a/module.json": manifest, "modules/a/go.sum": []byte("git.novox.be/novox/mesh-sdk/go v0.1.7 h1:x=\n")}} - msg, err := Convert(updatedSubject, updated(nil), forge.get, watchesMain) - if err != nil { - t.Fatal(err) - } - f, _ := forgemsg.DecodeForge(msg.Data) - if !reflect.DeepEqual(f.Manifests, map[string]string{"modules/a": string(manifest)}) || len(f.Locks) != 1 || len(f.Packages) != 0 { - t.Errorf("manifests %v locks %v packages %v", f.Manifests, f.Locks, f.Packages) - } - if len(forge.calls) == 0 || forge.calls[0].ref != head { - t.Errorf("calls %v, want the head %s", forge.calls, head) - } - // Dirs not known: neither field, and the forge is not asked. - forge = &forgeFiles{} - msg, err = Convert(updatedSubject, updated(map[string]any{"module_dirs": nil, "module_dirs_said": nil}), forge.get, watchesMain) - if err != nil { - t.Fatal(err) - } - f, _ = forgemsg.DecodeForge(msg.Data) - if f.Manifests != nil || f.Locks != nil || len(forge.calls) != 0 { - t.Errorf("manifests %v locks %v calls %v", f.Manifests, f.Locks, forge.calls) - } -} - -func TestAForgeErrorOrAMissingManifestIsRetryAndALockNotFoundIsLeftOut(t *testing.T) { // 1448/AC3 - boom := errors.New("Gitea API /repos/novox/mesh-delivery/contents/modules/a/go.sum?ref=x: 502 bad gateway") - trees := func() Trees { var c []call; return treesOf(&c, "r0", map[string]string{"modules/a": "t1"}, nil) } - for name, forge := range map[string]*forgeFiles{ - "a manifest error": {errs: map[string]error{"modules/a/module.json": boom}}, - "a manifest not found": {}, - "a lock file error": {have: map[string][]byte{"modules/a/module.json": []byte("{}")}, errs: map[string]error{"modules/a/go.sum": boom}}, - "a second lock error": {have: map[string][]byte{"modules/a/module.json": []byte("{}")}, errs: map[string]error{"modules/a/package-lock.json": boom}}, - } { - msg, err := convertMerged(mergedBody(nil), trees(), forge.get, nil) - if !errors.Is(err, ErrRetry) || msg.Data != nil { - t.Errorf("%s: err = %v data = %s, want ErrRetry and no message", name, err, msg.Data) - } - _, err = Convert(updatedSubject, updated(nil), forge.get, watchesMain) - if !errors.Is(err, ErrRetry) { - t.Errorf("%s (pull): err = %v, want ErrRetry", name, err) - } - } - forge := &forgeFiles{have: map[string][]byte{"modules/a/module.json": []byte("{}")}} - msg, err := convertMerged(mergedBody(nil), trees(), forge.get, nil) - if err != nil { - t.Fatal(err) - } - if f, _ := forgemsg.DecodeForge(msg.Data); f.Locks != nil { - t.Errorf("locks = %v, want none for lock files the forge does not have", f.Locks) - } -} - -func TestTheFilesAreAskedAtTheMergeCommitByOwnerRepoPathAndRef(t *testing.T) { // 1448/AC4 (the call's arguments; the manifest is in manifest_test) - forge := &forgeFiles{have: map[string][]byte{"modules/a/module.json": []byte("{}")}} - var calls []call - if _, err := convertMerged(mergedBody(nil), treesOf(&calls, "r0", map[string]string{"modules/a": "t1"}, nil), forge.get, nil); err != nil { - t.Fatal(err) - } - want := []fileCall{{"novox", "mesh-delivery", "modules/a/module.json", merge}, {"novox", "mesh-delivery", "modules/a/go.sum", merge}, - {"novox", "mesh-delivery", "modules/a/package-lock.json", merge}} - sort.Slice(forge.calls, func(i, j int) bool { return forge.calls[i].path < forge.calls[j].path }) // they are asked for concurrently - sort.Slice(want, func(i, j int) bool { return want[i].path < want[j].path }) - if !reflect.DeepEqual(forge.calls, want) { - t.Errorf("calls = %v, want %v", forge.calls, want) - } -} - -// slowForge answers like a forge that takes d a call: a module.json of the directory's name everywhere, a go.sum in -// the directories whose number is even and in the root, and counts the calls in flight. -type slowForge struct { - d time.Duration - mu sync.Mutex - inFlight, most, started, n int - failOn string - finished int -} - -func (f *slowForge) get(_, _, path, _ string) ([]byte, error) { - f.mu.Lock() - f.inFlight++ - f.started++ - if f.inFlight > f.most { - f.most = f.inFlight - } - f.mu.Unlock() - time.Sleep(f.d) - defer func() { f.mu.Lock(); f.inFlight--; f.finished++; f.mu.Unlock() }() - switch { - case path == f.failOn: - return nil, errors.New("Gitea API " + path + ": 502 bad gateway") - case strings.HasSuffix(path, "module.json"): - return []byte(`{"module":"` + path + `"}`), nil - case strings.HasSuffix(path, "go.sum") && (path == "go.sum" || path[len(path)-8]%2 == 0): - return []byte("sum of " + path), nil - } - return nil, ErrNotFound -} - -func manyDirs(n int) []string { - dirs := []string{""} - for i := 1; i < n; i++ { - dirs = append(dirs, fmt.Sprintf("modules/m%02d", i)) - } - return dirs -} - -func TestFortyDirectoriesAreReadEightAtATimeWithTheResultOfOneAtATime(t *testing.T) { // 1458/AC1 - dirs := manyDirs(40) - slow := &slowForge{d: 10 * time.Millisecond} - manifests, locks, err := inputsOf("novox", "mesh-catalog", merge, dirs, slow.get) - if err != nil { - t.Fatal(err) - } - if slow.most > MaxReadsInFlight || slow.most < 2 { - t.Errorf("at most %d calls were in flight, want more than one and at most %d", slow.most, MaxReadsInFlight) - } - if slow.started != 40*3 { - t.Errorf("%d calls, want 120", slow.started) - } - // The same read one file at a time. - wantM, wantL := map[string]string{}, map[string]map[string]string{} - one := &slowForge{} - for _, dir := range dirs { - m, l, err := inputsOfOne(dir, one.get) - if err != nil { - t.Fatal(err) - } - wantM[dir] = m - if l != nil { - wantL[dir] = l - } - } - if !reflect.DeepEqual(manifests, wantM) || !reflect.DeepEqual(locks, wantL) { - t.Errorf("the concurrent read differs from a one-at-a-time read: %d manifests %d locks, want %d and %d", len(manifests), len(locks), len(wantM), len(wantL)) - } - if len(locks) == 0 || len(locks) == 40 { - t.Errorf("%d directories with locks, the fixture should have some and not all", len(locks)) - } -} - -// inputsOfOne reads one directory with a single call at a time, as the bridge did before issue 1458. -func inputsOfOne(dir string, files Files) (string, map[string]string, error) { - at := func(name string) string { - if dir == "" { - return name - } - return dir + "/" + name - } - raw, err := files("o", "r", at("module.json"), "x") - if err != nil { - return "", nil, err - } - var locks map[string]string - for _, name := range LockFiles { - b, err := files("o", "r", at(name), "x") - if errors.Is(err, ErrNotFound) { - continue - } - if err != nil { - return "", nil, err - } - if locks == nil { - locks = map[string]string{} - } - s := sha256.Sum256(b) - locks[name] = hex.EncodeToString(s[:]) - } - return string(raw), locks, nil -} - -func TestOneFailingFileIsRetryAndEveryCallHasReturnedBeforeTheReadDoes(t *testing.T) { // 1458/AC2 - dirs := manyDirs(40) - slow := &slowForge{d: 10 * time.Millisecond, failOn: "modules/m05/go.sum"} - _, _, err := inputsOf("novox", "mesh-catalog", merge, dirs, slow.get) - if err == nil || !strings.Contains(err.Error(), "modules/m05/go.sum") || !strings.Contains(err.Error(), "502") { - t.Fatalf("err = %v, want the failing file named", err) - } - slow.mu.Lock() - defer slow.mu.Unlock() - if slow.inFlight != 0 || slow.finished != slow.started { - t.Errorf("%d calls in flight, %d of %d finished, when the read returned", slow.inFlight, slow.finished, slow.started) - } - if slow.started >= 40*3 { - t.Errorf("%d calls were made, want the read to stop asking after the failure", slow.started) - } - // Through Convert it is ErrRetry. - var calls []call - dirsMap := map[string]string{} - for _, d := range dirs[1:] { - dirsMap[d] = "t" - } - slow2 := &slowForge{failOn: "modules/m05/module.json"} - if _, err := convertMerged(mergedBody(nil), treesOf(&calls, "r0", dirsMap, nil), slow2.get, nil); !errors.Is(err, ErrRetry) { - t.Errorf("err = %v, want ErrRetry", err) - } -} - -// memKept is a Kept in memory. -type memKept map[string]Inputs - -func (k memKept) Get(tree string) (Inputs, bool) { in, ok := k[tree]; return in, ok } -func (k memKept) Put(tree string, in Inputs) { k[tree] = in } - -// Issue 1126 (mesh-catalog#535; issue 1458 met the kind first): a merge reads the forge only for the module directories -// whose tree changed. Its message is the same as one read whole; a directory whose tree is kept costs no read. -func mergeReadsOnlyChangedDirs(t *testing.T) { - manifest, sum := real(t, "module.json"), real(t, "go.sum") - forge := &forgeFiles{have: map[string][]byte{"modules/a/module.json": manifest, "modules/a/go.sum": sum, "modules/b/module.json": []byte(`{"module":"b"}`)}} - kept := memKept{} - var calls []call - first, err := convertMerged(mergedBody(nil), treesOf(&calls, "r0", map[string]string{"modules/a": "t1", "modules/b": "t2"}, nil), forge.get, kept) - if err != nil { - t.Fatal(err) - } - if len(forge.calls) != 6 { - t.Fatalf("the first merge read %d files, want 6 (a manifest and two lock files for each directory)", len(forge.calls)) - } - // The next merge changes modules/b alone: only its three files are read, and the message equals one read whole. - forge.calls = nil - forge.have["modules/b/module.json"] = []byte(`{"module":"b","v":2}`) - trees := map[string]string{"modules/a": "t1", "modules/b": "t3"} - next, err := convertMerged(mergedBody(nil), treesOf(&calls, "r1", trees, nil), forge.get, kept) - if err != nil { - t.Fatal(err) - } - for _, c := range forge.calls { - if !strings.HasPrefix(c.path, "modules/b/") { - t.Errorf("%s was read although its directory's tree is kept", c.path) - } - } - if len(forge.calls) != 3 { - t.Errorf("the second merge read %d files, want 3", len(forge.calls)) - } - whole, err := convertMerged(mergedBody(nil), treesOf(&calls, "r1", trees, nil), forge.get, nil) - if err != nil { - t.Fatal(err) - } - if string(next.Data) != string(whole.Data) { - t.Errorf("the message from kept inputs differs from one read whole:\n%s\n%s", next.Data, whole.Data) - } - if string(first.Data) == string(next.Data) { - t.Error("the second merge's message did not change") - } - // A failed read keeps the directories it read whole and nothing of the one that failed, so the next try reads only the - // rest: a merge too large for one try's bound converges over its tries. - kept2 := memKept{} - failing := &forgeFiles{have: forge.have, errs: map[string]error{"modules/b/module.json": errors.New("context deadline exceeded")}} - if _, err := convertMerged(mergedBody(nil), treesOf(&calls, "r1", trees, nil), failing.get, kept2); !errors.Is(err, ErrRetry) { - t.Fatalf("err = %v, want ErrRetry", err) - } - if _, ok := kept2["t1"]; !ok || len(kept2) != 1 { // modules/a's files are asked first, before the failure is seen - t.Errorf("a failed read kept %v, want modules/a's tree t1 alone", kept2) - } - failing.calls = nil - failing.errs = nil - again, err := convertMerged(mergedBody(nil), treesOf(&calls, "r1", trees, nil), failing.get, kept2) - if err != nil { - t.Fatal(err) - } - if string(again.Data) != string(whole.Data) { - t.Errorf("the message of the try after a failure differs from one read whole") - } - if len(failing.calls) != 3 { - t.Errorf("the try after a failure read %d files, want only modules/b's 3", len(failing.calls)) - } - // ADR 0593 §2: inputs an older bridge kept with the packages it read are taken as they are; their packages are left. -} diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/forgemade.go b/modules/mesh-delivery-forge-bridge/internal/bridge/forgemade.go deleted file mode 100644 index 6cc982b7..00000000 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/forgemade.go +++ /dev/null @@ -1,46 +0,0 @@ -package bridge - -import ( - "context" - "fmt" - - git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" -) - -// ForgePull is a pull request as the forge itself says it: what the bridge needs of a merge made on the forge, not -// through the gate (a recovery merge or the operator's own, which the gate holds no merge of; issue 1966). -type ForgePull struct { - Number int - Branch string // the pull request's head branch - Head string // the head commit - Merge string // the merge commit - Base string // the branch it was merged into -} - -// ForgeMade reads, through the seat `git`'s verb pull, the merged pull request whose merge commit is merge: by number -// when number is given (its merge commit must then equal merge), else by the merge commit. A pull request not merged, or -// merged at another commit, is refused. -func ForgeMade(ctx context.Context, call Caller, owner, repo string, number int, merge string) (ForgePull, error) { - in := git.PullInput{Repository: repository(owner, repo), MergeCommit: merge} - if number > 0 { - in = git.PullInput{Repository: repository(owner, repo), Number: int64(number)} - } - a, err := askGit[git.PullAnswer](ctx, call, git.VerbPull, in) - if err != nil { - return ForgePull{}, err - } - p := a.Pull - switch { - case p == nil || p.Number == 0: - return ForgePull{}, fmt.Errorf("the pull request of %s at %s: %w", in.Repository, merge, errNoAnswer) - case p.State != git.PullStateMerged: - return ForgePull{}, fmt.Errorf("the forge says the pull request %s#%d is %s, not merged", in.Repository, p.Number, p.State) - case p.MergeCommit != merge: - return ForgePull{}, fmt.Errorf("the forge says %s#%d was merged at %s, not at %s", in.Repository, p.Number, p.MergeCommit, merge) - case p.Base == "": - return ForgePull{}, fmt.Errorf("the forge gives no base branch for %s#%d", in.Repository, p.Number) - case p.Branch == "": - return ForgePull{}, fmt.Errorf("the forge gives no head branch for %s#%d", in.Repository, p.Number) - } - return ForgePull{Number: int(p.Number), Branch: p.Branch, Head: p.Head, Merge: p.MergeCommit, Base: p.Base}, nil -} diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/kept.go b/modules/mesh-delivery-forge-bridge/internal/bridge/kept.go deleted file mode 100644 index 2a384c8b..00000000 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/kept.go +++ /dev/null @@ -1,64 +0,0 @@ -package bridge - -// A merge of a repository of many modules read three files of the forge for every module, whatever the merge changed: -// the catalogue's 140 modules are 420 reads, which no longer fit the 30 s bound of a handled event while the forge is -// busy after a merge, so the merged message of mesh-catalog#535 was never written and the indexer never saw it (issue -// 1126; issue 1458 met the same kind at 131 modules and raised the reads in flight). A directory's git tree hash names -// every byte under it, so the manifest and the lock-file hashes read once at a tree hash are those of every later commit -// whose directory has the same tree: a merge reads the forge only for the directories it changed. - -// Inputs is what the bridge read of one module directory at one tree hash: its manifest and its lock files' hex sha256 -// by name (none when it has none). The bridge reads no mesh package (novox/hq ADR 0593 §2: only the indexer computes -// what a fingerprint takes); a value kept with the packages an older bridge read is taken, and those are left. -type Inputs struct { - Manifest string `json:"manifest"` - Locks map[string]string `json:"locks,omitempty"` - // Needs are the module's needs whole when its manifest names templates (inputsRead): a value of such a manifest kept - // without them, by a bridge before ADR 0632 §2, is read again. - Needs []string `json:"needs,omitempty"` -} - -// Kept holds Inputs by a directory's git tree hash (the bridge's state bucket inputs). Get answers false for a tree it -// does not hold or cannot read; Put is best effort: a value it could not keep is read from the forge next time. -type Kept interface { - Get(tree string) (Inputs, bool) - Put(tree string, in Inputs) -} - -// keptInputs splits dirs into the inputs kept for their tree hash and the directories still to read from the forge. -func keptInputs(dirs []string, trees map[string]string, kept Kept) (manifests map[string]string, locks map[string]map[string]string, needs map[string][]string, read []string) { - manifests, locks, needs = map[string]string{}, map[string]map[string]string{}, map[string][]string{} - for _, dir := range dirs { - tree := trees[dir] - if kept == nil || tree == "" { - read = append(read, dir) - continue - } - in, ok := kept.Get(tree) - if !ok || (in.Needs == nil && len(templatePaths(in.Manifest)) > 0) { - read = append(read, dir) - continue - } - manifests[dir] = in.Manifest - if len(in.Locks) > 0 { - locks[dir] = in.Locks - } - if in.Needs != nil { - needs[dir] = in.Needs - } - } - return manifests, locks, needs, read -} - -// keep puts what was read of each directory under its tree hash. -func keep(dirs []string, trees map[string]string, manifests map[string]string, locks map[string]map[string]string, needs map[string][]string, kept Kept) { - if kept == nil { - return - } - for _, dir := range dirs { - raw, ok := manifests[dir] - if tree := trees[dir]; ok && tree != "" { - kept.Put(tree, Inputs{Manifest: raw, Locks: locks[dir], Needs: needs[dir]}) - } - } -} diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/moved.go b/modules/mesh-delivery-forge-bridge/internal/bridge/moved.go index a559662c..9b25e9b4 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/moved.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/moved.go @@ -44,52 +44,37 @@ func (m Moved) HeadKey() string { return "branch." + m.Owner + "." + m.Repo + "." + keys.EscapeName(m.Branch) } -// Branch is a branch as the seat git's verb branch reads it: its head and whether it is protected. -type Branch struct { - Head string - Protected bool -} - -// ReadBranch reads a branch's head and protection through the seat git's verb branch (§11, §17); an answer that says -// an error, or names no 40-hex head, is an error, never a branch with none. -func ReadBranch(ctx context.Context, call Caller, m Moved) (Branch, error) { +// ReadHead reads a branch's head through the seat git's verb branch (design 47 H §739): never the event's body, and no +// protection (ADR 0682 §13). An answer that says an error, or names no 40-hex head, is an error, never a branch with none. +func ReadHead(ctx context.Context, call Caller, m Moved) (string, error) { a, err := askGit[git.BranchAnswer](ctx, call, git.VerbBranch, git.BranchInput{Repository: m.Repository(), Branch: m.Branch}) if err != nil { - return Branch{}, err + return "", err } if !sha40.MatchString(a.Head) { - return Branch{}, fmt.Errorf("the seat git's branch %s of %s names no 40-hex head (%q)", m.Branch, m.Repository(), a.Head) + return "", fmt.Errorf("the seat git's branch %s of %s names no 40-hex head (%q)", m.Branch, m.Repository(), a.Head) } - return Branch{Head: a.Head, Protected: a.Protected}, nil + return a.Head, nil } -// MoveMessage is the one message of a move of a watched branch to head (design 47 G §509, §714, A-236): merged, with -// the pull request and the watched branch as base, when the seat's verb pull names head a pull request's merge; pushed, -// with the branch, head and before (the head last written for the branch, empty for none), when it names none. Both -// carry the take-in inputs at head. A pull the forge could not say is ErrRetry, never read as none. -func MoveMessage(ctx context.Context, call Caller, m Moved, head, before string, trees Trees, files Files, kept Kept) (Message, error) { - what := fmt.Sprintf("%s of %s at %s", m.Branch, m.Repository(), head) - raw, err := call(ctx, GitKey(git.VerbPull), git.PullInput{Repository: m.Repository(), MergeCommit: head}) +// HeadMoved is the one message of a move of a watched branch's head (design 47 H §739): its subject on the stream forge +// and its body, before the head the bridge held for the branch (empty the first time), start true when said at the +// bridge's start. A head equal to before writes nothing, which the caller decides before it asks. +func HeadMoved(m Moved, head, before string, start bool) (Message, error) { + event, err := forgemsg.HeadMovedEvent(m.Repository(), m.Branch) if err != nil { - return Message{}, fmt.Errorf("%w: %s: the seat git did not answer pull: %v", ErrRetry, what, err) + return Message{}, err } - var a git.PullAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return Message{}, fmt.Errorf("%w: %s: the seat git's answer of pull is not its contract's: %v", ErrRetry, what, err) + data, err := forgemsg.EncodeHeadMoved(forgemsg.HeadMoved{Repository: m.Repository(), Branch: m.Branch, Head: head, Before: before, Start: start}) + if err != nil { + return Message{}, err } - f := forgemsg.Forge{Repository: m.Repository()} - switch { - case a.Error != "" && a.ErrorKind == git.ErrorKindNotFound: - f.Kind, f.Branch, f.Head, f.Before = forgemsg.ForgePushed, m.Branch, head, before - case a.Error != "": - return Message{}, fmt.Errorf("%w: %s: the seat git refused pull: %s", ErrRetry, what, a.Error) - case a.Pull == nil || a.Pull.Number <= 0 || a.Pull.MergeCommit != head || a.Pull.State != git.PullStateMerged: - return Message{}, fmt.Errorf("%w: %s: the seat git's pull at that merge commit names no merged pull request merged there", ErrRetry, what) - default: - if !sha40.MatchString(a.Pull.Head) || a.Pull.Branch == "" { - return Message{}, unreadable(BranchMovedSubject, "%s: the pull request %s#%d names no branch or 40-hex head", what, m.Repository(), a.Pull.Number) - } - f.Kind, f.Branch, f.Number, f.Head, f.Merge, f.Base = forgemsg.ForgeMerged, a.Pull.Branch, int(a.Pull.Number), a.Pull.Head, head, m.Branch + said := fmt.Sprintf("%s of %s moved to %s", m.Branch, m.Repository(), head) + if before != "" { + said += " from " + before } - return landed(what, f, head, trees, files, kept) + if start { + said += ", read at the start" + } + return Message{Event: event, Data: data, Said: said}, nil } diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/moved_test.go b/modules/mesh-delivery-forge-bridge/internal/bridge/moved_test.go index 17ed5a68..809ec10f 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/moved_test.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/moved_test.go @@ -3,20 +3,17 @@ package bridge import ( "context" "encoding/json" - "errors" "testing" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - - "mesh-delivery-forge-bridge/internal/gitfixture" + "git.novox.be/novox/mesh-sdk/go/keys" ) -// Design 47 G §4, §11, §507, §509, §714, A-236 (FB1, FB9, FB10): the watched branches are the registrations' by origin, and -// before the first registration the gate's source's, no branch fixed in code; a move of a watched branch is one message: -// merged with its pull request and base when the seat's pull names the new head a pull request's merge, pushed with -// its branch, head and before when it names none, both carrying the commit's take-in inputs; a pull the forge could not -// say is heard again, never read as a push. -func TestAMoveOfAWatchedBranchIsOneMessage(t *testing.T) { +// Design 47 G §4, §507, A-236; H §739: the watched branches are the registrations' by origin, and before the first +// registration the gate's source's, no branch fixed in code; a move of a watched branch is one head-moved naming the +// repository, the branch, the head read through the seat git's verb branch, the head held before and start; the read asks +// nothing but branch, and an unprotected branch's head is read like any other. +func TestAMoveOfAWatchedBranchIsOneHeadMoved(t *testing.T) { w := &Watched{} w.Set([]Registered{{Origin: "novox/mesh-sdk", Branches: []string{"main", "beta"}}}, []string{"main"}) for _, c := range []struct { @@ -31,47 +28,50 @@ func TestAMoveOfAWatchedBranchIsOneMessage(t *testing.T) { t.Errorf("before the first registration the gate's source's branches are watched, of every repository") } - const landedAt, before = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccccccccccccc" - moved := Moved{Owner: "novox", Repo: "mesh-sdk", Branch: "beta"} + const head, before = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccccccccccccc" + moved := Moved{Owner: "novox", Repo: "mesh-sdk", Branch: "feat/47-H"} for _, c := range []struct { name string - pull json.RawMessage - want forgemsg.Forge - retry bool - calls1 int + answer string + head string + fails bool }{ - {"a merge", gitfixture.Given(t, "pull answers", "verb:pull.answer"), forgemsg.Forge{Kind: forgemsg.ForgeMerged, - Branch: "feat/47-G", Number: 178, Head: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Merge: landedAt, Base: "beta"}, false, 1}, - {"an admitted push", json.RawMessage(`{"error":"no pull request merged at that commit","error-kind":"not-found"}`), - forgemsg.Forge{Kind: forgemsg.ForgePushed, Branch: "beta", Head: landedAt, Before: before}, false, 1}, - {"a pull the forge could not say", gitfixture.Given(t, "pull answers an error, never none", "verb:pull.answer"), - forgemsg.Forge{}, true, 0}, + {"a protected branch", `{"head":"` + head + `","protected":true}`, head, false}, + {"an unprotected branch, read like any other (ADR 0682 §13)", `{"head":"` + head + `","protected":false}`, head, false}, + {"an answer naming no head", `{"head":"abc"}`, "", true}, + {"a refusal", `{"error":"no such branch","error-kind":"not-found"}`, "", true}, } { var asked []string ask := func(_ context.Context, key string, body any) (json.RawMessage, error) { b, _ := json.Marshal(body) asked = append(asked, key+" "+string(b)) - return c.pull, nil + return json.RawMessage(c.answer), nil } - var trees []call - msg, err := MoveMessage(context.Background(), ask, moved, landedAt, before, treesOf(&trees, "r0", map[string]string{"modules/a": "t1"}, nil), anyFiles, nil) - if c.retry { - if !errors.Is(err, ErrRetry) || msg.Data != nil { - t.Errorf("%s: %v, %s; want ErrRetry and nothing written", c.name, err, msg.Data) - } - continue + got, err := ReadHead(context.Background(), ask, moved) + if (err != nil) != c.fails || got != c.head { + t.Errorf("%s: %q %v, want %q, failing %v", c.name, got, err, c.head, c.fails) } + if len(asked) != 1 || asked[0] != `seat:git.branch {"branch":"feat/47-H","repository":"novox/mesh-sdk"}` { + t.Errorf("%s: asked %v, want only the seat git's branch", c.name, asked) + } + } + + for _, c := range []struct { + name string + before string + start bool + }{{"the first move", "", false}, {"a later move", before, false}, {"read at the start", before, true}} { + msg, err := HeadMoved(moved, head, c.before, c.start) if err != nil { t.Fatalf("%s: %v", c.name, err) } - f, err := forgemsg.DecodeForge(msg.Data) - c.want.V, c.want.Repository, c.want.Root = forgemsg.Version, "novox/mesh-sdk", "r0" - c.want.Trees, c.want.Manifests = map[string]string{"modules/a": "t1"}, map[string]string{"modules/a": "{}"} - if err != nil || !forgemsg.SameForge(f, c.want) || msg.Event != "forge.novox.mesh-sdk."+c.want.Kind { - t.Errorf("%s: %s %+v (%v), want %+v", c.name, msg.Event, f, err, c.want) - } - if len(trees) != c.calls1 || trees[0].sha != landedAt || asked[0] != `seat:git.pull {"merge-commit":"`+landedAt+`","repository":"novox/mesh-sdk"}` { - t.Errorf("%s: trees asked %v, pull asked %v; want the landed commit's", c.name, trees, asked) + h, err := forgemsg.DecodeHeadMoved(msg.Data) + want := forgemsg.HeadMoved{V: forgemsg.Version, Repository: "novox/mesh-sdk", Branch: "feat/47-H", Head: head, Before: c.before, Start: c.start} + if err != nil || h != want || msg.Event != "forge.novox.mesh-sdk."+keys.EscapeName("feat/47-H")+".head-moved" { + t.Errorf("%s: %s %+v (%v), want %+v", c.name, msg.Event, h, err, want) } } + if _, err := HeadMoved(moved, head, head, false); err == nil { + t.Errorf("a head equal to the one held makes a message; want none") + } } diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/owed.go b/modules/mesh-delivery-forge-bridge/internal/bridge/owed.go index 425865ae..4fc6d2ed 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/owed.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/owed.go @@ -7,14 +7,12 @@ import ( git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" ) // OwedCall is one act owed to the forge as the seat git's verb that performs it: the seat that said it (Of), the act's // id, and the verb with its input (novox/hq design 47 *What the gate owes the forge*). Every verb is safe to repeat at -// the forge: a status and the view replace what stands, a merge of a pull request merged at that head is answered -// performed, and a comment and a note line carry the id, which the seat's holder skips when it already holds it. +// the forge: a status and the view replace what stands, and a comment and a note line carry the id, which the seat's holder skips when it already holds it. type OwedCall struct { Of string ID string @@ -53,13 +51,6 @@ func GateOwed(data []byte) (OwedCall, error) { return nil } switch o.Act { - case seat.OwedActMerge: - // Only a switched act is a merge (§169): from G's delivery the gate owes none (§167), a session calls merge-pull - // itself; a merge of the old state, not yet performed by the old bridge, is not dropped. - if err := needsPull(); err != nil { - return c, err - } - c.Verb, c.Input = git.VerbMergePull, git.MergePullInput{ID: o.ID, Repository: o.Repository, Number: o.Number, Head: o.Head} case seat.OwedActStatus: if o.Context == "" || o.State == "" { return c, undecodable("the owed status %s names no context or state", o.ID) @@ -87,24 +78,6 @@ func GateOwed(data []byte) (OwedCall, error) { return c, nil } -// CheckerOwed reads the seat mesh-delivery-checker's event owed (its mesh/check status) into the seat git's verb status. -func CheckerOwed(data []byte) (OwedCall, error) { - var o checker.OwedEvent - if err := json.Unmarshal(data, &o); err != nil { - return OwedCall{}, undecodable("the checker's owed is not json: %v", err) - } - c := OwedCall{Of: checker.Seat, ID: o.ID, Act: o.Act, Repository: o.Repository, Number: int(o.Number)} - if err := c.common(o.Head); err != nil { - return c, err - } - if o.Act != checker.OwedActStatus || o.Context == "" || o.State == "" { - return c, undecodable("the checker's owed %s is %q of the context %q in the state %q, not a status", o.ID, o.Act, o.Context, o.State) - } - c.Verb, c.Input = git.VerbStatus, git.StatusInput{ID: o.ID, Repository: o.Repository, Commit: o.Head, Context: o.Context, - State: o.State, Description: o.Description, Target: o.Target} - return c, nil -} - func (c OwedCall) common(head string) error { switch { case c.ID == "": @@ -121,20 +94,18 @@ func (c OwedCall) common(head string) error { } // Outcome is what an act's call of the seat git came to, as owed.ended says it: performed when the forge holds the act -// (done now, or its id already held); refused with the forge's own words when the seat answers a refusal or an error -// of the kind refused; could not be performed with the error when the seat did not answer, answered an error of the +// (done now, or its id already held); refused with the forge's own words when the seat answers an error of the kind +// refused; could not be performed with the error when the seat did not answer, answered an error of the // kind failed, or answered what the contract cannot read. func Outcome(raw json.RawMessage, callErr error) (outcome, words string) { if callErr != nil { return forgemsg.OwedCouldNotBePerformed, callErr.Error() } - var a git.MergePullAnswer // every act verb's answer is this one's fields or fewer + var a git.StatusAnswer // every act verb's answer (status, comment, view, note) has these fields if err := json.Unmarshal(raw, &a); err != nil { return forgemsg.OwedCouldNotBePerformed, "the seat git's answer is not its contract's: " + err.Error() } switch { - case a.Refused != "": - return forgemsg.OwedRefused, a.Refused case a.Error != "" && a.ErrorKind == git.ErrorKindRefused: return forgemsg.OwedRefused, a.Error case a.Error != "": @@ -143,5 +114,5 @@ func Outcome(raw json.RawMessage, callErr error) (outcome, words string) { case a.Performed || a.Held: return forgemsg.OwedPerformed, "" } - return forgemsg.OwedCouldNotBePerformed, "the seat git's answer says neither performed, held, refused nor an error: " + string(raw) + return forgemsg.OwedCouldNotBePerformed, "the seat git's answer says neither performed, held nor an error: " + string(raw) } diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go b/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go index 394ab724..50fd163d 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go @@ -17,7 +17,6 @@ import ( // act, under the act's id; what cannot be read is undecodable, and every answer is one outcome. func TestAnOwedEventIsTheSeatGitsVerbAndItsAnswerOneOutcome(t *testing.T) { gate := func(name string) []byte { return gitfixture.Seat(t, "mesh-delivery", "events", name, "event:owed")[0] } - chk := gitfixture.Seat(t, "mesh-delivery-checker", "events", "owed is said", "event:owed")[0] a40 := strings.Repeat("a", 40) edit := func(raw []byte, k string, v any) []byte { var m map[string]any @@ -38,7 +37,7 @@ func TestAnOwedEventIsTheSeatGitsVerbAndItsAnswerOneOutcome(t *testing.T) { input any bad string }{ - {"a merge on no pull request", GateOwed, edit(gate("owed is said, a merge"), "number", 0), "", nil, "no pull request"}, + {"a merge, which the bridge no longer performs (design 47 H §764)", GateOwed, gate("owed is said, a merge"), "", nil, "none the seat git"}, {"a status on the head", GateOwed, gate("owed is said, a status"), "status", git.StatusInput{ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate", Repository: "novox/mesh-sdk", Commit: a40, Context: "mesh/merge-gate", State: "pending", Description: "waits for the operator's Approve", Target: "https://forge.test/x"}, ""}, {"a view", GateOwed, edit(edit(gate("owed is said, a status"), "act", "view"), "text", "the view"), "view", @@ -47,13 +46,9 @@ func TestAnOwedEventIsTheSeatGitsVerbAndItsAnswerOneOutcome(t *testing.T) { git.CommentInput{ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate", Repository: "novox/mesh-sdk", Number: 178, Text: "hello"}, ""}, {"a note line on its commit", GateOwed, edit(edit(edit(gate("owed is said, a status"), "act", "note"), "line", "a line"), "commit", strings.Repeat("c", 40)), "note", git.NoteInput{ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate", Repository: "novox/mesh-sdk", Commit: strings.Repeat("c", 40), Line: "a line"}, ""}, - {"the checker's status", CheckerOwed, chk, "status", git.StatusInput{ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/check", - Repository: "novox/mesh-sdk", Commit: a40, Context: "mesh/check", State: "success", Description: "passed", Target: "https://forge.test/x"}, ""}, {"not json", GateOwed, []byte("{"), "", nil, "not json"}, {"no id", GateOwed, edit(gate("owed is said, a merge"), "id", nil), "", nil, "no id"}, - {"a short head", CheckerOwed, edit(chk, "head", "abc"), "", nil, "40 hex"}, - {"a merge of the switch", GateOwed, gate("owed is said, a merge"), "merge-pull", git.MergePullInput{ID: "merge.feat=47-G.0123456789ab.novox/mesh-sdk#178", - Repository: "novox/mesh-sdk", Number: 178, Head: a40}, ""}, + {"a short head", GateOwed, edit(gate("owed is said, a status"), "head", "abc"), "", nil, "40 hex"}, {"a comment on no pull request", GateOwed, edit(edit(gate("owed is said, a status"), "act", "comment"), "number", 0), "", nil, "no pull request"}, {"an act of no kind", GateOwed, edit(gate("owed is said, a status"), "act", "label"), "", nil, "none the seat git"}, {"a repository not owner/name", GateOwed, edit(gate("owed is said, a status"), "repository", "mesh-sdk"), "", nil, "owner"}, @@ -78,8 +73,7 @@ func TestAnOwedEventIsTheSeatGitsVerbAndItsAnswerOneOutcome(t *testing.T) { err error outcome, words string }{ - {"a merge performed", answers("merge-pull")[0], nil, forgemsg.OwedPerformed, ""}, - {"a merge refused", answers("merge-pull")[1], nil, forgemsg.OwedRefused, "the head moved"}, + {"a status performed", answers("status")[0], nil, forgemsg.OwedPerformed, ""}, {"a comment already held", answers("comment")[0], nil, forgemsg.OwedPerformed, ""}, {"the forge's error, of the kind refused", failed("comment"), nil, forgemsg.OwedRefused, "403"}, {"the forge's error, of the kind failed", failed("view"), nil, forgemsg.OwedCouldNotBePerformed, "502"}, diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/paths_test.go b/modules/mesh-delivery-forge-bridge/internal/bridge/paths_test.go deleted file mode 100644 index 734224fd..00000000 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/paths_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package bridge - -import ( - "os" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" -) - -// ADR 0495 clause 1 with the lead's decision L8 of R4e: the forge bridge is no reader of a manifest's `paths`. A merge of a -// module whose artifacts name their paths (mesh-sdk's module.json at 9cb4d59) gives a message that carries the manifest as -// the forge answered it and no named path's object: the indexer asks the forge for those itself. -func TestAMergedMessageCarriesNoNamedPathsTheBridgeDerived(t *testing.T) { - raw, err := os.ReadFile("testdata/mesh-sdk-9cb4d59.module.json") - if err != nil { - t.Fatal(err) - } - files := func(owner, repo, path, ref string) ([]byte, error) { - if path == "module.json" { - return raw, nil - } - return nil, ErrNotFound - } - var calls []call - msg, err := convertMerged(mergedBody(map[string]any{"repo": "mesh-sdk", "module_dirs": []string{""}}), treesOf(&calls, "r0", map[string]string{"": "r0"}, nil), files, nil) - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(msg.Data) - if err != nil { - t.Fatal(err) - } - if len(f.Paths) != 0 || f.Manifests[""] != string(raw) || len(calls) != 1 { - t.Errorf("message paths %v, manifest carried %v, trees asked %d times; want no paths, the manifest, one ask", f.Paths, f.Manifests[""] == string(raw), len(calls)) - } -} diff --git a/modules/mesh-delivery-forge-bridge/internal/groups/groups.go b/modules/mesh-delivery-forge-bridge/internal/groups/groups.go deleted file mode 100644 index f3f76197..00000000 --- a/modules/mesh-delivery-forge-bridge/internal/groups/groups.go +++ /dev/null @@ -1,301 +0,0 @@ -// Package groups is what the forge bridge's process and its tools bundle share of a delivery group's end (novox/hq ADR -// 0633 §4, issue 1585): the keys of the bridge's state performed, and the asks of the state end-asks, through which the -// tool bridge_group_end_again asks the process to say a group's end again (the bridge serves no request subject, ADR 0437 -// §4, so a tool asks in a state the process watches, as indexer_take_in asks the indexer in takeins). -package groups - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "slices" - "sort" - "strings" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The bridge's states the tools read and write. -const ( - // PerformedState is the bridge's state of what it performed and published. - PerformedState = "performed" - // EndAsksState is the state of asks to say a group's end again, keyed by the group escaped as a key. - EndAsksState = "end-asks" -) - -// EndAsksBucket is its bucket on the bus, `_` of the module the bridge runs as, its credential's (A-296). -func EndAsksBucket(module string) string { return module + "_" + EndAsksState } - -// Key is the key of performed that says a group's end on a base is written: `groups..`, each part escaped as -// a key name, its value the last member's merge commit the end named (design 47 G §715: one end per base). -func Key(group, base string) (string, error) { - part, err := KeyOf(group, base) - if err != nil { - return "", err - } - return "groups." + part, nil -} - -// KeyOf is a group's id (its branch) and a base, each escaped as a key name, as the states performed and end-asks key -// them: `.`. -func KeyOf(group, base string) (string, error) { - if strings.TrimSpace(group) == "" { - return "", errors.New("a group's id is empty") - } - if strings.TrimSpace(base) == "" { - return "", errors.New("a group's base is empty") - } - return keys.EscapeName(group) + "." + keys.EscapeName(base), nil -} - -// Bases are the distinct bases of a group's members, in the order the members name them; a member naming none is -// named in missing by its repository and number. -func Bases(g seat.Group) (bases, missing []string) { - for _, m := range g.Members { - switch { - case m.Base == "": - missing = append(missing, fmt.Sprintf("%s#%d", m.Repository, m.Number)) - case !slices.Contains(bases, m.Base): - bases = append(bases, m.Base) - } - } - return bases, missing -} - -// OnBase is the members of a group whose base is base, in the group's order. -func OnBase(g seat.Group, base string) []seat.Member { - var out []seat.Member - for _, m := range g.Members { - if m.Base == base { - out = append(out, m) - } - } - return out -} - -// PublishedKey is the key of performed that says a member's merged message is written: `published.<16 hex digits of the -// sha256 of #>`, its value the merge commit the message named (a pull request merges once). -func PublishedKey(repository string, number int) string { - sum := sha256.Sum256([]byte(fmt.Sprintf("%s#%d", strings.ToLower(repository), number))) - return "published." + hex.EncodeToString(sum[:8]) -} - -// EndID is the message id of a group's end on a base, and of one said again by hand at a time: the stream's duplicate -// window drops a second publish of the same id. -func EndID(group, base, lastMerge, again string) string { - id := "group-end." + group + "." + base + "." + lastMerge - if again != "" { - id += "." + again - } - return id -} - -// AgainStamp is the time a hand ask appends to a group end's message id. -func AgainStamp(at time.Time) string { return at.UTC().Format("20060102T150405.000000000Z") } - -// EndAsk is a value of the end-asks state: which group's end a person asked to be said again, why, who and when, and, once -// the bridge read it, its answer. -type EndAsk struct { - V int `json:"v"` - Group string `json:"group"` - Base string `json:"base"` - Why string `json:"why,omitempty"` - By string `json:"by,omitempty"` - At time.Time `json:"at"` - Written bool `json:"written,omitempty"` - Answer string `json:"answer,omitempty"` - Answered time.Time `json:"answered,omitzero"` -} - -// Done says the ask is answered. -func (a EndAsk) Done() bool { return !a.Answered.IsZero() } - -// NewEndAsk is the value bridge_group_end_again writes for a group: its key (the group escaped as a key) and the value. -func NewEndAsk(group, base, why, by string, at time.Time) (string, []byte, error) { - group, base = strings.TrimSpace(group), strings.TrimSpace(base) - if group == "" { - return "", nil, errors.New("name the group whose end is said again (group)") - } - if base == "" { - return "", nil, errors.New("name the watched branch its end is said again on (base)") - } - key, err := KeyOf(group, base) - if err != nil { - return "", nil, err - } - data, err := json.Marshal(EndAsk{V: 1, Group: group, Base: base, Why: strings.TrimSpace(why), By: by, At: at.UTC()}) - return key, data, err -} - -// DecodeEndAsk reads an end-asks value. -func DecodeEndAsk(data []byte) (EndAsk, error) { - var a EndAsk - if err := json.Unmarshal(data, &a); err != nil { - return a, err - } - if a.V != 1 || a.Group == "" || a.Base == "" { - return a, errors.New("an end-asks value of no version 1 naming no group and base") - } - return a, nil -} - -// Row is one group on one base as bridge_groups answers it: the seat mesh-delivery's group and what the bridge kept of its end. -type Row struct { - Key string `json:"key"` - Group string `json:"group"` - Base string `json:"base"` - State string `json:"state,omitempty"` - Members []RowMember `json:"members"` - Ended bool `json:"ended"` - // EndedWith is the last member's merge commit the end named, when it is written. - EndedWith string `json:"ended-with,omitempty"` - Open bool `json:"open"` - Words string `json:"words"` - // LastEndAsk is the last ask to say the group's end again (bridge_group_end_again), its who, why and when, and the - // bridge's answer once it read it; absent when none was asked. The state end-asks keeps the last per group. - LastEndAsk *EndAsk `json:"last-end-ask,omitempty"` -} - -// RowMember is one member of a group: its delivery state at the seat and, once its merged message is written, the merge -// commit it named. -type RowMember struct { - Repository string `json:"repository"` - Number int `json:"number"` - State string `json:"state"` - Commit string `json:"commit,omitempty"` - Published bool `json:"published"` -} - -// Rows are the groups the seat mesh-delivery's verb groups answers, each with what the bridge kept: ended (its end written, -// with the last merge it named) or open (some member's merged message is not written, or its end not written). published -// is performed's `published.` values by key (the merge commit), ended its `groups.` values by key; asks are the end-asks -// values by the same key, and one that does not read is named unread as `end-asks.`. A group whose id cannot be a -// key is named unread by its id. -func Rows(of []seat.Group, published, ended map[string]string, asks map[string][]byte) (rows []Row, unread []string) { - lastAsk := map[string]*EndAsk{} - for key, raw := range asks { - a, err := DecodeEndAsk(raw) - if err != nil { - unread = append(unread, EndAsksState+"."+key) - continue - } - lastAsk[key] = &a - } - for _, g := range of { - if len(g.Members) < 2 { - continue - } - bases, missing := Bases(g) - for _, m := range missing { - unread = append(unread, "the member "+m+" of the group "+g.ID+" names no base") - } - for _, base := range bases { - key, err := KeyOf(g.ID, base) - if err != nil { - unread = append(unread, "a group with no id") - continue - } - r := Row{Key: key, Group: g.ID, Base: base, State: g.State} - allPublished := true - for _, m := range OnBase(g, base) { - commit, pub := published[PublishedKey(m.Repository, int(m.Number))] - r.Members = append(r.Members, RowMember{Repository: m.Repository, Number: int(m.Number), State: m.State, Commit: commit, Published: pub}) - allPublished = allPublished && pub - } - r.EndedWith, r.Ended = ended["groups."+key] - r.LastEndAsk = lastAsk[key] - r.Open = !r.Ended - switch { - case r.Ended: - r.Words = "its end is written" - case allPublished: - r.Words = "every member's merged message is written, and its end is not written: bridge_group_end_again says it" - default: - r.Words = "gathered: not every member's merged message is written" - } - rows = append(rows, r) - } - } - sortRows(rows) - sort.Strings(unread) - return rows, unread -} - -func sortRows(rows []Row) { sort.Slice(rows, func(i, j int) bool { return rows[i].Key < rows[j].Key }) } - -// MembersOf are a group's members with their heads, in the group's order, each pull request once: a group the seat -// answers with a member twice (feat/47-G-join11 named novox/mesh-sdk#189 twice, 2026-11-14) keeps the later head at the -// first place, since a merged message naming a member twice is refused whole and no merge of that branch is taken in. -func MembersOf(g seat.Group) []meshdeliveryclient.Head { - out := make([]meshdeliveryclient.Head, 0, len(g.Members)) - at := map[string]int{} - for _, m := range g.Members { - h := meshdeliveryclient.Head{Repository: m.Repository, Number: int(m.Number), Head: m.Head} - k := fmt.Sprintf("%s#%d", m.Repository, m.Number) - if i, twice := at[k]; twice { - out[i] = h - continue - } - at[k] = len(out) - out = append(out, h) - } - return out -} - -// Named is the group of id among the groups the seat answered, when it has more than one member and names the pull -// request number of repository among them (a lone pull request is no group). -func Named(of []seat.Group, id, repository string, number int) (seat.Group, bool) { - for _, g := range of { - if g.ID != id || len(g.Members) < 2 { - continue - } - if slices.ContainsFunc(g.Members, func(m seat.Member) bool { - return trunk.SameRepository(m.Repository, repository) && int(m.Number) == number - }) { - return g, true - } - } - return seat.Group{}, false -} - -// Read is the open delivery groups the seat mesh-delivery's verb groups answers by default, called through call by the -// verb's manifest key: the bridge reads a group from the seat, never from the gate's state (design 47 *A group's merges are -// taken in together*). The ended ones are never asked whole: their list outgrows one bus message (lead: principle 7, live -// 02:06); one is read by its id with ReadGroup. An answer saying an error, or one the contract cannot type, is an error: a -// failed read is never read as no group. -func Read(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error)) ([]seat.Group, error) { - return ask(ctx, call, seat.GroupsInput{}) -} - -// ReadAll is every delivery group, the ended ones too (all). Its answer grows with every group that ended, so only a -// tool a person asks reads it, never the take-in or the catch-up. -func ReadAll(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error)) ([]seat.Group, error) { - return ask(ctx, call, seat.GroupsInput{All: seat.GroupsInputAllTrue}) -} - -// ReadGroup is the one group id names, ended or not, as the verb answers with its group: none for a group it does not know. -func ReadGroup(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error), id string) ([]seat.Group, error) { - return ask(ctx, call, seat.GroupsInput{Group: id}) -} - -func ask(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error), in seat.GroupsInput) ([]seat.Group, error) { - raw, err := call(ctx, "seat:"+seat.Seat+"."+seat.VerbGroups, in) - if err != nil { - return nil, fmt.Errorf("the seat %s did not answer %s: %w", seat.Seat, seat.VerbGroups, err) - } - var a seat.GroupsAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf("the seat %s's answer of %s is not its contract's: %w", seat.Seat, seat.VerbGroups, err) - } - if a.Error != "" { - return nil, fmt.Errorf("the seat %s refused %s: %s", seat.Seat, seat.VerbGroups, a.Error) - } - return a.Groups, nil -} diff --git a/modules/mesh-delivery-forge-bridge/internal/groups/owedask.go b/modules/mesh-delivery-forge-bridge/internal/groups/owedask.go index ab509455..02e4d96a 100644 --- a/modules/mesh-delivery-forge-bridge/internal/groups/owedask.go +++ b/modules/mesh-delivery-forge-bridge/internal/groups/owedask.go @@ -10,9 +10,11 @@ import ( // What a person asks of the bridge's performing of what is owed (novox/hq design 47 *What the gate owes the forge*): the // tools bridge_owed (its consumers' backlog), bridge_owed_again and bridge_owed_drop write an ask into the state -// owed-asks and wait for the bridge's answer there, as bridge_group_end_again does, since the bridge is the other program +// owed-asks and wait for the bridge's answer there, since the bridge is the other program // and serves no request subject (ADR 0437 §4). const ( + // PerformedState is the bridge's state of the acts it performed, the `requires` entry performed. + PerformedState = "performed" // OwedAsksState is the state of asks about what is owed, one key per kind of ask and act. OwedAsksState = "owed-asks" ) diff --git a/modules/mesh-delivery-forge-bridge/internal/groups/read_test.go b/modules/mesh-delivery-forge-bridge/internal/groups/read_test.go deleted file mode 100644 index 672f4aee..00000000 --- a/modules/mesh-delivery-forge-bridge/internal/groups/read_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package groups - -import ( - "context" - "encoding/json" - "errors" - "strings" - "testing" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" -) - -// The seat answers the whole list of groups with more than one bus message carries once many have ended (live 02:06); -// a read of the open ones, or of one by its id, is answered; Read never asks for all (lead: principle 7). -func TestReadsNeverAskTheEndedGroupsWhole(t *testing.T) { - const bus = 1 << 20 - seatOf := func(_ context.Context, _ string, body any) (json.RawMessage, error) { - in := body.(seat.GroupsInput) - groups := []seat.Group{{ID: "feat/open", State: "gathering"}} - switch { - case in.Group != "": - groups = []seat.Group{{ID: in.Group}} - case in.All == seat.GroupsInputAllTrue: - for i := 0; i < 3000; i++ { - groups = append(groups, seat.Group{ID: "ended", Why: strings.Repeat("x", 500)}) - } - } - raw, _ := json.Marshal(seat.GroupsAnswer{Groups: groups}) - if len(raw) > bus { - return nil, errors.New("the answer is more than the bus carries in one message") - } - return raw, nil - } - if got, err := Read(context.Background(), seatOf); err != nil || len(got) != 1 || got[0].ID != "feat/open" { - t.Errorf("Read: %v %v; want the open group alone", got, err) - } - if got, err := ReadGroup(context.Background(), seatOf, "feat/ended"); err != nil || len(got) != 1 || got[0].ID != "feat/ended" { - t.Errorf("ReadGroup: %v %v; want the group by its id", got, err) - } - if _, err := ReadAll(context.Background(), seatOf); err == nil { - t.Errorf("ReadAll: want the seat's refusal to be an error, never read as no group") - } - // A member the seat names twice is said once, at its later head (2026-11-14: the take-in of every repository with a - // branch of that group was refused whole). - twice := seat.Group{ID: "feat/twice", Members: []seat.Member{{Repository: "o/a", Number: 1, Head: "old"}, {Repository: "o/b", Number: 2, Head: "b"}, {Repository: "o/a", Number: 1, Head: "new"}}} - if got := MembersOf(twice); len(got) != 2 || got[0].Repository != "o/a" || got[0].Head != "new" || got[1].Repository != "o/b" { - t.Errorf("MembersOf a group naming o/a#1 twice = %+v, want o/a#1 at new, then o/b#2", got) - } -} diff --git a/modules/mesh-delivery-forge-bridge/manifest_test.go b/modules/mesh-delivery-forge-bridge/manifest_test.go index a83d6332..9760f1bf 100644 --- a/modules/mesh-delivery-forge-bridge/manifest_test.go +++ b/modules/mesh-delivery-forge-bridge/manifest_test.go @@ -99,22 +99,21 @@ func TestManifestDeclarations(t *testing.T) { // 1235/AC1 if !reflect.DeepEqual(m.Streams, []stream{{Name: "forge", Events: []string{"forge.**", "owed.ended"}}}) { t.Errorf("streams = %+v", m.Streams) } - // What the gate and the checker owe the forge is each seat's event owed, heard on its own stream (design 47 *What the - // gate owes the forge*), never read from their state. The forge's events are the seat git's (design 47 *The seat git*); forge.delete: a branch's end, said as a - // branch-deleted kind (design 51, DLV-FB1). The state performed's binding is asked again on the seat mesh-broker's - // recreated and dropped, and asked of its show (design 47 G §577). - // Every move of a watched branch is heard on branch-moved, and the watched branches from the registrations, before the - // first the gate's source (design 47 G §4, §11, §507). - if want := []string{"git.branch-moved", "git.forge-delete", "git.pull-closed", "git.pull-merged", "git.pull-updated", "mesh-broker.dropped", "mesh-broker.recreated", "mesh-catalog.registration-changed", "mesh-conditions.findings-asked", "mesh-delivery-checker.owed", "mesh-delivery.owed", "mesh-delivery.source-moved"}; !reflect.DeepEqual(sorted(m.Consumes), want) { + // What the gate owes the forge is its seat's event owed, heard on its own stream (design 47 *What the gate owes the + // forge*), never read from its state. The state performed's binding is asked again on the seat mesh-broker's recreated + // and dropped, and asked of its show (design 47 G §577). Every move of a watched branch is heard on branch-moved, and + // the watched branches from the registrations, before the first the gate's source (design 47 G §4, §507; H §739). No + // pull request event, no checker and no finding is heard (design 47 H §764, H-A-48). + if want := []string{"git.branch-moved", "mesh-broker.dropped", "mesh-broker.recreated", "mesh-catalog.registration-changed", "mesh-delivery.owed", "mesh-delivery.source-moved"}; !reflect.DeepEqual(sorted(m.Consumes), want) { t.Errorf("consumes = %v, want %v", m.Consumes, want) } - // A group is read from the seat mesh-delivery's verb groups (design 47, acceptance 49): the bridge reads no state of - // another module's. + // The bridge reads no state of another module's. if len(m.Reads) != 0 { t.Errorf("reads = %v, want none", m.Reads) } - if want := []string{"seat:git.branch", "seat:git.comment", "seat:git.file", "seat:git.merge-pull", "seat:git.note", "seat:git.open-pulls", - "seat:git.pull", "seat:git.status", "seat:git.tags", "seat:git.trees", "seat:git.view", "seat:mesh-broker.show", "seat:mesh-catalog.registrations", "seat:mesh-delivery.groups", "seat:mesh-delivery.source", "seat:mesh-hand-acts.hand-act"}; !reflect.DeepEqual(sorted(m.Invokes), want) { + // No pull, tree, file, open pull requests, merge or group is asked (design 47 H §739, §764). + if want := []string{"seat:git.branch", "seat:git.comment", "seat:git.note", "seat:git.status", "seat:git.tags", "seat:git.view", + "seat:mesh-broker.show", "seat:mesh-catalog.registrations", "seat:mesh-delivery.source", "seat:mesh-hand-acts.hand-act"}; !reflect.DeepEqual(sorted(m.Invokes), want) { t.Errorf("invokes = %v, want %v", m.Invokes, want) } if b, ok := m.OwnSecrets["broker"]; !ok || len(m.OwnSecrets) != 1 || b != "${dir:state}/broker" { @@ -123,25 +122,34 @@ func TestManifestDeclarations(t *testing.T) { // 1235/AC1 if m.SecretsOwner != "mesh-delivery-forge-bridge" { t.Errorf("secrets-owner = %q", m.SecretsOwner) } - // The head last written on FORGE for each pull request, so a sync writes only what differs (ADR 0443 §5), and what a - // merge read of each module directory by its tree, so a merge reads the forge only for the directories it changed - // (issue 1126). What it performed of what is owed is kept data in the new form, one key per act, kept 7 days as the - // owners' streams owed are; its size is the template's own (design 47 *What the gate owes the forge*, ADR 0595 §3). - if !reflect.DeepEqual(m.State, []state{{Name: "heads", History: 1}, {Name: "inputs", History: 1}, {Name: "end-asks", History: 1}, {Name: "owed-asks", History: 1}}) { // 1279/AC6, 1126, 1585 - t.Errorf("state = %+v, want the buckets heads, inputs, end-asks and owed-asks", m.State) + // The head held for each watched branch (design 47 H §739), and the asks about what is owed. What it performed of what is + // owed is kept data in the new form, one key per act, kept 7 days as the owner's stream owed is; its size is the + // template's own (design 47 *What the gate owes the forge*, ADR 0595 §3). No inputs, end-asks or findings (H §764, H-A-48). + if !reflect.DeepEqual(m.State, []state{{Name: "heads", History: 1}, {Name: "owed-asks", History: 1}}) { + t.Errorf("state = %+v, want the buckets heads and owed-asks", m.State) } - // Design 47 G §387, §529: the bridge gains the finding branch-unprotected, so it asks the findings state and the finding stream - // by their templates (7 days, 16 MiB) as every part but a foundation part does. - if want := []kept{{Name: "performed", Storage: "key-value", Template: "state", Options: map[string]any{"history": float64(1), "ttl-seconds": float64(604800)}}, - {Name: "findings", Storage: "key-value", Template: "state", Options: map[string]any{"history": float64(5)}}, - {Name: "finding-events", Storage: "stream", Template: "events", Options: map[string]any{ - "events": []any{"finding-written.*", "finding-cleared.*", "findings-stated.*"}, "max-age-days": float64(7), "max-mib": float64(16)}}}; !reflect.DeepEqual(m.Requires, want) { - t.Errorf("requires = %+v, want performed, findings and finding-events as %+v", m.Requires, want) + if want := []kept{{Name: "performed", Storage: "key-value", Template: "state", Options: map[string]any{"history": float64(1), "ttl-seconds": float64(604800)}}}; !reflect.DeepEqual(m.Requires, want) { + t.Errorf("requires = %+v, want performed alone as %+v", m.Requires, want) } - // 1585/T18: the tools read the groups and ask the bridge to say a group's end again, through its state end-asks. The tool bridge_merged_message answers a merge's merged message again (issue 1585); bridge_tags reads a package's tags for the builder's floor (design 51). - if want := []string{"bridge_group_end_again", "bridge_groups", "bridge_merged_message", "bridge_owed", "bridge_owed_again", "bridge_owed_drop", "bridge_tags"}; !reflect.DeepEqual(sorted(m.Tools), want) { + // bridge_tags reads a package's tags for the builder's floor (design 51); the owed tools ask the bridge through owed-asks. + if want := []string{"bridge_owed", "bridge_owed_again", "bridge_owed_drop", "bridge_tags"}; !reflect.DeepEqual(sorted(m.Tools), want) { t.Errorf("tools = %v, want %v", m.Tools, want) } + // Design 47 H §764 (B3 AC1): the earlier model's names are in no file of the bridge but tests asserting their absence. + retired := []string{"pushed", "forge.group.merged", "bridge_groups", "bridge_group_end_again", "bridge_merged_message", + "OwedActMerge", "mesh-delivery-checker", "seat:git.merge-pull", "branch-unprotected", "ForgeMerged", "ForgePushed"} + _ = filepath.WalkDir(".", func(p string, d fs.DirEntry, err error) error { + if err != nil || d.IsDir() || strings.HasSuffix(p, "_test.go") || (!strings.HasSuffix(p, ".go") && !strings.HasSuffix(p, ".json")) { + return err + } + data, _ := os.ReadFile(p) + for _, name := range retired { + if bytes.Contains(data, []byte(name)) { + t.Errorf("%s names %q, which design 47 H §764 retires", p, name) + } + } + return nil + }) // No other state, no seat, no event (ADR 0437 §4; ADR 0521: no check.status); its kept data on the bus is the one entry of requires above. for _, k := range []string{"logs", "emits", "claims", "provides", "uses", "defines-seats", "seat", "seats"} { if _, ok := top[k]; ok { diff --git a/modules/mesh-delivery-forge-bridge/module.json b/modules/mesh-delivery-forge-bridge/module.json index f4317a99..d4243381 100644 --- a/modules/mesh-delivery-forge-bridge/module.json +++ b/modules/mesh-delivery-forge-bridge/module.json @@ -3,16 +3,10 @@ "version": "0.1", "slug": "forge-bridge", "consumes": [ - "git.pull-updated", - "git.pull-merged", - "git.pull-closed", - "git.forge-delete", "git.branch-moved", "mesh-catalog.registration-changed", - "mesh-conditions.findings-asked", "mesh-delivery.source-moved", "mesh-delivery.owed", - "mesh-delivery-checker.owed", "mesh-broker.recreated", "mesh-broker.dropped" ], @@ -21,15 +15,10 @@ ], "state": [ { "name": "heads", "history": 1 }, - { "name": "inputs", "history": 1 }, - { "name": "end-asks", "history": 1 }, { "name": "owed-asks", "history": 1 } ], "tools": [ "bridge_tags", - "bridge_groups", - "bridge_group_end_again", - "bridge_merged_message", "bridge_owed", "bridge_owed_again", "bridge_owed_drop" @@ -39,13 +28,7 @@ "seat:git.comment", "seat:git.view", "seat:git.note", - "seat:git.merge-pull", - "seat:mesh-delivery.groups", "seat:mesh-hand-acts.hand-act", - "seat:git.open-pulls", - "seat:git.trees", - "seat:git.file", - "seat:git.pull", "seat:git.tags", "seat:git.branch", "seat:mesh-catalog.registrations", @@ -58,22 +41,6 @@ "storage": "key-value", "template": "state", "options": { "history": 1, "ttl-seconds": 604800 } - }, - { - "name": "findings", - "storage": "key-value", - "template": "state", - "options": { "history": 5 } - }, - { - "name": "finding-events", - "storage": "stream", - "template": "events", - "options": { - "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], - "max-age-days": 7, - "max-mib": 16 - } } ], "own-secrets": { -- 2.54.0 From 9fe6330d799b31123ae99de0d9b4c54f0d1e80ec Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:34:07 +0100 Subject: [PATCH 019/104] B4: the bridge's whole test says head-moved; bridge_heads reads the heads held MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bridge's whole test runs the program against an embedded bus as the node does: a start, a merge, an admitted push to an unprotected branch and a restart after a move each give one head-moved naming the head read through the seat git's branch and the head held before (start true at a start); a head heard twice, a branch not watched and a restart at the head held give none, and the bridge asks the seat git nothing but branch. Its bus permissions are composed for the manifest as it now stands. The pull, open pull request, group and unprotected-branch tests go; the owed test performs the gate's statuses once, after a restart and again by hand. bridge_heads answers each key of the state heads with the head the bridge holds, read-only. Builds: design 47 H §739 (how checked), §774; lead answers H-A-48, H-A-85 (1) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../mesh-delivery-forge-bridge-tools/main.go | 48 +- .../main_test.go | 63 ++ .../integration_test.go | 660 ++++-------------- .../manifest_test.go | 5 +- .../mesh-delivery-forge-bridge/module.json | 1 + 5 files changed, 228 insertions(+), 549 deletions(-) diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go index 9b246454..466eff29 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go @@ -1,6 +1,6 @@ // Command mesh-delivery-forge-bridge-tools serves the forge bridge's tools (design 51; design 47 *What the gate owes the // forge*): the runtime launches it for a call. bridge_tags reads a package's git tags through the seat git's verb tags, -// for the builder's floor; bridge_owed, bridge_owed_again and bridge_owed_drop write an ask into the bridge's state +// for the builder's floor; bridge_heads reads the head the bridge holds for each watched branch; bridge_owed, bridge_owed_again and bridge_owed_drop write an ask into the bridge's state // owed-asks and wait for the bridge's answer there, since the bridge is the other program and serves no request subject // (ADR 0437 §4). package main @@ -21,8 +21,36 @@ import ( "mesh-delivery-forge-bridge/internal/groups" ) -// Tools are the bridge's reading tools: forge calls the seat git. -func Tools(forge bridge.Caller) []stdio.Tool { +// HeadsTool reads the bridge's state heads (design 47 H §739, H-A-48, H-A-85). +const HeadsTool = "bridge_heads" + +// headState is the state heads as bridge_heads reads it (stdio.KeptState). +type headState interface { + Keys() ([]string, error) + Get(key string) (*stdio.StateEntry, error) +} + +// heads is the state heads: each key, branch..., with the head the bridge holds for it. +func heads(s headState) (map[string]string, error) { + keys, err := s.Keys() + if err != nil { + return nil, fmt.Errorf("the bridge's state heads cannot be listed: %w", err) + } + out := map[string]string{} + for _, k := range keys { + e, err := s.Get(k) + if err != nil { + return nil, fmt.Errorf("the bridge's state heads cannot be read at %s: %w", k, err) + } + if e != nil { + out[k] = strings.TrimSpace(string(e.Value)) + } + } + return out, nil +} + +// Tools are the bridge's reading tools: forge calls the seat git, held is the state heads. +func Tools(forge bridge.Caller, held headState) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } return []stdio.Tool{ {Name: bridge.TagsTool, @@ -35,6 +63,18 @@ func Tools(forge bridge.Caller) []stdio.Tool { Run: func(args map[string]any) (any, error) { return bridge.Tags(context.Background(), forge, str(args, "repository"), str(args, "prefix")) }}, + {Name: HeadsTool, + Description: "The head the forge bridge holds for each watched branch, the one its last head-moved named (design 47 H §739): " + + "each key of its state heads, branch..., with its head. Read-only; an untaken head is " + + "recovered with the gate's gate_head_take, never said again here.", + Input: map[string]any{"type": "object", "properties": map[string]any{}}, + Run: func(map[string]any) (any, error) { + h, err := heads(held) + if err != nil { + return nil, err + } + return map[string]any{"heads": h}, nil + }}, } } @@ -95,7 +135,7 @@ func main() { // The module the runtime serves these tools as: the bridge's, whose states they ask (design 47 G A-296). served := os.Getenv(stdio.ServedAs) performed := stdio.State(groups.PerformedState) - tools := Tools(askCaller) + tools := Tools(askCaller, stdio.State("heads")) owedAsks := stdio.State(groups.OwedAsksState) recorder := meshhandactsclient.Recorder{Ask: stdio.Ask} tools = append(tools, OwedTools(askState(owedAsks, groups.OwedAsksBucket(served), 25*time.Second, func(v []byte) bool { diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go index ce28c7ed..2ed11529 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go @@ -3,19 +3,82 @@ package main import ( "encoding/json" "errors" + "reflect" "testing" "time" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" + stdio "git.novox.be/novox/mesh-sdk/go" "mesh-delivery-forge-bridge/internal/groups" ) +// memState is a state in memory as bridge_heads reads it. +type memState struct { + vals map[string]string + err error +} + +func (m memState) Keys() ([]string, error) { + if m.err != nil { + return nil, m.err + } + var out []string + for k := range m.vals { + out = append(out, k) + } + return out, nil +} + +func (m memState) Get(key string) (*stdio.StateEntry, error) { + v, ok := m.vals[key] + if !ok { + return nil, nil + } + return &stdio.StateEntry{Value: []byte(v)}, nil +} + // Design 47 *What the gate owes the forge*: bridge_owed reads what the bridge performed and its consumer's backlog, // bridge_owed_again and bridge_owed_drop write an ask and answer what the bridge answered, a drop naming why and // recorded as a hand act first. func TestTheBridgeTools(t *testing.T) { + // Design 47 H §739, H-A-48, H-A-85: bridge_heads answers each key of the state heads with its head, and says a state + // it cannot read, never none. + t.Run("bridge_heads", func(t *testing.T) { + const h1 = "1111111111111111111111111111111111111111" + for _, c := range []struct { + name string + state memState + want map[string]string + fails bool + }{ + {"two branches held", memState{vals: map[string]string{"branch.novox.mesh-sdk.main": h1, "branch.novox.mesh-sdk.beta": h1}}, + map[string]string{"branch.novox.mesh-sdk.main": h1, "branch.novox.mesh-sdk.beta": h1}, false}, + {"none held", memState{vals: map[string]string{}}, map[string]string{}, false}, + {"a state that cannot be listed", memState{err: errors.New("no responders")}, nil, true}, + } { + var run func(map[string]any) (any, error) + for _, tl := range Tools(nil, c.state) { + if tl.Name == HeadsTool { + run = tl.Run + } + } + if run == nil { + t.Fatalf("no tool %s", HeadsTool) + } + out, err := run(map[string]any{}) + if c.fails { + if err == nil { + t.Errorf("%s: %v, want an error", c.name, out) + } + continue + } + if m, _ := out.(map[string]any); err != nil || !reflect.DeepEqual(m["heads"], c.want) { + t.Errorf("%s: %v %v, want %v", c.name, out, err, c.want) + } + } + }) t.Run("the owed tools", func(t *testing.T) { at := time.Date(2026, 11, 9, 21, 0, 0, 0, time.UTC) var asked []groups.OwedAsk diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go index 278ab6ad..5a1a1ec6 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go @@ -4,8 +4,6 @@ package main import ( "context" - "crypto/sha256" - "encoding/hex" "encoding/json" "errors" "fmt" @@ -23,9 +21,7 @@ import ( git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" - "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" "mesh-delivery-forge-bridge/internal/gitfixture" @@ -36,13 +32,12 @@ import ( // controller's user, and the bridge's own principal . with the permissions composed for its manifest, and // no others, so a permission the bridge lacks fails a test here and not on the mesh (issue 1279). // -// From module.json: the seat git's events heard through its durable on EVENTS; what the gate and the checker owe heard -// through its durable on each seat's own stream owed (SEAT__owed); the seat git's verbs, the seat mesh-delivery's -// groups and the seat mesh-hand-acts' hand-act called on mesh.seat..call.. (or its plain fallback); -// its own states heads, inputs, end-asks and owed-asks, and performed under the name its binding gives (the seat -// mesh-broker's show); its stream forge. It reads no state of the gate's or -// the checker's (design 47, acceptance 49 and 53). `**` is written `>` on the wire. The controller's own user keeps all -// rights, as it has. +// From module.json: the registrations and the gate's source-moved heard through its durable on EVENTS; branch-moved and +// what the gate owes heard through its durable on each seat's own stream (SEAT__); the seat git's verbs, the +// seat mesh-catalog's registrations, the seat mesh-delivery's source, the seat mesh-broker's show and the seat +// mesh-hand-acts' hand-act called on mesh.seat..call.. (or its plain fallback); its own states heads +// and owed-asks, and performed under the name its binding gives; its stream forge. `**` is written `>` on the wire. The +// controller's own user keeps all rights, as it has. const busConf = ` listen: 127.0.0.1:-1 jetstream { store_dir: %q } @@ -66,31 +61,13 @@ accounts { "$JS.API.STREAM.INFO.KV_mod_mesh-delivery-forge-bridge_performed_b1" "$JS.FC.KV_mod_mesh-delivery-forge-bridge_performed_b1.>" "$KV.mod_mesh-delivery-forge-bridge_performed_b1.>" - "$JS.API.CONSUMER.CREATE.KV_mod_mesh-delivery-forge-bridge_findings_b1.>" - "$JS.API.CONSUMER.DELETE.KV_mod_mesh-delivery-forge-bridge_findings_b1.>" - "$JS.API.DIRECT.GET.KV_mod_mesh-delivery-forge-bridge_findings_b1.>" - "$JS.API.STREAM.INFO.KV_mod_mesh-delivery-forge-bridge_findings_b1" - "$JS.FC.KV_mod_mesh-delivery-forge-bridge_findings_b1.>" "$KV.mod_mesh-delivery-forge-bridge_findings_b1.>" "$JS.API.STREAM.NAMES" "$JS.API.CONSUMER.CREATE.EVENTS" "$JS.API.CONSUMER.CREATE.EVENTS.>" "$JS.API.CONSUMER.DELETE.EVENTS.>" "$JS.API.CONSUMER.MSG.NEXT.EVENTS.>" - "mesh.bus.mesh-delivery-forge-bridge.finding-events.finding-written.n1" - "mesh.bus.mesh-delivery-forge-bridge.finding-events.finding-cleared.n1" - "mesh.bus.mesh-delivery-forge-bridge.finding-events.findings-stated.n1" - "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-forge-bridge_inputs.>" - "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-forge-bridge_inputs.>" - "$JS.API.DIRECT.GET.KV_mesh-delivery-forge-bridge_inputs.>" - "$JS.API.STREAM.INFO.KV_mesh-delivery-forge-bridge_inputs" - "$JS.FC.KV_mesh-delivery-forge-bridge_inputs.>" "$KV.mesh-delivery-forge-bridge_inputs.>" - "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-forge-bridge_end-asks.>" - "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-forge-bridge_end-asks.>" - "$JS.API.DIRECT.GET.KV_mesh-delivery-forge-bridge_end-asks.>" - "$JS.API.STREAM.INFO.KV_mesh-delivery-forge-bridge_end-asks" - "$JS.FC.KV_mesh-delivery-forge-bridge_end-asks.>" "$KV.mesh-delivery-forge-bridge_end-asks.>" "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-forge-bridge_owed-asks.>" "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-forge-bridge_owed-asks.>" @@ -105,10 +82,6 @@ accounts { "$JS.ACK.SEAT_mesh-delivery_owed.n1_mesh-delivery-forge-bridge.>" "$JS.API.CONSUMER.INFO.SEAT_mesh-delivery_owed.n1_mesh-delivery-forge-bridge" "$JS.API.CONSUMER.MSG.NEXT.SEAT_mesh-delivery_owed.n1_mesh-delivery-forge-bridge" - "$JS.API.STREAM.INFO.SEAT_mesh-delivery-checker_owed" - "$JS.ACK.SEAT_mesh-delivery-checker_owed.n1_mesh-delivery-forge-bridge.>" - "$JS.API.CONSUMER.INFO.SEAT_mesh-delivery-checker_owed.n1_mesh-delivery-forge-bridge" - "$JS.API.CONSUMER.MSG.NEXT.SEAT_mesh-delivery-checker_owed.n1_mesh-delivery-forge-bridge" "mesh.seat.mesh-broker.call.show.n1~mesh-delivery-forge-bridge" "mesh.seat.mesh-broker.tool.show" "mesh.seat.mesh-catalog.call.registrations.n1~mesh-delivery-forge-bridge" @@ -129,20 +102,8 @@ accounts { "mesh.seat.git.tool.view" "mesh.seat.git.call.note.n1~mesh-delivery-forge-bridge" "mesh.seat.git.tool.note" - "mesh.seat.git.call.merge-pull.n1~mesh-delivery-forge-bridge" - "mesh.seat.git.tool.merge-pull" - "mesh.seat.git.call.open-pulls.n1~mesh-delivery-forge-bridge" - "mesh.seat.git.tool.open-pulls" - "mesh.seat.git.call.trees.n1~mesh-delivery-forge-bridge" - "mesh.seat.git.tool.trees" - "mesh.seat.git.call.file.n1~mesh-delivery-forge-bridge" - "mesh.seat.git.tool.file" - "mesh.seat.git.call.pull.n1~mesh-delivery-forge-bridge" - "mesh.seat.git.tool.pull" "mesh.seat.git.call.tags.n1~mesh-delivery-forge-bridge" "mesh.seat.git.tool.tags" - "mesh.seat.mesh-delivery.call.groups.n1~mesh-delivery-forge-bridge" - "mesh.seat.mesh-delivery.tool.groups" "mesh.seat.mesh-hand-acts.call.hand-act.n1~mesh-delivery-forge-bridge" "mesh.seat.mesh-hand-acts.tool.hand-act" "mesh.stream.mesh-delivery-forge-bridge.event.forge.>" @@ -190,25 +151,14 @@ func startBus(t *testing.T) *server.Server { return srv } -// startBridge runs the program against an embedded bus with the stream EVENTS, the bridge's stream FORGE and its durable -// consumer _ on EVENTS, as the controller makes them (mesh-control internal/broker streams.go:192, -// nats.go:1387-1396, modstreams.go). It returns a control connection, its JetStream and a context. -func startBridge(t *testing.T, openReply string) (*nats.Conn, jetstream.JetStream, context.Context, <-chan error) { - b := startBed(t, openReply, nil) - return b.ctl, b.js, b.ctx, b.done -} - // bed is a started bridge with the bus it runs against. type bed struct { - srv *server.Server - ctl *nats.Conn - js jetstream.JetStream - ctx context.Context - done <-chan error - reply func(string) - // files sets what the stand-in seat git answers to file from then on; it is asked with the verb's input. - files func(func(repository, path, ref string) (string, bool)) - // answer sets the stand-in's answer to one verb of a seat (`.`) from then on. + srv *server.Server + ctl *nats.Conn + js jetstream.JetStream + ctx context.Context + done <-chan error + // answer sets the stand-in's answer to one verb of a seat (`.`, or `. `) from then on. answer func(verb string, answer string) // calls are the verbs the stand-in was called with, in order, as `. `. calls func() []string @@ -219,33 +169,18 @@ type bed struct { // answerOf is a verb's answer in the reply envelope of mesh-sdk go/process/call.go ({result, error, node}). func answerOf(answer string) []byte { return []byte(`{"result":` + answer + `,"node":"n0"}`) } -// fileAnswer is the seat git's answer to file: the content, or absent. -func fileAnswer(path, ref, content string, found bool) string { - if !found { - return `{"absent":true}` - } - b, _ := json.Marshal(git.FileAnswer{Path: path, Ref: ref, Content: content, Size: int64(len(content))}) - return string(b) -} - // boundPerformed is the bus name the stand-in seat mesh-broker's show answers for the state performed. const boundPerformed = "mod_mesh-delivery-forge-bridge_performed_b1" -// boundFindings is the bus name the stand-in seat mesh-broker's show answers for the state findings. -const boundFindings = "mod_mesh-delivery-forge-bridge_findings_b1" +// catalog is the repository the stand-in registrations name, its branch main watched (the seat mesh-catalog's fixture). +const catalog = "novox/mesh-catalog" -// boundFindingEvents and boundFindingEventsSubject are the stream and subject the stand-in seat mesh-broker's show answers -// for the bridge's finding events (design 47 G §529, A-274). -const ( - boundFindingEvents = "mod_mesh-delivery-forge-bridge_finding-events_b1" - boundFindingEventsSubject = "mesh.bus.mesh-delivery-forge-bridge.finding-events" -) - -// startBed is startBridge with a step between the streams and the consumers: prepare writes what the streams hold before -// the bridge's consumers are made, as the grants part makes them, from now (ADR 0443 §1), and reply sets the answer of the -// seat git's open-pulls from then on. A stand-in holds the seats the bridge calls: git (every verb, trees r0 by default, -// a module.json of {} at every path), mesh-delivery's groups (none by default) and mesh-hand-acts' hand-act. -func startBed(t *testing.T, openReply string, prepare func(ctx context.Context, js jetstream.JetStream)) *bed { +// startBed runs the program the way the node does (its entry, run, with MESH_BROKER_FILE) against an embedded bus with +// the stream EVENTS, the seats' streams owed and branch-moved, the bridge's stream forge, its states and its durable +// consumers, as the controller and the grants part make them. A stand-in holds the seats the bridge calls: git (branch at +// head for main of the catalog, the act verbs as their fixtures answer), mesh-catalog's registrations (the catalog's main), +// mesh-delivery's source, mesh-broker's show and mesh-hand-acts' hand-act. +func startBed(t *testing.T, head string) *bed { srv := startBus(t) ctl, err := nats.Connect(srv.ClientURL(), nats.UserInfo("ctl", "pw")) if err != nil { @@ -264,38 +199,26 @@ func startBed(t *testing.T, openReply string, prepare func(ctx context.Context, if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "FORGE", Subjects: []string{"mesh.stream.mesh-delivery-forge-bridge.event.forge.>", "mesh.stream.mesh-delivery-forge-bridge.event.owed.ended"}}); err != nil { t.Fatal(err) } - // The bridge's own stream of its findings' events, its requires entry finding-events under the names the seat - // mesh-broker's show answers (design 47 G §529, A-274), which its finding writer says into. - if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: boundFindingEvents, Subjects: []string{boundFindingEventsSubject + ".>"}}); err != nil { - t.Fatal(err) - } - // Each seat's own stream owed, as its contract keeps it (Stream, SEAT__owed), as the grants part makes it: no - // subjects of its own, sourced from EVENTS filtered by the event's subject. - for name, subjects := range map[string]string{seat.StreamOwed: seat.SubjectOwedAll, checker.StreamOwed: checker.SubjectOwedAll, git.StreamBranchMoved: git.SubjectBranchMoved} { + seats := map[string]string{seat.StreamOwed: seat.SubjectOwedAll, git.StreamBranchMoved: git.SubjectBranchMoved} + for name, subjects := range seats { if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: name, MaxAge: 7 * 24 * time.Hour, Sources: []*jetstream.StreamSource{{Name: "EVENTS", FilterSubject: subjects}}}); err != nil { t.Fatal(err) } } - // The bridge's states, made from the manifest's state entries and its requires before the process starts; the state - // performed under the bus name the seat mesh-broker's show answers for it (boundPerformed), never an old name (§577). - for _, name := range []string{headsBucket(forgeBridgeModule()), boundPerformed, boundFindings, inputsBucket(forgeBridgeModule()), groupkeys.EndAsksBucket(forgeBridgeModule()), groupkeys.OwedAsksBucket(forgeBridgeModule())} { + for _, name := range []string{headsBucket(forgeBridgeModule()), boundPerformed, groupkeys.OwedAsksBucket(forgeBridgeModule())} { if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: name, History: 1}); err != nil { t.Fatal(err) } } - if prepare != nil { - prepare(ctx, js) - } acct := process.Account{Node: "n1", Module: "mesh-delivery-forge-bridge"} if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{ Durable: acct.EventConsumerName(), AckPolicy: jetstream.AckExplicitPolicy, DeliverPolicy: jetstream.DeliverNewPolicy, - FilterSubjects: []string{git.SubjectPullUpdated, git.SubjectPullMerged, git.SubjectPullClosed, git.SubjectForgeDelete, - "mesh.seat.mesh-catalog.event.registration-changed", "mesh.seat.mesh-delivery.event.source-moved"}, + FilterSubjects: []string{"mesh.seat.mesh-catalog.event.registration-changed", "mesh.seat.mesh-delivery.event.source-moved"}, }); err != nil { t.Fatal(err) } - for name, subjects := range map[string]string{seat.StreamOwed: seat.SubjectOwedAll, checker.StreamOwed: checker.SubjectOwedAll, git.StreamBranchMoved: git.SubjectBranchMoved} { + for name, subjects := range seats { if _, err := js.CreateOrUpdateConsumer(ctx, name, acct.SeatEventConsumerConfig([]string{subjects}, false)); err != nil { t.Fatal(err) } @@ -304,20 +227,15 @@ func startBed(t *testing.T, openReply string, prepare func(ctx context.Context, // The stand-in seats, answering on the caller-named subject and its plain fallback. var mu sync.Mutex answers := map[string]string{ - "git.open-pulls": openReply, "git.trees": `{"root":"r0","trees":{"":"t0","modules/a":"t1"}}`, - "mesh-delivery.groups": `{"groups":[]}`, "mesh-hand-acts.hand-act": `{"recorded":true}`, - // No registration yet: the watched branches are the gate's source's, main (design 47 G §507). - "mesh-catalog.registrations": `{"registrations":[]}`, "mesh-delivery.source": `{"branches":["main"]}`, - "git.pull": `{"error":"no pull request merged at that commit","error-kind":"not-found"}`, - "mesh-broker.show": `{"state":"created","binding":{"local":"performed","storage":"key-value","template":"state","bucket":"` + boundPerformed + `"}}`, - "mesh-broker.show findings": `{"state":"created","binding":{"local":"findings","storage":"key-value","template":"state","bucket":"` + boundFindings + `"}}`, - "mesh-broker.show finding-events": `{"state":"created","binding":{"local":"finding-events","storage":"stream","template":"events","stream":"` + - boundFindingEvents + `","subject":"` + boundFindingEventsSubject + `"}}`, + "mesh-hand-acts.hand-act": `{"recorded":true}`, + "mesh-catalog.registrations": string(gitfixture.Seat(t, "mesh-catalog", "verbs", "registrations answers one with its versions", "verb:registrations.answer")[0]), + "mesh-delivery.source": `{"branches":["main"]}`, + "mesh-broker.show": `{"state":"created","binding":{"local":"performed","storage":"key-value","template":"state","bucket":"` + boundPerformed + `"}}`, + "git.branch " + catalog: `{"repository":"` + catalog + `","branch":"main","head":"` + head + `","protected":true}`, } - for _, verb := range []string{"status", "comment", "view", "note", "merge-pull"} { + for _, verb := range []string{"status", "comment", "view", "note"} { answers["git."+verb] = string(gitfixture.Given(t, verb+" answers", "verb:"+verb+".answer")) } - filesOf := func(_, path, _ string) (string, bool) { return "{}", strings.HasSuffix(path, "module.json") } var called []string for _, subject := range []string{"mesh.seat.*.call.*.*", "mesh.seat.*.tool.*"} { sub, err := ctl.Subscribe(subject, func(m *nats.Msg) { @@ -325,23 +243,14 @@ func startBed(t *testing.T, openReply string, prepare func(ctx context.Context, verb := parts[2] + "." + parts[4] mu.Lock() called = append(called, verb+" "+string(m.Data)) - answer, files := answers[verb], filesOf - var in struct { - Repository string - Local string `json:"local-name"` - } + answer := answers[verb] + var in struct{ Repository string } if json.Unmarshal(m.Data, &in) == nil && answers[verb+" "+in.Repository] != "" { - answer = answers[verb+" "+in.Repository] // a move's branch and pull, set per repository (landedOn) - } - if in.Local != "" && answers[verb+" "+in.Local] != "" { - answer = answers[verb+" "+in.Local] // show answers each entry of the module's requires by its local name + answer = answers[verb+" "+in.Repository] } mu.Unlock() - if verb == "git.file" { - var in git.FileInput - _ = json.Unmarshal(m.Data, &in) - content, found := files(in.Repository, in.Path, in.Ref) - answer = fileAnswer(in.Path, in.Ref, content, found) + if answer == "" { + answer = `{"error":"the stand-in holds no answer"}` } _ = m.Respond(answerOf(answer)) }) @@ -370,10 +279,8 @@ func startBed(t *testing.T, openReply string, prepare func(ctx context.Context, start() t.Cleanup(func() { stop() }) set := func(verb, answer string) { mu.Lock(); answers[verb] = answer; mu.Unlock() } - return &bed{srv: srv, ctl: ctl, js: js, ctx: ctx, done: done, reply: func(s string) { set("git.open-pulls", s) }, - files: func(f func(repository, path, ref string) (string, bool)) { mu.Lock(); filesOf = f; mu.Unlock() }, - answer: set, - calls: func() []string { mu.Lock(); defer mu.Unlock(); return append([]string(nil), called...) }, + return &bed{srv: srv, ctl: ctl, js: js, ctx: ctx, done: done, answer: set, + calls: func() []string { mu.Lock(); defer mu.Unlock(); return append([]string(nil), called...) }, restart: func(between func()) { stop() <-done @@ -382,357 +289,98 @@ func startBed(t *testing.T, openReply string, prepare func(ctx context.Context, }} } -// landedOn sets the stand-in seat git so main of repository is protected at at, which the pull request number on branch -// at prHead merged. -func landedOn(b *bed, repository string, number int, branch, prHead, at string) { - b.answer("git.branch "+repository, `{"repository":"`+repository+`","branch":"main","head":"`+at+`","protected":true}`) - b.answer("git.pull "+repository, fmt.Sprintf(`{"pull":{"repository":%q,"number":%d,"branch":%q,"head":%q,"base":"main","state":"merged","merge-commit":%q}}`, - repository, number, branch, prHead, at)) +// headAt sets the stand-in seat git so main of the catalog is at head, protected or not. +func headAt(b *bed, head string, protected bool) { + p := "true" + if !protected { + p = "false" + } + b.answer("git.branch "+catalog, `{"repository":"`+catalog+`","branch":"main","head":"`+head+`","protected":`+p+`}`) } -// moveMain says main of repository moved, as the seat git says it, naming a head the bridge never takes (§11). -func moveMain(t *testing.T, b *bed, repository string) { +// move says branch of the catalog moved, as the seat git says it, naming a head the bridge never takes (§739). +func move(t *testing.T, b *bed, branch string) { t.Helper() - ev, _ := json.Marshal(git.BranchMovedEvent{Repository: repository, Branch: "main", Head: strings.Repeat("f", 40)}) + ev, _ := json.Marshal(git.BranchMovedEvent{Repository: catalog, Branch: branch, Head: strings.Repeat("f", 40)}) if _, err := b.js.Publish(b.ctx, git.SubjectBranchMoved, ev); err != nil { t.Fatal(err) } } -// TestBridgeWritesPullMessages starts the program the way the node does (its entry, run, with MESH_BROKER_FILE). -func TestBridgeWritesPullMessages(t *testing.T) { // 1235/AC2 - ctl, js, ctx, _ := startBridge(t, `{"pulls":[]}`) - defer branchDeletedCase(t, ctl.ConnectedUrl(), js, ctx) - - // pull.updated as the seat git says it (its contract's PullUpdatedEvent). - ev, _ := json.Marshal(git.PullUpdatedEvent{Repository: "novox/mesh-delivery", Number: 12, Title: "t", Base: "main", Branch: "feat/x", Head: head, - Change: &git.Change{Paths: []string{"modules/a/x.go"}, ModuleDirs: []string{"modules/a"}}}) - if _, err := js.Publish(ctx, git.SubjectPullUpdated, ev); err != nil { - t.Fatal(err) - } - - forge, err := js.Stream(ctx, "FORGE") - if err != nil { - t.Fatal(err) - } - var info *jetstream.StreamInfo - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - if info, err = forge.Info(ctx); err == nil && info.State.Msgs >= 2 { - break - } - } - // The open message the bridge writes at its start (ADR 0443 §5), and the event's message. - if info.State.Msgs != 2 { - t.Fatalf("FORGE holds %d messages within 20 s, want 2", info.State.Msgs) - } - raw, err := forge.GetLastMsgForSubject(ctx, "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-delivery.pull") - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(raw.Data) - if err != nil { - t.Fatal(err) - } - want := forgemsg.Forge{V: keys.Version, Kind: "pull", Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, - Action: "updated", Dirs: []string{"modules/a"}, DirsKnown: true, Manifests: map[string]string{"modules/a": "{}"}} - if !forgemsg.SameForge(f, want) { - t.Errorf("message = %+v, want %+v", f, want) - } - - // The event is acknowledged: the consumer owes nothing and has nothing pending. - cons, err := js.Consumer(ctx, "EVENTS", "n1_mesh-delivery-forge-bridge") - if err != nil { - t.Fatal(err) - } - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - ci, err := cons.Info(ctx) - if err == nil && ci.NumAckPending == 0 && ci.NumPending == 0 && ci.Delivered.Consumer >= 1 { - return - } - } - ci, _ := cons.Info(ctx) - t.Errorf("the event is not acknowledged: %+v", ci) -} - -// branchDeletedCase is DLV-FB1's case of the bridge's whole-module test (design 51): the seat git's forge.delete of a -// branch is a branch-deleted message on FORGE, and a forge.delete from another account than the seat's holder is refused -// by the bus. -func branchDeletedCase(t *testing.T, srv string, js jetstream.JetStream, ctx context.Context) { +// held waits, on a watch of the state heads, until it holds head for main of the catalog. +func held(t *testing.T, b *bed, head string) { t.Helper() - ev, _ := json.Marshal(git.ForgeDeleteEvent{Repository: "novox/mesh-sdk", Ref: "feat/x", RefType: "branch"}) - if _, err := js.Publish(ctx, git.SubjectForgeDelete, ev); err != nil { - t.Fatal(err) - } - forge, err := js.Stream(ctx, "FORGE") + kv, err := b.js.KeyValue(b.ctx, headsBucket(forgeBridgeModule())) if err != nil { t.Fatal(err) } - subject := "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-sdk.branch-deleted" - var raw *jetstream.RawStreamMsg - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - if raw, err = forge.GetLastMsgForSubject(ctx, subject); err == nil { - break - } - } - if err != nil || !strings.Contains(string(raw.Data), `"branch":"feat/x"`) { - t.Fatalf("no branch-deleted message on FORGE within 20 s: %v", err) - } - other, err := nats.Connect(srv, nats.UserInfo("n1.mesh-delivery-forge-bridge", "pw")) + w, err := kv.Watch(b.ctx, "branch.novox.mesh-catalog.main") if err != nil { t.Fatal(err) } - defer other.Close() - ojs, _ := jetstream.New(other) - octx, cancel := context.WithTimeout(ctx, 2*time.Second) - defer cancel() - if _, err := ojs.Publish(octx, git.SubjectForgeDelete, ev); err == nil { - t.Error("a forge.delete from the bridge's account was taken by the bus: only the seat git's holder may say it") - } -} - -const merge = "89abcdef0123456789abcdef0123456789abcdef" - -// openPull is one entry of the seat git's open-pulls answer. -func openPull(repo string, number int, branch, head string) string { - b, _ := json.Marshal(git.OpenPull{Pull: git.Pull{Repository: "novox/" + repo, Number: int64(number), Base: "main", Branch: branch, Head: head, State: "open"}, - Checks: map[string]git.Status{}, Required: []string{}}) - return string(b) -} - -// TestBridgeWritesMergedMessage: the stand-in seat git answers trees and file on the caller-named subjects. -func TestBridgeWritesMergedMessage(t *testing.T) { // 1236/AC4, 1448/AC5 - bed := startBed(t, `{"pulls":[]}`, nil) - js, ctx := bed.js, bed.ctx - // The stand-in forge's files are two real files of this repository (this module's module.json and go.sum, read from the - // working tree), in the seat git's file answer: the root has a manifest only, modules/a a manifest and go.sum. - manifest, err := os.ReadFile("../../module.json") - if err != nil { - t.Fatal(err) - } - sum, err := os.ReadFile("../../go.sum") - if err != nil { - t.Fatal(err) - } - bed.files(func(_, path, ref string) (string, bool) { - if ref != merge { - t.Errorf("the forge was asked for %s at %s, want the merge commit %s", path, ref, merge) - } - switch path { - case "module.json", "modules/a/module.json": - return string(manifest), true - case "modules/a/go.sum": - return string(sum), true - } - return "", false - }) - // design 47 G §11, §509, §714: main moved, read by the seat's branch, and the forge names #12 merged at its head. - landedOn(bed, "novox/mesh-delivery", 12, "feat/x", head, merge) - moveMain(t, bed, "novox/mesh-delivery") - - forge, err := js.Stream(ctx, "FORGE") - if err != nil { - t.Fatal(err) - } - var info *jetstream.StreamInfo - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - if info, err = forge.Info(ctx); err == nil && info.State.Msgs >= 2 { - break - } - } - // The open message the bridge writes at its start (ADR 0443 §5), and the event's message. - if info.State.Msgs != 2 { - t.Fatalf("FORGE holds %d messages within 20 s, want 2", info.State.Msgs) - } - raw, err := forge.GetLastMsgForSubject(ctx, "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox.mesh-delivery.merged") - if err != nil { - t.Fatal(err) - } - f, err := forgemsg.DecodeForge(raw.Data) - if err != nil { - t.Fatal(err) - } - want := forgemsg.Forge{V: keys.Version, Kind: "merged", Repository: "novox/mesh-delivery", Branch: "feat/x", Number: 12, Head: head, - Merge: merge, Base: "main", Root: "r0", Trees: map[string]string{"": "t0", "modules/a": "t1"}, - Manifests: map[string]string{"": string(manifest), "modules/a": string(manifest)}, - // No mesh package: only the indexer computes what a fingerprint takes (ADR 0593 §2). - Locks: map[string]map[string]string{"modules/a": {"go.sum": hex.EncodeToString(sha256Sum(sum))}}} - if !forgemsg.SameForge(f, want) { - t.Errorf("message = %+v, want %+v", f, want) - } - var trees []string - for _, c := range bed.calls() { - if strings.HasPrefix(c, "git.trees ") { - trees = append(trees, c) - } - } - in, _ := json.Marshal(git.TreesInput{Repository: "novox/mesh-delivery", Commit: merge}) - if len(trees) != 1 || trees[0] != "git.trees "+string(in) { - t.Errorf("the seat git was asked for trees %v, want once at the merge commit", trees) - } - cons, err := js.Consumer(ctx, git.StreamBranchMoved, "n1_mesh-delivery-forge-bridge") - if err != nil { - t.Fatal(err) - } - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - ci, err := cons.Info(ctx) - if err == nil && ci.NumAckPending == 0 && ci.NumPending == 0 && ci.Delivered.Consumer >= 1 { - return - } - } - ci, _ := cons.Info(ctx) - t.Errorf("the event is not acknowledged: %+v", ci) -} - -// TestBridgeSaysTheOpenPullsAtStart: the forge holds two open pull requests when the bridge starts; one message each is on -// FORGE, and the open message naming both after them (ADR 0443 §5). -func TestBridgeSaysTheOpenPullsAtStart(t *testing.T) { // 1237/AC1 - // The entries are the seat git's open-pulls answer (its contract's OpenPull). - _, js, ctx, _ := startBridge(t, `{"pulls":[ - `+openPull("mesh-delivery", 12, "feat/x", head)+`, - `+openPull("mesh-catalog", 300, "feat/x", strings.Repeat("a", 40))+`]}`) - forge, err := js.Stream(ctx, "FORGE") - if err != nil { - t.Fatal(err) - } - var info *jetstream.StreamInfo - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - if info, err = forge.Info(ctx); err == nil && info.State.Msgs >= 3 { - break - } - } - if info.State.Msgs != 3 { - t.Fatalf("FORGE holds %d messages within 20 s, want 3", info.State.Msgs) - } - for _, repo := range []string{"mesh-delivery", "mesh-catalog"} { - raw, err := forge.GetLastMsgForSubject(ctx, "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox."+repo+".pull") - if err != nil { - t.Fatal(err) - } - if f, err := forgemsg.DecodeForge(raw.Data); err != nil || f.Action != "updated" || f.DirsKnown || f.Branch != "feat/x" { - t.Errorf("%s: %+v err %v", repo, f, err) - } - } -} - -// TestBridgeExitsWhenTheOpenPullsCannotBeRead: the process manager starts it again. -func TestBridgeExitsWhenTheOpenPullsCannotBeRead(t *testing.T) { // 1237/AC3 - _, _, _, done := startBridge(t, `{"error":"the forge said 502","error-kind":"failed","pulls":[]}`) - select { - case err := <-done: - if err == nil || !strings.Contains(err.Error(), "open-pulls") || !strings.Contains(err.Error(), "the forge said 502") { - t.Errorf("run returned %v", err) - } - case <-time.After(10 * time.Second): - t.Fatal("the bridge did not exit") - } -} - -// TestBridgeReadsTheForgeAtStartAndAfterAReconnectAndHearsNoOlderEvent starts the bridge whole against a fake forge with two -// open pull requests, one of them with its head already kept in the bucket heads, and a bus whose EVENTS holds older pull events from -// before its consumer was made, under the permissions the controller composes for the bridge. At start it writes the one pull message that differs and the open message naming both; -// the bus connection closed, it reads the forge again and writes the open message alone, since every head is held now; -// for the older events it writes nothing (ADR 0443 §1, §5). -func TestBridgeReadsTheForgeAtStartAndAfterAReconnectAndHearsNoOlderEvent(t *testing.T) { // 1279/AC8 - h2 := strings.Repeat("a", 40) - pullSubject := func(repo string) string { - return "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox." + repo + ".pull" - } - openSubject := "mesh.stream.mesh-delivery-forge-bridge.event.forge.open" - b := startBed(t, `{"pulls":[`+openPull("mesh-delivery", 12, "feat/x", head)+`,`+openPull("mesh-catalog", 300, "feat/x", h2)+`]}`, - func(ctx context.Context, js jetstream.JetStream) { - // Older events: a pull request long closed and one long updated, from before the bridge's consumer. - for subject, ev := range map[string]any{ - git.SubjectPullUpdated: git.PullUpdatedEvent{Repository: "novox/mesh-old", Number: 5, Base: "main", Branch: "feat/old", Head: h2}, - git.SubjectPullClosed: git.PullClosedEvent{Repository: "novox/mesh-older", Number: 6, Base: "main", Branch: "feat/older", Head: h2}, - } { - raw, _ := json.Marshal(ev) - if _, err := js.Publish(ctx, subject, raw); err != nil { - t.Fatal(err) - } + defer w.Stop() + bound := time.After(20 * time.Second) + for { + select { + case e := <-w.Updates(): + if e != nil && string(e.Value()) == head { + return } - // What the bridge kept of an earlier write: the head of mesh-delivery#12. - kv, err := js.KeyValue(ctx, headsBucket(forgeBridgeModule())) - if err != nil { - t.Fatal(err) - } - if _, err := kv.PutString(ctx, "novox.mesh-delivery.12", head); err != nil { - t.Fatal(err) - } - }) - forge, err := b.js.Stream(b.ctx, "FORGE") - if err != nil { - t.Fatal(err) + case <-bound: + t.Fatalf("the state heads does not hold %s within 20 s", head) + } } - waitMsgs := func(want uint64) { +} + +// Design 47 H §739 (B4 AC1, the bridge's whole test): a start, a merge, an admitted push to an unprotected branch and a +// restart each give one head-moved on the stream forge, naming the head read through the seat git's verb branch and the +// head held before, start true at a start; a head heard twice, a restart at the head held and a branch not watched give +// none; the bridge asks no pull, tree or file. +func TestBridgeSaysOneHeadMovedPerMove(t *testing.T) { + const h1, h2, h3, h4, h5 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222", + "3333333333333333333333333333333333333333", "4444444444444444444444444444444444444444", "5555555555555555555555555555555555555555" + b := startBed(t, h1) + ch := heard(t, b) + subject := forgeSubject("forge.novox.mesh-catalog.main.head-moved") + said := func(what string, want forgemsg.HeadMoved) { t.Helper() - var info *jetstream.StreamInfo - for deadline := time.Now().Add(10 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - if info, err = forge.Info(b.ctx); err == nil && info.State.Msgs >= want { - break - } - } - time.Sleep(300 * time.Millisecond) // and nothing more arrives - if info, err = forge.Info(b.ctx); err != nil || info.State.Msgs != want { - t.Fatalf("FORGE holds %d messages (%v), want %d", info.State.Msgs, err, want) + h, err := forgemsg.DecodeHeadMoved(next(t, ch, subject)) + want.V, want.Repository, want.Branch = forgemsg.Version, catalog, "main" + if err != nil || h != want { + t.Errorf("%s: %+v %v, want %+v", what, h, err, want) } } - named := func(seq uint64) []forgemsg.OpenPull { - t.Helper() - raw, err := forge.GetMsg(b.ctx, seq) - if err != nil || raw.Subject != openSubject { - t.Fatalf("message %d: %v %v, want the open message", seq, raw, err) + said("the start", forgemsg.HeadMoved{Head: h1, Start: true}) + headAt(b, h2, true) + move(t, b, "main") + said("a merge", forgemsg.HeadMoved{Head: h2, Before: h1}) + move(t, b, "main") // the same head heard twice + move(t, b, "feat/47-H") // a branch not watched + headAt(b, h3, false) // an admitted push, the branch unprotected (ADR 0682 §13) + move(t, b, "main") + said("an admitted push to an unprotected branch", forgemsg.HeadMoved{Head: h3, Before: h2}) + held(t, b, h3) // the bridge keeps the head after it writes the message: a stop between says the older head before + b.restart(func() { headAt(b, h4, true) }) + said("a restart after a move", forgemsg.HeadMoved{Head: h4, Before: h3, Start: true}) + held(t, b, h4) + b.restart(func() {}) // at the head held: nothing + headAt(b, h5, true) + move(t, b, "main") + said("the next move, the first message after the restart at the head held", forgemsg.HeadMoved{Head: h5, Before: h4}) + for _, c := range b.calls() { + if strings.HasPrefix(c, "git.") && !strings.HasPrefix(c, "git.branch ") { + t.Errorf("the bridge asked %s; it asks the seat git nothing but branch", c) } - f, err := forgemsg.DecodeForge(raw.Data) - if err != nil { - t.Fatal(err) - } - return f.Open } - bothOpen := []forgemsg.OpenPull{{Repository: "novox/mesh-catalog", Number: 300}, {Repository: "novox/mesh-delivery", Number: 12}} - same := func(got []forgemsg.OpenPull) bool { - return len(got) == 2 && got[0] == bothOpen[0] && got[1] == bothOpen[1] - } - - // At start: the one pull message that differs (1), the open message naming both (2). - waitMsgs(2) - if raw, err := forge.GetMsg(b.ctx, 1); err != nil || raw.Subject != pullSubject("mesh-catalog") { - t.Fatalf("message 1 = %v %v, want mesh-catalog's pull message", raw, err) - } - if got := named(2); !same(got) { - t.Fatalf("the open message names %v, want %v", got, bothOpen) - } - - // The connection closes and reopens: the forge is read again, every head is held, the open message alone follows. - conns, err := b.srv.Connz(&server.ConnzOptions{}) + heads, err := b.js.KeyValue(b.ctx, headsBucket(forgeBridgeModule())) if err != nil { t.Fatal(err) } - closed := 0 - for _, c := range conns.Conns { - if c.Name == "n1.mesh-delivery-forge-bridge" { - if err := b.srv.DisconnectClientByID(c.Cid); err != nil { - t.Fatal(err) - } - closed++ - } - } - if closed != 1 { - t.Fatalf("%d connections of the bridge found", closed) - } - waitMsgs(3) - if got := named(3); !same(got) { - t.Fatalf("after the reconnect the open message names %v, want %v", got, bothOpen) - } - - // For the older events nothing was written. - for _, repo := range []string{"mesh-old", "mesh-older"} { - if raw, err := forge.GetLastMsgForSubject(b.ctx, pullSubject(repo)); err == nil { - t.Errorf("a message for %s's older event: %+v", repo, raw) - } + if e, err := heads.Get(b.ctx, "branch.novox.mesh-catalog.main"); err != nil || string(e.Value()) != h5 { + t.Errorf("the state heads holds %v (%v), want %s", e, err, h5) } } -// heard is every message published under the bridge's stream subjects from now, by subject. func heard(t *testing.T, b *bed) <-chan *nats.Msg { t.Helper() ch := make(chan *nats.Msg, 64) @@ -787,37 +435,8 @@ func refusedRead(t *testing.T, b *bed, bucket string) { // Acceptance 49: the forge bridge sets the group on each member's merged message and says the group's end once, after the // last member's, from the seat mesh-delivery's verb groups; its account reads no state of the gate's. -func TestBridgeSaysAGroupFromTheSeatsGroups(t *testing.T) { // 1585, ADR 0633 §4 - b := startBed(t, `{"pulls":[]}`, nil) - headB := strings.Repeat("b", 40) - mergeB := strings.Repeat("e", 40) - groups, _ := json.Marshal(seat.GroupsAnswer{Groups: []seat.Group{{ID: "feat/x", State: "merging", Members: []seat.Member{ - {Repository: "novox/mesh-delivery", Number: 12, Head: head, State: "merged", Base: "main"}, {Repository: "novox/mesh-sdk", Number: 4, Head: headB, State: "merging", Base: "main"}}}}}) - b.answer("mesh-delivery.groups", string(groups)) - ch := heard(t, b) - landedOn(b, "novox/mesh-delivery", 12, "feat/x", head, merge) - landedOn(b, "novox/mesh-sdk", 4, "feat/x", headB, mergeB) - for _, m := range []git.PullMergedEvent{{Repository: "novox/mesh-delivery"}, {Repository: "novox/mesh-sdk"}} { - moveMain(t, b, m.Repository) - repo := strings.TrimPrefix(m.Repository, "novox/") - f, err := forgemsg.DecodeForge(next(t, ch, "mesh.stream.mesh-delivery-forge-bridge.event.forge.novox."+repo+".merged")) - if err != nil || f.Group != "feat/x" || len(f.Members) != 2 || f.Members[1].Number != 4 { - t.Fatalf("%s's merged message: %+v %v, want the group feat/x with both members", repo, f, err) - } - } - end, err := forgemsg.DecodeForgeGroupEnd(next(t, ch, forgeSubject(forgemsg.ForgeGroupEndEvent))) - if err != nil || end.Group != "feat/x" || end.Base != "main" || len(end.Members) != 2 || end.Members[0].Merge != merge || end.Members[1].Merge != mergeB { - t.Errorf("the group's end: %+v %v", end, err) - } - refusedRead(t, b, "mesh-delivery-gate_merges") -} - -// Acceptance 53 (design 47 *What the gate owes the forge*): an owed act said on a seat's own stream owed is performed through -// the seat git and its outcome said as owed.ended; said twice it is performed once; one it cannot read is said undecodable; -// one said while the bridge is stopped is performed once after its restart; bridge_owed_again's ask is answered by the -// process; and its account reads neither the gate's nor the checker's state. func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { - b := startBed(t, `{"pulls":[]}`, nil) + b := startBed(t, strings.Repeat("1", 40)) ch := heard(t, b) ended := func() forgemsg.OwedEnded { t.Helper() @@ -836,7 +455,7 @@ func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { } return n } - gateOwed := gitfixture.Seat(t, seat.Seat, "events", "owed is said, a merge", "event:owed")[0] + gateOwed := gitfixture.Seat(t, seat.Seat, "events", "owed is said, a status", "event:owed")[0] subject := seat.SubjectOwed("novox~mesh-sdk", "178") for range 2 { if _, err := b.js.Publish(b.ctx, subject, gateOwed); err != nil { @@ -844,7 +463,7 @@ func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { } } if e := ended(); e.Outcome != forgemsg.OwedPerformed || e.Of != seat.Seat { - t.Errorf("the gate's merge: %+v, want performed", e) + t.Errorf("the gate's status: %+v, want performed", e) } if _, err := b.js.Publish(b.ctx, subject, []byte("{")); err != nil { t.Fatal(err) @@ -852,21 +471,24 @@ func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { if e := ended(); e.Outcome != forgemsg.OwedUndecodable { t.Errorf("an act it cannot read: %+v, want undecodable", e) } - if n := count("git.merge-pull"); n != 1 { + if n := count("git.status"); n != 1 { t.Errorf("an act said twice was performed %d times", n) } // Said while the bridge is stopped: performed once after its restart. - checkerOwed := gitfixture.Seat(t, checker.Seat, "events", "owed is said", "event:owed")[0] + other := map[string]any{} + _ = json.Unmarshal(gateOwed, &other) + other["id"] = "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/other" + otherOwed, _ := json.Marshal(other) b.restart(func() { - if _, err := b.js.Publish(b.ctx, checker.SubjectOwed("novox~mesh-sdk", "178"), checkerOwed); err != nil { + if _, err := b.js.Publish(b.ctx, subject, otherOwed); err != nil { t.Fatal(err) } }) - if e := ended(); e.Of != checker.Seat || e.Outcome != forgemsg.OwedPerformed { - t.Errorf("the checker's status after the restart: %+v, want performed", e) + if e := ended(); e.Of != seat.Seat || e.Outcome != forgemsg.OwedPerformed { + t.Errorf("the gate's status after the restart: %+v, want performed", e) } - if n := count("git.status"); n != 1 { - t.Errorf("the checker's status was performed %d times, want once", n) + if n := count("git.status"); n != 2 { + t.Errorf("the statuses were performed %d times, want twice", n) } // bridge_owed_again asks through the state owed-asks; the process performs the act again and answers there. var g struct { @@ -898,8 +520,8 @@ func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { } if a, err := groupkeys.DecodeOwedAsk(e.Value()); err == nil && a.Done() { answered = true - if a.Outcome != forgemsg.OwedPerformed || count("git.merge-pull") != 2 { - t.Errorf("bridge_owed_again: %+v, merge-pull asked %d times; want performed again", a, count("git.merge-pull")) + if a.Outcome != forgemsg.OwedPerformed || count("git.status") != 3 { + t.Errorf("bridge_owed_again: %+v, status asked %d times; want performed again", a, count("git.status")) } } case <-bound: @@ -907,52 +529,4 @@ func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { } } refusedRead(t, b, "mesh-delivery-gate_owed") - refusedRead(t, b, "mesh-delivery-checker_owed") -} - -func sha256Sum(b []byte) []byte { s := sha256.Sum256(b); return s[:] } - -// Design 47 G §17, §383, §529, A-251 (FB2): the bridge started whole against the real bus says a move of a branch whose protection -// was removed as the finding branch-unprotected, into its bound state findings and its finding stream, and writes no message. -func TestBridgeSaysAnUnprotectedBranchAsAFinding(t *testing.T) { - b := startBed(t, `{"pulls":[]}`, nil) - b.answer("git.branch novox/mesh-delivery", `{"repository":"novox/mesh-delivery","branch":"main","head":"`+merge+`","protected":false}`) - moveMain(t, b, "novox/mesh-delivery") - kv, err := b.js.KeyValue(b.ctx, boundFindings) - if err != nil { - t.Fatal(err) - } - var e jetstream.KeyValueEntry - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - if e, err = kv.Get(b.ctx, "merge.novox/mesh-delivery/main.branch-unprotected"); err == nil { - break - } - } - if err != nil { - t.Fatalf("the finding is not in the bound state findings: %v", err) - } - var f struct{ Kind, Scope, ID, Observer string } - if err := json.Unmarshal(e.Value(), &f); err != nil || f.Kind != "branch-unprotected" || f.Observer != "mesh-delivery-forge-bridge" { - t.Errorf("the finding = %s %v", e.Value(), err) - } - // A-274: the finding is said under the bridge's binding finding-events, never on the old stream. - events, err := b.js.Stream(b.ctx, boundFindingEvents) - if err != nil { - t.Fatal(err) - } - for deadline := time.Now().Add(20 * time.Second); ; time.Sleep(50 * time.Millisecond) { - if _, err = events.GetLastMsgForSubject(b.ctx, boundFindingEventsSubject+".finding-written.n1"); err == nil || time.Now().After(deadline) { - break - } - } - if err != nil { - t.Errorf("no finding-written under the binding finding-events: %v", err) - } - forge, err := b.js.Stream(b.ctx, "FORGE") - if err != nil { - t.Fatal(err) - } - if info, err := forge.Info(b.ctx); err != nil || info.State.Msgs != 1 { // the open message of its start only - t.Errorf("FORGE holds %+v %v: an unprotected branch's move writes no message", info, err) - } } diff --git a/modules/mesh-delivery-forge-bridge/manifest_test.go b/modules/mesh-delivery-forge-bridge/manifest_test.go index 9760f1bf..6420c530 100644 --- a/modules/mesh-delivery-forge-bridge/manifest_test.go +++ b/modules/mesh-delivery-forge-bridge/manifest_test.go @@ -131,8 +131,9 @@ func TestManifestDeclarations(t *testing.T) { // 1235/AC1 if want := []kept{{Name: "performed", Storage: "key-value", Template: "state", Options: map[string]any{"history": float64(1), "ttl-seconds": float64(604800)}}}; !reflect.DeepEqual(m.Requires, want) { t.Errorf("requires = %+v, want performed alone as %+v", m.Requires, want) } - // bridge_tags reads a package's tags for the builder's floor (design 51); the owed tools ask the bridge through owed-asks. - if want := []string{"bridge_owed", "bridge_owed_again", "bridge_owed_drop", "bridge_tags"}; !reflect.DeepEqual(sorted(m.Tools), want) { + // bridge_tags reads a package's tags for the builder's floor (design 51); bridge_heads reads the state heads (design 47 + // H-A-85); the owed tools ask the bridge through owed-asks. + if want := []string{"bridge_heads", "bridge_owed", "bridge_owed_again", "bridge_owed_drop", "bridge_tags"}; !reflect.DeepEqual(sorted(m.Tools), want) { t.Errorf("tools = %v, want %v", m.Tools, want) } // Design 47 H §764 (B3 AC1): the earlier model's names are in no file of the bridge but tests asserting their absence. diff --git a/modules/mesh-delivery-forge-bridge/module.json b/modules/mesh-delivery-forge-bridge/module.json index d4243381..c29a645c 100644 --- a/modules/mesh-delivery-forge-bridge/module.json +++ b/modules/mesh-delivery-forge-bridge/module.json @@ -19,6 +19,7 @@ ], "tools": [ "bridge_tags", + "bridge_heads", "bridge_owed", "bridge_owed_again", "bridge_owed_drop" -- 2.54.0 From f79c0a7b784ceea9438af676b9fcda8a808b1011 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:39:29 +0100 Subject: [PATCH 020/104] C3b: the seat mesh-delivery's owed acts name no merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bridge performs no merge since the merge call (design 47 H §764), so the owed act merge (OwedActMerge) leaves the seat's definition, its fixture and the generated contracts; the bridge's tests no longer read a merge fixture to refuse. A row of the client's test reads the definition's act enum and fails while merge is in it. Builds: design 47 H §764 (the forge bridge: the merge act of a switched key); lead answer H-A-91 (3) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../clients/meshdeliveryclient/client_test.go | 22 +++++++++++++++++++ .../go/seats/meshdelivery/contract.go | 3 +-- .../go/seats/meshdelivery/contract_test.go | 2 -- .../seats/mesh-delivery/fixtures/events.json | 15 ------------- .../seats/mesh-delivery/seat.json | 3 +-- .../ts/seats/meshdelivery/index.d.ts | 4 ++-- .../mesh-delivery-forge-bridge/gate_test.go | 4 +--- .../internal/bridge/owed_test.go | 3 +-- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go index a8f0e9e1..4086eefe 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go @@ -1,6 +1,9 @@ package meshdeliveryclient import ( + "encoding/json" + "os" + "reflect" "strings" "testing" @@ -85,4 +88,23 @@ func TestTheAsksAndOwedActsKeepTheirFormsAndRules(t *testing.T) { t.Errorf("%s: CheckOwed = %v, want %q", name, err, c.says) } } + + // Design 47 H §764 (the forge bridge: the merge act of a switched key), H-A-91 (3): the seat's owed acts name no merge. + raw, err := os.ReadFile("../../../seats/mesh-delivery/seat.json") + if err != nil { + t.Fatal(err) + } + var def struct { + Defs map[string]struct { + Properties map[string]struct { + Enum []string `json:"enum"` + } `json:"properties"` + } `json:"defs"` + } + if err := json.Unmarshal(raw, &def); err != nil { + t.Fatal(err) + } + if acts, want := def.Defs["Owed"].Properties["act"].Enum, []string{"status", "view", "comment", "note"}; !reflect.DeepEqual(acts, want) { + t.Errorf("the owed acts are %v, want %v", acts, want) + } } diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go index bd4badad..d393057a 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go @@ -230,7 +230,7 @@ type Fill struct { // Owed is one act the gate owes the forge, said once under its id and safe to repeat at the forge (design 47 *What the gate owes the forge*); the forge bridge performs it through the seat git's verb of the same act. type Owed struct { - // the act: merge (the seat git's merge-pull), status, view, comment or note + // the act: status, view, comment or note Act string `json:"act"` // the operator's ask that approved the heads, for a merge Ask string `json:"ask,omitempty"` @@ -264,7 +264,6 @@ type Owed struct { // The values of Owed's act. const ( - OwedActMerge = "merge" OwedActStatus = "status" OwedActView = "view" OwedActComment = "comment" diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go index 364734a0..ecf2ddf3 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go @@ -17,8 +17,6 @@ func TestFixtures(t *testing.T) { decode func([]byte) (any, error) subjectIs *regexp.Regexp }{ - {name: "owed is said, a merge", subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}", wire: "{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}", - decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "owed is said, a status", subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}", wire: "{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"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\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "record-opened is said", subject: "mesh.seat.mesh-delivery.event.record-opened.0123456789abcdef", given: "{\"at\":\"2026-11-20T02:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", wire: "{\"at\":\"2026-11-20T02:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json index 03bf11b8..1488efd3 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json @@ -1,19 +1,4 @@ [ - { - "name": "owed is said, a merge", - "of": "event:owed", - "subject": "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", - "given": { - "id": "merge.feat=47-G.0123456789ab.novox/mesh-sdk#178", - "act": "merge", - "repository": "novox/mesh-sdk", - "number": 178, - "head": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "group": "feat/47-G", - "ask": "merge.feat=47-G.0123456789ab", - "said": "2026-11-09T20:00:00Z" - } - }, { "name": "owed is said, a status", "of": "event:owed", diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json index 5546f304..744014a5 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json @@ -553,13 +553,12 @@ "act": { "type": "string", "enum": [ - "merge", "status", "view", "comment", "note" ], - "description": "the act: merge (the seat git's merge-pull), status, view, comment or note" + "description": "the act: status, view, comment or note" }, "repository": { "type": "string", diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts index 11e963b8..6131f639 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts @@ -90,8 +90,8 @@ export interface Fill { /** one act the gate owes the forge, said once under its id and safe to repeat at the forge (design 47 *What the gate owes the forge*); the forge bridge performs it through the seat git's verb of the same act */ export interface Owed { - /** the act: merge (the seat git's merge-pull), status, view, comment or note */ - "act": "merge" | "status" | "view" | "comment" | "note"; + /** the act: status, view, comment or note */ + "act": "status" | "view" | "comment" | "note"; /** the operator's ask that approved the heads, for a merge */ "ask"?: string; /** the commit a status or a note line is on; the head when absent */ diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go index db0c6332..4b6c5c89 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go @@ -59,8 +59,7 @@ func newOwing(f *seatFake) (*owing, *fakePub, memPerformed) { } // Design 47 *What the gate owes the forge*: an owed act is the seat git's verb under its id, its outcome said as -// owed.ended on the stream forge before it is kept in performed, an act it cannot read said undecodable (a merge among -// them: the bridge performs no merge, design 47 H §764). +// owed.ended on the stream forge before it is kept in performed, an act it cannot read said undecodable. func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { t.Run("the names are the manifest's", theNamesAreTheManifests) t.Run("performed is opened by its binding", performedIsOpenedByItsBinding) @@ -82,7 +81,6 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { map[string]json.RawMessage{"seat:git.status": answer("status", "status answers an error, never none")}, nil, "seat:git.status", forgemsg.OwedRefused, true, ""}, {"a status not answered", seat.Seat, gate("owed is said, a status"), nil, nil, "seat:git.status", forgemsg.OwedCouldNotBePerformed, true, ""}, - {"a merge, which the bridge does not perform", seat.Seat, gate("owed is said, a merge"), nil, nil, "", forgemsg.OwedUndecodable, true, ""}, {"an act it cannot read", seat.Seat, []byte(`{`), nil, nil, "", forgemsg.OwedUndecodable, false, ""}, {"a seat that says no owed act", "mesh-delivery-checker", gate("owed is said, a status"), nil, nil, "", forgemsg.OwedUndecodable, false, ""}, {"the stream forge refusing the outcome", seat.Seat, gate("owed is said, a status"), statusOK, errors.New("no responders"), diff --git a/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go b/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go index 50fd163d..e59b80e5 100644 --- a/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go +++ b/modules/mesh-delivery-forge-bridge/internal/bridge/owed_test.go @@ -37,7 +37,6 @@ func TestAnOwedEventIsTheSeatGitsVerbAndItsAnswerOneOutcome(t *testing.T) { input any bad string }{ - {"a merge, which the bridge no longer performs (design 47 H §764)", GateOwed, gate("owed is said, a merge"), "", nil, "none the seat git"}, {"a status on the head", GateOwed, gate("owed is said, a status"), "status", git.StatusInput{ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate", Repository: "novox/mesh-sdk", Commit: a40, Context: "mesh/merge-gate", State: "pending", Description: "waits for the operator's Approve", Target: "https://forge.test/x"}, ""}, {"a view", GateOwed, edit(edit(gate("owed is said, a status"), "act", "view"), "text", "the view"), "view", @@ -47,7 +46,7 @@ func TestAnOwedEventIsTheSeatGitsVerbAndItsAnswerOneOutcome(t *testing.T) { {"a note line on its commit", GateOwed, edit(edit(edit(gate("owed is said, a status"), "act", "note"), "line", "a line"), "commit", strings.Repeat("c", 40)), "note", git.NoteInput{ID: "status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate", Repository: "novox/mesh-sdk", Commit: strings.Repeat("c", 40), Line: "a line"}, ""}, {"not json", GateOwed, []byte("{"), "", nil, "not json"}, - {"no id", GateOwed, edit(gate("owed is said, a merge"), "id", nil), "", nil, "no id"}, + {"no id", GateOwed, edit(gate("owed is said, a status"), "id", nil), "", nil, "no id"}, {"a short head", GateOwed, edit(gate("owed is said, a status"), "head", "abc"), "", nil, "40 hex"}, {"a comment on no pull request", GateOwed, edit(edit(gate("owed is said, a status"), "act", "comment"), "number", 0), "", nil, "no pull request"}, {"an act of no kind", GateOwed, edit(gate("owed is said, a status"), "act", "label"), "", nil, "none the seat git"}, -- 2.54.0 From be741a7a8ff17ef9be6ed9a9f1613af5d0777b11 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:40:18 +0100 Subject: [PATCH 021/104] C1c: a catalog revision carries its movers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat mesh-catalog's CatalogRevision gains movers, the take-in's entries ({module, commit, fingerprint, repository}), so a redelivered source-moved whose revision is already kept says take-in.taken again from them, recomputing nothing. The branch revision's fixture names one mover; the generated fixture test fails without the field. Builds: design 47 H §743; lead answer H-A-92 (hq 8c0b04e3) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshcatalog/contract.go | 2 ++ .../go/seats/meshcatalog/contract_test.go | 2 +- .../seats/mesh-catalog/fixtures/states.json | 10 +++++++++- .../seats/mesh-catalog/seat.json | 7 +++++++ .../ts/seats/meshcatalog/index.d.ts | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index da3b1a43..d264f4cf 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -723,6 +723,8 @@ type CatalogRevision struct { Heads string `json:"heads,omitempty"` // trunk or candidate Kind string `json:"kind"` + // the movers of the take-in that wrote it, so a redelivered source-moved whose revision is kept says take-in.taken again from them, recomputing nothing (design 47 H §743, H-A-92); absent for one with no mover + Movers []TakeInEntry `json:"movers,omitempty"` // the catalog graph revision's number, counted by its holder Revision int64 `json:"revision"` // the source revision it was taken in from; for a candidate, the source revision its heads are merged onto 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 e45c4441..5e372012 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go @@ -59,7 +59,7 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v ModulesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "the module verb (captured: xclip)", subject: "", given: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}", wire: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}", decode: func(b []byte) (any, error) { var v ModuleAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", + {name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", decode: func(b []byte) (any, error) { var v CatalogRevisionsByBranchRevisionValue err := json.Unmarshal(b, &v) 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 13c0a262..b4fd8e72 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json @@ -200,7 +200,15 @@ "digest": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" } ], - "branch": "main" + "branch": "main", + "movers": [ + { + "module": "xclip", + "commit": "f469eb387a3015569d9b16c66ed418e9dd098f64", + "fingerprint": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "repository": "novox/mesh-catalog" + } + ] } }, { diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index 3c0efb8e..2919b314 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -1935,6 +1935,13 @@ "branch": { "type": "string", "description": "the watched branch the revision is of" + }, + "movers": { + "type": "array", + "items": { + "$ref": "#/defs/TakeInEntry" + }, + "description": "the movers of the take-in that wrote it, so a redelivered source-moved whose revision is kept says take-in.taken again from them, recomputing nothing (design 47 H §743, H-A-92); absent for one with no mover" } }, "required": [ 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 565cd644..339b02e8 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -285,6 +285,8 @@ export interface CatalogRevision { "heads"?: string; /** trunk or candidate */ "kind": string; + /** the movers of the take-in that wrote it, so a redelivered source-moved whose revision is kept says take-in.taken again from them, recomputing nothing (design 47 H §743, H-A-92); absent for one with no mover */ + "movers"?: TakeInEntry[]; /** the catalog graph revision's number, counted by its holder */ "revision": number; /** the source revision it was taken in from; for a candidate, the source revision its heads are merged onto */ -- 2.54.0 From 969caea37f961e3d24e92c3755bbcfc9ab9d25a6 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:48:23 +0100 Subject: [PATCH 022/104] C3c: the seat mesh-delivery's owed acts keep no merge's ask or group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Owed definition's fields ask and group were kept only for a merge, and the owed act merge went in C3b; nothing reads them, so they leave the definition and the generated contracts. A row of the client's test reads the definition and fails while either field is in it. Builds: design 47 H §764 (the forge bridge: the merge act of a switched key); lead answer H-A-95 (2) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/clients/meshdeliveryclient/client_test.go | 6 ++++++ .../go/seats/meshdelivery/contract.go | 4 ---- .../mesh-delivery-contracts/seats/mesh-delivery/seat.json | 8 -------- .../ts/seats/meshdelivery/index.d.ts | 4 ---- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go index 4086eefe..adb3af7b 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/client_test.go @@ -107,4 +107,10 @@ func TestTheAsksAndOwedActsKeepTheirFormsAndRules(t *testing.T) { if acts, want := def.Defs["Owed"].Properties["act"].Enum, []string{"status", "view", "comment", "note"}; !reflect.DeepEqual(acts, want) { t.Errorf("the owed acts are %v, want %v", acts, want) } + // H-A-95 (2): the fields kept for a merge go with the act. + for _, field := range []string{"ask", "group"} { + if _, ok := def.Defs["Owed"].Properties[field]; ok { + t.Errorf("an owed act still has the field %s, kept only for a merge", field) + } + } } diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go index d393057a..90390053 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go @@ -232,16 +232,12 @@ type Fill struct { type Owed struct { // the act: status, view, comment or note Act string `json:"act"` - // the operator's ask that approved the heads, for a merge - Ask string `json:"ask,omitempty"` // the commit a status or a note line is on; the head when absent Commit string `json:"commit,omitempty"` // a status: its context, such as mesh/merge-gate Context string `json:"context,omitempty"` // a status: what it says Description string `json:"description,omitempty"` - // the delivery group the pull request is a member of, for a merge - Group string `json:"group,omitempty"` // the pull request's head the act is for Head string `json:"head"` // the act's id, the same each time it is said again; a comment and a note line carry it, so the forge holds it once diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json index 744014a5..015f9657 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json @@ -574,14 +574,6 @@ "description": "the pull request's head the act is for", "pattern": "^[0-9a-f]{40}$" }, - "group": { - "type": "string", - "description": "the delivery group the pull request is a member of, for a merge" - }, - "ask": { - "type": "string", - "description": "the operator's ask that approved the heads, for a merge" - }, "commit": { "type": "string", "description": "the commit a status or a note line is on; the head when absent", diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts index 6131f639..242866c4 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts @@ -92,16 +92,12 @@ export interface Fill { export interface Owed { /** the act: status, view, comment or note */ "act": "status" | "view" | "comment" | "note"; - /** the operator's ask that approved the heads, for a merge */ - "ask"?: string; /** the commit a status or a note line is on; the head when absent */ "commit"?: string; /** a status: its context, such as mesh/merge-gate */ "context"?: string; /** a status: what it says */ "description"?: string; - /** the delivery group the pull request is a member of, for a merge */ - "group"?: string; /** the pull request's head the act is for */ "head": string; /** the act's id, the same each time it is said again; a comment and a note line carry it, so the forge holds it once */ -- 2.54.0 From c94e8564e6dd20e43560ed0f6a38abd847a70b44 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:49:06 +0100 Subject: [PATCH 023/104] C-R3: the runner's queue keeps the pipelines running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat mesh-pipeline-runner's state queue gains the key form running., value {pipeline}, written when a pipeline is placed and deleted at its end, its cancel or its approval wait, so pipelines-at-once is judged against the running keys alone. A fixture row reads the new form; the generator refused it before the form was defined. Builds: design 47 H §748; lead answer H-A-96 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshpipelinerunner/contract.go | 41 +++++++++++++++++++ .../seats/meshpipelinerunner/contract_test.go | 6 +++ .../mesh-pipeline-runner/fixtures/states.json | 7 ++++ .../seats/mesh-pipeline-runner/seat.json | 18 +++++++- .../ts/seats/meshpipelinerunner/index.d.ts | 12 ++++++ .../ts/seats/meshpipelinerunner/index.js | 17 ++++++++ 6 files changed, 100 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 96e4131c..a1a2a21f 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -340,6 +340,41 @@ func DecodeQueueByWaitingSequenceValue(raw []byte) (QueueByWaitingSequenceValue, return v, nil } +// QueueByRunningPipelineKey is the key of one value of the state queue under the form "running.". +func QueueByRunningPipelineKey(pipeline string) string { return "running." + pipeline } + +// ParseQueueByRunningPipelineKey reads the parts of a key of the form "running.", in the order of the form; the last result is false for a key of another form. +func ParseQueueByRunningPipelineKey(key string) (string, bool) { + rest := key + if !strings.HasPrefix(rest, "running.") { + return "", false + } + rest = rest[8:] + if rest == "" { + return "", false + } + v1 := rest + rest = "" + if rest != "" { + return "", false + } + return v1, true +} + +// DecodeQueueByRunningPipelineValue reads one value of the state queue under the form "running.", refusing a field QueueByRunningPipelineValue does not know and any text after the value. +func DecodeQueueByRunningPipelineValue(raw []byte) (QueueByRunningPipelineValue, error) { + var v QueueByRunningPipelineValue + 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 } @@ -1259,6 +1294,12 @@ type QueueByQueueNextValue = int64 // QueueByWaitingSequenceValue is one value of the state queue under the key waiting.. type QueueByWaitingSequenceValue = Waiting +// QueueByRunningPipelineValue is one value of the state queue under the key running.. +type QueueByRunningPipelineValue struct { + // the pipeline's key, as the key names it + Pipeline string `json:"pipeline"` +} + // KeptByLevelDigestValue is one value of the state kept under the key .. type KeptByLevelDigestValue = KeptResult diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index d4d39dba..d8012f6e 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -65,6 +65,12 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, + {name: "a running pipeline in the queue", subject: "", given: "{\"pipeline\":\"main.3589\"}", wire: "{\"pipeline\":\"main.3589\"}", + decode: func(b []byte) (any, error) { + var v QueueByRunningPipelineValue + err := json.Unmarshal(b, &v) + return v, err + }, subjectIs: nil}, {name: "a pipeline waiting its turn, its seq given", subject: "", given: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"v\":1}", decode: func(b []byte) (any, error) { var v PipelinesByBranchSourceValue diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json index 18285de8..8a189b70 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json @@ -191,6 +191,13 @@ "pipeline": "main.3590" } }, + { + "name": "a running pipeline in the queue", + "of": "state:queue/running.", + "given": { + "pipeline": "main.3589" + } + }, { "name": "a pipeline waiting its turn, its seq given", "of": "state:pipelines/.", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 68879ae5..a2ba9896 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -755,7 +755,7 @@ "name": "queue", "template": "state", "history": 1, - "description": "the pipelines waiting their turn under pipelines-at-once, the lowest sequence read first by key order (design 47 H §748, H-A-36, H-A-72)", + "description": "the pipelines waiting their turn under pipelines-at-once, the lowest sequence read first by key order, and the pipelines running (design 47 H §748, H-A-36, H-A-72, H-A-96)", "key-forms": [ { "key": "queue.next", @@ -771,6 +771,22 @@ "$ref": "#/defs/Waiting" }, "description": "a waiting pipeline, its sequence 20 digits" + }, + { + "key": "running.", + "value": { + "type": "object", + "properties": { + "pipeline": { + "type": "string", + "description": "the pipeline's key, as the key names it" + } + }, + "required": [ + "pipeline" + ] + }, + "description": "a running pipeline, written by compare-and-set when it is placed and deleted at its end, its cancel or its approval wait; pipelines-at-once is judged against these keys alone (H-A-96)" } ] }, diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index ec8bf096..3fef19f9 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -123,6 +123,12 @@ export declare function queueByWaitingSequenceKey(sequence: string): string; /** The parts of a key of the form "waiting.", or undefined for a key of another form. */ export declare function parseQueueByWaitingSequenceKey(_key: string): { sequence: string } | undefined; +/** The key of one value of the state queue under the form "running.". */ +export declare function queueByRunningPipelineKey(pipeline: string): string; + +/** The parts of a key of the form "running.", or undefined for a key of another form. */ +export declare function parseQueueByRunningPipelineKey(_key: string): { pipeline: string } | undefined; + /** The key of one value of the state kept under the form ".". */ export declare function keptByLevelDigestKey(level: string, digest: string): string; @@ -769,6 +775,12 @@ export type QueueByQueueNextValue = number; /** is one value of the state queue under the key waiting.. */ export type QueueByWaitingSequenceValue = Waiting; +/** is one value of the state queue under the key running.. */ +export interface QueueByRunningPipelineValue { + /** the pipeline's key, as the key names it */ + "pipeline": string; +} + /** is one value of the state kept under the key .. */ export type KeptByLevelDigestValue = KeptResult; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js index e8e03364..721b6839 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js @@ -203,6 +203,23 @@ export function parseQueueByWaitingSequenceKey(_key) { return { sequence }; } +/** The key of one value of the state queue under the form "running.". */ +export function queueByRunningPipelineKey(pipeline) { + return "running." + pipeline; +} + +/** The parts of a key of the form "running.", or undefined for a key of another form. */ +export function parseQueueByRunningPipelineKey(_key) { + let _rest = _key; + if (!_rest.startsWith("running.")) return undefined; + _rest = _rest.slice(8); + if (_rest === "") return undefined; + const pipeline = _rest; + _rest = ""; + if (_rest !== "") return undefined; + return { pipeline }; +} + /** The key of one value of the state kept under the form ".". */ export function keptByLevelDigestKey(level, digest) { return level + "." + digest; -- 2.54.0 From 89e0926feb4015d0af59df49fc6df52ad844b7c8 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:52:48 +0100 Subject: [PATCH 024/104] C-R4: the runner's rerun, accept and ask-again name the mover's module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pipeline of several movers is never ambiguous: the seat mesh-pipeline-runner's verbs rerun, accept and ask-again gain the optional input module, the mover's; a call naming none on a pipeline of one mover is taken as that mover. Fixture rows of each verb's input name a module and failed to read back before the field was defined. Builds: design 47 H §746; lead answer H-A-101 (1) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshpipelinerunner/contract.go | 6 ++++ .../seats/meshpipelinerunner/contract_test.go | 6 ++++ .../mesh-pipeline-runner/fixtures/verbs.json | 29 +++++++++++++++++++ .../seats/mesh-pipeline-runner/seat.json | 12 ++++++++ .../ts/seats/meshpipelinerunner/index.d.ts | 6 ++++ 5 files changed, 59 insertions(+) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index a1a2a21f..f69231f0 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -1120,6 +1120,8 @@ type ReviewAnswer struct { // RerunInput is what rerun takes. type RerunInput struct { Artifact string `json:"artifact,omitempty"` + // the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) + Module string `json:"module,omitempty"` // the pipeline's key Pipeline string `json:"pipeline"` Step string `json:"step"` @@ -1148,6 +1150,8 @@ type RerunAnswer struct { // AcceptInput is what accept takes. type AcceptInput struct { Artifact string `json:"artifact,omitempty"` + // the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) + Module string `json:"module,omitempty"` // the pipeline's key Pipeline string `json:"pipeline"` Step string `json:"step"` @@ -1200,6 +1204,8 @@ type PlaceAnswer struct { // AskAgainInput is what ask-again takes. type AskAgainInput struct { + // the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) + Module string `json:"module,omitempty"` // the pipeline's key Pipeline string `json:"pipeline"` // why, written with the caller the runtime proves in the hand-act log diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index d8012f6e..04ae77cc 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -93,6 +93,12 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v ReviewAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "show answers a pipeline with its log and fill", subject: "", given: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.3589\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", wire: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.3589\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", decode: func(b []byte) (any, error) { var v ShowAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "rerun names the mover's module", subject: "", given: "{\"module\":\"nats\",\"pipeline\":\"main.3589\",\"step\":\"unit\",\"why\":\"a flaky test, issue 1966\"}", wire: "{\"module\":\"nats\",\"pipeline\":\"main.3589\",\"step\":\"unit\",\"why\":\"a flaky test, issue 1966\"}", + decode: func(b []byte) (any, error) { var v RerunInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "accept names the mover's module", subject: "", given: "{\"module\":\"nats\",\"pipeline\":\"main.3589\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", wire: "{\"module\":\"nats\",\"pipeline\":\"main.3589\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", + decode: func(b []byte) (any, error) { var v AcceptInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "ask-again names the mover's module", subject: "", given: "{\"module\":\"nats\",\"pipeline\":\"main.3589\",\"why\":\"the build node was away\"}", wire: "{\"module\":\"nats\",\"pipeline\":\"main.3589\",\"why\":\"the build node was away\"}", + decode: func(b []byte) (any, error) { var v AskAgainInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "accept asks with why", subject: "", given: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", wire: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.3589\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", decode: func(b []byte) (any, error) { var v AcceptInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "stands answers a wait on a build node", subject: "", given: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", wire: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json index 645ac715..a056bb02 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json @@ -100,6 +100,35 @@ ] } }, + { + "name": "rerun names the mover's module", + "of": "verb:rerun.input", + "given": { + "pipeline": "main.3589", + "module": "nats", + "step": "unit", + "why": "a flaky test, issue 1966" + } + }, + { + "name": "accept names the mover's module", + "of": "verb:accept.input", + "given": { + "pipeline": "main.3589", + "module": "nats", + "step": "integration", + "why": "flaky upstream, issue 1966" + } + }, + { + "name": "ask-again names the mover's module", + "of": "verb:ask-again.input", + "given": { + "pipeline": "main.3589", + "module": "nats", + "why": "the build node was away" + } + }, { "name": "accept asks with why", "of": "verb:accept.input", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index a2ba9896..9eadc6d6 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -340,6 +340,10 @@ "type": "string", "description": "the pipeline's key" }, + "module": { + "type": "string", + "description": "the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101)" + }, "step": { "type": "string", "enum": [ @@ -393,6 +397,10 @@ "type": "string", "description": "the pipeline's key" }, + "module": { + "type": "string", + "description": "the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101)" + }, "step": { "type": "string", "enum": [ @@ -509,6 +517,10 @@ "type": "string", "description": "the pipeline's key" }, + "module": { + "type": "string", + "description": "the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101)" + }, "why": { "type": "string", "description": "why, written with the caller the runtime proves in the hand-act log" diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 3fef19f9..474c4287 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -632,6 +632,8 @@ export interface ReviewAnswer { /** is what rerun takes. */ export interface RerunInput { "artifact"?: string; + /** the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) */ + "module"?: string; /** the pipeline's key */ "pipeline": string; "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; @@ -648,6 +650,8 @@ export interface RerunAnswer { /** is what accept takes. */ export interface AcceptInput { "artifact"?: string; + /** the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) */ + "module"?: string; /** the pipeline's key */ "pipeline": string; "step": "validate" | "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; @@ -688,6 +692,8 @@ export interface PlaceAnswer { /** is what ask-again takes. */ export interface AskAgainInput { + /** the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) */ + "module"?: string; /** the pipeline's key */ "pipeline": string; /** why, written with the caller the runtime proves in the hand-act log */ -- 2.54.0 From 5bf6fd9b01cede32ec258d1dd720f7c4704c1d97 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:00:13 +0100 Subject: [PATCH 025/104] graph: the refused cycle is shared code, read by the indexer and the validate step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RefusedCycle, with its running-version break and its path search, moves from the indexer's internal/index into mesh-delivery-sdk/graph, so the assigner's validate step reads the same rule the indexer's take-in does; the indexer calls the shared function. The rule's table test moves with it; the indexer keeps its test of the trunk catalogues against the shared rule. Builds: design 47 H §745; lead answers H-A-34, H-A-104 (2) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../internal/index/branch_take_in.go | 4 +- .../internal/index/catalog_edges.go | 84 ------------- .../internal/index/catalog_edges_test.go | 45 +------ .../internal/index/pending.go | 4 +- modules/mesh-delivery-sdk/graph/cycle.go | 94 +++++++++++++++ modules/mesh-delivery-sdk/graph/cycle_test.go | 48 ++++++++ .../internal/watch/verdicts.go | 114 ------------------ 7 files changed, 154 insertions(+), 239 deletions(-) create mode 100644 modules/mesh-delivery-sdk/graph/cycle.go create mode 100644 modules/mesh-delivery-sdk/graph/cycle_test.go delete mode 100644 modules/mesh-delivery-watchman/internal/watch/verdicts.go diff --git a/modules/mesh-delivery-indexer/internal/index/branch_take_in.go b/modules/mesh-delivery-indexer/internal/index/branch_take_in.go index b1df57d8..6ff91d8d 100644 --- a/modules/mesh-delivery-indexer/internal/index/branch_take_in.go +++ b/modules/mesh-delivery-indexer/internal/index/branch_take_in.go @@ -6,6 +6,8 @@ import ( "maps" "strings" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-sdk/go/process" ) @@ -53,7 +55,7 @@ func (ix *Indexer) ApplyBranchSource(ctx context.Context, branch string, a meshd return err } // A cycle with a build edge no running version breaks is refused here as at the trunk's take-in (design 47 G §49, A-326). - if cycle := RefusedCycle(WithEdges(ix.withActs(ctx, entries))); cycle != nil { + if cycle := graph.RefusedCycle(WithEdges(ix.withActs(ctx, entries))); cycle != nil { ix.logf("catalog graph: the branch %s at source revision %d keeps no revision: its catalog graph holds a cycle with a build edge, which no running version breaks (design 47 G §49): %s; taken in again at its next source-moved", branch, a.Revision, strings.Join(cycle, ", ")) return nil } diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_edges.go b/modules/mesh-delivery-indexer/internal/index/catalog_edges.go index a26a47c4..70d441e3 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_edges.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_edges.go @@ -453,87 +453,3 @@ func (ix *Indexer) withActs(ctx context.Context, entries map[string]meshcatalog. } return WithActs(entries, defs) } - -// RefusedCycle is a cycle of the entries' edges that the take-in refuses (design 47 G §49, A-326, A-333), as the artifacts it -// passes through with the first named again at its end; nil when there is none. A cycle of delivery edges (kinds 2, 4, 5, 6) -// alone is delivered as one step, so only a cycle holding a build edge (kind 1 or 3) is refused, and not one of package edges -// (kind 1) alone: the language's own build refuses a real import cycle (A-333). A build edge of kind 3 that goes out of an -// artifact of a module holding a build seat into an artifact that seat builds is where such a cycle is broken: the running -// version builds the new one (§270), so a cycle through it is allowed, as the cycle through a build module's own inputs is. -func RefusedCycle(entries map[string]meshcatalog.CatalogEntry) []meshcatalog.ArtifactRef { - var edges []meshcatalog.Edge - for _, m := range slices.Sorted(maps.Keys(entries)) { - for _, x := range entries[m].Edges { - if x.From != "" && x.To != "" && !brokenAtTheRunningVersion(x, entries) { - edges = append(edges, x) - } - } - } - next := map[meshcatalog.ArtifactRef][]meshcatalog.Edge{} - for _, x := range edges { - next[x.From] = append(next[x.From], x) - } - for _, x := range edges { - if x.Kind != 1 && x.Kind != 3 { - continue - } - if path := pathBack(next, x.To, x.From, x.Kind != 1); path != nil { - return append([]meshcatalog.ArtifactRef{x.From}, path...) - } - } - return nil -} - -// brokenAtTheRunningVersion says whether x is a build edge of kind 3 out of an artifact of a module that holds a build seat -// (an acting rule of step build) into an artifact that seat builds (A-326). -func brokenAtTheRunningVersion(x meshcatalog.Edge, entries map[string]meshcatalog.CatalogEntry) bool { - if x.Kind != 3 { - return false - } - builder, to := entries[strings.SplitN(x.From, ":", 2)[0]], entries[strings.SplitN(x.To, ":", 2)[0]] - i := slices.IndexFunc(to.Artifacts, func(a meshcatalog.Artifact) bool { return a.Ref == x.To }) - if i < 0 { - return false - } - art := to.Artifacts[i] - return slices.ContainsFunc(builder.Acts, func(r meshcatalog.ActingRule) bool { - if r.Step != seatdef.StepBuild { - return false - } - if r.On == seatdef.OnKindImage { - return art.Kind == "image" - } - return seatdef.ActingRule{On: r.On}.ActsOn(art.Language) - }) -} - -// pathBack is the shortest path of next from start to end, start and end included, that holds an edge of a kind other than 1 -// unless other is true already (a cycle of package edges alone is none of §49's, A-333); nil when there is none. -func pathBack(next map[meshcatalog.ArtifactRef][]meshcatalog.Edge, start, end meshcatalog.ArtifactRef, other bool) []meshcatalog.ArtifactRef { - type at struct { - ref meshcatalog.ArtifactRef - other bool - } - from := at{start, other} - before := map[at]at{from: {}} - queue := []at{from} - for len(queue) > 0 { - cur := queue[0] - queue = queue[1:] - if cur.ref == end && cur.other { - var path []meshcatalog.ArtifactRef - for ; cur != (at{}); cur = before[cur] { - path = append([]meshcatalog.ArtifactRef{cur.ref}, path...) - } - return path - } - for _, x := range next[cur.ref] { - n := at{x.To, cur.other || x.Kind != 1} - if _, seen := before[n]; !seen { - before[n] = cur - queue = append(queue, n) - } - } - } - return nil -} diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go index 07f9d977..1161e913 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_edges_test.go @@ -8,6 +8,8 @@ import ( "testing" "time" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-sdk/go/seatdef" ) @@ -278,44 +280,9 @@ func TestAKeptRevisionHoldsTheActsAndTheKindFiveEdges(t *testing.T) { } } -// A-326, A-333 (design 47 G §49, §51): a cycle through a build module's own inputs is broken at its running version and -// allowed, as are a cycle of package edges alone and a cycle of delivery edges alone; any other cycle with a build edge is -// refused, naming every artifact on it. Today's trunk catalogue and G's own (the entries of G's dry run, 2026-11-13, kept -// in testdata with what the edges are computed from) are accepted. -func TestACycleWithABuildEdgeIsRefusedUnlessABuildSeatsRunningVersionBreaksIt(t *testing.T) { - builder := meshcatalog.CatalogEntry{Module: "mesh-build-go", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-build-go:files", Language: "go"}}, - Acts: []meshcatalog.ActingRule{{Seat: "node-build-go", Step: seatdef.StepBuild, On: "go"}}} - handActs := meshcatalog.CatalogEntry{Module: "mesh-hand-acts", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-hand-acts:tools", Language: "go"}}, - Edges: []meshcatalog.Edge{{Kind: 3, From: "mesh-build-go:files", To: "mesh-hand-acts:tools", Word: "toolchains", Why: "go"}}} - trunkCycle := builder - trunkCycle.Edges = []meshcatalog.Edge{{Kind: 6, From: "mesh-hand-acts:tools", To: "mesh-build-go:files", Word: "seat:mesh-hand-acts.hand-act"}} - a := meshcatalog.CatalogEntry{Module: "a", Artifacts: []meshcatalog.Artifact{{Ref: "a:go", Language: "go"}}, - Edges: []meshcatalog.Edge{{Kind: 1, From: "b:go", To: "a:go", Word: "packages"}}} - b := meshcatalog.CatalogEntry{Module: "b", Artifacts: []meshcatalog.Artifact{{Ref: "b:go", Language: "go"}}, - Edges: []meshcatalog.Edge{{Kind: 1, From: "a:go", To: "b:go", Word: "packages"}}} - noSeat := trunkCycle - noSeat.Acts = nil - verbsOnly := meshcatalog.CatalogEntry{Module: "c", Artifacts: []meshcatalog.Artifact{{Ref: "c:go"}}, Edges: []meshcatalog.Edge{{Kind: 6, From: "d:go", To: "c:go"}}} - verbsBack := meshcatalog.CatalogEntry{Module: "d", Artifacts: []meshcatalog.Artifact{{Ref: "d:go"}}, Edges: []meshcatalog.Edge{{Kind: 4, From: "c:go", To: "d:go"}}} - for _, c := range []struct { - name string - entries []meshcatalog.CatalogEntry - want []meshcatalog.ArtifactRef - }{ - {"the trunk catalogue's cycle through a build module's own inputs", []meshcatalog.CatalogEntry{trunkCycle, handActs}, nil}, - {"two artifacts each needing the other's new package, package edges alone", []meshcatalog.CatalogEntry{a, b}, nil}, - {"the same cycle from a module that holds no build seat", []meshcatalog.CatalogEntry{noSeat, handActs}, - []meshcatalog.ArtifactRef{"mesh-build-go:files", "mesh-hand-acts:tools", "mesh-build-go:files"}}, - {"a cycle of delivery edges alone", []meshcatalog.CatalogEntry{verbsOnly, verbsBack}, nil}, - } { - entries := map[string]meshcatalog.CatalogEntry{} - for _, e := range c.entries { - entries[e.Module] = e - } - if got := RefusedCycle(entries); !slices.Equal(got, c.want) { - t.Errorf("%s: refused %v, want %v", c.name, got, c.want) - } - } +// A-326, A-333 (design 47 G §49, §51): today's trunk catalogue and G's own (the entries of G's dry run, 2026-11-13, kept +// in testdata with what the edges are computed from) are accepted by the shared cycle rule (graph.RefusedCycle). +func TestTheTrunkCataloguesHoldNoRefusedCycle(t *testing.T) { for _, name := range []string{"catalog-entries-trunk-2026-11-13", "catalog-entries-47-G-2026-11-13"} { raw, err := os.ReadFile("testdata/" + name + ".json") if err != nil { @@ -325,7 +292,7 @@ func TestACycleWithABuildEdgeIsRefusedUnlessABuildSeatsRunningVersionBreaksIt(t if err := json.Unmarshal(raw, &entries); err != nil { t.Fatal(err) } - if got := RefusedCycle(WithEdges(entries)); got != nil { + if got := graph.RefusedCycle(WithEdges(entries)); got != nil { t.Errorf("%s: refused %v, want the catalogue accepted", name, got) } } diff --git a/modules/mesh-delivery-indexer/internal/index/pending.go b/modules/mesh-delivery-indexer/internal/index/pending.go index 6c27b250..aac05b07 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending.go +++ b/modules/mesh-delivery-indexer/internal/index/pending.go @@ -10,6 +10,8 @@ import ( "strings" "time" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" @@ -787,7 +789,7 @@ func (ix *Indexer) refuseCycle(ctx context.Context, ready []PendingEntry, d *dry if err != nil { return "", false, err } - cycle := RefusedCycle(WithEdges(ix.withActs(ctx, entries))) + cycle := graph.RefusedCycle(WithEdges(ix.withActs(ctx, entries))) if cycle == nil { return "", false, nil } diff --git a/modules/mesh-delivery-sdk/graph/cycle.go b/modules/mesh-delivery-sdk/graph/cycle.go new file mode 100644 index 00000000..988b45fe --- /dev/null +++ b/modules/mesh-delivery-sdk/graph/cycle.go @@ -0,0 +1,94 @@ +package graph + +import ( + "maps" + "slices" + "strings" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/seatdef" +) + +// RefusedCycle is a cycle of the entries' edges that the take-in and the validate step refuse (design 47 H-A-34, H-A-104) (design 47 G §49, A-326, A-333), as the artifacts it +// passes through with the first named again at its end; nil when there is none. A cycle of delivery edges (kinds 2, 4, 5, 6) +// alone is delivered as one step, so only a cycle holding a build edge (kind 1 or 3) is refused, and not one of package edges +// (kind 1) alone: the language's own build refuses a real import cycle (A-333). A build edge of kind 3 that goes out of an +// artifact of a module holding a build seat into an artifact that seat builds is where such a cycle is broken: the running +// version builds the new one (§270), so a cycle through it is allowed, as the cycle through a build module's own inputs is. +func RefusedCycle(entries map[string]meshcatalog.CatalogEntry) []meshcatalog.ArtifactRef { + var edges []meshcatalog.Edge + for _, m := range slices.Sorted(maps.Keys(entries)) { + for _, x := range entries[m].Edges { + if x.From != "" && x.To != "" && !brokenAtTheRunningVersion(x, entries) { + edges = append(edges, x) + } + } + } + next := map[meshcatalog.ArtifactRef][]meshcatalog.Edge{} + for _, x := range edges { + next[x.From] = append(next[x.From], x) + } + for _, x := range edges { + if x.Kind != 1 && x.Kind != 3 { + continue + } + if path := pathBack(next, x.To, x.From, x.Kind != 1); path != nil { + return append([]meshcatalog.ArtifactRef{x.From}, path...) + } + } + return nil +} + +// brokenAtTheRunningVersion says whether x is a build edge of kind 3 out of an artifact of a module that holds a build seat +// (an acting rule of step build) into an artifact that seat builds (A-326). +func brokenAtTheRunningVersion(x meshcatalog.Edge, entries map[string]meshcatalog.CatalogEntry) bool { + if x.Kind != 3 { + return false + } + builder, to := entries[strings.SplitN(x.From, ":", 2)[0]], entries[strings.SplitN(x.To, ":", 2)[0]] + i := slices.IndexFunc(to.Artifacts, func(a meshcatalog.Artifact) bool { return a.Ref == x.To }) + if i < 0 { + return false + } + art := to.Artifacts[i] + return slices.ContainsFunc(builder.Acts, func(r meshcatalog.ActingRule) bool { + if r.Step != seatdef.StepBuild { + return false + } + if r.On == seatdef.OnKindImage { + return art.Kind == "image" + } + return seatdef.ActingRule{On: r.On}.ActsOn(art.Language) + }) +} + +// pathBack is the shortest path of next from start to end, start and end included, that holds an edge of a kind other than 1 +// unless other is true already (a cycle of package edges alone is none of §49's, A-333); nil when there is none. +func pathBack(next map[meshcatalog.ArtifactRef][]meshcatalog.Edge, start, end meshcatalog.ArtifactRef, other bool) []meshcatalog.ArtifactRef { + type at struct { + ref meshcatalog.ArtifactRef + other bool + } + from := at{start, other} + before := map[at]at{from: {}} + queue := []at{from} + for len(queue) > 0 { + cur := queue[0] + queue = queue[1:] + if cur.ref == end && cur.other { + var path []meshcatalog.ArtifactRef + for ; cur != (at{}); cur = before[cur] { + path = append([]meshcatalog.ArtifactRef{cur.ref}, path...) + } + return path + } + for _, x := range next[cur.ref] { + n := at{x.To, cur.other || x.Kind != 1} + if _, seen := before[n]; !seen { + before[n] = cur + queue = append(queue, n) + } + } + } + return nil +} diff --git a/modules/mesh-delivery-sdk/graph/cycle_test.go b/modules/mesh-delivery-sdk/graph/cycle_test.go new file mode 100644 index 00000000..c5b687a6 --- /dev/null +++ b/modules/mesh-delivery-sdk/graph/cycle_test.go @@ -0,0 +1,48 @@ +package graph + +import ( + "slices" + "testing" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/seatdef" +) + +// A-326, A-333 (design 47 G §49, §51): a cycle through a build module's own inputs is broken at its running version and +// allowed, as are a cycle of package edges alone and a cycle of delivery edges alone; any other cycle with a build edge is +// refused, naming every artifact on it (design 47 H-A-104: the rule both the indexer and the validate step read). +func TestACycleWithABuildEdgeIsRefusedUnlessABuildSeatsRunningVersionBreaksIt(t *testing.T) { + builder := meshcatalog.CatalogEntry{Module: "mesh-build-go", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-build-go:files", Language: "go"}}, + Acts: []meshcatalog.ActingRule{{Seat: "node-build-go", Step: seatdef.StepBuild, On: "go"}}} + handActs := meshcatalog.CatalogEntry{Module: "mesh-hand-acts", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-hand-acts:tools", Language: "go"}}, + Edges: []meshcatalog.Edge{{Kind: 3, From: "mesh-build-go:files", To: "mesh-hand-acts:tools", Word: "toolchains", Why: "go"}}} + trunkCycle := builder + trunkCycle.Edges = []meshcatalog.Edge{{Kind: 6, From: "mesh-hand-acts:tools", To: "mesh-build-go:files", Word: "seat:mesh-hand-acts.hand-act"}} + a := meshcatalog.CatalogEntry{Module: "a", Artifacts: []meshcatalog.Artifact{{Ref: "a:go", Language: "go"}}, + Edges: []meshcatalog.Edge{{Kind: 1, From: "b:go", To: "a:go", Word: "packages"}}} + b := meshcatalog.CatalogEntry{Module: "b", Artifacts: []meshcatalog.Artifact{{Ref: "b:go", Language: "go"}}, + Edges: []meshcatalog.Edge{{Kind: 1, From: "a:go", To: "b:go", Word: "packages"}}} + noSeat := trunkCycle + noSeat.Acts = nil + verbsOnly := meshcatalog.CatalogEntry{Module: "c", Artifacts: []meshcatalog.Artifact{{Ref: "c:go"}}, Edges: []meshcatalog.Edge{{Kind: 6, From: "d:go", To: "c:go"}}} + verbsBack := meshcatalog.CatalogEntry{Module: "d", Artifacts: []meshcatalog.Artifact{{Ref: "d:go"}}, Edges: []meshcatalog.Edge{{Kind: 4, From: "c:go", To: "d:go"}}} + for _, c := range []struct { + name string + entries []meshcatalog.CatalogEntry + want []meshcatalog.ArtifactRef + }{ + {"the trunk catalogue's cycle through a build module's own inputs", []meshcatalog.CatalogEntry{trunkCycle, handActs}, nil}, + {"two artifacts each needing the other's new package, package edges alone", []meshcatalog.CatalogEntry{a, b}, nil}, + {"the same cycle from a module that holds no build seat", []meshcatalog.CatalogEntry{noSeat, handActs}, + []meshcatalog.ArtifactRef{"mesh-build-go:files", "mesh-hand-acts:tools", "mesh-build-go:files"}}, + {"a cycle of delivery edges alone", []meshcatalog.CatalogEntry{verbsOnly, verbsBack}, nil}, + } { + entries := map[string]meshcatalog.CatalogEntry{} + for _, e := range c.entries { + entries[e.Module] = e + } + if got := RefusedCycle(entries); !slices.Equal(got, c.want) { + t.Errorf("%s: refused %v, want %v", c.name, got, c.want) + } + } +} diff --git a/modules/mesh-delivery-watchman/internal/watch/verdicts.go b/modules/mesh-delivery-watchman/internal/watch/verdicts.go deleted file mode 100644 index d0f7d2e9..00000000 --- a/modules/mesh-delivery-watchman/internal/watch/verdicts.go +++ /dev/null @@ -1,114 +0,0 @@ -package watch - -import ( - "encoding/json" - "fmt" - "strings" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" -) - -// KindManifestRefused is a module whose manifest the indexer's judge refused (novox/hq ADR 0578 §1): every reader holds -// it, composing nothing of its own, until a mended manifest is merged. -const KindManifestRefused = "manifest-refused" - -// KindManifestOutgrown is a module whose manifest the indexer accepted before and a stricter judge finds problems in -// (novox/hq ADR 0579 §1): it stays accepted and runs; the warning stands until the manifest is mended. -const KindManifestOutgrown = FindingManifestOutgrown - -// The manifest findings are the indexer's verdicts heard as events (design 47 G §500): `manifest-refused` raises the refusal, and -// `manifest-accepted`, which carries `problems` (what a stricter validator finds in a manifest it still accepts), raises -// `manifest-outgrown` or, with none, clears it and any refusal. The watchman seeds both from the indexer's verdicts at its start -// (VerdictsTool). `manifest-waits` is no longer written: every revision is judged by a validator built from its own heads (§16). - -// VerdictsTool is the indexer's tool that lists its verdicts, which seeds the findings at the start; it is asked of the holder of -// the seat mesh-catalog when it is asked (design 47 G A-210, §428), never of a module named here. -const VerdictsTool = "indexer_verdicts" - -// VerdictRow is one verdict as the tool lists it (the fields the watchman reads). -type VerdictRow struct { - Module string `json:"module"` - State string `json:"state"` - Problems []string `json:"problems"` - Warnings []string `json:"warnings"` - At time.Time `json:"at"` -} - -// ManifestRefused hears the seat mesh-catalog's manifest-refused: the module's manifest is refused until a mended one is accepted. -func (w *Watchman) ManifestRefused(e meshcatalog.ManifestRefusedEvent) { - if e.Module == "" { - w.say("a manifest-refused names no module, left") - return - } - w.mu.Lock() - defer w.mu.Unlock() - w.verdict(e.Module, e.Problems, nil, true) -} - -// manifestAccepted hears the problems a manifest-accepted carries (Accepted calls it, w.mu held): none clears the module's findings, some are its warning. -func (w *Watchman) manifestAccepted(module string, problems []string) { - w.verdict(module, nil, problems, false) -} - -// SeedVerdicts raises, at the start, the findings of the newest verdict of each module the indexer's tool listed: a refused one, or an -// accepted one with warnings. A module whose newest verdict is accepted clears both. -func (w *Watchman) SeedVerdicts(rows []VerdictRow) { - newest := map[string]VerdictRow{} - for _, r := range rows { - if old, ok := newest[r.Module]; !ok || r.At.After(old.At) { - newest[r.Module] = r - } - } - w.mu.Lock() - defer w.mu.Unlock() - for module, r := range newest { - switch r.State { - case meshcatalogclient.VerdictRefused: - w.verdict(module, r.Problems, nil, true) - case meshcatalogclient.VerdictAccepted: - w.verdict(module, nil, r.Warnings, false) - } - } -} - -// DecodeVerdictRows reads the answer of the indexer's verdicts tool. -func DecodeVerdictRows(raw []byte) ([]VerdictRow, error) { - var a struct { - Verdicts []VerdictRow `json:"verdicts"` - } - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf("not an answer of the indexer's verdicts: %w", err) - } - return a.Verdicts, nil -} - -// verdict writes and clears a module's manifest findings, w.mu held: a refusal (problems, refused) or an outgrown manifest (warnings). -func (w *Watchman) verdict(module string, problems, warnings []string, refused bool) { - refusedKey := FindingKey(ScopeModule, module, KindManifestRefused) - outgrownKey := FindingKey(ScopeModule, module, KindManifestOutgrown) - if refused { - w.unfind(outgrownKey) - w.find(Finding{Scope: ScopeModule, ID: module, Kind: KindManifestRefused, Severity: Warning, Source: "indexer.verdicts", - Summary: "the indexer's judge refused the manifest of " + module + ": " + strings.Join(problems, "; "), - Said: strings.Join(problems, "; "), - Headline: "The manifest of " + module + " is refused", - Explanation: "The indexer's judge refused it, so every node, the grants part and the assigner hold " + module + ": " + - "nothing of it changes until a mended manifest is merged, and every other module goes on.", - Needs: "a pull request that mends the manifest of " + module}) - return - } - w.unfind(refusedKey) - if len(warnings) == 0 { - w.unfind(outgrownKey) - return - } - w.find(Finding{Scope: ScopeModule, ID: module, Kind: KindManifestOutgrown, Severity: Warning, Source: "indexer.verdicts", - Summary: "the manifest of " + module + " breaks rules the indexer's judge holds it to now: " + strings.Join(warnings, "; "), - Said: strings.Join(warnings, "; "), - Headline: "The manifest of " + module + " needs mending", - Explanation: "A stricter judge found problems in a manifest it accepted before; " + module + " stays accepted and " + - "runs, and its next change is refused until they are mended (novox/hq ADR 0579).", - Needs: "a pull request that mends the manifest of " + module}) -} -- 2.54.0 From f6163349af3103d7fb8b22cdf03493c7df1d5074 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:05:11 +0100 Subject: [PATCH 026/104] W1: the watchman reads the H1 take-in, the mover's entry and the want MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The watchman follows the one model in one pass. Its take-in waits are the seat's take-in.pending and take-in.taken, keyed ., timed from the message's own time by the setting take-in-bound (60 minutes by default), and seeded from indexer_pending's held take-ins; the group bound goes. A taken-in mover's bus state is read from its catalog entry by fingerprint through the seat mesh-catalog's verb entry, bus-state-overdue timed from the take-in. The manifest verdicts and their findings, the head timing of source-moved, acting-part-late and delivery-waits go, with their readers, consumes and the indexer_verdicts invoke. A want awaiting its hand placement is not timed, and the want readers follow the H1 want. A record-opened is heard on record-opened.. Builds: design 47 H §741, §744, §764 (the indexer: manifest-refused, manifest-accepted, the watchman's findings; the assigner: acting-part-late, delivery-waits), §772; lead answers H-A-25, H-A-37, H-A-49, H-A-70, H-A-78 (2), H-A-79, H-A-91 (2), H-A-94, H-A-95 (1), H-A-97, H-A-102 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../cmd/mesh-delivery-watchman/consumes.go | 79 ++--- .../integration_test.go | 2 +- .../cmd/mesh-delivery-watchman/main.go | 68 ++-- .../cmd/mesh-delivery-watchman/main_test.go | 46 +-- .../internal/watch/busstate.go | 161 +++++++-- .../internal/watch/findings_test.go | 324 ++++++++---------- .../internal/watch/mirror.go | 28 +- .../internal/watch/names.go | 1 - .../internal/watch/pipelines.go | 107 +----- .../internal/watch/pipelines_test.go | 155 ++------- .../internal/watch/records.go | 25 +- .../internal/watch/signals.go | 4 +- .../internal/watch/takein.go | 198 +++++------ .../internal/watch/waits.go | 130 ++----- .../internal/watch/waits_test.go | 138 ++------ .../internal/watch/watch.go | 23 +- .../internal/watch/watch_test.go | 8 +- .../mesh-delivery-watchman/manifest_test.go | 30 +- modules/mesh-delivery-watchman/module.json | 30 +- 19 files changed, 614 insertions(+), 943 deletions(-) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go index 895cfae4..7065d307 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "git.novox.be/novox/mesh-contracts/go/seats/meshbroker" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -26,8 +25,8 @@ import ( "mesh-delivery-watchman/internal/watch" ) -// **What the watchman consumes** (its manifest's `consumes`; novox/hq ADR 0595 §4, design 25 § 12.2; DLV-W1): the seat mesh-catalog's -// manifest-accepted and the seat mesh-broker's created and refused, all on its durable consumer on EVENTS (the seat's +// **What the watchman consumes** (its manifest's `consumes`; novox/hq ADR 0595 §4, design 25 § 12.2; DLV-W1): the seat mesh-broker's +// created and refused (a taken-in mover's bus state is read from its catalog entry, busstate.go), all on its durable consumer on EVENTS (the seat's // events on the seat's subjects like every seat's: the lead's ruling, registry milestone 13:0x); beside it any module // stream its membership names (Hears). Each consumer is the one the grants part makes; one // not there yet is opened when the watchman's membership next changes, and one opened is never opened twice. An event is @@ -35,35 +34,18 @@ import ( // Consumed event names, as the consumes name them (the emitter is read from the subject's emitter token). const ( - eventAccepted = "manifest-accepted" - // eventManifestRefused is the seat mesh-catalog's manifest-refused; meshGrantsSeat the seat of the store whose filling, full, room and waits it hears. - eventManifestRefused = "manifest-refused" - meshGrantsSeat = "mesh-grants" - eventCreated = "created" - eventRefused = "refused" + // meshGrantsSeat is the seat of the store whose filling, full and room it hears. + meshGrantsSeat = "mesh-grants" + eventCreated = "created" + eventRefused = "refused" ) -// consumed hands one consumed event to the watchman, by its subject: manifest-accepted, and the seat mesh-broker's created -// and refused. Anything else is left. +// consumed hands one consumed event to the watchman, by its subject: the seats' events it times, and the seat mesh-broker's +// created and refused. Anything else is left. func consumed(w *watch.Watchman, subject string, body []byte, logf func(string, ...any)) { switch { - case subject == meshcatalog.SubjectManifestAccepted: - var a meshcatalog.ManifestAcceptedEvent - if err := json.Unmarshal(body, &a); err != nil || a.Module == "" { - logf("a manifest-accepted that does not read is left: %v", err) - return - } - w.Accepted(a) - case subject == meshcatalog.SubjectManifestRefused: - var r meshcatalog.ManifestRefusedEvent - if err := json.Unmarshal(body, &r); err != nil || r.Module == "" { - logf("a manifest-refused that does not read is left: %v", err) - return - } - w.ManifestRefused(r) case pipelineSubject(w, subject, body): case engineWaitSubject(w, subject, body): - case moduleWaitSubject(w, subject, body): case recordSubject(w, subject, body): case buildSeatSubject(w, subject, body): case brokerSubject(subject) && strings.HasSuffix(subject, ".event."+eventCreated): @@ -84,7 +66,7 @@ func consumed(w *watch.Watchman, subject string, body []byte, logf func(string, // hearConsumed opens the watchman's durable consumers: on EVENTS now, and on each module stream its membership names as // that membership arrives. A consumer the bus does not hold yet is said and tried again at the membership's next change. func hearConsumed(ctx context.Context, js jetstream.JetStream, cred process.Account, hub *process.EventHub, w *watch.Watchman, binding *process.Binding, logf func(string, ...any)) { - // The seats' events (manifest-accepted, the bus module's created and refused) are one handler of the module's one + // The seats' events (the bus module's created and refused among them) are one handler of the module's one // pull of EVENTS, beside the take-in events and the views reader. The seat mesh-broker's recreated and dropped go to // the binding of the watchman's finding-events (design 47 G A-274, §577), which this handler holds, since a message has // one taker; and the binding asks show again at each bind of the hub's consumer, as its Register does. @@ -99,16 +81,17 @@ func hearConsumed(ctx context.Context, js jetstream.JetStream, cred process.Acco _ = m.Ack() } // One handler per seat it consumes, since a message has one taker (design 47 G A-322): the events the branches follower of the - // catalog half adopts (the seat mesh-catalog's registration-changed, the seat mesh-delivery's source-moved) are the follower's, and - // the watchman takes source-moved from it (AdoptEvent, main.go), never from a second handler. + // catalog half adopts (the seat mesh-catalog's registration-changed, the seat mesh-delivery's source-moved) are the follower's + // alone: the watchman learns no head (design 47 H §741). var patterns []string for _, seat := range []string{meshwants.Seat, meshGrantsSeat, meshpipelinerunner.Seat, nodeengine.Seat, meshbroker.Seat, nodebuildgo.Seat, nodebuildimage.Seat, nodebuildnode.Seat} { patterns = append(patterns, "mesh.seat."+seat+".event.>") } - for _, e := range []string{meshdelivery.EventRecordOpened, meshdelivery.EventRecordEnded, meshdelivery.EventFilling, meshdelivery.EventFull, meshdelivery.EventRoom} { + patterns = append(patterns, meshdelivery.SubjectRecordOpenedAll) // record-opened. (design 47 H-A-25) + for _, e := range []string{meshdelivery.EventRecordEnded, meshdelivery.EventFilling, meshdelivery.EventFull, meshdelivery.EventRoom} { patterns = append(patterns, seatdef.EventSubject(meshdelivery.Seat, e)) } - for _, e := range []string{eventAccepted, eventManifestRefused, meshdelivery.EventFilling, meshdelivery.EventFull, meshdelivery.EventRoom} { + for _, e := range []string{meshdelivery.EventFilling, meshdelivery.EventFull, meshdelivery.EventRoom} { patterns = append(patterns, seatdef.EventSubject(meshcatalog.Seat, e)) } for _, pattern := range patterns { @@ -190,15 +173,10 @@ func brokerSubject(subject string) bool { return strings.HasPrefix(subject, "mesh.seat."+meshbroker.Seat+".event.") } -// pipelineSubject hands the gate's `source-moved`, the runner's `pipeline-started`, `step-started` and `step-ended` and the assigner's -// `step-progress` to the watchman (watch/pipelines.go, watch/steps.go, design 47 G §12, §732): the head of a watched branch, its -// pipeline and each step's clock. It says whether the subject was one of them. +// pipelineSubject hands the runner's `step-started` and `step-ended` and the assigner's `step-progress` to the watchman +// (watch/pipelines.go, watch/steps.go, design 47 G §732, H §741): each step's clock. It says whether the subject was one of them. func pipelineSubject(w *watch.Watchman, subject string, body []byte) bool { switch { - case strings.HasPrefix(subject, "mesh.seat."+meshdelivery.Seat+".event."+meshdelivery.EventSourceMoved+"."): - w.SourceMoved(body) - case strings.HasPrefix(subject, "mesh.seat."+meshpipelinerunner.Seat+".event."+meshpipelinerunner.EventPipelineStarted+"."): - w.PipelineStarted(body) case strings.HasPrefix(subject, "mesh.seat."+meshpipelinerunner.Seat+".event."+meshpipelinerunner.EventStepStarted+"."): w.StepEvent(body) w.StepStarted(body) @@ -217,10 +195,14 @@ func pipelineSubject(w *watch.Watchman, subject string, body []byte) bool { // `record-ended` to the watchman (watch/records.go, design 47 G §148, §181). It says whether the subject was one of them. func recordSubject(w *watch.Watchman, subject string, body []byte) bool { parts := strings.Split(subject, ".") - if len(parts) != 5 || parts[0] != "mesh" || parts[1] != "seat" || parts[3] != "event" { + if len(parts) < 5 || parts[0] != "mesh" || parts[1] != "seat" || parts[3] != "event" { return false } seat, event := parts[2], parts[4] + // record-opened is said on record-opened. (design 47 H-A-25); every other event here has no token after its name. + if want := map[bool]int{true: 6, false: 5}[seat == meshdelivery.Seat && event == meshdelivery.EventRecordOpened]; len(parts) != want { + return false + } switch { case event == meshwants.EventWaitHeld: w.WaitHeld(seat, body) @@ -258,25 +240,6 @@ func engineWaitSubject(w *watch.Watchman, subject string, body []byte) bool { return true } -// moduleWaitSubject hands a module's `wait-held` and `wait-ended` on its own stream, on -// mesh.stream..event..., to the watchman: the form the builder says a key queued behind a package -// in (design 47 G A-192). It says whether the subject was one. -func moduleWaitSubject(w *watch.Watchman, subject string, body []byte) bool { - parts := strings.Split(subject, ".") - if len(parts) != 7 || parts[0] != "mesh" || parts[1] != "stream" || parts[3] != "event" { - return false - } - switch parts[4] { - case nodeengine.EventWaitHeld: - w.ModuleWaitHeld(parts[2], body) - case nodeengine.EventWaitEnded: - w.ModuleWaitEnded(parts[2], body) - default: - return false - } - return true -} - // buildSeatSubject hands the build seats' `ask-taken`, `step-progress` and `step-ended`, on // mesh.seat..event.., to the watchman (design 47 G §483, §496, §602, A-136): it times every ask of a // build seat from them. It says whether the subject was one of them. diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go index bab80b58..261d6bfc 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go @@ -578,7 +578,7 @@ func aWantIsMirroredAsAPulseAndTheHaveNamingItEndsIt(t *testing.T) { fpOld := meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64) putWant := func(node, module, fp string) { t.Helper() - body, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp, Composed: "sha256:" + strings.Repeat("c", 64)}) + body, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp, Version: "0.1.4", Pipeline: "main.42", Rank: 1}) if err != nil { t.Fatal(err) } diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go index 06174855..29d25829 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go @@ -12,10 +12,10 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "io" + "io/fs" "log" "os" "os/signal" @@ -31,7 +31,6 @@ import ( "git.novox.be/novox/mesh-contracts/go/seats/meshbroker" "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshwatchdogsclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "mesh-delivery-watchman/internal/socket" "mesh-delivery-watchman/internal/watch" @@ -274,11 +273,17 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro w := watch.New(cred.Module, &kvOut{ctx: ctx, presence: kvs.presence, pulse: kvs.pulse, stuk: kvs.stuck, findings: held, js: js, cred: cred}, time.Now) w.Logf(logger.Printf) - // The seat mesh-delivery's source-moved is the branches follower's event (one taker, design 47 G A-322): the watchman takes it from the - // follower's subscription, beside the follower's handler. - if err := reader.AdoptEvent(meshdelivery.Seat, meshdelivery.EventSourceMoved, func(_ context.Context, data []byte) error { w.SourceMoved(data); return nil }); err != nil { + // A taken-in mover's catalog entry is read by its fingerprint through the seat mesh-catalog's verb entry (design 47 + // H-A-94 (1)), its answer heard on its own goroutine. + entries := meshcatalogclient.NewEntries(calls.Call) + entries.Changed = w.EntryChanged + w.ReadEntriesWith(entries) + // The setting take-in-bound (design 47 H §744, H-A-94 (2)), read at the start from the file the manifest declares. + bound, err := takeInBound(getenv) + if err != nil { return err } + w.SetTakeInBound(bound) // What the wants and the modules hold is ended by their own late read (watch.ReadLate), never by the start's end. w.WantsAt(func() string { return reader.HolderBucket(meshwants.Seat, meshwants.StateWants) }) w.AwaitsWants() @@ -400,7 +405,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } else { atCatalog := atHolder(calls.Call, holders, meshcatalog.Seat) // the indexer holds the seat mesh-catalog seedTakeIn(w, atCatalog, logger.Printf) - seedVerdicts(w, atCatalog, logger.Printf) seedSteps(w, calls.Call, logger.Printf) calls.Close() } @@ -476,6 +480,32 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } } +// takeInBound is the setting take-in-bound, a Go duration such as 60m, read from the file the manifest declares with the +// content ${config:take-in-bound}, which MESH_WATCHMAN_TAKE_IN_BOUND_FILE names; zero, its default, for no path, no file or an +// empty one, and an error naming the file for a content that is no positive duration. +func takeInBound(getenv func(string) string) (time.Duration, error) { + path := getenv("MESH_WATCHMAN_TAKE_IN_BOUND_FILE") + if path == "" { + return 0, nil + } + raw, err := os.ReadFile(path) + if errors.Is(err, fs.ErrNotExist) { + return 0, nil + } + if err != nil { + return 0, err + } + v := strings.TrimSpace(string(raw)) + if v == "" { + return 0, nil + } + d, err := time.ParseDuration(v) + if err != nil || d <= 0 { + return 0, fmt.Errorf("the setting take-in-bound in %s is %q, no positive duration such as 60m", path, v) + } + return d, nil +} + // eventsStream is the shared stream of the modules' ordinary events, as the bus names it. const eventsStream = "EVENTS" @@ -499,10 +529,10 @@ func atHolder(call func(key string, body any) (json.RawMessage, error), holders func seedTakeIn(w *watch.Watchman, call func(key string, body any) (json.RawMessage, error), logf func(string, ...any)) { raw, err := call(pendingTool, map[string]any{}) if err == nil { - var a takein.PendingAnswer - if a, err = takein.DecodePendingAnswer(raw); err == nil { + var a watch.HeldTakeIns + if a, err = watch.DecodeHeldTakeIns(raw); err == nil { w.SeedTakeIn(a) - logf("take-in: %d waits the indexer holds are watched from their own since (%s)", len(a.Waits), pendingTool) + logf("take-in: %d take-ins the indexer holds are watched from their own since (%s)", len(a.Held), pendingTool) return } } @@ -527,20 +557,6 @@ func seedSteps(w *watch.Watchman, call func(key string, body any) (json.RawMessa logf("steps: %s cannot be asked (%v), so a step open before this start is timed only once an event of it is heard", standsVerb, err) } -// seedVerdicts asks the indexer's verdicts and raises the findings they hold (design 47 G §500): a verdict said while the watchman was -// down is then not lost. An indexer that does not answer is said: the findings are then raised from the verdicts heard after. -func seedVerdicts(w *watch.Watchman, call func(key string, body any) (json.RawMessage, error), logf func(string, ...any)) { - raw, err := call(watch.VerdictsTool, map[string]any{"all": true}) - if err == nil { - var rows []watch.VerdictRow - if rows, err = watch.DecodeVerdictRows(raw); err == nil { - w.SeedVerdicts(rows) - return - } - } - logf("verdicts: %s cannot be asked (%v), so a manifest refused before this start is said only once a verdict of it is heard", watch.VerdictsTool, err) -} - // takeInHeard hands one take-in event of the indexer to the watchman, by its name relative to the indexer, and acknowledges it; // one that is not a take-in event is said and acknowledged, since hearing it again would not read it. func takeInHeard(w *watch.Watchman, m jetstream.Msg, logf func(string, ...any)) { @@ -548,7 +564,11 @@ func takeInHeard(w *watch.Watchman, m jetstream.Msg, logf func(string, ...any)) if !ok { logf("the subject %s of the take-in stream is not an event's, left", m.Subject()) } else { - w.TakeIn(event, m.Data()) + at := time.Now() + if meta, err := m.Metadata(); err == nil { + at = meta.Timestamp // the message's own time (design 47 H-A-94 (2)) + } + w.TakeIn(event, m.Data(), at) } if meta, err := m.Metadata(); err == nil && meta.NumPending == 0 { w.TakeInCaughtUp() diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go index 3843658f..df548974 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go @@ -5,18 +5,17 @@ import ( "encoding/json" "errors" "fmt" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "io" "strings" "testing" "time" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" + "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/views" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" - "mesh-delivery-watchman/internal/watch" "github.com/nats-io/nats.go/jetstream" @@ -67,9 +66,10 @@ func TestRunNeedsItsCredential(t *testing.T) { // 1135/AC6 if !out.findings[watch.FindingKey(watch.ScopeModule, "m", watch.KindBusStateRefused+"-l")] { t.Fatalf("refused reached no finding: %v", out.findings) } + // Design 47 H §764, H-A-49: manifest-accepted is retired; it is heard by nothing. consumed(w, "mesh.seat.mesh-catalog.event.manifest-accepted", []byte(`{"module":"m","digest":"d","bus-state":[]}`), say) - if len(out.findings) != 0 { - t.Fatalf("an accepted manifest no longer asking for l left %v", out.findings) + if len(out.findings) != 1 { + t.Fatalf("a manifest-accepted was heard: %v", out.findings) } consumed(w, "mesh.seat.mesh-broker.event.refused", []byte(`{"module":"m","local":"l"}`), say) consumed(w, "mesh.seat.mesh-broker.event.created", []byte(`{"module":"m","local-name":"l"}`), say) @@ -77,39 +77,36 @@ func TestRunNeedsItsCredential(t *testing.T) { // 1135/AC6 t.Fatalf("created left %v", out.findings) } }) - t.Run("design 47 G §500: the indexer's manifest-refused reaches the watchman by its subject", func(t *testing.T) { + t.Run("design 47 H-A-25: a record-opened on record-opened. reaches the watchman by its subject", func(t *testing.T) { out := &findingsOut{findings: map[string]bool{}} w := watch.New(watchmanModule, out, time.Now) - consumed(w, "mesh.seat.mesh-catalog.event.manifest-refused", []byte(`{"module":"m","digest":"d","problems":["x"]}`), func(string, ...any) {}) - if !out.findings[watch.FindingKey(watch.ScopeModule, "m", watch.KindManifestRefused)] { - t.Fatalf("a refused manifest reached %v", out.findings) + at := time.Now().Add(-25 * time.Hour).UTC().Format(time.RFC3339) + consumed(w, "mesh.seat.mesh-delivery.event.record-opened.fedcba9876543210", []byte(`{"record":"r1","milestone":"main.42","branch":"main","source":42,"call":"fedcba9876543210","at":"`+at+`"}`), func(string, ...any) {}) + if !out.findings[watch.FindingKey(watch.ScopeDelivery, "r1", watch.KindRecordOpen)] { + t.Fatalf("a record open 25 hours reached %v", out.findings) } }) t.Run("design 47 G §499, §541: a node-engine's wait-held and wait-ended reach the watchman by their subjects", func(t *testing.T) { out := &findingsOut{findings: map[string]bool{}} w := watch.New(watchmanModule, out, time.Now) say := func(string, ...any) {} - body := fmt.Sprintf(`{"step":"compose","reason":"entry-missing","since":%q}`, time.Now().Add(-2*time.Hour).UTC().Format(time.RFC3339)) + body := fmt.Sprintf(`{"step":"kept-build","reason":"node away","node":"build1","since":%q}`, time.Now().Add(-2*time.Hour).UTC().Format(time.RFC3339)) consumed(w, "mesh.seat.node-engine.event.wait-held.ace.web", []byte(body), say) - if !out.findings[watch.FindingKey(watch.ScopeDelivery, "ace.web", watch.KindDeliveryWaits)] { - t.Fatalf("a hold two hours old reached %v", out.findings) + if !out.findings[watch.FindingKey(watch.ScopeDelivery, "ace.web", watch.KindKeptBuildWaits)] { + t.Fatalf("a wait two hours old reached %v", out.findings) } consumed(w, "mesh.seat.node-engine.event.wait-ended.ace.web", []byte(body), say) if len(out.findings) != 0 { t.Fatalf("wait-ended left %v", out.findings) } }) - t.Run("design 47 G A-192: a module's wait-held on its stream, naming a part, reaches the watchman", func(t *testing.T) { + t.Run("design 47 H §764, H-A-70: a module's wait-held on its stream, naming a part, is an acting part's wait and reaches nothing", func(t *testing.T) { out := &findingsOut{findings: map[string]bool{}} w := watch.New(watchmanModule, out, time.Now) body := fmt.Sprintf(`{"step":"building","part":"mesh-sdk@v0.1.14","module":"web","fingerprint":"src2:f","bound":"1h0m0s","since":%q}`, time.Now().Add(-2*time.Hour).UTC().Format(time.RFC3339)) consumed(w, "mesh.stream.mesh-delivery-builder.event.wait-held.web.src2:f", []byte(body), func(string, ...any) {}) - if len(out.findings) != 1 { - t.Fatalf("a package wait two hours old reached %v", out.findings) - } - consumed(w, "mesh.stream.mesh-delivery-builder.event.wait-ended.web.src2:f", []byte(body), func(string, ...any) {}) if len(out.findings) != 0 { - t.Fatalf("wait-ended left %v", out.findings) + t.Fatalf("a package wait two hours old reached %v", out.findings) } }) err := run(context.Background(), func(string) string { return "" }, io.Discard) @@ -119,11 +116,11 @@ func TestRunNeedsItsCredential(t *testing.T) { // 1135/AC6 t.Run("1966/AC195-5: a seed indexer_pending could not answer, or answered unreadably, ends nothing", func(t *testing.T) { for name, call := range map[string]func(string, any) (json.RawMessage, error){ "cannot be asked": func(string, any) (json.RawMessage, error) { return nil, errors.New("no answer") }, - "unreadable": func(string, any) (json.RawMessage, error) { return json.RawMessage(`{"waits":`), nil }, + "unreadable": func(string, any) (json.RawMessage, error) { return json.RawMessage(`{"held":`), nil }, } { out := &findingsOut{findings: map[string]bool{}} w := watch.New(watchmanModule, out, time.Now) - const key = "m.00000000000000000042" + key := watch.TakeInKey("main", 42) old := watch.Finding{Scope: watch.ScopeDelivery, ID: key, Kind: watch.KindTakeInWaits, Severity: watch.Warning, Source: "take-in", Since: time.Now().Add(-3 * time.Hour), Summary: "held", Said: "held", Headline: "held", Explanation: "held", Needs: "a take-in"} value, err := watch.EncodeFinding(old) @@ -132,12 +129,7 @@ func TestRunNeedsItsCredential(t *testing.T) { // 1135/AC6 } out.findings[old.Key()] = true w.SeedFinding(old.Key(), value) - body, err := takein.EncodeTakeIn(takein.TakeIn{Kind: takein.TakeInPending, Key: "m.00000000000000000043", What: takein.TakeInRevision, Since: time.Now(), Lost: []string{"m.00000000000000000043"}, - Merges: []takein.Merge{{Repository: "novox/a", Number: 1, Merge: "c0ffee"}}}) - if err != nil { - t.Fatal(err) - } - w.TakeIn(takein.TakeInPendingEvent, body) + w.TakeIn(watch.TakeInPendingEvent, []byte(`{"branch":"main","source":43,"why":"the catalog store is full"}`), time.Now()) seedTakeIn(w, call, func(string, ...any) {}) var asked string seedTakeIn(w, atHolder(func(key string, _ any) (json.RawMessage, error) { asked = key; return nil, errors.New("no answer") }, diff --git a/modules/mesh-delivery-watchman/internal/watch/busstate.go b/modules/mesh-delivery-watchman/internal/watch/busstate.go index 2def5880..d03be9e3 100644 --- a/modules/mesh-delivery-watchman/internal/watch/busstate.go +++ b/modules/mesh-delivery-watchman/internal/watch/busstate.go @@ -1,6 +1,7 @@ package watch import ( + "context" "encoding/json" "fmt" "sort" @@ -8,24 +9,27 @@ import ( "time" "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshwatchdogsclient" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/catalogue" ) // **A refused or overdue creation of bus state is loud** (novox/hq ADR 0595 §4; design 25 § 12.2; DLV-W1). The watchman -// hears, through its `consumes`, the indexer's `manifest-accepted` (which carries the module's bus-state entries whole) -// and the bus module's own `created` and `refused`. An entry an accepted manifest asks for that has no `created` or -// `refused` within OverdueBound is the finding bus-state-overdue, naming the module and the entry; a `refused` is the -// finding bus-state-refused, with why. A later `created` clears both, and so does a later accepted manifest of that -// module that no longer asks for the entry. Never the bus module's to raise: it cannot while it is down. +// learns the bus-state entries a mover's manifest asks for from the mover's catalog entry, read by its fingerprint through +// the seat mesh-catalog's verb `entry` once the indexer's `take-in.taken` names the mover (design 47 H-A-94 (1), H-A-49), +// and hears the bus module's own `created` and `refused`. An entry a taken-in mover asks for that has no `created` or +// `refused` within OverdueBound of its `take-in.taken` is the finding bus-state-overdue, naming the module and the entry; +// a `refused` is the finding bus-state-refused, with why. A later `created` clears both, and so does a later take-in of +// that module whose entry no longer asks for the entry. Never the bus module's to raise: it cannot while it is down. // // The bound is a row of the signals table: a pulse key per entry with OverdueBound to live, whose expiry is the finding, // so no loop looks and a pulse that stood across a restart still acts. Both findings outlive a restart (signalKind), // since what ends them is heard, not read. // -// The bus module says `created` once per entry, so an entry it said created is not waited on again when a later manifest -// of its module is accepted with the same entry (review round 1): its mark, a pulse key with no time to live under the -// row bus-state-created, is read back at a restart (SeedSignal), and goes when a refused is heard or a manifest no -// longer asks for the entry, so a later ask of it waits again. +// The bus module says `created` once per entry, so an entry it said created is not waited on again when a later take-in +// of its module asks for the same entry (review round 1): its mark, a pulse key with no time to live under the +// row bus-state-created, is read back at a restart (SeedSignal), and goes when a refused is heard or an entry no +// longer asks for it, so a later ask of it waits again. // OverdueBound is how long an accepted entry may wait for the bus module's created or refused. const OverdueBound = 5 * time.Minute @@ -59,41 +63,138 @@ func refusedKey(module, local string) string { return FindingKey(ScopeModule, module, KindBusStateRefused+"-"+local) } -// Accepted is the indexer's manifest-accepted heard: each entry it asks for waits OverdueBound for the bus module's word, -// and every entry of the module this watchman waits on or holds a finding of that it no longer asks for is ended. -func (w *Watchman) Accepted(a meshcatalog.ManifestAcceptedEvent) { +// EntryReader reads a mover's catalog entry by its fingerprint through the seat mesh-catalog's verb `entry` +// (meshcatalogclient.Entries): Need answers one kept or asks it once, telling its Changed when answered; Release forgets it. +type EntryReader interface { + Need(ctx context.Context, fingerprint string) (meshcatalog.CatalogEntry, meshcatalogclient.EntryState) + Release(fingerprint string) +} + +// ReadEntriesWith sets the reader of the movers' catalog entries; with none, a take-in's movers wait on no bus state. +func (w *Watchman) ReadEntriesWith(r EntryReader) { w.mu.Lock() defer w.mu.Unlock() - w.manifestAccepted(a.Module, a.Problems) // §500: the problems a stricter validator finds are the module's warning + w.entries = r +} + +// moverTaken is a mover of a take-in whose catalog entry is asked: its module and the take-in's time. +type moverTaken struct { + module string + at time.Time +} + +// moversTaken asks the catalog entry of each mover a take-in.taken names, w.mu held: an entry already answered is read +// now, any other once its answer comes (EntryChanged). +func (w *Watchman) moversTaken(movers []meshcatalog.TakeInEntry, at time.Time) { + if w.entries == nil { + return + } + for _, m := range movers { + if m.Fingerprint == "" || m.Module == "" { + continue + } + w.movers[m.Fingerprint] = moverTaken{module: m.Module, at: at} + if e, state := w.entries.Need(context.Background(), m.Fingerprint); state == meshcatalogclient.EntryAnswered { + w.entryRead(m.Fingerprint, e) + } + } +} + +// EntryChanged hears the answer of a mover's entry asked by its fingerprint (the Entries' Changed): an answered entry's +// bus state is waited on; one the holder does not hold is said, since its bus state cannot be known. +func (w *Watchman) EntryChanged(row meshcatalogclient.EntryRow) { + w.mu.Lock() + defer w.mu.Unlock() + m, ok := w.movers[row.Fingerprint] + if !ok { + return + } + switch { + case row.State == meshcatalogclient.EntryAnswered && row.Entry != nil: + w.entryRead(row.Fingerprint, *row.Entry) + case row.State == meshcatalogclient.EntryNotFound: + w.say("the catalog entry of %s at %s is not held (%s), so its bus state is not waited on", m.module, short(row.Fingerprint), row.Detail) + delete(w.movers, row.Fingerprint) + w.entries.Release(row.Fingerprint) + } +} + +// entryRead is a mover's entry answered, w.mu held: its bus state is waited on from the take-in's time, and the entry +// is forgotten. +func (w *Watchman) entryRead(fingerprint string, e meshcatalog.CatalogEntry) { + m, ok := w.movers[fingerprint] + if !ok { + return + } + delete(w.movers, fingerprint) + defer w.entries.Release(fingerprint) + asked, err := BusStateOfEntry(e) + if err != nil { + w.say("the catalog entry of %s at %s does not read (%v), so its bus state is not waited on", m.module, short(fingerprint), err) + return + } + w.busStateAsked(m.module, fingerprint, asked, m.at) +} + +// BusStateOfEntry is the bus state a catalog entry's manifest asks for: the stored manifest keeps it beside requires, under +// catalogue.BusStateField. +func BusStateOfEntry(e meshcatalog.CatalogEntry) ([]catalogue.BusStateEntry, error) { + raw, err := json.Marshal(e.Manifest) + if err != nil { + return nil, err + } + var m map[string]json.RawMessage + if err := json.Unmarshal(raw, &m); err != nil { + return nil, err + } + var entries []catalogue.BusStateEntry + if b, ok := m[catalogue.BusStateField]; ok { + if err := json.Unmarshal(b, &entries); err != nil { + return nil, err + } + } + return entries, nil +} + +// busStateAsked is a taken-in mover's bus state, w.mu held: each entry it asks for waits OverdueBound from the take-in +// for the bus module's word, and every entry of the module this watchman waits on or holds a finding of that it no +// longer asks for is ended. +func (w *Watchman) busStateAsked(module, fingerprint string, entries []catalogue.BusStateEntry, at time.Time) { asked := map[string]bool{} - for _, e := range a.BusState { + for _, e := range entries { if e.Name == "" { continue } asked[e.Name] = true - if w.busCreated[signalKey(rowBusCreated, busStateID(a.Module, e.Name))] { + if w.busCreated[signalKey(rowBusCreated, busStateID(module, e.Name))] { continue // said created already, and created is said once per entry: nothing to wait for } - // One refused since an earlier verdict waits again: a new verdict asks the bus module again. - w.signal(rowBusState, busStateID(a.Module, e.Name), OverdueBound, signalDue{Do: dueFind, Finding: Finding{ - Scope: ScopeModule, ID: a.Module, Token: KindBusStateOverdue + "-" + e.Name, Kind: KindBusStateOverdue, - Severity: Warning, Source: rowBusState, Since: w.now().Add(OverdueBound).UTC().Truncate(time.Second), - Summary: fmt.Sprintf("the bus module said nothing of %s's %s (%s) within %s of its accepted manifest %s", a.Module, - e.Name, e.Storage, OverdueBound, short(a.Digest)), - Headline: "The bus state " + e.Name + " of " + a.Module + " was not created", - Explanation: "The indexer accepted a manifest of " + a.Module + " asking the bus module for " + e.Name + ", and the bus " + - "module said neither created nor refused within " + OverdueBound.String() + ": it is down, or behind. " + a.Module + + // One refused since an earlier take-in waits again: a new take-in asks the bus module again. + f := Finding{ + Scope: ScopeModule, ID: module, Token: KindBusStateOverdue + "-" + e.Name, Kind: KindBusStateOverdue, + Severity: Warning, Source: rowBusState, Since: at.Add(OverdueBound).UTC().Truncate(time.Second), + Summary: fmt.Sprintf("the bus module said nothing of %s's %s (%s) within %s of its take-in at %s", module, + e.Name, e.Storage, OverdueBound, short(fingerprint)), + Headline: "The bus state " + e.Name + " of " + module + " was not created", + Explanation: "The indexer took in " + module + ", whose manifest asks the bus module for " + e.Name + ", and the bus " + + "module said neither created nor refused within " + OverdueBound.String() + ": it is down, or behind. " + module + " fails at its start while the entry's binding is missing (novox/hq ADR 0595 §1).", - Needs: "a look at the bus module's health and its process's log; nats_first_view_again asks it to read the verdicts again"}}) + Needs: "a look at the bus module's health and its process's log; nats_first_view_again asks it to read the entries again"} + if left := OverdueBound - w.now().Sub(at); left > 0 { + w.signal(rowBusState, busStateID(module, e.Name), left, signalDue{Do: dueFind, Finding: f}) + } else { + w.unsignal(rowBusState, busStateID(module, e.Name)) + w.find(f) + } } - for _, local := range w.busStateEntriesOf(a.Module) { + for _, local := range w.busStateEntriesOf(module) { if asked[local] { continue } - w.unsignal(rowBusState, busStateID(a.Module, local)) - w.unfind(overdueKey(a.Module, local)) - w.unfind(refusedKey(a.Module, local)) - w.uncreated(a.Module, local) + w.unsignal(rowBusState, busStateID(module, local)) + w.unfind(overdueKey(module, local)) + w.unfind(refusedKey(module, local)) + w.uncreated(module, local) } } diff --git a/modules/mesh-delivery-watchman/internal/watch/findings_test.go b/modules/mesh-delivery-watchman/internal/watch/findings_test.go index 896c8807..33d7ce1f 100644 --- a/modules/mesh-delivery-watchman/internal/watch/findings_test.go +++ b/modules/mesh-delivery-watchman/internal/watch/findings_test.go @@ -1,8 +1,11 @@ package watch import ( + "context" "encoding/json" "errors" + "fmt" + "slices" "strings" "sync/atomic" "testing" @@ -12,7 +15,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient/heard" "git.novox.be/novox/mesh-contracts/provisioning/go/clients/meshprovisionerclient" @@ -42,181 +44,116 @@ func TestTheWatchmansFindings(t *testing.T) { // want are the finding keys standing at the end, with their severity. want map[string]string }{ - {"ADR 0633 §5 (1585/T21): a revision waiting for an indexer build is a finding past 60 minutes from its since, not within; a group past 30", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + {"design 47 H §744, H-A-94 (2): a held take-in is a finding past take-in-bound from its message's time, not within; the setting counts", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { w.TakeInCaughtUp() // a live message, heard after the replay - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), takeInBody(t, takein.TakeInPending, revKey, t0)) - if o.ttls[signalKey("take-in", revKey)] != TakeInRevisionBound || len(o.findings) != 0 { - t.Fatalf("a revision's wait: ttls %v, findings %v", o.ttls, o.findings) + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 42, "the catalog store is full"), t0) + if o.ttls[signalKey(takeInRow, revKey)] != DefaultTakeInBound || len(o.findings) != 0 { + t.Fatalf("a held take-in: ttls %v, findings %v", o.ttls, o.findings) } - w.TakeIn(takeInEvent(t, takein.TakeInPending, groupKey), takeInBody(t, takein.TakeInPending, groupKey, t0)) - if o.ttls[signalKey("take-in", groupKey)] != TakeInGroupBound { - t.Fatalf("a group's wait: ttls %v", o.ttls) + w.SetTakeInBound(20 * time.Minute) + w.TakeIn(TakeInPendingEvent, pendingBody(t, "feat/x", 7, ""), c.t.Add(-5*time.Minute)) + if o.ttls[signalKey(takeInRow, TakeInKey("feat/x", 7))] != 15*time.Minute { + t.Fatalf("a take-in held five minutes under a 20-minute bound: ttls %v", o.ttls) } - expire(w, c, signalKey("take-in", groupKey), TakeInGroupBound) - if len(o.findings) != 1 { - t.Fatalf("findings at 30 minutes: %v", o.findings) + expire(w, c, signalKey(takeInRow, revKey), DefaultTakeInBound) + if f := o.findings[FindingKey(ScopeDelivery, revKey, KindTakeInWaits)]; !strings.Contains(f.Summary, "the catalog store is full") { + t.Fatalf("the finding does not say why: %v", o.findings) } - expire(w, c, signalKey("take-in", revKey), TakeInRevisionBound-TakeInGroupBound) - }, map[string]string{FindingKey(ScopeDelivery, revKey, KindTakeInWaits): Warning, FindingKey(ScopeDelivery, groupKey, KindTakeInWaits): Warning}}, - {"ADR 0633 §5 (1585/T21): the take-in.taken of a named indexer, a hand take-in or a drop clears the finding", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + }, map[string]string{FindingKey(ScopeDelivery, revKey, KindTakeInWaits): Warning}}, + {"design 47 H §744: the take-in.taken of the source, the indexer's, a hand take-in's or a skip's, clears the finding", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { w.TakeInCaughtUp() // a live message, heard after the replay - for _, by := range []string{"", "operator@shanks"} { - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), takeInBody(t, takein.TakeInPending, revKey, t0)) - expire(w, c, signalKey("take-in", revKey), TakeInRevisionBound) + for _, taken := range []meshcatalog.TakeInTaken{{Branch: "main", Source: 42, Call: "fedcba9876543210", Revision: 3}, + {Branch: "main", Source: 42, By: "operator@shanks", Why: "the store has room", Skipped: true}} { + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 42, ""), t0) + expire(w, c, signalKey(takeInRow, revKey), DefaultTakeInBound) if len(o.findings) != 1 { t.Fatalf("findings past the bound: %v", o.findings) } - taken, err := takein.EncodeTakeIn(takein.TakeIn{Kind: takein.TakeInTaken, Key: revKey, What: takein.TakeInRevision, Since: t0, - Merges: []takein.Merge{{Repository: "novox/a", Merge: "c0ffee"}}, By: by, Why: map[bool]string{true: "dropped", false: ""}[by != ""], Dropped: by != ""}) - if err != nil { - t.Fatal(err) - } - w.TakeIn(takeInEvent(t, takein.TakeInTaken, revKey), taken) + body, _ := json.Marshal(taken) + w.TakeIn(TakeInTakenEvent, body, c.t) c.t = t0 } }, map[string]string{}}, - {"ADR 0633 §5 (1585/T21): a group's take-in.taken ends its 30 minutes, and the revision then pending under m. starts its own 60", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.TakeInCaughtUp() // a live message, heard after the replay - w.TakeIn(takeInEvent(t, takein.TakeInPending, groupKey), takeInBody(t, takein.TakeInPending, groupKey, t0)) - expire(w, c, signalKey("take-in", groupKey), 25*time.Minute) - w.TakeIn(takeInEvent(t, takein.TakeInTaken, groupKey), takeInBody(t, takein.TakeInTaken, groupKey, t0)) - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), takeInBody(t, takein.TakeInPending, revKey, c.t)) - if len(o.findings) != 0 || o.ttls[signalKey("take-in", revKey)] != TakeInRevisionBound { - t.Fatalf("after the hand-over: findings %v, ttls %v", o.findings, o.ttls) - } - expire(w, c, signalKey("take-in", revKey), TakeInRevisionBound) - }, map[string]string{FindingKey(ScopeDelivery, revKey, KindTakeInWaits): Warning}}, - {"ADR 0633 §5 (1585/T21): a pending event heard again at the start, since past its bound, is said once the replay has caught up, not before", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), takeInBody(t, takein.TakeInPending, revKey, t0.Add(-2*time.Hour))) + {"design 47 H §744: a pending heard again at the start, past its bound, is said once the replay has caught up, not before; one followed by its taken never raises", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 42, ""), t0.Add(-2*time.Hour)) + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 43, ""), t0.Add(-2*time.Hour)) + w.TakeIn(TakeInTakenEvent, takenBody(t, "main", 43), t0.Add(-2*time.Hour)) if len(o.findings) != 0 || len(o.pulses) != 0 { - t.Fatalf("a replayed old wait before the replay caught up: findings %v, pulses %v", o.findings, o.pulses) + t.Fatalf("replayed old waits before the replay caught up: findings %v, pulses %v", o.findings, o.pulses) } w.TakeInCaughtUp() }, map[string]string{FindingKey(ScopeDelivery, revKey, KindTakeInWaits): Warning}}, - {"1966/AC195-5: a seed ends the finding and the held wait of a key indexer_pending no longer names, and keeps one it names with its own since", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - // A previous run's finding for revKey stands in the bucket (read at the start); a wait of staleKey is held from an event. - old := Finding{Scope: ScopeDelivery, ID: revKey, Kind: KindTakeInWaits, Severity: Warning, Source: "take-in", Since: t0.Add(-3 * time.Hour), Observer: testModule, Summary: "held", Said: "held", Headline: "held", Explanation: "held", Needs: "a take-in"} + {"design 47 H-A-94 (2), H-A-97: a seed from indexer_pending ends the finding and the wait of a key it no longer names, and times one it names from its own since", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + // A previous run's finding for main.41 stands in the bucket (read at the start); a wait of main.40 is held from an event. + stale := TakeInKey("main", 41) + old := Finding{Scope: ScopeDelivery, ID: stale, Kind: KindTakeInWaits, Severity: Warning, Source: takeInRow, Since: t0.Add(-3 * time.Hour), Observer: testModule, Summary: "held", Said: "held", Headline: "held", Explanation: "held", Needs: "a take-in"} value, err := EncodeFinding(old) if err != nil { t.Fatal(err) } o.findings[old.Key()] = old w.SeedFinding(old.Key(), value) - const staleKey = "m.00000000000000000099" w.TakeInCaughtUp() - w.TakeIn(takeInEvent(t, takein.TakeInPending, staleKey), takeInBody(t, takein.TakeInPending, staleKey, c.t)) - w.SeedTakeIn(takein.PendingAnswer{Waits: []takein.PendingWait{{Key: groupKey, What: takein.TakeInGroup, Keys: []string{groupKey}, - Merges: []takein.Merge{{Repository: "novox/a", Number: 1, Merge: "c0ffee"}}, Since: c.t.Add(-10 * time.Minute)}}}) - if _, ok := o.findings[old.Key()]; ok || w.signals[signalKey("take-in", staleKey)].Finding.ID != "" || w.signals[signalKey("take-in", revKey)].Finding.ID != "" { - t.Fatalf("a wait the answer does not name stands: findings %v, signals %v", o.findings, w.signals) - } - if o.ttls[signalKey("take-in", groupKey)] != TakeInGroupBound-10*time.Minute { - t.Fatalf("the named wait: ttl %v, want the rest of its bound from its own since", o.ttls[signalKey("take-in", groupKey)]) - } - }, map[string]string{}}, - {"1966/AC195-4: a taken event for a key the watchman holds no wait for changes no finding and no signal", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.TakeInCaughtUp() - w.TakeIn(takeInEvent(t, takein.TakeInPending, groupKey), takeInBody(t, takein.TakeInPending, groupKey, t0)) - ttls, pulses := len(o.ttls), len(o.pulses) - w.TakeIn(takeInEvent(t, takein.TakeInTaken, revKey), takeInBody(t, takein.TakeInTaken, revKey, t0)) - if o.findingWrites != 0 || len(o.ttls) != ttls || len(o.pulses) != pulses || o.ttls[signalKey("take-in", groupKey)] != TakeInGroupBound { - t.Fatalf("a taken for an unheld key: findings written %d, ttls %v, pulses %v", o.findingWrites, o.ttls, o.pulses) - } - }, map[string]string{}}, - {"ADR 0633 §5 (1585/T21): a replayed pending followed by its taken never raises", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), takeInBody(t, takein.TakeInPending, revKey, t0.Add(-2*time.Hour))) - w.TakeIn(takeInEvent(t, takein.TakeInTaken, revKey), takeInBody(t, takein.TakeInTaken, revKey, t0.Add(-2*time.Hour))) - w.TakeInCaughtUp() - if o.findingWrites != 0 || len(o.pulses) != 0 { - t.Fatalf("a wait that ended in the replay wrote %d findings and left pulses %v", o.findingWrites, o.pulses) - } - }, map[string]string{}}, - {"ADR 0633 §5 (1585/T21): a wait the indexer holds at a restart within its bound is seeded from indexer_pending and raised past it", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - // The restarted watchman's durable consumer hears nothing of the pending event it acknowledged before; the wait - // began ten minutes ago, and the indexer still holds it. - since := c.t.Add(-10 * time.Minute) - w.SeedTakeIn(takein.PendingAnswer{Waits: []takein.PendingWait{{Key: revKey, What: takein.TakeInRevision, Keys: []string{revKey}, - Merges: []takein.Merge{{Repository: "novox/a", Number: 1, Merge: "c0ffee"}}, Lost: []string{"m.00000000000000000042"}, Since: since}}}) - w.TakeInCaughtUp() - if len(o.findings) != 0 || o.ttls[signalKey("take-in", revKey)] != TakeInRevisionBound-10*time.Minute { - t.Fatalf("within its bound: findings %v, ttl %v; want none yet and the rest of the bound", o.findings, o.ttls[signalKey("take-in", revKey)]) - } - expire(w, c, signalKey("take-in", revKey), TakeInRevisionBound-10*time.Minute) - }, map[string]string{FindingKey(ScopeDelivery, revKey, KindTakeInWaits): Warning}}, - {"ADR 0633 §1 (issue 1921): (A-476 b) a revision held because its message is lost or unread is raised past the revision bound from its since, naming why", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.TakeInCaughtUp() - body, err := takein.EncodeTakeIn(takein.TakeIn{Kind: takein.TakeInPending, Key: revKey, What: takein.TakeInRevision, Since: c.t, - Merges: []takein.Merge{{Repository: "novox/a", Number: 1, Merge: "c0ffee"}}, Lost: []string{revKey}}) + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 40, ""), c.t) + seed, err := DecodeHeldTakeIns([]byte(`{"held":[{"branch":"main","source":42,"why":"the catalog store is full","since":"` + c.t.Add(-10*time.Minute).Format(time.RFC3339) + `"}]}`)) if err != nil { t.Fatal(err) } - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), body) - if o.ttls[signalKey("take-in", revKey)] != TakeInRevisionBound || len(o.findings) != 0 { - t.Fatalf("a lost message: ttls %v, findings %v", o.ttls, o.findings) + w.SeedTakeIn(seed) + if _, ok := o.findings[old.Key()]; ok || w.signals[signalKey(takeInRow, TakeInKey("main", 40))].Finding.ID != "" { + t.Fatalf("a wait the answer does not name stands: findings %v, signals %v", o.findings, w.signals) } - expire(w, c, signalKey("take-in", revKey), TakeInRevisionBound) - for _, f := range o.findings { - if !strings.Contains(f.Summary, "lost or unread") { - t.Errorf("finding %q does not say why", f.Summary) - } + if o.ttls[signalKey(takeInRow, revKey)] != DefaultTakeInBound-10*time.Minute { + t.Fatalf("the named wait: ttl %v, want the rest of its bound from its own since", o.ttls[signalKey(takeInRow, revKey)]) + } + expire(w, c, signalKey(takeInRow, revKey), DefaultTakeInBound-10*time.Minute) + if _, err := DecodeHeldTakeIns([]byte(`{"held":[{"branch":"main","source":42,"why":"w"}]}`)); err == nil { + t.Error("a held take-in with no since was read") } }, map[string]string{FindingKey(ScopeDelivery, revKey, KindTakeInWaits): Warning}}, - {"ADR 0633 §5 (1585/T21): a drop clears the wait, and the merges left under it said pending again with the same since are raised from it", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.TakeInCaughtUp() // a live message, heard after the replay - w.TakeIn(takeInEvent(t, takein.TakeInPending, revKey), takeInBody(t, takein.TakeInPending, revKey, t0)) - expire(w, c, signalKey("take-in", revKey), TakeInRevisionBound) - if len(o.findings) != 1 { - t.Fatalf("findings past the bound: %v", o.findings) + {"1966/AC195-4: a taken event for a key the watchman holds no wait for changes no finding and no signal", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + w.TakeInCaughtUp() + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 42, ""), t0) + ttls, pulses := len(o.ttls), len(o.pulses) + w.TakeIn(TakeInTakenEvent, takenBody(t, "main", 9), t0) + if o.findingWrites != 0 || len(o.ttls) != ttls || len(o.pulses) != pulses || o.ttls[signalKey(takeInRow, revKey)] != DefaultTakeInBound { + t.Fatalf("a taken for an unheld key: findings written %d, ttls %v, pulses %v", o.findingWrites, o.ttls, o.pulses) } - w.TakeIn(takeInEvent(t, takein.TakeInTaken, revKey), takeInBody(t, takein.TakeInTaken, revKey, t0)) - if len(o.findings) != 0 { - t.Fatalf("the drop left %v", o.findings) - } - next := "m.00000000000000000043" - w.TakeIn(takeInEvent(t, takein.TakeInPending, next), takeInBody(t, takein.TakeInPending, next, t0)) - }, map[string]string{FindingKey(ScopeDelivery, "m.00000000000000000043", KindTakeInWaits): Warning}}, - {"design 47 G §500: manifest-refused raises the refusal, manifest-accepted clears it and carries an outgrown manifest's problems", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - w.ManifestRefused(meshcatalog.ManifestRefusedEvent{Module: "nats", Problems: []string{"removes a stream"}}) - w.ManifestRefused(meshcatalog.ManifestRefusedEvent{Module: "power", Problems: []string{"shows nothing"}}) - k := FindingKey(ScopeModule, "nats", KindManifestRefused) - if f := o.findings[k]; !strings.Contains(f.Summary, "refused the manifest of nats: removes a stream") { - t.Fatalf("findings = %v", o.findings) - } - w.Accepted(meshcatalog.ManifestAcceptedEvent{Module: "nats", Digest: strings.Repeat("d", 64)}) - w.Accepted(meshcatalog.ManifestAcceptedEvent{Module: "power", Digest: strings.Repeat("d", 64)}) - // ADR 0579 §1: an accepted manifest a stricter judge outgrew is a warning until mended. - w.Accepted(meshcatalog.ManifestAcceptedEvent{Module: "node-tools", Digest: strings.Repeat("d", 64), Problems: []string{"says no credential form"}}) - if f := o.findings[FindingKey(ScopeModule, "node-tools", KindManifestOutgrown)]; f.Severity != Warning || !strings.Contains(f.Summary, "says no credential form") { - t.Fatalf("findings = %v", o.findings) - } - w.Accepted(meshcatalog.ManifestAcceptedEvent{Module: "node-tools", Digest: strings.Repeat("e", 64), Problems: []string{}}) - // The start seeds from the indexer's verdicts: the newest of each module counts. - w.SeedVerdicts([]VerdictRow{ - {Module: "nats", State: meshcatalogclient.VerdictRefused, Problems: []string{"old"}, At: t0}, - {Module: "nats", State: meshcatalogclient.VerdictAccepted, At: t0.Add(time.Hour)}, - {Module: "power", State: meshcatalogclient.VerdictRefused, Problems: []string{"shows nothing"}, At: t0}, - {Module: "node-tools", State: meshcatalogclient.VerdictAccepted, Warnings: []string{"w"}, At: t0}}) - if len(o.findings) != 2 || o.findings[FindingKey(ScopeModule, "power", KindManifestRefused)].Kind == "" || o.findings[FindingKey(ScopeModule, "node-tools", KindManifestOutgrown)].Kind == "" { - t.Fatalf("findings = %v", o.findings) - } - w.Accepted(meshcatalog.ManifestAcceptedEvent{Module: "power"}) - w.Accepted(meshcatalog.ManifestAcceptedEvent{Module: "node-tools"}) }, map[string]string{}}, - {"DLV-W1, 1966/AC37-AC38 (ADR 0595 §4, design 25 § 12.2): an accepted entry the bus module says nothing of in five minutes is overdue until created; a refused one stands until created; a later verdict no longer asking ends both", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { - accepted := func(locals ...string) meshcatalog.ManifestAcceptedEvent { - a := meshcatalog.ManifestAcceptedEvent{Module: "mesh-knowledge", Digest: strings.Repeat("d", 64)} + {"DLV-W1, 1966/AC37-AC38 (ADR 0595 §4), design 47 H-A-94 (1): an entry a taken-in mover's catalog entry asks for that the bus module says nothing of in five minutes is overdue until created; a refused one stands until created; a later take-in no longer asking ends both", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + entries := &fakeEntries{entries: map[string]meshcatalog.CatalogEntry{}, answer: true} + w.ReadEntriesWith(entries) + source := int64(0) + accepted := func(locals ...string) { + source++ + fp := fmt.Sprintf("src2:%064d", source) + var bus []map[string]string for _, l := range locals { - a.BusState = append(a.BusState, meshcatalog.ManifestAcceptedEventBusStateItem{Name: l, Storage: "ledger"}) + bus = append(bus, map[string]string{"name": l, "storage": "ledger"}) } - return a + entries.entries[fp] = meshcatalog.CatalogEntry{Module: "mesh-knowledge", Fp: fp, Manifest: map[string]any{"module": "mesh-knowledge", "bus-state": bus}} + w.TakeIn(TakeInTakenEvent, takenBody(t, "main", source, meshcatalog.TakeInEntry{Module: "mesh-knowledge", Fingerprint: fp, Commit: "c0ffee", Repository: "novox/mesh-knowledge"}), c.t) + } + // The first entry is asked and answered after: its wait is timed from the take-in, not from the answer. + entries.answer = false + accepted("records", "drafts", "kept") + if len(o.ttls) != 0 || len(entries.released) != 0 { + t.Fatalf("a wait before the entry was answered: %v", o.ttls) + } + fp1 := fmt.Sprintf("src2:%064d", 1) + e1 := entries.entries[fp1] + c.t = c.t.Add(time.Minute) + w.EntryChanged(meshcatalogclient.EntryRow{Fingerprint: fp1, State: meshcatalogclient.EntryAnswered, Entry: &e1}) + entries.answer = true + if !slices.Equal(entries.released, []string{fp1}) { + t.Fatalf("the entry read is not released: %v", entries.released) } - w.Accepted(accepted("records", "drafts", "kept")) pk := func(local string) string { return signalKey(rowBusState, busStateID("mesh-knowledge", local)) } - if o.ttls[pk("records")] != OverdueBound { - t.Fatalf("no five-minute pulse for records: %v", o.ttls) + if o.ttls[pk("records")] != OverdueBound-time.Minute { + t.Fatalf("no pulse for records within five minutes of its take-in: %v", o.ttls) } w.BrokerCreated(BrokerSaid{Module: "mesh-knowledge", Local: "drafts"}) - expire(w, c, pk("drafts"), 5*time.Minute) // created in time: no finding + expire(w, c, pk("drafts"), 4*time.Minute) // created in time: no finding expire(w, c, pk("records"), 0) overdue := o.findings[overdueKey("mesh-knowledge", "records")] if overdue.Kind != KindBusStateOverdue || !strings.Contains(overdue.Summary, "mesh-knowledge's records") { @@ -226,13 +163,13 @@ func TestTheWatchmansFindings(t *testing.T) { if _, open := o.findings[overdueKey("mesh-knowledge", "records")]; open { t.Fatal("created did not clear overdue") } - // Review round 1: created is said once per entry, so a second accepted manifest with the same entries waits on + // Review round 1: created is said once per entry, so a second take-in with the same entries waits on // none of them, and the mark that says so has no time to live. delete(o.pulses, pk("records")) // expired above; the fake keeps an expired pulse - w.Accepted(accepted("records", "drafts")) + accepted("records", "drafts") for _, local := range []string{"records", "drafts"} { if _, waits := o.pulses[pk(local)]; waits { - t.Fatalf("a second accepted manifest waits again on %s, said created already", local) + t.Fatalf("a second take-in waits again on %s, said created already", local) } if mk := signalKey(rowBusCreated, busStateID("mesh-knowledge", local)); o.ttls[mk] != 0 || o.pulses[mk].Owes == "" { t.Fatalf("the mark of %s created is %v with time to live %v", local, o.pulses[mk], o.ttls[mk]) @@ -246,9 +183,9 @@ func TestTheWatchmansFindings(t *testing.T) { if !signalKind(mustEncode(t, o.findings[refusedKey("mesh-knowledge", "kept")])) { t.Error("a refused creation would be dropped at a restart") } - // A later verdict asking for kept alone again waits on it again; one no longer asking for it ends it. - w.Accepted(accepted("kept", "fresh")) - w.Accepted(accepted("fresh")) + // A later take-in asking for kept again waits on it again; one no longer asking for it ends it. + accepted("kept", "fresh") + accepted("fresh") if _, open := o.findings[refusedKey("mesh-knowledge", "kept")]; open { t.Fatal("a verdict no longer asking for kept left its finding") } @@ -257,7 +194,7 @@ func TestTheWatchmansFindings(t *testing.T) { } w.BrokerCreated(BrokerSaid{Module: "mesh-knowledge", Local: "fresh"}) // A refused create stands until created. - w.Accepted(accepted("gone")) + accepted("gone") w.BrokerRefused(BrokerSaid{Module: "mesh-knowledge", Local: "gone"}) }, map[string]string{refusedKey("mesh-knowledge", "gone"): Urgent}}, {"ADR 0615 §5 (review round 1): a consumer the watchman cannot bind is family-not-heard naming its stream, until it binds", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { @@ -493,38 +430,39 @@ func TestTheWatchmansFindings(t *testing.T) { w.DeadLettersHeld(map[string]int{"SEAT_X.y_worker": 1}, who) w.NoticesWaiting(true) }, map[string]string{"bus.SEAT_X.y_worker.max-deliveries": Warning, "bus.DEAD_LETTER_NOTICES.controller.notices-waiting": Warning}}, - {"ADR 0603 §8: a want held by a rule and a provision asked each raise a finding naming the wait past their bound, and clear when it ends", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { + {"design 47 H-A-95 (1): a want awaiting its hand placement is not timed, and is timed once it no longer holds; ADR 0603 §8: a provision asked raises a finding naming the wait past its bound, and clears when it ends", func(t *testing.T, w *Watchman, o *fakeOut, c *clock) { w.SetStepBound(30 * time.Minute) - held, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpOld, Self: true, Newest: fpNew, Rule: meshwantsclient.RuleCanary, Words: "the canary ace does not run it yet"}) - released, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Self: true}) + held, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpOld, Hold: true, Words: meshwantsclient.HoldAwaitsHandPlacement}) + if err != nil { + t.Fatal(err) + } + released, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Pipeline: "main.42", Rank: 1}) + if err != nil { + t.Fatal(err) + } asked, _ := meshprovisionerclient.Encode(meshprovisionerclient.Provision{Provision: "oidc", Consumer: meshprovisionerclient.End{Module: "photos", Node: "ace"}, Provider: meshprovisionerclient.End{Module: "keycloak", Node: "novox"}, State: meshprovisionerclient.Asked, At: t0}) provided, _ := meshprovisionerclient.Encode(meshprovisionerclient.Provision{Provision: "oidc", Consumer: meshprovisionerclient.End{Module: "photos", Node: "ace"}, Provider: meshprovisionerclient.End{Module: "keycloak", Node: "novox"}, State: meshprovisionerclient.Provided, At: t0}) - w.EngineRunning("ace", "web", []byte(`{"fingerprint":"`+fpOld+`"}`)) // the node runs what the held want names: the hold is still the wait - w.Want("want.ace.web", held, Put, t0) + w.Want("want.ace.web", held, Put, c.t) w.Provision("ace.photos.oidc", asked, Put) - waits := map[string]string{AssignerWantsBucket: "want.ace.web", ProvisionsBucket: "ace.photos.oidc"} - if len(o.pulses) != 2 || len(o.findings) != 0 { - t.Fatalf("pulses %v findings %v", o.pulses, o.findings) + if _, timed := o.pulses[pulseKeyOf(t, testWants(), "want.ace.web")]; timed || len(o.pulses) != 1 || len(o.stuck) != 0 || len(o.findings) != 0 { + t.Fatalf("a held want is timed: pulses %v stuck %v findings %v", o.pulses, o.stuck, o.findings) } - // The keys are written again as their parts move on, with new words and a new time: the wait still began at t0. + // The provision is written again as it moves on, with new words and a new time: the wait still began at t0. c.t = c.t.Add(20 * time.Minute) - held2, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpOld, Self: true, Newest: fpNew, Rule: meshwantsclient.RuleCanary, Words: "the canary ace runs it, not healthy yet"}) asked2, _ := meshprovisionerclient.Encode(meshprovisionerclient.Provision{Provision: "oidc", Consumer: meshprovisionerclient.End{Module: "photos", Node: "ace"}, Provider: meshprovisionerclient.End{Module: "keycloak", Node: "novox"}, State: meshprovisionerclient.Asked, Why: "the provider is applying", At: c.t}) - w.Want("want.ace.web", held2, Put, c.t) w.Provision("ace.photos.oidc", asked2, Put) - for bucket, key := range waits { - expire(w, c, pulseKeyOf(t, bucket, key), 31*time.Minute) - } - for bucket, key := range waits { - f := o.findings[FindingKey(ScopeDelivery, stuckKeyOf(t, bucket, key), KindStuck)] - if f.Kind != KindStuck || !f.Since.Equal(t0) || !strings.Contains(f.Summary, "bound 30m0s") { - t.Fatalf("%s: findings = %v", bucket, o.findings) - } + expire(w, c, pulseKeyOf(t, ProvisionsBucket, "ace.photos.oidc"), 31*time.Minute) + f := o.findings[FindingKey(ScopeDelivery, stuckKeyOf(t, ProvisionsBucket, "ace.photos.oidc"), KindStuck)] + if f.Kind != KindStuck || !f.Since.Equal(t0) || !strings.Contains(f.Summary, "bound 30m0s") { + t.Fatalf("findings = %v", o.findings) } w.Want("want.ace.web", released, Put, c.t) + if _, timed := o.pulses[pulseKeyOf(t, testWants(), "want.ace.web")]; !timed { + t.Fatalf("a want no longer held is not timed: pulses %v", o.pulses) + } w.Provision("ace.photos.oidc", provided, Put) }, map[string]string{}}, } @@ -551,37 +489,45 @@ func TestTheWatchmansFindings(t *testing.T) { } } -const ( - revKey = "m.00000000000000000042" - groupKey = "g.feat/take-in" -) +// revKey is the take-in wait's key of main's source revision 42 (design 47 H-A-94 (2)). +var revKey = TakeInKey("main", 42) -func takeInEvent(t *testing.T, kind, key string) string { +// pendingBody is a take-in.pending's body, in the contract's form. +func pendingBody(t *testing.T, branch string, source int64, why string) []byte { t.Helper() - e, err := takein.TakeInEvent(kind) - if err != nil { - t.Fatal(err) - } - return e -} - -// takeInBody is a take-in event's body for a key: a group's when it starts with g. -func takeInBody(t *testing.T, kind, key string, since time.Time) []byte { - t.Helper() - body := takein.TakeIn{Kind: kind, Key: key, What: takein.TakeInRevision, Since: since, - Merges: []takein.Merge{{Repository: "novox/a", Number: 1, Merge: "c0ffee"}}} - if key[0] == 'g' { - body.What, body.Group = takein.TakeInGroup, "feat/take-in" - } else if kind == takein.TakeInPending { - body.Lost = []string{key} - } - b, err := takein.EncodeTakeIn(body) + b, err := json.Marshal(meshcatalog.TakeInPending{Branch: branch, Source: source, Why: why}) if err != nil { t.Fatal(err) } return b } +// takenBody is a take-in.taken's body naming its movers, in the contract's form. +func takenBody(t *testing.T, branch string, source int64, movers ...meshcatalog.TakeInEntry) []byte { + t.Helper() + b, err := json.Marshal(meshcatalog.TakeInTaken{Branch: branch, Source: source, Call: "fedcba9876543210", Revision: source, Entries: movers}) + if err != nil { + t.Fatal(err) + } + return b +} + +// fakeEntries answers a mover's catalog entry by fingerprint: at once when answer is set, else asked. +type fakeEntries struct { + entries map[string]meshcatalog.CatalogEntry + answer bool + released []string +} + +func (f *fakeEntries) Need(_ context.Context, fp string) (meshcatalog.CatalogEntry, meshcatalogclient.EntryState) { + if e, ok := f.entries[fp]; ok && f.answer { + return e, meshcatalogclient.EntryAnswered + } + return meshcatalog.CatalogEntry{}, meshcatalogclient.EntryAsked +} + +func (f *fakeEntries) Release(fp string) { f.released = append(f.released, fp) } + // Design 47 G §689, A-14, A-22: a token other than the kind goes into the contract finding's id and reads back as it was // written; the finding's time is its `since`; the resolved words are not on the wire. func TestAFindingIsTheContractsWithItsRefInItsID(t *testing.T) { diff --git a/modules/mesh-delivery-watchman/internal/watch/mirror.go b/modules/mesh-delivery-watchman/internal/watch/mirror.go index af76a4b1..0fba92cb 100644 --- a/modules/mesh-delivery-watchman/internal/watch/mirror.go +++ b/modules/mesh-delivery-watchman/internal/watch/mirror.go @@ -7,7 +7,6 @@ import ( "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshwatchdogsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" @@ -124,7 +123,6 @@ func (w *Watchman) Want(key string, value []byte, op Op, at time.Time) { return case Delete: delete(w.wants, key) - delete(w.held, key) w.moved(w.wantsBucket(), key) return } @@ -136,30 +134,16 @@ func (w *Watchman) Want(key string, value []byte, op Op, at time.Time) { } if want.Removed { delete(w.wants, key) - delete(w.held, key) + w.moved(w.wantsBucket(), key) + return + } + if want.Hold { + // A want awaiting its hand placement (design 47 H §772) is not progress owed, so it is not timed (H-A-95 (1)). + delete(w.wants, key) w.moved(w.wantsBucket(), key) return } w.wants[key] = want.Fp - if want.Newest != "" || want.Rule != 0 { - // A want held by a rule (ADR 0603 §8) waits on the rule, not on the node: its wait is the hold's, from the time the - // assigner wrote it, and the node running what the want names does not end it. - if at.IsZero() { - at = w.now() - } - w.held[key] = true - w.mirrorKept(w.wantsBucket(), key, - describe("the hold on %s on %s at %s (rule %d) to end, bound %s: %s", module, node, shortFP(want.Fp), want.Rule, w.stepBound, want.Words), - "held|"+want.Fp+"|"+want.Newest, at) - return - } - if w.held[key] { - delete(w.held, key) - if pk, err := meshwatchdogsclient.PulseKey(w.wantsBucket(), key); err == nil { - delete(w.starts, pk) - } - w.stuckMoved(w.wantsBucket(), key) // the hold ended: its finding is cleared - } if w.have(node, module) == want.Fp { w.moved(w.wantsBucket(), key) return diff --git a/modules/mesh-delivery-watchman/internal/watch/names.go b/modules/mesh-delivery-watchman/internal/watch/names.go index 3ed7e271..1f85ef71 100644 --- a/modules/mesh-delivery-watchman/internal/watch/names.go +++ b/modules/mesh-delivery-watchman/internal/watch/names.go @@ -30,6 +30,5 @@ func BucketsOf(module string) OwnBuckets { // The findings a value of another part is raised as, named by their words. const ( - FindingManifestOutgrown = "manifest-outgrown" FindingNodeAccountFallback = "node-account-fallback" ) diff --git a/modules/mesh-delivery-watchman/internal/watch/pipelines.go b/modules/mesh-delivery-watchman/internal/watch/pipelines.go index 05cb4a7b..4ae9cd60 100644 --- a/modules/mesh-delivery-watchman/internal/watch/pipelines.go +++ b/modules/mesh-delivery-watchman/internal/watch/pipelines.go @@ -5,115 +5,14 @@ import ( "fmt" "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) -// What the runner and the gate say of a watched branch's head, heard as events (design 47 G §12, §75, §112): a head the -// gate says moved (`source-moved`) that starts no pipeline within five minutes is the finding `pipeline-stands`, naming the -// branch and its head, raised by the condition keeper and cleared by the runner's `pipeline-started` for that head. - -// KindPipelineStands is a watched branch's head, or a step, standing still (design 47 G §12, §75). +// KindPipelineStands is a pipeline step standing still (design 47 H §741; G §12, §75): the watchman learns no head, so a +// watched branch's head that starts no pipeline is the gate's head-untaken alone, and a pipeline waiting its turn raises +// nothing (steps.go). const KindPipelineStands = "pipeline-stands" -// HeadBound is how long a watched branch's head may stand with no pipeline started (design 47 G §12, §112: the record's five -// minutes). -const HeadBound = 5 * time.Minute - -// headRow is the signals table's row of a head with no pipeline. -const headRow = "head-pipeline" - -// head is a watched branch's head still waiting for its pipeline. -type head struct { - revision int64 - at time.Time -} - -// SourceMoved hears the seat mesh-delivery's `source-moved`: the branch's head is a new source revision, and its pipeline -// is due within HeadBound. A move made by a gathered group is a member governed by the take-in's own bound (ADR 0633 §5), -// so it is not timed here (design 47 G §12). A later move of the same branch replaces the head that waits. -func (w *Watchman) SourceMoved(body []byte) { - var m meshdelivery.SourceMovedEvent - if err := json.Unmarshal(body, &m); err != nil || m.Branch == "" || m.Revision == 0 { - w.say("a source-moved does not read, left: %v", err) - return - } - w.mu.Lock() - defer w.mu.Unlock() - id := headID(m.Branch) - w.unsignal(headRow, id) - w.unfind(FindingKey(ScopeDelivery, id, KindPipelineStands)) - if m.Group != "" { - delete(w.heads, m.Branch) - return - } - at := w.now() - if m.At != nil && !m.At.IsZero() { - at = *m.At - } - w.heads[m.Branch] = head{revision: m.Revision, at: at} - w.timeHead(m.Branch) -} - -// timeHead times the head of a branch that waits for its pipeline, w.mu held: five minutes from its own time, unless the -// branch has a pending revision, whose take-in wait governs it (design 47 G §497) and which times it again once taken in. -func (w *Watchman) timeHead(branch string) { - h, ok := w.heads[branch] - if !ok || w.branchPending(branch) { - return - } - id := headID(branch) - f := Finding{Scope: ScopeDelivery, ID: id, Kind: KindPipelineStands, Severity: Warning, Source: headRow, Since: h.at, - Summary: fmt.Sprintf("the head of %s (source revision %d) has started no pipeline since %s", branch, h.revision, stamp(h.at)), - Said: fmt.Sprintf("no pipeline in %s", HeadBound), - Headline: "A change has started no pipeline", - Explanation: "The head of the watched branch " + branch + " (source revision " + fmt.Sprint(h.revision) + ") moved " + - HeadBound.String() + " ago or more and the pipeline runner has said no pipeline started for it.", - Needs: "the runner to start the pipeline (its verbs mesh-pipeline-runner.stands and mesh-pipeline-runner.list say where it is)"} - left := HeadBound - w.now().Sub(h.at) - if left > 0 { - w.signal(headRow, id, left, signalDue{Do: dueFind, Finding: f}) - return - } - w.find(f) -} - -// branchPending is whether an open take-in wait names the branch (design 47 G §497): its head is behind a pending revision. -func (w *Watchman) branchPending(branch string) bool { - for _, b := range w.pendingBranch { - if b == branch { - return true - } - } - return false -} - -// PipelineStarted hears the runner's `pipeline-started`: it ends the wait of the head it is for (the branch's head at that -// source revision or a later one). A run on request is no head's pipeline. -func (w *Watchman) PipelineStarted(body []byte) { - var p meshpipelinerunner.PipelineStartedEvent - if err := json.Unmarshal(body, &p); err != nil || p.Branch == "" { - w.say("a pipeline-started does not read, left: %v", err) - return - } - if p.Run != "" { - return - } - w.mu.Lock() - defer w.mu.Unlock() - h, ok := w.heads[p.Branch] - if !ok || p.Source < h.revision { - return - } - delete(w.heads, p.Branch) - id := headID(p.Branch) - w.unsignal(headRow, id) - w.unfind(FindingKey(ScopeDelivery, id, KindPipelineStands)) -} - -// headID is the finding's id of a branch's head. -func headID(branch string) string { return "head-" + unsafeKey.ReplaceAllString(branch, "_") } - // KindBuildCapacityWaits is a build seat whose oldest queued step has waited the bound (design 47 G §86). const KindBuildCapacityWaits = "build-capacity-waits" diff --git a/modules/mesh-delivery-watchman/internal/watch/pipelines_test.go b/modules/mesh-delivery-watchman/internal/watch/pipelines_test.go index 230a4739..e45c2b74 100644 --- a/modules/mesh-delivery-watchman/internal/watch/pipelines_test.go +++ b/modules/mesh-delivery-watchman/internal/watch/pipelines_test.go @@ -7,115 +7,8 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" ) -func moved(branch string, rev int64, group string, at time.Time) []byte { - b, _ := json.Marshal(meshdelivery.SourceMovedEvent{Branch: branch, Revision: rev, Group: group, At: &at}) - return b -} - -// takeInBodyOn is a take-in event's body that names its watched branch (design 47 G §493). -func takeInBodyOn(t *testing.T, kind, key, branch string, since time.Time) []byte { - t.Helper() - var m map[string]any - if err := json.Unmarshal(takeInBody(t, kind, key, since), &m); err != nil { - t.Fatal(err) - } - m["branch"] = branch - b, err := json.Marshal(m) - if err != nil { - t.Fatal(err) - } - return b -} - -func started(branch string, rev int64, run string) []byte { - b, _ := json.Marshal(meshpipelinerunner.PipelineStartedEvent{Branch: branch, Source: rev, Run: run, Module: "m", Pipeline: "p"}) - return b -} - -// design 47 G §12, §79 (test 76): a head with no pipeline within five minutes is `pipeline-stands`, cleared by the -// runner's `pipeline-started` for that head; a gathered group's member and a run on request do not. -func TestAHeadWithNoPipelineStands(t *testing.T) { - key := FindingKey(ScopeDelivery, headID("main"), KindPipelineStands) - cases := []struct { - name string - run func(w *Watchman, o *fakeOut, c *clock) - stand bool - }{ - {"five minutes and no pipeline", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "", c.t)) - if o.ttls[signalKey(headRow, headID("main"))] != HeadBound || len(o.findings) != 0 { - t.Fatalf("within the bound: %v %v", o.ttls, o.findings) - } - expire(w, c, signalKey(headRow, headID("main")), HeadBound) - }, true}, - {"its pipeline-started clears it", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "", c.t)) - expire(w, c, signalKey(headRow, headID("main")), HeadBound) - w.PipelineStarted(started("main", 7, "")) - }, false}, - {"a pipeline before the bound raises none", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "", c.t)) - w.PipelineStarted(started("main", 8, "")) - if _, ok := o.pulses[signalKey(headRow, headID("main"))]; ok { - t.Fatal("the pulse stands") - } - }, false}, - {"a pipeline of an older head does not clear a newer head", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "", c.t)) - w.PipelineStarted(started("main", 6, "")) - expire(w, c, signalKey(headRow, headID("main")), HeadBound) - }, true}, - {"a gathered group's member is not timed", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "grp", c.t)) - if len(o.pulses) != 0 { - t.Fatalf("a pulse for a member: %v", o.pulses) - } - }, false}, - {"a head behind a pending revision of its branch is not timed", func(w *Watchman, o *fakeOut, c *clock) { - w.TakeIn(takeInEvent(t, takein.TakeInPending, "m.1"), takeInBodyOn(t, takein.TakeInPending, "m.1", "main", c.t)) - w.SourceMoved(moved("main", 7, "", c.t)) - if _, ok := o.pulses[signalKey(headRow, headID("main"))]; ok { - t.Fatalf("a pulse for a head behind a pending revision: %v", o.pulses) - } - }, false}, - {"a pending revision of another branch does not hold it", func(w *Watchman, o *fakeOut, c *clock) { - w.TakeIn(takeInEvent(t, takein.TakeInPending, "m.1"), takeInBodyOn(t, takein.TakeInPending, "m.1", "other", c.t)) - w.SourceMoved(moved("main", 7, "", c.t)) - expire(w, c, signalKey(headRow, headID("main")), HeadBound) - }, true}, - {"a head whose pending revision is taken in is timed again", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "", c.t)) - w.TakeIn(takeInEvent(t, takein.TakeInPending, "m.1"), takeInBodyOn(t, takein.TakeInPending, "m.1", "main", c.t)) - if _, ok := o.pulses[signalKey(headRow, headID("main"))]; ok { - t.Fatalf("the head is timed behind a pending revision: %v", o.pulses) - } - c.t = c.t.Add(HeadBound) - w.TakeIn(takeInEvent(t, takein.TakeInTaken, "m.1"), takeInBodyOn(t, takein.TakeInTaken, "m.1", "main", c.t)) - if _, ok := o.findings[key]; !ok { - t.Fatalf("the head, past its five minutes when taken in, stands: %v", o.findings) - } - }, true}, - {"a run on request is no head's pipeline", func(w *Watchman, o *fakeOut, c *clock) { - w.SourceMoved(moved("main", 7, "", c.t)) - w.PipelineStarted(started("main", 7, "run-1")) - expire(w, c, signalKey(headRow, headID("main")), HeadBound) - }, true}, - } - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - w, o, c := setup() - tc.run(w, o, c) - if _, ok := o.findings[key]; ok != tc.stand { - t.Fatalf("the finding stands %v, want %v: %v", ok, tc.stand, o.findings) - } - }) - } -} - func queuedStep(pipeline, step, seat, outcome string, started time.Time) []byte { b, _ := json.Marshal(meshpipelinerunner.StepEvent{Pipeline: pipeline, Branch: "main", Module: "m", Commit: "c", Result: meshpipelinerunner.StepResult{Step: step, Seat: seat, Outcome: outcome, Started: &started}}) @@ -249,37 +142,31 @@ func TestARecordOpenADayIsAFinding(t *testing.T) { } } -// design 47 G §502, A-200 (WM16): a record is tied to the entries of the take-in.taken of its milestone `.`; it -// is covered only while one of those entries is held by an `acting-part-late` wait, so another record's late entry covers nothing. -func TestARecordIsCoveredOnlyByTheWaitsOfItsOwnEntries(t *testing.T) { +// design 47 G §502, A-200 (WM16), H-A-25: a record is tied to its source revision by its milestone `.`, the +// key of that revision's take-in wait: while its take-in is held and said, take-in-waits covers it; once taken in it is open +// at 24 hours, and another record's held take-in covers nothing of it. +func TestARecordIsCoveredOnlyWhileItsOwnTakeInIsHeld(t *testing.T) { w, o, c := setup() - taken := func(key string, source int64, module string) { - var m map[string]any - if err := json.Unmarshal(takeInBody(t, takein.TakeInTaken, key, c.t), &m); err != nil { - t.Fatal(err) - } - m["branch"], m["source"] = "main", source - m["entries"] = []map[string]any{{"commit": "c", "fingerprint": "f", "module": module}} - b, _ := json.Marshal(m) - w.TakeIn(takeInEvent(t, takein.TakeInTaken, key), b) - } - taken("m.1", 7, "web") - taken("m.2", 8, "db") + w.TakeInCaughtUp() + w.TakeIn(TakeInTakenEvent, takenBody(t, "main", 8), c.t) + w.TakeIn(TakeInPendingEvent, pendingBody(t, "main", 7, "the catalog store is full"), c.t) rec := func(id, milestone string) []byte { - b, _ := json.Marshal(meshdelivery.RecordOpenedEvent{Record: id, Milestone: milestone, At: &c.t}) + b, _ := json.Marshal(meshdelivery.RecordOpenedEvent{Record: id, Milestone: milestone, Branch: "main", Call: "fedcba9876543210", At: &c.t}) return b } - w.RecordOpen(rec("rWeb", "main.7")) - w.RecordOpen(rec("rDb", "main.8")) - late, _ := json.Marshal(meshwants.Wait{Step: "place", Part: "mesh-delivery-indexer", Node: "ace", Module: "web", Since: c.t, Bound: "30m"}) - w.WaitHeld("mesh-wants", late) - expire(w, c, signalKey(actingRow, "mesh-wants-place-mesh-delivery-indexer-ace-web"), 30*time.Minute) - expire(w, c, signalKey(recordRow, "rWeb"), RecordOpenBound) - expire(w, c, signalKey(recordRow, "rDb"), 0) - if _, ok := o.findings[FindingKey(ScopeDelivery, "rWeb", KindRecordOpen)]; ok { - t.Fatalf("a record whose entry is held by acting-part-late is covered: %v", o.findings) + w.RecordOpen(rec("rHeld", "main.7")) + w.RecordOpen(rec("rTaken", "main.8")) + expire(w, c, signalKey(takeInRow, TakeInKey("main", 7)), DefaultTakeInBound) + expire(w, c, signalKey(recordRow, "rHeld"), RecordOpenBound-DefaultTakeInBound) + expire(w, c, signalKey(recordRow, "rTaken"), 0) + if _, ok := o.findings[FindingKey(ScopeDelivery, "rHeld", KindRecordOpen)]; ok { + t.Fatalf("a record whose take-in is held and said is not covered: %v", o.findings) } - if _, ok := o.findings[FindingKey(ScopeDelivery, "rDb", KindRecordOpen)]; !ok { - t.Fatalf("a record of other entries is open at 24 hours whatever else is late: %v", o.findings) + if _, ok := o.findings[FindingKey(ScopeDelivery, "rTaken", KindRecordOpen)]; !ok { + t.Fatalf("a record taken in is not open at 24 hours whatever else is held: %v", o.findings) + } + w.TakeIn(TakeInTakenEvent, takenBody(t, "main", 7), c.t) + if _, ok := o.findings[FindingKey(ScopeDelivery, "rHeld", KindRecordOpen)]; !ok { + t.Fatalf("a record whose take-in ended is not open: %v", o.findings) } } diff --git a/modules/mesh-delivery-watchman/internal/watch/records.go b/modules/mesh-delivery-watchman/internal/watch/records.go index d08a0e4e..8d600b08 100644 --- a/modules/mesh-delivery-watchman/internal/watch/records.go +++ b/modules/mesh-delivery-watchman/internal/watch/records.go @@ -3,7 +3,6 @@ package watch import ( "encoding/json" "fmt" - "strings" "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" @@ -14,15 +13,14 @@ import ( // - `filling`, `full` and `room` of a store against its cap: `store-filling` while it stands past its cap's share, urgent // when it is full, cleared by `room` or by a `filling` under FillingFrom; // - `record-opened` and `record-ended` of a delivery record: `record-open` when it has stood open for 24 hours, unless -// another condition already tells why (`acting-part-late`, or a store `full`). +// another condition already tells why (a store `full`, or the take-in held). // Each is a row of the signals table: its pulse is its bound, written at the event, so a restart loses none. // The kinds of these findings. const ( - KindActingPartLate = "acting-part-late" - KindPutStands = "put-stands" - KindStoreFilling = "store-filling" - KindRecordOpen = "record-open" + KindPutStands = "put-stands" + KindStoreFilling = "store-filling" + KindRecordOpen = "record-open" ) // The rows of the signals table of these findings, which a restart keeps. @@ -126,12 +124,11 @@ func (w *Watchman) RecordEnded(body []byte) { w.unfind(FindingKey(ScopeDelivery, r.Record, KindRecordOpen)) } -// recordCovered says another condition tells the operator why a record is open (design 47 G §502, A-200): the record is tied to the -// entries of its source revision's `take-in.taken` by its milestone, `.`, and is covered while one of those -// entries is held by a wait that raised `acting-part-late`, or a store says `full`; a record whose revision is not known to be taken in -// is covered by a standing `take-in-waits`. +// recordCovered says another condition tells the operator why a record is open (design 47 G §502, A-200): a store says `full`, or +// the record's source revision, its milestone `.` (H-A-25), is not known to be taken in while a `take-in-waits` +// stands. func (w *Watchman) recordCovered(record string) bool { - entries, taken := w.takenEntries[w.recordMilestone[record]] + taken := w.taken[w.recordMilestone[record]] for _, v := range w.findings { f, err := DecodeFinding(v) if err != nil { @@ -140,12 +137,6 @@ func (w *Watchman) recordCovered(record string) bool { switch { case f.Kind == KindStoreFilling && f.Severity == Urgent: return true - case f.Kind == KindActingPartLate && taken: - for _, module := range entries { - if strings.HasSuffix(f.ID, "-"+module) { - return true - } - } case f.Kind == KindTakeInWaits && !taken: return true } diff --git a/modules/mesh-delivery-watchman/internal/watch/signals.go b/modules/mesh-delivery-watchman/internal/watch/signals.go index 9391c456..ac7a4022 100644 --- a/modules/mesh-delivery-watchman/internal/watch/signals.go +++ b/modules/mesh-delivery-watchman/internal/watch/signals.go @@ -777,8 +777,8 @@ var SignalRows = []struct{ Row, Signal, Bound, Kind string }{ {"S10", "the self-check's checked", (3 * SelfCheckEvery).String(), KindSelfCheckSilent}, {"S11", "a machine's tool runner heartbeat", "3 × its interval (" + (3 * HeartbeatEvery).String() + " when it says none)", KindToolsSilent}, {"S21", "a machine's provisioner client's files not placed", ApplyEvery.String(), KindApplyFailing}, - {"take-in", "a source revision or a delivery group the indexer holds back (ADR 0633 §5)", TakeInRevisionBound.String() + " a revision, " + TakeInGroupBound.String() + " a group", KindTakeInWaits}, - {actingRow, "an acting part's wait held, or a put's, a put without hold that stands (the seats' wait-held, ended by wait-ended)", "the wait's own bound", KindActingPartLate + ", " + KindPutStands}, + {takeInRow, "a source revision whose take-in the indexer holds (take-in.pending, ended by take-in.taken; design 47 H §744)", "the setting take-in-bound, " + DefaultTakeInBound.String() + " by default", KindTakeInWaits}, + {actingRow, "a put without hold that stands (the seat mesh-wants' wait-held, ended by wait-ended)", "the wait's own bound", KindPutStands}, {storeRow, "a store of the delivery's parts filling or full (the seats' filling, full and room)", "filling from " + fmt.Sprintf("%.0f", FillingFrom*100) + " %, full urgent", KindStoreFilling}, {recordRow, "a delivery record open (the seat mesh-delivery's record-opened, ended by record-ended)", RecordOpenBound.String(), KindRecordOpen}, {"provisions", "a provision of mesh-provisioner in waits (ADR 0570 §7)", "at once", KindNeedsOperator}, diff --git a/modules/mesh-delivery-watchman/internal/watch/takein.go b/modules/mesh-delivery-watchman/internal/watch/takein.go index e534ac6c..48f85b9e 100644 --- a/modules/mesh-delivery-watchman/internal/watch/takein.go +++ b/modules/mesh-delivery-watchman/internal/watch/takein.go @@ -9,75 +9,107 @@ import ( "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" ) -// KindTakeInWaits is a source revision or a delivery group the indexer holds back and has not taken in within its bound -// (novox/hq ADR 0633 §5, issue 1585): a revision for the indexer build it names, a group for its end. It stands until a -// `take-in.taken` ends the wait, whoever ended it (the named indexer, a revert, a hand take-in or a drop). +// KindTakeInWaits is a source revision the indexer holds back and has not taken in within the setting take-in-bound +// (design 47 H §744, H-A-94 (2); G §497): its take-in cannot be written. It stands until a `take-in.taken` of that source +// ends the wait, whoever ended it (the indexer's take-in, a hand take-in or a skip). const KindTakeInWaits = "take-in-waits" -// The bounds of a take-in wait, from the `take-in.pending` event's own since. +// DefaultTakeInBound is the setting take-in-bound's default (design 47 H §744, H-A-94 (2)). +const DefaultTakeInBound = 60 * time.Minute + +// The take-in events of the indexer, by their names relative to it. const ( - TakeInRevisionBound = 60 * time.Minute - TakeInGroupBound = 30 * time.Minute + TakeInPendingEvent = "take-in.pending" + TakeInTakenEvent = "take-in.taken" ) // takeInRow is the signals table's row of a take-in wait. const takeInRow = "take-in" -// TakeIn hears one take-in event of the indexer, by its name relative to the indexer (`take-in.`), the wait's key -// in its body: a pending one starts the wait for its key, whose bound runs from the event's since, and a taken one ends it. A group's -// taken event ends the group's wait only: the revision it becomes is its own key and starts its own, longer wait. -func (w *Watchman) TakeIn(event string, body []byte) { - kind, err := takein.ParseTakeInEvent(event) - if err != nil { - w.say("a take-in event is left: %v", err) - return +// TakeInKey is a take-in wait's key, `.` (design 47 H-A-94 (2)). +func TakeInKey(branch string, source int64) string { return fmt.Sprintf("%s.%d", branch, source) } + +// HeldTakeIn is one take-in the indexer holds, as indexer_pending answers it (design 47 H-A-97, H-A-102): the contract's +// form with since, when it was held. +type HeldTakeIn struct { + meshcatalog.TakeInPending + Since time.Time `json:"since"` +} + +// HeldTakeIns is the answer of indexer_pending (design 47 H-A-102). +type HeldTakeIns struct { + Held []HeldTakeIn `json:"held"` +} + +// DecodeHeldTakeIns reads the answer of indexer_pending. +func DecodeHeldTakeIns(raw []byte) (HeldTakeIns, error) { + var a HeldTakeIns + if err := json.Unmarshal(raw, &a); err != nil { + return HeldTakeIns{}, fmt.Errorf("not an answer of indexer_pending: %w", err) } - t, err := takein.DecodeTakeIn(body) - if err != nil { - w.say("the body of %s cannot be read, left: %v", event, err) - return + for _, h := range a.Held { + if h.Branch == "" || h.Source == 0 || h.Since.IsZero() { + return HeldTakeIns{}, fmt.Errorf("indexer_pending names a held take-in with no branch, source or since: %+v", h) + } } - if t.Kind != kind { - w.say("the body of %s says the kind %q, left", event, t.Kind) - return - } - // The wait names the watched branch it is of (design 47 G §493), by the contract's body. - var named meshcatalog.TakeInPending - _ = json.Unmarshal(body, &named) - var taken meshcatalog.TakeInTaken - _ = json.Unmarshal(body, &taken) - key := t.Key + return a, nil +} + +// SetTakeInBound sets the setting take-in-bound; zero or less keeps its default. +func (w *Watchman) SetTakeInBound(d time.Duration) { w.mu.Lock() defer w.mu.Unlock() - w.takeIn(kind, key, t) - w.pendingOf(kind, key, named.Branch) - if kind == takein.TakeInTaken && taken.Branch != "" && taken.Source != 0 && len(taken.Entries) > 0 { - var modules []string - for _, e := range taken.Entries { - modules = append(modules, e.Module) - } - w.takenEntries[fmt.Sprintf("%s.%d", taken.Branch, taken.Source)] = modules // a record's milestone (A-200) - w.rejudgeRecords() + if d > 0 { + w.takeInBound = d } } -// SeedTakeIn starts, at the watchman's start and before its consumer on the take-in stream, the wait of every revision -// and group the indexer holds now, as indexer_pending answers them (ADR 0633 §5): the consumer is durable, so the +// TakeIn hears one take-in event of the indexer, by its name relative to the indexer, heard at the message's own time: +// a `take-in.pending` starts the wait of its `.`, whose bound runs from that time, and a `take-in.taken` +// ends it, and asks the catalog entry of each mover it names (busstate.go). +func (w *Watchman) TakeIn(event string, body []byte, at time.Time) { + switch event { + case TakeInPendingEvent: + var p meshcatalog.TakeInPending + if err := json.Unmarshal(body, &p); err != nil || p.Branch == "" || p.Source == 0 { + w.say("the body of %s cannot be read, left: %v", event, err) + return + } + w.mu.Lock() + defer w.mu.Unlock() + w.takeInHeldSince(TakeInKey(p.Branch, p.Source), p.Why, at) + case TakeInTakenEvent: + var t meshcatalog.TakeInTaken + if err := json.Unmarshal(body, &t); err != nil || t.Branch == "" || t.Source == 0 { + w.say("the body of %s cannot be read, left: %v", event, err) + return + } + key := TakeInKey(t.Branch, t.Source) + w.mu.Lock() + defer w.mu.Unlock() + w.takeInEnded(key) + w.taken[key] = true // a record's milestone (A-200, H-A-25) + w.rejudgeRecords() + w.moversTaken(t.Entries, at) + default: + w.say("a take-in event %s is left: not take-in.pending or take-in.taken", event) + } +} + +// SeedTakeIn starts, at the watchman's start and before its consumer on the take-in stream, the wait of every take-in +// the indexer holds now, as indexer_pending answers it (design 47 H-A-94 (2), H-A-97): the consumer is durable, so the // pending events it acknowledged before a restart are not heard again, and a wait within its bound would otherwise be -// lost. Each wait's bound runs from its own since, as a pending event's does; the stream's events that follow replace -// or end it. A wait or finding the answer does not name is ended. -func (w *Watchman) SeedTakeIn(a takein.PendingAnswer) { +// lost. Each wait's bound runs from its own since; the stream's events that follow replace or end it. A wait or finding +// the answer does not name is ended. +func (w *Watchman) SeedTakeIn(a HeldTakeIns) { w.mu.Lock() defer w.mu.Unlock() - // A wait or finding of a key the answer does not name is ended as a take-in.taken would end it: the finding a previous - // run wrote (read at the start, before the seed), a wait held from an event, a signal standing (design 47, Taken in by - // the indexer it names). Only an answered seed gets here: one that could not ask ends nothing. + // Only an answered seed gets here: one that could not ask ends nothing. named := map[string]bool{} - for _, wait := range a.Waits { - named[wait.Key] = true + for _, h := range a.Held { + named[TakeInKey(h.Branch, h.Source)] = true } stale := map[string]bool{} for _, value := range w.findings { @@ -96,64 +128,36 @@ func (w *Watchman) SeedTakeIn(a takein.PendingAnswer) { } } for _, key := range slices.Sorted(maps.Keys(stale)) { - w.takeIn(takein.TakeInTaken, key, takein.TakeIn{Kind: takein.TakeInTaken, Key: key}) + w.takeInEnded(key) } - for _, wait := range a.Waits { - w.takeIn(takein.TakeInPending, wait.Key, takein.TakeIn{Kind: takein.TakeInPending, Key: wait.Key, What: wait.What, - Merges: wait.Merges, Group: wait.Group, Members: wait.Members, WaitsFor: wait.WaitsFor, Since: wait.Since}) + for _, h := range a.Held { + w.takeInHeldSince(TakeInKey(h.Branch, h.Source), h.Why, h.Since) } } -// pendingOf records or ends the branch an open take-in wait names (design 47 G §497), w.mu held: the head of a branch behind a -// pending revision raises no `pipeline-stands`, and is timed again, from the move of the head, once the branch has none. -func (w *Watchman) pendingOf(kind, key, branch string) { - if kind == takein.TakeInTaken { - branch = w.pendingBranch[key] - delete(w.pendingBranch, key) - if branch != "" && !w.branchPending(branch) { - w.timeHead(branch) - } - return - } - if branch == "" { - return - } - w.pendingBranch[key] = branch - if _, ok := w.heads[branch]; ok { - id := headID(branch) - w.unsignal(headRow, id) - w.unfind(FindingKey(ScopeDelivery, id, KindPipelineStands)) - } +// takeInEnded ends the wait of key, w.mu held. +func (w *Watchman) takeInEnded(key string) { + delete(w.takeInHeld, key) + w.unsignal(takeInRow, key) + w.unfind(FindingKey(ScopeDelivery, key, KindTakeInWaits)) } -// takeIn is one take-in event of key, w.mu held. -func (w *Watchman) takeIn(kind, key string, t takein.TakeIn) { - finding := FindingKey(ScopeDelivery, key, KindTakeInWaits) - if kind == takein.TakeInTaken { - delete(w.takeInHeld, key) - w.unsignal(takeInRow, key) - w.unfind(finding) - return +// takeInHeldSince is the take-in of key held since since, for why, w.mu held: its finding is due take-in-bound from since. +func (w *Watchman) takeInHeldSince(key, why string, since time.Time) { + bound := w.takeInBound + why = strings.TrimSpace(why) + if why == "" { + why = "the indexer said no reason" } - bound, what := TakeInRevisionBound, "a source revision is held (a message lost or unread, no room for it, or its refusal)" - if t.What == takein.TakeInGroup { - bound, what = TakeInGroupBound, "a delivery group is gathered and its end has not come" - } - var merges []string - for _, m := range t.Merges { - merges = append(merges, m.Repository) - } - f := Finding{Scope: ScopeDelivery, ID: key, Kind: KindTakeInWaits, Severity: Warning, Source: "take-in", Since: t.Since, - Summary: fmt.Sprintf("%s: %s, since %s (%s)", key, what, stamp(t.Since), strings.Join(merges, ", ")), + f := Finding{Scope: ScopeDelivery, ID: key, Kind: KindTakeInWaits, Severity: Warning, Source: takeInRow, Since: since, + Summary: fmt.Sprintf("%s: the take-in of this source revision is held, since %s (%s)", key, stamp(since), why), Said: fmt.Sprintf("held for %s", bound), Headline: "A merged change is held back by the indexer", - Explanation: "The indexer holds " + what + " and has not taken it in within " + bound.String() + ", so what the merge changes does " + - "not reach the machines.", - Needs: "the take-in by hand (indexer_take_in_pending), or a drop (indexer_drop_pending)"} - left := bound - w.now().Sub(t.Since) - w.unfind(finding) - w.unsignal(takeInRow, key) - delete(w.takeInHeld, key) + Explanation: "The indexer holds the take-in of the source revision " + key + " (" + why + ") and has not taken it in within " + + bound.String() + ", so what the merge changes does not reach the machines.", + Needs: "the take-in by hand (indexer_take_in_pending), or a skip (indexer_take_in_skip)"} + left := bound - w.now().Sub(since) + w.takeInEnded(key) switch { case left > 0: w.signal(takeInRow, key, left, signalDue{Do: dueFind, Finding: f}) diff --git a/modules/mesh-delivery-watchman/internal/watch/waits.go b/modules/mesh-delivery-watchman/internal/watch/waits.go index 034bc357..34fc9f59 100644 --- a/modules/mesh-delivery-watchman/internal/watch/waits.go +++ b/modules/mesh-delivery-watchman/internal/watch/waits.go @@ -10,31 +10,40 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) -// What the holders of an acting part's wait say, heard as the seats' events (design 47 G §266, §269, ADR 0596 §2), never read -// from their state: `wait-held` and `wait-ended` of a wait (the seat mesh-wants, and the seat mesh-pipeline-runner for its -// `pipeline` step). A wait held past its bound is the finding `acting-part-late`, timed by that bound alone from the time -// `wait-held` carries as `clock-from` (its `since` where it carries none), and ended by `wait-ended`, whoever ended it (the -// part's new version running, or a release). Its pulse is its bound, written at the event, so a restart loses none. +// What the holder of the seat mesh-wants says of a put's wait (design 47 G §498), heard as the seat's `wait-held` and +// `wait-ended`, never read from its state: a put without hold that stands past its bound is the finding `put-stands`, timed +// by that bound alone from the time `wait-held` carries as `clock-from` (its `since` where it carries none), and ended by +// `wait-ended`. An acting part's wait is no finding (design 47 H §764, H-A-70). Its pulse is its +// bound, written at the event, so a restart loses none. -// actingRow is the row of the signals table of an acting part's wait. +// actingRow is the row of the signals table of a put's wait. const actingRow = "acting-wait" func waitID(seat string, a meshwants.Wait) string { return strings.Join([]string{seat, a.Step, a.Part, a.Node, a.Module}, "-") } -// WaitHeld hears a seat's `wait-held`: the finding is due when the wait's bound has run from its clock. +// WaitHeld hears a seat's `wait-held`: a put's finding is due when its bound has run from its clock; any other wait is left. func (w *Watchman) WaitHeld(seat string, body []byte) { a, ok := decodeWait(w, seat, "wait-held", body) if !ok { return } + bound, err := time.ParseDuration(a.Bound) + if err != nil || bound <= 0 { + w.say("the put of %s says no bound (%q), so it is never late", a.Module, a.Bound) + return + } + from := a.Since + if a.ClockFrom != nil { + from = *a.ClockFrom + } w.mu.Lock() defer w.mu.Unlock() - w.waitHeld(seat, a) + w.putStands(waitID(seat, a), a, bound, from) } -// WaitEnded hears a seat's `wait-ended`: the wait ran or was released, so its finding and its pulse end. +// WaitEnded hears a seat's `wait-ended`: the put ran or was released, so its finding and its pulse end. func (w *Watchman) WaitEnded(seat string, body []byte) { a, ok := decodeWait(w, seat, "wait-ended", body) if !ok { @@ -44,57 +53,21 @@ func (w *Watchman) WaitEnded(seat string, body []byte) { defer w.mu.Unlock() id := waitID(seat, a) w.unsignal(actingRow, id) - w.unfind(FindingKey(ScopeDelivery, id, KindActingPartLate)) w.unfind(FindingKey(ScopeDelivery, id, KindPutStands)) - w.rejudgeRecords() } +// decodeWait reads a put's wait; a wait of another step is left unsaid, since it is no finding. func decodeWait(w *Watchman, seat, event string, body []byte) (meshwants.Wait, bool) { var a meshwants.Wait - if err := json.Unmarshal(body, &a); err != nil || (a.Part == "" && a.Step != meshwants.WaitStepPut) || a.Module == "" || a.Since.IsZero() { + if err := json.Unmarshal(body, &a); err != nil || (a.Step == meshwants.WaitStepPut && (a.Module == "" || a.Since.IsZero())) { w.say("the %s of the seat %s does not read, left: %v", event, seat, err) return a, false } - return a, true -} - -// waitHeld is one wait held, w.mu held. -func (w *Watchman) waitHeld(seat string, a meshwants.Wait) { - bound, err := time.ParseDuration(a.Bound) - if err != nil || bound <= 0 { - w.say("the wait of %s at %s says no bound (%q), so it is never late", a.Module, a.Part, a.Bound) - return - } - from := a.Since - if a.ClockFrom != nil { - from = *a.ClockFrom - } - id := waitID(seat, a) - if a.Step == meshwants.WaitStepPut { - w.putStands(id, a, bound, from) - return - } - f := Finding{Scope: ScopeDelivery, ID: id, Kind: KindActingPartLate, Severity: Warning, Source: actingRow, Since: a.Since, - Summary: fmt.Sprintf("%s on %s waits for %s to run %s at the step %s, since %s (bound %s)", a.Module, orWords(a.Node, "no node"), a.Part, - orWords(a.Version, "its new version"), a.Step, stamp(a.Since), bound), - Said: "held for " + bound.String(), - Headline: "An acting part's new version has not come", - Explanation: "A step waits until " + a.Part + " runs its new version, and its bound of " + bound.String() + - " has run, so what the step does is held back.", - Needs: "the part's new version to run, or the wait released by hand (the holder's release tool)"} - left := bound - w.now().Sub(from) - w.unsignal(actingRow, id) - w.unfind(f.Key()) - if left > 0 { - w.signal(actingRow, id, left, signalDue{Do: dueFind, Finding: f}) - return - } - w.find(f) - w.rejudgeRecords() // a record whose entry this wait holds is covered now (§502) + return a, a.Step == meshwants.WaitStepPut } // putStands is a put's wait held (`step: put`, design 47 G §498): a put without hold that stands past its bound is said as the -// finding `put-stands`, never `acting-part-late`, since no acting part is waited for. w.mu held. +// finding `put-stands`, since no acting part is waited for. w.mu held. func (w *Watchman) putStands(id string, a meshwants.Wait, bound time.Duration, from time.Time) { f := Finding{Scope: ScopeDelivery, ID: id, Kind: KindPutStands, Severity: Warning, Source: actingRow, Since: a.Since, Summary: fmt.Sprintf("a put of %s on %s at %s stands, since %s (bound %s)", a.Module, orWords(a.Node, "no node"), @@ -114,17 +87,15 @@ func (w *Watchman) putStands(id string, a meshwants.Wait, bound time.Duration, f w.find(f) } -// What a node-engine says of a hold it keeps (design 47 G §499, §541), heard on the seat node-engine's `wait-held` and `wait-ended` -// (`mesh.seat.node-engine.event...`, the node the one that says it): a hold of the composition (`step: -// compose`, with its reason) standing past composing's 30 minutes (§266) is the finding `delivery-waits`, naming the node, the -// module and the reason, and a wait for a kept build (`step: kept-build`, naming the build node) standing past building's default -// bound of 60 minutes is `kept-build-waits`. Each clears on `wait-ended`. +// What a node-engine says of a wait for a kept build (design 47 G §499, §541), heard on the seat node-engine's `wait-held` +// and `wait-ended` (`mesh.seat.node-engine.event...`, the node the one that says it): a wait for a kept +// build (`step: kept-build`, naming the build node) standing past building's default bound of 60 minutes is +// `kept-build-waits`, cleared on `wait-ended`. A hold of the composition is no finding (design 47 H +// §764, H-A-91 (2)). -// The findings of a node-engine's waits, and the bounds that stand when its event names none. +// The finding of a node-engine's wait for a kept build, and the bound that stands when its event names none. const ( - KindDeliveryWaits = "delivery-waits" KindKeptBuildWaits = "kept-build-waits" - ComposeBound = 30 * time.Minute KeptBuildBound = 60 * time.Minute ) @@ -133,17 +104,18 @@ const engineRow = "engine-wait" func engineWaitID(node, module string) string { return node + "." + module } -// EngineWaitHeld hears the node-engine of node saying `wait-held` for module. +// EngineWaitHeld hears the node-engine of node saying `wait-held` for module: a wait for a kept build is timed, any other +// left. func (w *Watchman) EngineWaitHeld(node, module string, body []byte) { var a nodeengine.Wait if err := json.Unmarshal(body, &a); err != nil || a.Since.IsZero() { w.say("a wait-held of the node-engine of %s for %s does not read, left: %v", node, module, err) return } - kind, bound := KindDeliveryWaits, ComposeBound - if a.Step == nodeengine.WaitStepKeptBuild { - kind, bound = KindKeptBuildWaits, KeptBuildBound + if a.Step != nodeengine.WaitStepKeptBuild { + return } + bound := KeptBuildBound if d, err := time.ParseDuration(a.Bound); err == nil && d > 0 { bound = d } @@ -152,11 +124,8 @@ func (w *Watchman) EngineWaitHeld(node, module string, body []byte) { from = *a.ClockFrom } id := engineWaitID(node, module) - what := "holds the composition of " + module - if a.Step == nodeengine.WaitStepKeptBuild { - what = "waits for the kept build of " + module + " on " + orWords(a.Node, "no node") - } - f := Finding{Scope: ScopeDelivery, ID: id, Kind: kind, Severity: Warning, Machine: node, Source: engineRow, Since: a.Since, + what := "waits for the kept build of " + module + " on " + orWords(a.Node, "no node") + f := Finding{Scope: ScopeDelivery, ID: id, Kind: KindKeptBuildWaits, Severity: Warning, Machine: node, Source: engineRow, Since: a.Since, Summary: fmt.Sprintf("the node-engine of %s %s: %s, since %s (bound %s)", node, what, orWords(a.Reason, "no reason said"), stamp(a.Since), bound), Said: "held for " + bound.String(), Headline: "A module's delivery is held on a machine", @@ -174,38 +143,11 @@ func (w *Watchman) EngineWaitHeld(node, module string, body []byte) { w.find(f) } -// EngineWaitEnded hears the node-engine of node saying `wait-ended` for module: the hold is over, whichever kind it was. +// EngineWaitEnded hears the node-engine of node saying `wait-ended` for module: the wait is over. func (w *Watchman) EngineWaitEnded(node, module string) { id := engineWaitID(node, module) w.mu.Lock() defer w.mu.Unlock() w.unsignal(engineRow, id) - w.unfind(FindingKey(ScopeDelivery, id, KindDeliveryWaits)) w.unfind(FindingKey(ScopeDelivery, id, KindKeptBuildWaits)) } - -// ModuleWaitHeld hears a module's `wait-held` on its own stream (`mesh.stream..event.wait-held..`), the form -// the builder says a key queued behind a package in, with the package as its `part` (design 47 G A-192, ADR 0603 §8): it is timed as any -// acting part's wait. A wait naming no part is a toolchain wait, which the builder times itself (§672), and is left. -func (w *Watchman) ModuleWaitHeld(holder string, body []byte) { - var a meshwants.Wait - if json.Unmarshal(body, &a) == nil && a.Part == "" { - return - } - a2, ok := decodeWait(w, holder, "wait-held", body) - if !ok { - return - } - w.mu.Lock() - defer w.mu.Unlock() - w.waitHeld(holder, a2) -} - -// ModuleWaitEnded hears the same module's `wait-ended`. -func (w *Watchman) ModuleWaitEnded(holder string, body []byte) { - var a meshwants.Wait - if json.Unmarshal(body, &a) == nil && a.Part == "" { - return - } - w.WaitEnded(holder, body) -} diff --git a/modules/mesh-delivery-watchman/internal/watch/waits_test.go b/modules/mesh-delivery-watchman/internal/watch/waits_test.go index b45b150b..611bb38d 100644 --- a/modules/mesh-delivery-watchman/internal/watch/waits_test.go +++ b/modules/mesh-delivery-watchman/internal/watch/waits_test.go @@ -10,71 +10,9 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) -func heldWait(module string, since time.Time, from *time.Time) []byte { - b, _ := json.Marshal(meshwants.Wait{Step: "place", Part: "mesh-delivery-indexer", Version: "src2:new", Node: "ace", Module: module, - Since: since, ClockFrom: from, Bound: "30m"}) - return b -} - -// design 47 G §266, §269 (WM6): a wait held is the finding `acting-part-late` once its bound has run from the time `wait-held` -// carries as `clock-from` (its `since` where it carries none), not within it; `wait-ended` ends it. -func TestAnActingPartsWaitIsLateByItsBoundFromItsClock(t *testing.T) { - id := "mesh-wants-place-mesh-delivery-indexer-ace-web" - key := FindingKey(ScopeDelivery, id, KindActingPartLate) - t.Run("within the bound nothing, past it a finding, wait-ended ends it", func(t *testing.T) { - w, o, c := setup() - w.WaitHeld("mesh-wants", heldWait("web", c.t, nil)) - if o.ttls[signalKey(actingRow, id)] != 30*time.Minute || len(o.findings) != 0 { - t.Fatalf("within the bound: ttl %v, findings %v", o.ttls[signalKey(actingRow, id)], o.findings) - } - expire(w, c, signalKey(actingRow, id), 30*time.Minute) - if _, ok := o.findings[key]; !ok { - t.Fatalf("past its bound: %v", o.findings) - } - w.WaitEnded("mesh-wants", heldWait("web", c.t, nil)) - if len(o.findings) != 0 { - t.Fatalf("wait-ended left %v", o.findings) - } - }) - t.Run("the bound counts from clock-from, not from since", func(t *testing.T) { - w, o, c := setup() - from := c.t.Add(-20 * time.Minute) - w.WaitHeld("mesh-wants", heldWait("web", c.t.Add(-time.Hour), &from)) - if got := o.ttls[signalKey(actingRow, id)]; got != 10*time.Minute { - t.Fatalf("a wait whose clock began 20 minutes ago has %v left, want 10m", got) - } - }) - t.Run("a wait whose bound ran before it was heard is a finding at once", func(t *testing.T) { - w, o, c := setup() - w.WaitHeld("mesh-wants", heldWait("web", c.t.Add(-2*time.Hour), nil)) - if _, ok := o.findings[key]; !ok { - t.Fatalf("a late wait: %v", o.findings) - } - }) - // The grants part's wait is held as a seat's event too (design 47 G §269, G-20 A-12): its body names no node, and its release - // is said `wait-ended` with how `released`, which clears the finding. - t.Run("the seat mesh-grants' granting wait is late by its bound and ended by its release", func(t *testing.T) { - w, o, c := setup() - body := func(how string) []byte { - b, _ := json.Marshal(map[string]any{"step": "grant", "part": "mesh-grants", "version": "fp", "module": "web", "bound": "10m0s", - "since": c.t, "clock-from": c.t, "how": how}) - return b - } - gid := "mesh-grants-grant-mesh-grants--web" - w.WaitHeld("mesh-grants", body("")) - expire(w, c, signalKey(actingRow, gid), 10*time.Minute) - if _, ok := o.findings[FindingKey(ScopeDelivery, gid, KindActingPartLate)]; !ok { - t.Fatalf("past its bound: %v", o.findings) - } - w.WaitEnded("mesh-grants", body("released")) - if len(o.findings) != 0 { - t.Fatalf("the release left %v", o.findings) - } - }) -} - -// design 47 G §498 (WM14): a put's wait (`step: put`, no part) raises `put-stands` once its bound has run, and a pipeline's wait -// raises nothing for it; `wait-ended` ends it. +// design 47 G §498 (WM14): a put's wait (`step: put`, no part) raises `put-stands` once its bound has run, not within it; +// `wait-ended` ends it. Design 47 H §764, H-A-70: an acting part's wait is no finding (acting-part-late retired), so it +// writes no pulse and no finding, past its bound or not. func TestAPutWithoutHoldThatStandsIsPutStands(t *testing.T) { put := func(since time.Time) []byte { b, _ := json.Marshal(meshwants.Wait{Step: meshwants.WaitStepPut, Node: "ace", Module: "web", Fingerprint: "fp-1", Since: since, Bound: "30m"}) @@ -82,6 +20,12 @@ func TestAPutWithoutHoldThatStandsIsPutStands(t *testing.T) { } id := "mesh-wants-put--ace-web" w, o, c := setup() + acting, _ := json.Marshal(meshwants.Wait{Step: "place", Part: "mesh-delivery-indexer", Version: "src2:new", Node: "ace", Module: "web", + Since: c.t.Add(-2 * time.Hour), Bound: "30m"}) + w.WaitHeld("mesh-wants", acting) + if len(o.findings) != 0 || len(o.pulses) != 0 { + t.Fatalf("an acting part's wait is timed: findings %v, pulses %v", o.findings, o.pulses) + } w.WaitHeld("mesh-wants", put(c.t)) if len(o.findings) != 0 { t.Fatalf("within the bound: %v", o.findings) @@ -96,65 +40,31 @@ func TestAPutWithoutHoldThatStandsIsPutStands(t *testing.T) { } } -// design 47 G §499, §541 (WM4, WM5): a node-engine's hold of the composition standing 30 minutes is `delivery-waits` naming the node, -// the module and the reason, a wait for a kept build standing 60 minutes is `kept-build-waits`, and `wait-ended` clears either. +// design 47 G §499, §541 (WM5): a node-engine's wait for a kept build standing 60 minutes is `kept-build-waits` naming the node, +// the module and the reason, and `wait-ended` clears it. Design 47 H §764, H-A-91 (2): a hold of the composition is no finding +// (delivery-waits retired). func TestANodeEnginesWaitIsAFindingPastItsBound(t *testing.T) { held := func(step, reason string, since time.Time) []byte { b, _ := json.Marshal(nodeengine.Wait{Step: step, Reason: reason, Node: "build1", Since: since, Owner: "node-engine"}) return b } - for _, tc := range []struct { - name, step, reason, kind string - bound time.Duration - }{ - {"a hold of the composition", nodeengine.WaitStepCompose, "restore point missing", KindDeliveryWaits, 30 * time.Minute}, - {"a wait for a kept build", nodeengine.WaitStepKeptBuild, "node away", KindKeptBuildWaits, 60 * time.Minute}, - } { - t.Run(tc.name, func(t *testing.T) { - w, o, c := setup() - id := "ace.web" - w.EngineWaitHeld("ace", "web", held(tc.step, tc.reason, c.t)) - if o.ttls[signalKey(engineRow, id)] != tc.bound || len(o.findings) != 0 { - t.Fatalf("within the bound: ttl %v, findings %v", o.ttls[signalKey(engineRow, id)], o.findings) - } - expire(w, c, signalKey(engineRow, id), tc.bound) - f, ok := o.findings[FindingKey(ScopeDelivery, id, tc.kind)] - if !ok || len(o.findings) != 1 || !strings.Contains(f.Summary, tc.reason) { - t.Fatalf("past its bound: %v", o.findings) - } - w.EngineWaitEnded("ace", "web") - if len(o.findings) != 0 { - t.Fatalf("wait-ended left %v", o.findings) - } - }) - } -} - -// design 47 G A-192 (WM13): a key queued behind a package is a wait the builder says on its own stream with the package as its part; -// past its bound it is `acting-part-late`, `wait-ended` clears it, and a toolchain wait (no part) is left to the builder. -func TestAKeyQueuedBehindAPackageIsAnActingPartsWait(t *testing.T) { - body := func(part string, since time.Time) []byte { - b, _ := json.Marshal(meshwants.Wait{Step: "building", Part: part, On: "package:" + part, Module: "web", Fingerprint: "src2:f", Since: since, Bound: "1h0m0s"}) - return b - } - const holder = "builder" w, o, c := setup() - id := waitID(holder, meshwants.Wait{Step: "building", Part: "mesh-sdk@v0.1.14", Module: "web"}) - w.ModuleWaitHeld(holder, body("mesh-sdk@v0.1.14", c.t)) - if o.ttls[signalKey(actingRow, id)] != time.Hour || len(o.findings) != 0 { - t.Fatalf("within the bound: ttl %v, findings %v", o.ttls[signalKey(actingRow, id)], o.findings) + id := "ace.web" + w.EngineWaitHeld("ace", "web", held(nodeengine.WaitStepCompose, "restore point missing", c.t.Add(-time.Hour))) + if len(o.ttls) != 0 || len(o.findings) != 0 { + t.Fatalf("a hold of the composition is timed: ttls %v, findings %v", o.ttls, o.findings) } - expire(w, c, signalKey(actingRow, id), time.Hour) - if _, ok := o.findings[FindingKey(ScopeDelivery, id, KindActingPartLate)]; !ok || len(o.findings) != 1 { + w.EngineWaitHeld("ace", "web", held(nodeengine.WaitStepKeptBuild, "node away", c.t)) + if o.ttls[signalKey(engineRow, id)] != KeptBuildBound || len(o.findings) != 0 { + t.Fatalf("within the bound: ttl %v, findings %v", o.ttls[signalKey(engineRow, id)], o.findings) + } + expire(w, c, signalKey(engineRow, id), KeptBuildBound) + f, ok := o.findings[FindingKey(ScopeDelivery, id, KindKeptBuildWaits)] + if !ok || len(o.findings) != 1 || !strings.Contains(f.Summary, "node away") { t.Fatalf("past its bound: %v", o.findings) } - w.ModuleWaitEnded(holder, body("mesh-sdk@v0.1.14", c.t)) + w.EngineWaitEnded("ace", "web") if len(o.findings) != 0 { t.Fatalf("wait-ended left %v", o.findings) } - w, o, c = setup() - w.ModuleWaitHeld(holder, body("", c.t.Add(-2*time.Hour))) - if len(o.findings) != 0 || len(o.ttls) != 0 { - t.Fatalf("a toolchain wait was timed by the watchman: %v %v", o.ttls, o.findings) - } } diff --git a/modules/mesh-delivery-watchman/internal/watch/watch.go b/modules/mesh-delivery-watchman/internal/watch/watch.go index f65d75b2..dbc256f5 100644 --- a/modules/mesh-delivery-watchman/internal/watch/watch.go +++ b/modules/mesh-delivery-watchman/internal/watch/watch.go @@ -70,7 +70,6 @@ type Watchman struct { haves map[string]string // the fingerprint each node runs of a module, by have key, from the node-engine's running // starts is, by pulse key, the first start of a wait whose mark still stands (mirrorKept). starts map[string]startMark - held map[string]bool // each want key held by a rule (ADR 0603 §8), mirrored as the hold's wait bound time.Duration // findings is every finding written, by key, as written; seededFindings those read at the start and not yet observed // again. @@ -111,13 +110,15 @@ type Watchman struct { // (WantsAt, design 47 G A-321); awaitsWants keeps the seeded entries of any `_wants` bucket until the late read. wantsAt func() string awaitsWants bool - // heads is, by watched branch, the head still waiting for its pipeline (pipelines.go). - heads map[string]head - // pendingBranch is, by key, the watched branch of each open take-in wait that names one (takein.go, design 47 G §497). - pendingBranch map[string]string - // takenEntries are the modules of each taken-in revision, by `.`, and recordMilestone each open record's - // milestone, which joins a record to them (records.go, design 47 G §502). - takenEntries map[string][]string + // takeInBound is the setting take-in-bound (takein.go). + takeInBound time.Duration + // entries reads a taken-in mover's catalog entry by its fingerprint, and movers are the movers whose entry is asked, by + // fingerprint (busstate.go). + entries EntryReader + movers map[string]moverTaken + // taken is each taken-in source revision, by `.`, and recordMilestone each open record's milestone, which + // joins a record to it (records.go, design 47 G §502). + taken map[string]bool recordMilestone map[string]string // queued is, by build seat, each step queued on it for a build node and since when (pipelines.go). queued map[string]map[string]time.Time @@ -132,12 +133,12 @@ type Watchman struct { // New is the watchman of module (its credential's), writing to out, reading the time from now. func New(module string, out Out, now func() time.Time) *Watchman { return &Watchman{module: module, own: BucketsOf(module), out: out, now: now, counts: map[string]int{}, presence: map[string]presence{}, - pulses: map[string]*pulse{}, stuck: map[string]meshwatchdogsclient.Stuck{}, wants: map[string]string{}, haves: map[string]string{}, held: map[string]bool{}, starts: map[string]startMark{}, bound: meshwatchdogsclient.PulseMoveBound, stepBound: StepBound, progressBound: ProgressBound, - findings: map[string][]byte{}, seededFindings: map[string]bool{}, signals: map[string]signalDue{}, busCreated: map[string]bool{}, takeInHeld: map[string]Finding{}, pendingBranch: map[string]string{}, takenEntries: map[string][]string{}, recordMilestone: map[string]string{}, away: map[string]bool{}, + pulses: map[string]*pulse{}, stuck: map[string]meshwatchdogsclient.Stuck{}, wants: map[string]string{}, haves: map[string]string{}, starts: map[string]startMark{}, bound: meshwatchdogsclient.PulseMoveBound, stepBound: StepBound, progressBound: ProgressBound, + findings: map[string][]byte{}, seededFindings: map[string]bool{}, signals: map[string]signalDue{}, busCreated: map[string]bool{}, takeInHeld: map[string]Finding{}, takeInBound: DefaultTakeInBound, movers: map[string]moverTaken{}, taken: map[string]bool{}, recordMilestone: map[string]string{}, away: map[string]bool{}, advised: map[string]int{}, advisedSince: map[string]time.Time{}, provFailed: map[string]map[string]ProvReport{}, closures: map[string]map[string]time.Time{}, waiting: map[string]map[string]string{}, - standing: map[string]map[string]bool{}, readWhole: map[string]bool{}, awaited: map[string]bool{}, heads: map[string]head{}, queued: map[string]map[string]time.Time{}, steps: map[string]*openStep{}, awaySaid: map[string]time.Time{}, opened: map[string]Finding{}} + standing: map[string]map[string]bool{}, readWhole: map[string]bool{}, awaited: map[string]bool{}, queued: map[string]map[string]time.Time{}, steps: map[string]*openStep{}, awaySaid: map[string]time.Time{}, opened: map[string]Finding{}} } // Logf sets where a write that failed is said; it is silent until set. diff --git a/modules/mesh-delivery-watchman/internal/watch/watch_test.go b/modules/mesh-delivery-watchman/internal/watch/watch_test.go index 9550a9bf..b16033b5 100644 --- a/modules/mesh-delivery-watchman/internal/watch/watch_test.go +++ b/modules/mesh-delivery-watchman/internal/watch/watch_test.go @@ -605,9 +605,9 @@ func TestARunningStepPastItsBoundIsStuck(t *testing.T) { // 1908 // its fingerprint. func wantValue(t *testing.T, fp string, removed bool) []byte { t.Helper() - w := meshwantsclient.Want{Fp: fp, Composed: "sha256:" + strings.Repeat("c", 64), Removed: removed} + w := meshwantsclient.Want{Fp: fp, Version: "0.1.4", Pipeline: "main.42", Rank: 1, Removed: removed} // the H1 want (H-A-37) if removed { - w.Composed = "" + w = meshwantsclient.Want{Fp: fp, Removed: true} } b, err := meshwantsclient.EncodeWant(w) if err != nil { @@ -720,11 +720,11 @@ func TestAStuckKeyWhoseKeyIsGoneIsClosedAtTheStart(t *testing.T) { // A pulse of another key of the bucket, and a finding the bucket is the source of, stood at the start. pk := pulseKeyOf(t, row.bucket, "want.n9.gone") w.SeedPulse(pk) - fv, err := EncodeFinding(Finding{Scope: ScopeModule, ID: "gone", Kind: KindManifestRefused, Severity: Warning, Source: row.bucket, Summary: "refused", Since: t0}) + fv, err := EncodeFinding(Finding{Scope: ScopeModule, ID: "gone", Kind: KindStuck, Severity: Warning, Source: row.bucket, Summary: "refused", Since: t0}) if err != nil { t.Fatal(err) } - fk := FindingKey(ScopeModule, "gone", KindManifestRefused) + fk := FindingKey(ScopeModule, "gone", KindStuck) o.findings[fk], _ = DecodeFinding(fv) w.SeedFinding(fk, fv) w.AwaitsWants() diff --git a/modules/mesh-delivery-watchman/manifest_test.go b/modules/mesh-delivery-watchman/manifest_test.go index 0e53eb8a..23f9209d 100644 --- a/modules/mesh-delivery-watchman/manifest_test.go +++ b/modules/mesh-delivery-watchman/manifest_test.go @@ -64,6 +64,12 @@ type manifest struct { MaxAgeDays int `json:"max-age-days"` MaxMiB int `json:"max-mib"` } `json:"streams"` + Config map[string]struct { + Type string `json:"type"` + Description string `json:"description"` + Trusted bool `json:"trusted"` + Default string `json:"default"` + } `json:"config"` OwnSecrets map[string]string `json:"own-secrets"` SecretsOwner string `json:"secrets-owner"` Resources []map[string]any `json:"resources"` @@ -127,12 +133,17 @@ func TestManifestStateAndReads(t *testing.T) { // 1135/AC6 } // The join: its first view asked again by hand is a hand act, recorded through the seat (views.StatusTools). The waits the // indexer holds at the watchman's start are asked of its tool (ADR 0633 §5), a verb edge as the view's. - if want := []string{"mesh-delivery-indexer.indexer_pending", "mesh-delivery-indexer.indexer_verdicts", "seat:mesh-hand-acts.hand-act", "seat:mesh-conditions.conditions", "seat:mesh-broker.show", "seat:mesh-catalog.revision", "seat:mesh-catalog.registrations", "seat:mesh-delivery.source", "seat:mesh-pipeline-runner.stands"}; !reflect.DeepEqual(m.Invokes, want) { + // Design 47 H-A-79, H-A-94 (1): no indexer_verdicts; a mover's entry is read through the seat mesh-catalog's verb entry. + if want := []string{"mesh-delivery-indexer.indexer_pending", "seat:mesh-hand-acts.hand-act", "seat:mesh-conditions.conditions", "seat:mesh-broker.show", "seat:mesh-catalog.revision", "seat:mesh-catalog.registrations", "seat:mesh-catalog.entry", "seat:mesh-delivery.source", "seat:mesh-pipeline-runner.stands"}; !reflect.DeepEqual(m.Invokes, want) { t.Errorf("invokes = %v, want %v", m.Invokes, want) } // DLV-M5 its first views, 1585/T20 the indexer's take-in events, and DLV-W1 (ADR 0595 §4): the accepted verdicts and the bus module's created and refused, durably. - if want := []string{"seat:mesh-wants.views.wants", "seat:mesh-module-assigner.views.seat-holders", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", "mesh-delivery-indexer.take-in.pending", "mesh-delivery-indexer.take-in.taken", "mesh-catalog.manifest-accepted", "mesh-catalog.manifest-refused", "mesh-delivery.source-moved", "mesh-delivery.filling", "mesh-delivery.full", "mesh-delivery.room", "mesh-delivery.record-opened", "mesh-delivery.record-ended", "mesh-catalog.filling", "mesh-catalog.full", "mesh-catalog.room", "mesh-wants.filling", "mesh-wants.full", "mesh-wants.room", "mesh-grants.filling", "mesh-grants.full", "mesh-grants.room", "node-build-go.ask-taken", "node-build-go.step-progress", "node-build-go.step-ended", "node-build-image.ask-taken", "node-build-image.step-progress", "node-build-image.step-ended", "node-build-node.ask-taken", "node-build-node.step-progress", "node-build-node.step-ended", "mesh-pipeline-runner.pipeline-started", "mesh-pipeline-runner.step-started", "mesh-pipeline-runner.step-ended", "mesh-wants.step-progress", "mesh-pipeline-runner.wait-held", "mesh-pipeline-runner.wait-ended", "mesh-wants.wait-held", "mesh-wants.wait-ended", "mesh-grants.wait-held", "mesh-grants.wait-ended", "mesh-delivery-builder.wait-held", "mesh-delivery-builder.wait-ended", "node-engine.wait-held", "node-engine.wait-ended", "node-engine.running", "mesh-broker.created", "mesh-broker.refused", "mesh-broker.recreated", "mesh-broker.dropped", "mesh-conditions.findings-asked"}; !reflect.DeepEqual(m.Consumes, want) { - t.Errorf("consumes = %v, want %v", m.Consumes, want) + if want := []string{"seat:mesh-wants.views.wants", "seat:mesh-module-assigner.views.seat-holders", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", "mesh-delivery-indexer.take-in.pending", "mesh-delivery-indexer.take-in.taken", "mesh-delivery.source-moved", "mesh-delivery.filling", "mesh-delivery.full", "mesh-delivery.room", "mesh-delivery.record-opened", "mesh-delivery.record-ended", "mesh-catalog.filling", "mesh-catalog.full", "mesh-catalog.room", "mesh-wants.filling", "mesh-wants.full", "mesh-wants.room", "mesh-grants.filling", "mesh-grants.full", "mesh-grants.room", "node-build-go.ask-taken", "node-build-go.step-progress", "node-build-go.step-ended", "node-build-image.ask-taken", "node-build-image.step-progress", "node-build-image.step-ended", "node-build-node.ask-taken", "node-build-node.step-progress", "node-build-node.step-ended", "mesh-pipeline-runner.step-started", "mesh-pipeline-runner.step-ended", "mesh-wants.step-progress", "mesh-wants.wait-held", "mesh-wants.wait-ended", "node-engine.wait-held", "node-engine.wait-ended", "node-engine.running", "mesh-broker.created", "mesh-broker.refused", "mesh-broker.recreated", "mesh-broker.dropped", "mesh-conditions.findings-asked"}; !reflect.DeepEqual(m.Consumes, want) { + t.Errorf("consumes = %v, want %v", m.Consumes, want) // design 47 H §741, §764, H-A-49, H-A-91 (2) + } + // Design 47 H §744, H-A-94 (2): the setting take-in-bound, 60 minutes by default, reaches the process as a file. + if c := m.Config["take-in-bound"]; c.Type != "string" || c.Default != "60m" { + t.Errorf("config take-in-bound = %+v, want a string defaulting to 60m", c) } // 1952/WM1: the watchman holds the seat mesh-watchdogs at mesh scope, its first seat (novox/hq ADR 0564 §1, §4). if !reflect.DeepEqual(m.Claims, []claim{{Name: "mesh-watchdogs", Scope: "mesh", Serves: []string{"signals", "stuck", "presence", "dead-letters", "resync"}}}) { @@ -228,6 +239,19 @@ func TestManifestResources(t *testing.T) { // 1135/AC6 if env["MESH_BROKER_FILE"] != "${dir:state}/broker" { t.Errorf("the process reads %v", env["MESH_BROKER_FILE"]) } + // Design 47 H §744: the setting take-in-bound's file, which the process reads at its start. + if env["MESH_WATCHMAN_TAKE_IN_BOUND_FILE"] != "${dir:state}/take-in-bound" { + t.Errorf("the process reads the take-in bound from %v", env["MESH_WATCHMAN_TAKE_IN_BOUND_FILE"]) + } + var boundFile map[string]any + for _, f := range byType["file"] { + if f["id"] == "take-in-bound" { + boundFile = f + } + } + if boundFile["path"] != "${dir:state}/take-in-bound" || boundFile["content"] != "${config:take-in-bound}" || boundFile["owner"] != user { + t.Errorf("the take-in bound's file = %v", boundFile) + } if h, _ := p["health"].(map[string]any); h["kind"] != "unit" { t.Errorf("health = %v", p["health"]) } diff --git a/modules/mesh-delivery-watchman/module.json b/modules/mesh-delivery-watchman/module.json index b3078253..2c6665b0 100644 --- a/modules/mesh-delivery-watchman/module.json +++ b/modules/mesh-delivery-watchman/module.json @@ -20,12 +20,12 @@ ], "invokes": [ "mesh-delivery-indexer.indexer_pending", - "mesh-delivery-indexer.indexer_verdicts", "seat:mesh-hand-acts.hand-act", "seat:mesh-conditions.conditions", "seat:mesh-broker.show", "seat:mesh-catalog.revision", "seat:mesh-catalog.registrations", + "seat:mesh-catalog.entry", "seat:mesh-delivery.source", "seat:mesh-pipeline-runner.stands" ], @@ -36,8 +36,6 @@ "mesh-catalog.catalog-revision", "mesh-delivery-indexer.take-in.pending", "mesh-delivery-indexer.take-in.taken", - "mesh-catalog.manifest-accepted", - "mesh-catalog.manifest-refused", "mesh-delivery.source-moved", "mesh-delivery.filling", "mesh-delivery.full", @@ -62,18 +60,11 @@ "node-build-node.ask-taken", "node-build-node.step-progress", "node-build-node.step-ended", - "mesh-pipeline-runner.pipeline-started", "mesh-pipeline-runner.step-started", "mesh-pipeline-runner.step-ended", "mesh-wants.step-progress", - "mesh-pipeline-runner.wait-held", - "mesh-pipeline-runner.wait-ended", "mesh-wants.wait-held", "mesh-wants.wait-ended", - "mesh-grants.wait-held", - "mesh-grants.wait-ended", - "mesh-delivery-builder.wait-held", - "mesh-delivery-builder.wait-ended", "node-engine.wait-held", "node-engine.wait-ended", "node-engine.running", @@ -111,6 +102,14 @@ "broker": "${dir:state}/broker" }, "secrets-owner": "mesh-delivery-watchman", + "config": { + "take-in-bound": { + "type": "string", + "description": "how long a source revision's take-in the indexer holds may wait for its take-in.taken before it is the finding take-in-waits, a Go duration such as 60m, counted from its take-in.pending (design 47 H section 744).", + "trusted": false, + "default": "60m" + } + }, "resources": [ { "id": "account", @@ -127,6 +126,14 @@ "place": ".", "unknown": "program" }, + { + "id": "take-in-bound", + "type": "file", + "path": "${dir:state}/take-in-bound", + "owner": "mesh-delivery-watchman", + "mode": "0600", + "content": "${config:take-in-bound}" + }, { "id": "socket-dir", "type": "directory", @@ -144,7 +151,8 @@ "./mesh-delivery-watchman" ], "env": { - "MESH_BROKER_FILE": "${dir:state}/broker" + "MESH_BROKER_FILE": "${dir:state}/broker", + "MESH_WATCHMAN_TAKE_IN_BOUND_FILE": "${dir:state}/take-in-bound" }, "user": "mesh-delivery-watchman", "health": { -- 2.54.0 From 78e169a8c6a58a99355e7a844ce2e309cbdf1453 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:11:18 +0100 Subject: [PATCH 027/104] C-R5: the runner's pipeline keeps the movers superseded out of it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat mesh-pipeline-runner's Pipeline gains superseded, the modules a newer waiting take-in of the same branch took out of the pipeline, written with the movers by compare-and-set, so the runner writes a mover's build-step why from it at the pipeline's placing. A fixture row of a waiting pipeline naming one failed to read back before the field was defined. Builds: design 47 H §748; lead answer H-A-107 (hq fabb927f) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshpipelinerunner/contract.go | 2 ++ .../seats/meshpipelinerunner/contract_test.go | 6 +++++ .../mesh-pipeline-runner/fixtures/states.json | 27 +++++++++++++++++++ .../seats/mesh-pipeline-runner/seat.json | 7 +++++ .../ts/seats/meshpipelinerunner/index.d.ts | 2 ++ 5 files changed, 44 insertions(+) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index f69231f0..da4e61a4 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -634,6 +634,8 @@ type Pipeline struct { Started *time.Time `json:"started,omitempty"` // every mover's steps, each naming its mover, approval last Steps []StepResult `json:"steps"` + // the modules a newer waiting take-in of the same branch took out of the pipeline, written with the movers by compare-and-set; at its placing the runner writes a mover's build-step why from it (design 47 H §748, H-A-107) + Superseded []string `json:"superseded,omitempty"` // the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606) Unlogged []LogEntry `json:"unlogged,omitempty"` // the layout version diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index 04ae77cc..c5eaedd9 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -77,6 +77,12 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, + {name: "a waiting pipeline names the movers a newer take-in took out of it", subject: "", given: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"superseded\":[\"mesh-config\"],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"superseded\":[\"mesh-config\"],\"v\":1}", + decode: func(b []byte) (any, error) { + var v PipelinesByBranchSourceValue + err := json.Unmarshal(b, &v) + return v, err + }, subjectIs: nil}, {name: "a run on request's pipeline, its mover waiting with one dependency's publish heard", subject: "", given: "{\"branch\":\"feat-x\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"published\":[\"mesh-sdk:go\"],\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"feat-x.run.r42\",\"revision\":12,\"run\":\"r42\",\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"feat-x\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"published\":[\"mesh-sdk:go\"],\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"feat-x.run.r42\",\"revision\":12,\"run\":\"r42\",\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", decode: func(b []byte) (any, error) { var v PipelinesByBranchRunRunValue diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json index 8a189b70..cb8363f2 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json @@ -222,6 +222,33 @@ ] } }, + { + "name": "a waiting pipeline names the movers a newer take-in took out of it", + "of": "state:pipelines/.", + "given": { + "pipeline": "main.3590", + "branch": "main", + "revision": 13, + "source": 3590, + "call": "fedcba9876543210", + "v": 1, + "seq": 2, + "outcome": "waiting", + "steps": [], + "movers": [ + { + "module": "nats", + "commit": "0123456789abcdef0123456789abcdef01234567", + "fingerprint": "fp-0124", + "repository": "mesh-networking", + "tier": 1 + } + ], + "superseded": [ + "mesh-config" + ] + } + }, { "name": "a run on request's pipeline, its mover waiting with one dependency's publish heard", "of": "state:pipelines/.run.", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 9eadc6d6..bc1dd376 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -1161,6 +1161,13 @@ }, "description": "the modules the pipeline moves, its take-in's entries (design 47 H §746)" }, + "superseded": { + "type": "array", + "items": { + "type": "string" + }, + "description": "the modules a newer waiting take-in of the same branch took out of the pipeline, written with the movers by compare-and-set; at its placing the runner writes a mover's build-step why from it (design 47 H §748, H-A-107)" + }, "seq": { "type": "integer", "description": "for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748)" diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 474c4287..f1aac9fc 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -261,6 +261,8 @@ export interface Pipeline { "started"?: string; /** every mover's steps, each naming its mover, approval last */ "steps": StepResult[]; + /** the modules a newer waiting take-in of the same branch took out of the pipeline, written with the movers by compare-and-set; at its placing the runner writes a mover's build-step why from it (design 47 H §748, H-A-107) */ + "superseded"?: string[]; /** the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606) */ "unlogged"?: LogEntry[]; /** the layout version */ -- 2.54.0 From 9a55e6e8c0faa36dd96be2d90c13e5bb42be0bf3 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:15:20 +0100 Subject: [PATCH 028/104] C1d: the seat mesh-catalog's module and inputs carry no source stamps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The indexer stamps no source revision on a module (the take-in's commit names it), so the seat mesh-catalog's state modules value and EntryInputs lose src and fp-src, and the fixture rows their stamps. A module value or an entry's inputs carrying either was read before and is refused now. Builds: design 47 H §764 (the indexer); lead answer H-A-48 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../clients/meshcatalogclient/catalog_test.go | 14 ++++++++++++++ .../go/seats/meshcatalog/contract.go | 13 +++---------- .../go/seats/meshcatalog/contract_test.go | 4 ++-- .../seats/mesh-catalog/fixtures/states.json | 8 ++------ .../seats/mesh-catalog/seat.json | 17 +---------------- .../ts/seats/meshcatalog/index.d.ts | 9 +-------- 6 files changed, 23 insertions(+), 42 deletions(-) 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 18ee10d6..44bc27f5 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go @@ -211,3 +211,17 @@ func TestTakeInBodiesAndNoneYetAreTheSeatsTypes(t *testing.T) { t.Errorf("a none-yet answer is written as %s", raw) } } + +// design 47 H-A-48: the indexer stamps no source revision on a module; the take-in's commit names it, so a module value and an +// entry's inputs carrying src or fp-src are not the seat's. +func TestNoSourceStamps(t *testing.T) { + if _, err := seat.DecodeModulesByModuleValue([]byte(`{"v":1,"repository":"mesh-sdk","commit":"` + hex64("a")[:40] + `","manifest":"` + hex64("b") + `","path":"go","src":41,"fp-src":41}`)); err == nil { + t.Error("a module value carrying src and fp-src is read") + } + var in seat.EntryInputs + dec := json.NewDecoder(strings.NewReader(`{"src":41,"fp-src":41}`)) + dec.DisallowUnknownFields() + if err := dec.Decode(&in); err == nil { + t.Error("an entry's inputs carrying src and fp-src are read") + } +} diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index d264f4cf..38996dd9 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -754,17 +754,13 @@ type Edge struct { Word string `json:"word,omitempty"` } -// EntryInputs is what the indexer computes its next revision from (the lead's ruling on milestone 47/G finding 1): what its fingerprint is computed from, the toolchains it was computed with, its manifest's problems and warnings, its artifacts' named paths and the source revisions it was taken in and its fingerprint moved at. +// EntryInputs is what the indexer computes its next revision from (the lead's ruling on milestone 47/G finding 1): what its fingerprint is computed from, the toolchains it was computed with, its manifest's problems and warnings, and its artifacts' named paths; no source revision is stamped on it (design 47 H-A-48). type EntryInputs struct { - // the source revision its fingerprint moved at - FpSrc int64 `json:"fp-src,omitempty"` - From *FingerprintInputs `json:"from,omitempty"` + From *FingerprintInputs `json:"from,omitempty"` // by artifact: the named paths it is built from Paths map[string][]string `json:"paths,omitempty"` // its manifest's problems, when refused or held Problems []string `json:"problems,omitempty"` - // the source revision it was taken in at; 0 before the indexer heard it - Src int64 `json:"src,omitempty"` // by language: the toolchain its fingerprint was computed with Toolchains map[string]ToolchainUsed `json:"toolchains,omitempty"` // the manifest fields the judge does not know, when held @@ -1385,8 +1381,7 @@ type ModulesByModuleValueInputs2 struct { type ModulesByModuleValue struct { Commit string `json:"commit"` // the old-form fingerprint - Fp string `json:"fp,omitempty"` - FpSrc int64 `json:"fp-src,omitempty"` + Fp string `json:"fp,omitempty"` // src2: fingerprint Fp2 string `json:"fp2,omitempty"` Inputs2 *ModulesByModuleValueInputs2 `json:"inputs2,omitempty"` @@ -1401,8 +1396,6 @@ type ModulesByModuleValue struct { Paths map[string][]string `json:"paths,omitempty"` Problems []string `json:"problems,omitempty"` Repository string `json:"repository"` - // the source revision - Src int64 `json:"src,omitempty"` // by language: the toolchain FP2 was computed with Toolchains map[string]ToolchainUsed `json:"toolchains,omitempty"` Unknown []string `json:"unknown,omitempty"` 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 5e372012..88198926 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go @@ -71,7 +71,7 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a catalog graph entry (xclip)", subject: "", given: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", + {name: "a catalog graph entry (xclip)", subject: "", given: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", decode: func(b []byte) (any, error) { var v CatalogRevisionsByEntryDigestValue err := json.Unmarshal(b, &v) @@ -95,7 +95,7 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "an entry with its artifacts and the edges into them, per artifact", subject: "", given: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", + {name: "an entry with its artifacts and the edges into them, per artifact", subject: "", given: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", decode: func(b []byte) (any, error) { var v CatalogRevisionsByEntryDigestValue err := json.Unmarshal(b, &v) 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 b4fd8e72..96c230ce 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json @@ -281,9 +281,7 @@ "version": "1.26.0", "recipe": "1" } - }, - "src": 41, - "fp-src": 41 + } }, "bases": [ "arch" @@ -440,9 +438,7 @@ "version": "1.26.0", "recipe": "1" } - }, - "src": 41, - "fp-src": 41 + } }, "bases": [ "arch" diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index 2919b314..a6d62b1a 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -948,13 +948,6 @@ "tree" ] }, - "src": { - "type": "integer", - "description": "the source revision" - }, - "fp-src": { - "type": "integer" - }, "repository": { "type": "string" }, @@ -1729,7 +1722,7 @@ }, "EntryInputs": { "type": "object", - "description": "what the indexer computes its next revision from (the lead's ruling on milestone 47/G finding 1): what its fingerprint is computed from, the toolchains it was computed with, its manifest's problems and warnings, its artifacts' named paths and the source revisions it was taken in and its fingerprint moved at", + "description": "what the indexer computes its next revision from (the lead's ruling on milestone 47/G finding 1): what its fingerprint is computed from, the toolchains it was computed with, its manifest's problems and warnings, and its artifacts' named paths; no source revision is stamped on it (design 47 H-A-48)", "properties": { "from": { "$ref": "#/defs/FingerprintInputs" @@ -1770,14 +1763,6 @@ "type": "string" }, "description": "the manifest fields the judge does not know, when held" - }, - "src": { - "type": "integer", - "description": "the source revision it was taken in at; 0 before the indexer heard it" - }, - "fp-src": { - "type": "integer", - "description": "the source revision its fingerprint moved at" } } }, 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 339b02e8..eaf806c4 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -316,17 +316,13 @@ export interface Edge { "word"?: string; } -/** what the indexer computes its next revision from (the lead's ruling on milestone 47/G finding 1): what its fingerprint is computed from, the toolchains it was computed with, its manifest's problems and warnings, its artifacts' named paths and the source revisions it was taken in and its fingerprint moved at */ +/** what the indexer computes its next revision from (the lead's ruling on milestone 47/G finding 1): what its fingerprint is computed from, the toolchains it was computed with, its manifest's problems and warnings, and its artifacts' named paths; no source revision is stamped on it (design 47 H-A-48) */ export interface EntryInputs { - /** the source revision its fingerprint moved at */ - "fp-src"?: number; "from"?: FingerprintInputs; /** by artifact: the named paths it is built from */ "paths"?: Record; /** its manifest's problems, when refused or held */ "problems"?: string[]; - /** the source revision it was taken in at; 0 before the indexer heard it */ - "src"?: number; /** by language: the toolchain its fingerprint was computed with */ "toolchains"?: Record; /** the manifest fields the judge does not know, when held */ @@ -880,7 +876,6 @@ export interface ModulesByModuleValue { "commit": string; /** the old-form fingerprint */ "fp"?: string; - "fp-src"?: number; /** src2: fingerprint */ "fp2"?: string; "inputs2"?: ModulesByModuleValueInputs2; @@ -895,8 +890,6 @@ export interface ModulesByModuleValue { "paths"?: Record; "problems"?: string[]; "repository": string; - /** the source revision */ - "src"?: number; /** by language: the toolchain FP2 was computed with */ "toolchains"?: Record; "unknown"?: string[]; -- 2.54.0 From f8eea0000a61ae69afc77b4dd62dde47d2f05548 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:20:33 +0100 Subject: [PATCH 029/104] V1: the view reads the H1 want, source, source-moved and held take-ins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A want counts as applied by its fingerprint and a motion event is keyed by it; the want's newest and rule, and the state held back read from them, go with the assigner's holds. A branch's source is {v, source, call, heads} with no group, its source-moved is read by its source, and the delivered event names no group. indexer_pending's held take-ins are said in the tiers' pending words with their branch, source, why and since, naming no module. The view reads no source stamp on a module. Its seat list, its first-view tool answers and its manifest name no callers; its source invoke reads call, not group. Builds: design 47 H §737, §744, §750, §752, §764 (the gate's groups; the indexer's pending and groups; the assigner's holds; the callers lists); lead answers H-A-26, H-A-37, H-A-48, H-A-66, H-A-78, H-A-102, H-A-109 (hq 3433db0e) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../cmd/mesh-delivery-view-tools/main.go | 26 +++-- .../mesh-delivery-view-tools/owners_test.go | 22 ++--- .../tiers_rows_test.go | 32 +++---- .../mesh-delivery-view/integration_test.go | 36 +++---- .../cmd/mesh-delivery-view/sources.go | 4 +- .../internal/view/catalog.go | 2 +- .../internal/view/history.go | 3 +- .../internal/view/motion.go | 5 +- .../mesh-delivery-view/internal/view/reach.go | 8 +- .../internal/view/reach_test.go | 32 ++++--- .../mesh-delivery-view/internal/view/read.go | 5 +- .../mesh-delivery-view/internal/view/serve.go | 3 - .../internal/view/source.go | 2 +- .../mesh-delivery-view/internal/view/tiers.go | 95 +++++++++---------- .../mesh-delivery-view/internal/view/view.go | 34 +++---- .../internal/view/view_test.go | 2 +- .../internal/view/wants_test.go | 23 ++--- modules/mesh-delivery-view/manifest_test.go | 29 +++--- modules/mesh-delivery-view/module.json | 7 +- modules/mesh-delivery-view/viewstate/reach.go | 3 +- 20 files changed, 170 insertions(+), 203 deletions(-) diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go index 9e75c8b2..201ece77 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go @@ -20,7 +20,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" stdio "git.novox.be/novox/mesh-sdk/go" @@ -486,10 +485,9 @@ func main() { r.BuildLog = stdio.Log(builds.BuildLogRead).Since r.Pending = pendingOf(holderOf(stdio.Ask)) // The build modules are no names (design 47 G A-82): the build seats on the seat list, each held by the module the seat - // list names for it; the seat list and its two tools are wired once by mesh-sdk (§204). - // Its callers name seats, never a module, resolved from the seat-holders view the catalog half's claimant serves (A-295, A-298). - gate := seatlist.NewPart("view", []string{stdio.AnyPerson, stdio.CallerSeatPrefix + "node-tool-runner", stdio.CallerSeatPrefix + "mesh-healers"}) - gate.Holders(branches.SeatHolders(context.Background())) + // list names for it; the seat list and its two tools are wired once by mesh-sdk (§204), open to every caller (design 47 H + // §752, H-A-66). + gate := seatlist.NewPart("view") go func() { <-stdio.Served() gate.Follow(seatlist.StdioBus(), nil, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-view-tools] "+f+"\n", a...) }) @@ -504,7 +502,7 @@ func main() { // view_first_views and view_first_view_again: where the view's process stands with its first views of the indexer's and // the assigner's states (ADR 0615 §6), and a re-read by hand. tools := append(Tools(r, u), gate.Tools()...) - tools = append(tools, AnswersTool(os.Getenv(stdio.ServedAs), views.ParseCallers(os.Getenv(views.CallersEnv(viewstate.ViewAnswersTool))), func(name string) views.Source { return views.KeptSource{State: stdio.State(name)} }, time.Now)) + tools = append(tools, AnswersTool(os.Getenv(stdio.ServedAs), func(name string) views.Source { return views.KeptSource{State: stdio.State(name)} }, time.Now)) tools = append(tools, views.StatusTools(os.Getenv(stdio.ServedAs), "view_first_views", "view_first_view_again", stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) if err := stdio.Serve("", tools); err != nil { fmt.Fprintf(os.Stderr, "[mesh-delivery-view-tools] %v\n", err) @@ -513,26 +511,26 @@ func main() { } // AnswersTool is answers, the first-view tool of the seat mesh-delivery-view's state answers (mesh-sdk views.FirstViewTool), -// answered to the callers its list names (the teller): its first view of the answers the view says on views.answers +// answered to every caller (design 47 H §752, H-A-66): its first view of the answers the view says on views.answers // (design 47 G A-175, A-178, §717, A-301). -func AnswersTool(module string, callers stdio.Callers, state func(string) views.Source, now func() time.Time) stdio.Tool { +func AnswersTool(module string, state func(string) views.Source, now func() time.Time) stdio.Tool { return views.FirstViewTool(module, viewstate.ViewAnswersTool, viewstate.ViewAnswersState, "the operator's answers given in the view to the asks of the seat mesh-wants, one key .view each, which the teller fills the ask from.", - callers, state(viewstate.ViewAnswersState), state(views.MarksState), now) + state(viewstate.ViewAnswersState), state(views.MarksState), now) } // pendingOf asks the indexer's tool indexer_pending (declared in invokes) of the module holding the seat mesh-catalog: what it // holds back and why (ADR 0633 §5; design 47 G A-210). -func pendingOf(holder func(seat string) (string, bool)) func() (takein.PendingAnswer, error) { - return func() (takein.PendingAnswer, error) { +func pendingOf(holder func(seat string) (string, bool)) func() (view.HeldTakeIns, error) { + return func() (view.HeldTakeIns, error) { module, ok := holder(view.CatalogSeat) if !ok { - return takein.PendingAnswer{}, fmt.Errorf("the holder of %s is not found", view.CatalogSeat) + return view.HeldTakeIns{}, fmt.Errorf("the holder of %s is not found", view.CatalogSeat) } raw, err := stdio.Ask(module+".indexer_pending", map[string]any{}) if err != nil { - return takein.PendingAnswer{}, err + return view.HeldTakeIns{}, err } - return takein.DecodePendingAnswer(raw) + return view.DecodeHeldTakeIns(raw) } } diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go index 93c1ed2f..e1fc2999 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go @@ -166,7 +166,7 @@ func ownersAnswerTheToolsAsBefore(t *testing.T) { // the form of the value the tool always answered, the modules without a fingerprint say why, and the module's history // is not a thing the catalog half keeps. a, err := run(t, owned, view.ModuleReadTool, map[string]any{"module": "a"}) - if raw, _ := json.Marshal(a); err != nil || !strings.Contains(string(raw), `"fp2":"`+fp2A+`"`) || !strings.Contains(string(raw), `"commit":"c1"`) || !strings.Contains(string(raw), `"src":7`) || !strings.Contains(string(raw), `"manifest":"`+manifestDigestA+`"`) { + if raw, _ := json.Marshal(a); err != nil || !strings.Contains(string(raw), `"fp2":"`+fp2A+`"`) || !strings.Contains(string(raw), `"commit":"c1"`) || strings.Contains(string(raw), `"src"`) || !strings.Contains(string(raw), `"manifest":"`+manifestDigestA+`"`) { t.Errorf("indexer_module a = %s, %v", raw, err) } if _, err := run(t, owned, view.ModuleReadTool, map[string]any{"module": "gone"}); err == nil { @@ -259,12 +259,12 @@ func startedBranches(t *testing.T, ctx context.Context, ask func(string, any) (j return b } -// catalogAnswer is the seat mesh-catalog's newest trunk revision: a with a fingerprint and the source revision it moved at, -// b with none and the reason. +// catalogAnswer is the seat mesh-catalog's newest trunk revision: a with a fingerprint (no source stamp, design 47 H-A-48), b +// with none and the reason. var catalogAnswer = meshcatalog.RevisionAnswer{ Revision: &meshcatalog.CatalogRevision{Revision: 4, Kind: meshcatalogclient.KindTrunk, Source: 7}, Entries: []meshcatalog.CatalogEntry{ - {Module: "a", Repository: "novox/r", Commit: "c1", Path: ".", Manifest: map[string]any{"module": "a"}, ManifestDigest: "sha256:" + manifestDigestA, Fp: fp2A, Inputs: &meshcatalog.EntryInputs{Src: 7}}, + {Module: "a", Repository: "novox/r", Commit: "c1", Path: ".", Manifest: map[string]any{"module": "a"}, ManifestDigest: "sha256:" + manifestDigestA, Fp: fp2A, Inputs: &meshcatalog.EntryInputs{}}, {Module: "b", Repository: "novox/r", Commit: "c2", Path: "modules/b", Manifest: map[string]any{"module": "b"}, None: "builder's fingerprint not yet known"}, }, } @@ -274,10 +274,10 @@ var catalogAnswer = meshcatalog.RevisionAnswer{ const manifestDigestA = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" // answers is the first-view tool of the seat mesh-delivery-view's state answers (design 47 G A-178, §717, A-301): a page of every -// key, answered to the teller its callers list names and refused to any other caller. +// key, answered to every caller (design 47 H §752, H-A-66). func TestTheViewReadsItsAnswersAsAnOwner(t *testing.T) { answers := source{"hold.plex.ab.view": `{"asking":"a1","option":"release"}`} - tool := AnswersTool("acme-view", views.ParseCallers("mesh-delivery-teller"), func(name string) views.Source { + tool := AnswersTool("acme-view", func(name string) views.Source { if name == viewstate.ViewAnswersState { return answers } @@ -286,11 +286,11 @@ func TestTheViewReadsItsAnswersAsAnOwner(t *testing.T) { if tool.Name != "answers" || !strings.Contains(tool.Description, "acme-view") { t.Fatalf("the tool is %s: %s", tool.Name, tool.Description) } - // Answered only to the callers its list names: the teller, never a call no runtime proved. - if !strings.Contains(tool.Description, "mesh-delivery-teller") { - t.Errorf("the tool's callers are not the teller: %s", tool.Description) + out, err := tool.Run(map[string]any{}) + if err != nil { + t.Fatalf("a caller is refused: %v", err) } - if out, err := tool.Run(map[string]any{}); err == nil { - t.Errorf("an unproven caller is answered: %v", out) + if raw, _ := json.Marshal(out); !strings.Contains(string(raw), "hold.plex.ab.view") { + t.Errorf("the page does not hold the answer: %s", raw) } } diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go index 8a497a16..4671f370 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go @@ -13,7 +13,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" ) @@ -93,33 +92,24 @@ func tiersToolSaysEachModulesWait(t *testing.T) { !reflect.DeepEqual(web.Waits, []view.TierWait{{Owner: "mesh-wants", Step: "delivery", Node: "ace", Bound: "60m", Since: since, Words: "waiting for delivery of db to g14"}}) { t.Errorf("web = %+v, want after db, waiting for the delivery of db in the assigner's words", web) } - // ADR 0633 §5 (1585/T24): a module the indexer holds back, read through indexer_pending, waits on the edge take-in from the - // wait's since; a held module the revision does not move is named in the first tier with that wait alone, a group's wait - // says its group, and a tool that cannot be asked is said and names no module. + // Design 47 H-A-109: a take-in the indexer holds, read through indexer_pending (H-A-102), is said in the tiers' pending words + // with its branch, source, why and since, and names no module; a tool that cannot be asked is said and names no module. heldSince := time.Date(2026, 11, 4, 22, 0, 0, 0, time.UTC) - r.Pending = func() (takein.PendingAnswer, error) { - return takein.PendingAnswer{Waits: []takein.PendingWait{ - {Key: "m.00000000000000000042", What: takein.TakeInRevision, WaitsFor: "src2:abc", Since: heldSince, Holds: []string{"web", "newmod"}}, - {Key: "g.feat", What: takein.TakeInGroup, Group: "feat", Since: heldSince.Add(time.Hour), Holds: []string{"lib"}}}}, nil + r.Pending = func() (view.HeldTakeIns, error) { + return view.DecodeHeldTakeIns([]byte(`{"held":[{"branch":"main","source":3590,"why":"the catalog store is full","since":"2026-11-04T22:00:00Z"}]}`)) } out, err = run(t, r, view.TiersTool, map[string]any{"revision": float64(9)}) held, _ := out.(view.Tiers) - if err != nil || len(held.Tiers) != 2 || held.Pending != "" { - t.Fatalf("view_tiers with waits = %+v, %v", out, err) + if err != nil || len(held.Tiers) != 2 || !reflect.DeepEqual(held.Tiers, got.Tiers) || + held.Pending != "the indexer holds the take-in of source revision 3590 of main since "+heldSince.Format(time.RFC3339)+": the catalog store is full" { + t.Fatalf("view_tiers with a held take-in = %+v, %v; want its tiers unchanged and the take-in said", out, err) } - web = held.Tiers[1][0] - if last := web.Waits[len(web.Waits)-1]; last.Step != view.TakeInStep || !last.Since.Equal(heldSince) || !strings.Contains(last.Words, "unread or lost") { - t.Errorf("web = %+v, want its last wait on the edge take-in since %s", web, heldSince) + if _, err := view.DecodeHeldTakeIns([]byte(`{"held":[{"branch":"main","why":"full"}]}`)); err == nil { + t.Error("a held take-in with no source or since is read") } - if lib := held.Tiers[0][1]; lib.Module != "lib" || lib.Waits[len(lib.Waits)-1].Step != view.TakeInStep || !strings.Contains(lib.Waits[len(lib.Waits)-1].Words, "group feat") { - t.Errorf("lib = %+v, want its last wait the group's", lib) - } - if nm := held.Tiers[0][len(held.Tiers[0])-1]; nm.Module != "newmod" || len(nm.Waits) != 1 || nm.Waits[0].Step != view.TakeInStep { - t.Errorf("the first tier = %+v, want newmod, which the revision does not move, named with its take-in wait alone", held.Tiers[0]) - } - r.Pending = func() (takein.PendingAnswer, error) { return takein.PendingAnswer{}, errors.New("no answer") } + r.Pending = func() (view.HeldTakeIns, error) { return view.HeldTakeIns{}, errors.New("no answer") } if out, err = run(t, r, view.TiersTool, map[string]any{"revision": float64(9)}); err != nil || !strings.Contains(out.(view.Tiers).Pending, "no answer") || - strings.Contains(fmt.Sprint(out.(view.Tiers).Tiers), view.TakeInStep) { + !reflect.DeepEqual(out.(view.Tiers).Tiers, got.Tiers) { t.Errorf("view_tiers with no answer of indexer_pending = %+v, %v", out, err) } r.Pending = nil diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go index 4ab8a135..90826819 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "slices" + "strconv" "strings" "sync" "testing" @@ -127,7 +128,7 @@ func serveCatalog(t testing.TB, ctx context.Context, js jetstream.JetStream, nc var a any = map[string]any{"branches": []string{catalogBranch}} if in.Branch != "" { h.mu.Lock() - a = meshdelivery.SourceAnswer{Branch: in.Branch, Revision: h.src.Revision, Group: h.src.Group, Repositories: h.src.Repositories} + a = meshdelivery.SourceAnswer{Branch: in.Branch, Revision: h.src.Revision, Call: h.src.Call, Repositories: h.src.Repositories} h.mu.Unlock() } raw, _ := json.Marshal(map[string]any{"result": a, "node": "n0"}) @@ -150,16 +151,20 @@ func serveCatalog(t testing.TB, ctx context.Context, js jetstream.JetStream, nc const catalogBranch = "release" // moveSource is the gate's next source revision of catalogBranch, said as source-moved (design 47 G §507, A-173). -func (h *catalogHolder) moveSource(rev int64, group string, heads map[string]string) { +func (h *catalogHolder) moveSource(rev int64, call string, heads map[string]string) { h.t.Helper() h.mu.Lock() - h.src = meshdelivery.SourceAnswer{Revision: rev, Group: group} + h.src = meshdelivery.SourceAnswer{Revision: rev, Call: call} for repository, head := range heads { h.src.Repositories = append(h.src.Repositories, meshdelivery.SourceHead{Repository: repository, Head: head, Trunk: catalogBranch}) } h.mu.Unlock() - body, _ := json.Marshal(meshdelivery.SourceMovedEvent{Branch: catalogBranch, Revision: rev, Group: group}) - if _, err := h.js.Publish(h.ctx, meshdelivery.SubjectSourceMoved(catalogBranch), body); err != nil { + ev := meshdelivery.SourceMovedEvent{V: 1, Branch: catalogBranch, Source: rev, Call: call} + for repository, head := range heads { + ev.Heads = append(ev.Heads, meshdelivery.SourceMovedEventHeadsItem{Repository: repository, Commit: head}) + } + body, _ := json.Marshal(ev) + if _, err := h.js.Publish(h.ctx, meshdelivery.SubjectSourceMoved(catalogBranch, strconv.FormatInt(rev, 10)), body); err != nil { h.t.Fatal(err) } } @@ -515,8 +520,8 @@ func TestProcessWholeListsEveryDifference(t *testing.T) { // 1297/B8 AC const fpOld = "src2:1111111111111111111111111111111111111111111111111111111111111111" const fpNew = "src2:2222222222222222222222222222222222222222222222222222222222222222" for key, d := range map[string]meshwantsclient.Want{ - "want.ace.plex": {Fp: fpNew, Composed: "sha256:" + strings.Repeat("c", 64)}, - "want.g14.plex": {Fp: fpOld, Composed: "sha256:" + strings.Repeat("c", 64), Newest: fpNew, Rule: meshwantsclient.RuleCanary, Words: "the canary ace does not run it healthy yet"}, + "want.ace.plex": {Fp: fpNew}, + "want.g14.plex": {Fp: fpOld, Words: "awaits its hand placement"}, } { v, err := meshwantsclient.EncodeWant(d) if err != nil { @@ -541,7 +546,7 @@ func TestProcessWholeListsEveryDifference(t *testing.T) { // 1297/B8 AC } wait(func(s view.Snapshot) bool { d := s.Wants - return len(d) == 2 && d[0].Node == "ace" && d[0].State == view.WantPending && d[1].Node == "g14" && d[1].State == view.WantHeldBack && d[1].Rule == meshwantsclient.RuleCanary + return len(d) == 2 && d[0].Node == "ace" && d[0].State == view.WantPending && d[1].Node == "g14" && d[1].State == view.WantPending && d[1].Words == "awaits its hand placement" }, "the two wants never showed with where they stand") if err := kv.Delete(ctx, "want.g14.plex"); err != nil { t.Fatal(err) @@ -834,7 +839,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { t.Cleanup(func() { stop(); <-done }) fp := "src2:" + strings.Repeat("2", 64) - want, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp, Composed: "sha256:" + strings.Repeat("c", 64)}) + want, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp}) failed, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fp, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthFailed}) good, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fp, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}) catalog.put(meshcatalog.CatalogEntry{Module: "web", Fp: fp, Manifest: map[string]any{"module": "a"}, Repository: "novox/web", Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath}) @@ -846,7 +851,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { } // The gate's source of the watched branch moves: the view asks the verb source for it and reads no gate state (A-173). const rev = 41 - catalog.moveSource(rev, "feat/x", map[string]string{"novox/web": strings.Repeat("1", 40)}) + catalog.moveSource(rev, "c-feat-x", map[string]string{"novox/web": strings.Repeat("1", 40)}) time.Sleep(time.Second) if info, err := events.Info(ctx, jetstream.WithSubjectFilter("mesh.mod.mesh-delivery-view.event."+DeliveredEventType)); err != nil || len(info.State.Subjects) != 0 { t.Fatalf("an event was said before the revision was delivered: %v %+v", err, info.State) @@ -862,8 +867,8 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { t.Fatal("the delivery of the source revision was never said") } var e view.DeliveredEvent - if err := json.Unmarshal(msg.Data, &e); err != nil || e.Branch != catalogBranch || e.Revision != rev || e.Group != "feat/x" || e.Heads["novox/web"] != strings.Repeat("1", 40) { - t.Errorf("the event = %+v, %v; want the branch %s, revision %d, group feat/x and the heads", e, err, catalogBranch, rev) + if err := json.Unmarshal(msg.Data, &e); err != nil || e.Branch != catalogBranch || e.Revision != rev || e.Heads["novox/web"] != strings.Repeat("1", 40) { + t.Errorf("the event = %+v, %v; want the branch %s, revision %d and the heads", e, err, catalogBranch, rev) } if msg.Header.Get("x-source") != "mesh-delivery-view" || msg.Header.Get("x-event-id") == "" { t.Errorf("the headers = %v", msg.Header) @@ -941,7 +946,6 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) { time.Sleep(2 * time.Second) // the view has read what stood: nothing fpOld, fpNew := "src2:"+strings.Repeat("1", 64), "src2:"+strings.Repeat("2", 64) - digest := "sha256:" + strings.Repeat("c", 64) put := func(bucket, key string, v []byte, err error) { t.Helper() if err != nil { @@ -952,7 +956,7 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) { } } want := func(node, module string) { - v, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Composed: digest}) + v, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew}) put(view.WantsBucket, "want."+node+"."+module, v, err) } have := func(node, module, fp string, phase string, health string, detail string) { @@ -990,10 +994,10 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) { }()) return jetstream.RawStreamMsg{} } - hex := strings.Repeat("c", 64) + hex := fpNew // a motion event is keyed by the fingerprint wanted (design 47 H-A-78) mv := waitFor("moving.ace.web." + hex) var body view.MotionBody - if err := json.Unmarshal(mv.Data, &body); err != nil || body.Node != "ace" || body.Module != "web" || body.FromFP != fpOld || body.ToFP != fpNew || body.Composed != digest || body.BoundSeconds != view.MotionBoundSeconds || body.Since.IsZero() { + if err := json.Unmarshal(mv.Data, &body); err != nil || body.Node != "ace" || body.Module != "web" || body.FromFP != fpOld || body.ToFP != fpNew || body.BoundSeconds != view.MotionBoundSeconds || body.Since.IsZero() { t.Errorf("moving = %+v, %v", body, err) } if mv.Subject != "mesh.mod.mesh-delivery-view.event.moving" { diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go index 0721deaa..f6472ef8 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go @@ -143,11 +143,11 @@ func (s *branchSources) hear(branch string, f *views.Follower) func(context.Cont if ev.Branch != branch && ev.Branch != esc { return nil } - held := func() bool { return revisionOf(f, esc) >= ev.Revision } + held := func() bool { return revisionOf(f, esc) >= ev.Source } if held() { return nil } - go sourcebranches.CatchUp(s.ctx, f, held, fmt.Sprintf("source of %s moved to %d", branch, ev.Revision)) + go sourcebranches.CatchUp(s.ctx, f, held, fmt.Sprintf("source of %s moved to %d", branch, ev.Source)) return nil } } diff --git a/modules/mesh-delivery-view/internal/view/catalog.go b/modules/mesh-delivery-view/internal/view/catalog.go index 42f5dc4a..a9970023 100644 --- a/modules/mesh-delivery-view/internal/view/catalog.go +++ b/modules/mesh-delivery-view/internal/view/catalog.go @@ -39,7 +39,7 @@ func ModuleValue(entry json.RawMessage) (json.RawMessage, error) { v.Verdict = e.Verdict } if in := e.Inputs; in != nil { - v.Src, v.FpSrc, v.Toolchains, v.Paths, v.Warnings = in.Src, in.FpSrc, in.Toolchains, in.Paths, in.Warnings + v.Toolchains, v.Paths, v.Warnings = in.Toolchains, in.Paths, in.Warnings if f := in.From; f != nil && v.Manifest != "" { v.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{Bases: f.Bases, Builder: f.Builder, Contexts: f.Contexts, ImportForm: f.ImportForm, Imports: f.Imports, Locks: f.Locks, Packages: f.Packages, Paths: f.Paths, Tree: f.Tree} diff --git a/modules/mesh-delivery-view/internal/view/history.go b/modules/mesh-delivery-view/internal/view/history.go index cdcc5355..e95a341d 100644 --- a/modules/mesh-delivery-view/internal/view/history.go +++ b/modules/mesh-delivery-view/internal/view/history.go @@ -40,7 +40,6 @@ type ModuleRevision struct { Op string `json:"op"` Repository string `json:"repository,omitempty"` Commit string `json:"commit,omitempty"` - Src uint64 `json:"src,omitempty"` FP2 string `json:"fp2,omitempty"` None2 string `json:"none2,omitempty"` Manifest string `json:"manifest,omitempty"` @@ -82,7 +81,7 @@ func (r Reader) ModuleHistory(module string) (ModuleHistory, error) { if err := json.Unmarshal(rev.Value, &m); err != nil { row.Unreadable = err.Error() } else { - row.Repository, row.Commit, row.Src, row.FP2, row.None2, row.Manifest, row.Path = m.Repository, m.Commit, uint64(m.Src), m.Fp2, m.None2, m.Manifest, m.Path + row.Repository, row.Commit, row.FP2, row.None2, row.Manifest, row.Path = m.Repository, m.Commit, m.Fp2, m.None2, m.Manifest, m.Path } } out.Values = append(out.Values, row) diff --git a/modules/mesh-delivery-view/internal/view/motion.go b/modules/mesh-delivery-view/internal/view/motion.go index 4e16e75d..6cc28369 100644 --- a/modules/mesh-delivery-view/internal/view/motion.go +++ b/modules/mesh-delivery-view/internal/view/motion.go @@ -7,8 +7,9 @@ import ( ) // motionOf derives where one module's want stands on one node from the want and the have as their seats carry them, through -// mesh-sdk's seat-neutral derivation (issue 1952 S7), which the condition keeper's hold uses too. +// mesh-sdk's seat-neutral derivation (issue 1952 S7), which the condition keeper's hold uses too. A want counts as applied by +// its fingerprint alone (design 47 H-A-78). func motionOf(w meshwantsclient.Want, wanted bool, h nodeengine.HaveByNodeModuleValue, has bool, words string, stuck bool) motion.Motion { - return motion.MotionOf(motion.Want{FP: w.Fp, Composed: w.Composed, Removed: w.Removed}, wanted, + return motion.MotionOf(motion.Want{FP: w.Fp, Removed: w.Removed}, wanted, motion.Have{FP: h.Fp, Composed: h.Composed, Phase: h.Phase, Health: h.Health, Detail: h.Detail}, has, words, stuck) } diff --git a/modules/mesh-delivery-view/internal/view/reach.go b/modules/mesh-delivery-view/internal/view/reach.go index e2456f9e..5de23073 100644 --- a/modules/mesh-delivery-view/internal/view/reach.go +++ b/modules/mesh-delivery-view/internal/view/reach.go @@ -60,9 +60,6 @@ func (m *Model) applyHistory(e Entry) { } h := m.modHist[e.Key] if n := len(h); n > 0 && h[n-1].Fp2 == mod.Fp2 && h[n-1].Commit == mod.Commit { - if mod.Src != 0 { - h[n-1].Src = mod.Src - } return } h = append(h, mod) @@ -197,10 +194,7 @@ func (m *Model) moduleReach(name string, mod meshcatalog.ModulesByModuleValue, h } var values []meshcatalog.ModulesByModuleValue // the catalogue's value of each change, in step with mr.Changes for i := len(hist) - 1; i >= 0 && len(mr.Changes) < viewstate.MostChanges; i-- { - c := viewstate.Change{Commit: hist[i].Commit, FP: hist[i].Fp2, Src: uint64(hist[i].Src)} - if c.Src == 0 { - c.Src = revOf(heads, c.Commit) - } + c := viewstate.Change{Commit: hist[i].Commit, FP: hist[i].Fp2, Src: revOf(heads, hist[i].Commit)} if n := len(mr.Changes); n > 0 && mr.Changes[n-1].FP == c.FP { mr.Changes[n-1] = c // the same fingerprint again, back to back: its first appearance is the older commit values[n-1] = hist[i] diff --git a/modules/mesh-delivery-view/internal/view/reach_test.go b/modules/mesh-delivery-view/internal/view/reach_test.go index 1616f662..45958694 100644 --- a/modules/mesh-delivery-view/internal/view/reach_test.go +++ b/modules/mesh-delivery-view/internal/view/reach_test.go @@ -26,15 +26,15 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { commitA, commitB, commitC := strings.Repeat("a", 40), strings.Repeat("b", 40), strings.Repeat("c", 40) commitS, commitX, commitD := strings.Repeat("5", 40), strings.Repeat("e", 40), strings.Repeat("d", 40) const fpMail = "src2:3333333333333333333333333333333333333333333333333333333333333333" - mod := func(module, fp, commit string, src uint64, history bool) Entry { - v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Src: int64(src), Path: module}) + mod := func(module, fp, commit string, _ uint64, history bool) Entry { // a module carries no source stamp (design 47 H-A-48) + v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Path: module}) if err != nil { t.Fatal(err) } return Entry{Bucket: ModulesBucket, Key: module, Value: v, At: t0, History: history, Branch: testBranch} } - modIn := func(fp, commit string, src uint64, in *meshcatalog.ModulesByModuleValueInputs2, history bool) Entry { - v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Src: int64(src), Path: "web", Inputs2: in}) + modIn := func(fp, commit string, _ uint64, in *meshcatalog.ModulesByModuleValueInputs2, history bool) Entry { + v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Path: "web", Inputs2: in}) if err != nil { t.Fatal(err) } @@ -46,18 +46,22 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { // A later build of web (fpLater) that g14, running fpNew, lacks; issue 1966: the hold names both builds, what moved when the // commit is the same, and a build that failed as failed. const fpLater = "src2:9999999999999999999999999999999999999999999999999999999999999999" - later := func(commit string, to *meshcatalog.ModulesByModuleValueInputs2, extra ...Entry) []Entry { - return append([]Entry{modIn(fpLater, commit, 12, to, true), modIn(fpLater, commit, 12, to, false)}, extra...) - } // Each watched branch's source as its verb source answers it, one revision heard after another (design 47 G A-173). srcOn := func(branch string, rev uint64, webHead string) Entry { - v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Group: "g", Heads: map[string]string{web: webHead, sdk: commitS}}) + v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Call: "c1", Source: int64(rev), Heads: map[string]string{web: webHead, sdk: commitS}}) if err != nil { t.Fatal(err) } return Entry{Bucket: SourceBucket, Key: keys.EscapeName(branch), Value: v, At: t0, Revision: rev} } src := func(rev uint64, webHead string) Entry { return srcOn(testBranch, rev, webHead) } + later := func(commit string, to *meshcatalog.ModulesByModuleValueInputs2, extra ...Entry) []Entry { + before := []Entry{modIn(fpLater, commit, 12, to, true), modIn(fpLater, commit, 12, to, false)} + if commit != commitC { // another commit is the head of the source revision after C's: no module carries a stamp (H-A-48) + before = append([]Entry{src(13, commit)}, before...) + } + return append(before, extra...) + } // The reach the view's own state held at its start (A-225). kept := func(reached string, rev uint64) Entry { key, _ := trunk.RepositoryKey(web) @@ -121,19 +125,19 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { then: []Entry{haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK), presenceE(t, "g14", false, t0)}}, {name: "a node returned lagging holds the head again", reached: commitB, holds: "web on g14", waiting: "not yet the", then: []Entry{haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK), presenceE(t, "g14", false, t0), presenceE(t, "g14", true, t0)}}, - {name: "a want held back at an older build holds the head as a lag does", reached: commitB, holds: "web on g14 runs build", - then: []Entry{wantE(t, "g14", "web", meshwantsclient.Want{Fp: fpOld, Newest: fpNew, Rule: 2}), haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK)}}, + {name: "a want at an older build holds the head as a lag does", reached: commitB, holds: "web on g14 runs build", + then: []Entry{wantE(t, "g14", "web", meshwantsclient.Want{Fp: fpOld}), haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK)}}, {name: "a later build of the same commit names the mesh package that moved", reached: commitB, holds: "web on ace runs build 22222222 (cccccccc), not yet 99999999 (cccccccc, a mesh package of mesh-sdk/go)", then: later(commitC, in("t1", "mesh-sdk/go"))}, {name: "a later build of the same commit names the tree that moved", reached: commitB, holds: "runs build 22222222 (cccccccc), not yet 99999999 (cccccccc, tree)", then: later(commitC, in("t2", "mesh-sdk/go"))}, - {name: "a later build of another commit names no input", reached: commitB, + {name: "a later build of another commit names no input", reached: commitC, holds: "runs build 22222222 (cccccccc), not yet 99999999 (eeeeeeee)", then: later(commitX, in("t2"))}, - {name: "the newest build, failed, is said failed with its first words", reached: commitB, + {name: "the newest build, failed, is said failed with its first words", reached: commitC, holds: "its newest build 99999999 (eeeeeeee) failed: go build ./...: undefined: Foo", then: later(commitX, in("t2"), builderKey(t, "web", fpLater, builds.BuilderBuild{State: builds.BuildFailed, Error: "go build ./...: undefined: Foo"}))}, - {name: "a failed build that is not the newest is the build the node waits for", reached: commitB, + {name: "a failed build that is not the newest is the build the node waits for", reached: commitC, holds: "the build it waits for 99999999 (eeeeeeee) failed: go build", then: append(later(commitX, in("t2"), builderKey(t, "web", fpLater, builds.BuilderBuild{State: builds.BuildFailed, Error: "go build ./...: undefined: Foo"})), modIn("src2:"+strings.Repeat("8", 64), commitD, 12, in("t3"), true), modIn("src2:"+strings.Repeat("8", 64), commitD, 12, in("t3"), false))}, @@ -246,7 +250,7 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { t.Errorf("said again: %+v", said[n:]) } for _, e := range said { - if len(e.Heads) != 1 || e.Group != "" || e.Revision == 0 { + if len(e.Heads) != 1 || e.Revision == 0 { t.Errorf("a reached head said as %+v", e) } } diff --git a/modules/mesh-delivery-view/internal/view/read.go b/modules/mesh-delivery-view/internal/view/read.go index 6df09c17..a42a62a5 100644 --- a/modules/mesh-delivery-view/internal/view/read.go +++ b/modules/mesh-delivery-view/internal/view/read.go @@ -21,7 +21,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" stdio "git.novox.be/novox/mesh-sdk/go" @@ -79,8 +78,8 @@ type Reader struct { // view_tiers works the tiers of a source revision from (design 47 G §512, A-242). Assignment func(revision int64) (meshwants.AssignmentRevision, error) Difference func(from, to int64) (meshwants.Difference, error) - // Pending reads the indexer's waits through its tool indexer_pending (ADR 0633 §5); unset names no module held back. - Pending func() (takein.PendingAnswer, error) + // Pending reads the take-ins the indexer holds through its tool indexer_pending (design 47 H §744, H-A-102); unset says none. + Pending func() (HeldTakeIns, error) // BuildLog reads the builder's log from a time (stdio.Log(builds.BuildLogRead).Since); unset reads none. BuildLog LogSince } diff --git a/modules/mesh-delivery-view/internal/view/serve.go b/modules/mesh-delivery-view/internal/view/serve.go index c3464576..0114be3f 100644 --- a/modules/mesh-delivery-view/internal/view/serve.go +++ b/modules/mesh-delivery-view/internal/view/serve.go @@ -237,9 +237,6 @@ func wantText(s Snapshot) [][]string { have = "none" } words := w.Words - if w.Rule != 0 { - words = fmt.Sprintf("rule %d: %s", w.Rule, w.Words) - } judged := w.Judgement if judged == "" { judged = "none" diff --git a/modules/mesh-delivery-view/internal/view/source.go b/modules/mesh-delivery-view/internal/view/source.go index d0c05680..6f3487b4 100644 --- a/modules/mesh-delivery-view/internal/view/source.go +++ b/modules/mesh-delivery-view/internal/view/source.go @@ -47,7 +47,7 @@ func SourceEntry(branch string, a meshdelivery.SourceAnswer) (Entry, error) { e.Deleted = true return e, nil } - v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Group: a.Group, Heads: heads}) + v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Source: a.Revision, Call: a.Call, Heads: heads}) if err != nil { return Entry{}, err } diff --git a/modules/mesh-delivery-view/internal/view/tiers.go b/modules/mesh-delivery-view/internal/view/tiers.go index 721b5da9..2dc02305 100644 --- a/modules/mesh-delivery-view/internal/view/tiers.go +++ b/modules/mesh-delivery-view/internal/view/tiers.go @@ -1,6 +1,7 @@ package view import ( + "encoding/json" "fmt" "maps" "slices" @@ -8,8 +9,8 @@ import ( "strings" "time" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" ) @@ -41,13 +42,14 @@ type Tiers struct { Tiers [][]TierModule `json:"tiers"` Cut string `json:"cut,omitempty"` Graph string `json:"graph,omitempty"` - // Pending says why the indexer's waits could not be read, so no module is named held by its revision's indexer (ADR 0633 §5). + // Pending says each take-in the indexer holds (its branch, source, why and since; design 47 H-A-109), or why they could not + // be read, and why the parts' waits could not be read. Pending string `json:"pending,omitempty"` } // TierModule is one module of a tier (design 47 G §512): its build (the fingerprint the difference says it is to run), the -// modules it is ordered after with the edge's kind, and each wait of its own now, from the parts' wait-held and the indexer's -// pending revisions (no wait is a module that reached every node present). +// modules it is ordered after with the edge's kind, and each wait of its own now, from the parts' wait-held (no wait is a +// module that reached every node present). type TierModule struct { Module string `json:"module"` // FP is the build. @@ -63,8 +65,7 @@ type TierAfter struct { } // TierWait is one wait of a module, as the part that holds it said it (design 47 G §512, §498): the seat or module that holds it -// (Owner), its step, the node it is on, what it waits on, its bound, since when, and its own words. The pending revision of the -// indexer is Owner mesh-catalog and Step take-in. +// (Owner), its step, the node it is on, what it waits on, its bound, since when, and its own words. type TierWait struct { Owner string `json:"owner"` Step string `json:"step"` @@ -147,12 +148,8 @@ func (r Reader) Tiers(revision uint64) (Tiers, error) { len(names), TiersMost, names[TiersMost], len(names)-TiersMost-1) names = names[:TiersMost] } + r.heldTakeIns(&out) waits := r.waitsHeld(&out) - held, heldAll := r.heldBack(&out) - in := map[string]bool{} - for _, n := range names { - in[n] = true - } for _, n := range names { t := tierOf[n] for len(out.Tiers) <= t { @@ -173,22 +170,8 @@ func (r Reader) Tiers(revision uint64) (Tiers, error) { } slices.SortFunc(tm.After, func(a, b TierAfter) int { return strings.Compare(a.Module+"\x00"+a.Kind, b.Module+"\x00"+b.Kind) }) tm.Waits = waits[n] - if w, ok := held[n]; ok { - tm.Waits = append(tm.Waits, w) - } out.Tiers[t] = append(out.Tiers[t], tm) } - // A module the indexer holds back is not at the revision yet, so no tier of it names it: it is named in the first tier with - // its wait alone (ADR 0633 §5). - for _, n := range heldAll { - if in[n] { - continue - } - if len(out.Tiers) == 0 { - out.Tiers = append(out.Tiers, nil) - } - out.Tiers[0] = append(out.Tiers[0], TierModule{Module: n, Waits: []TierWait{held[n]}}) - } compact := out.Tiers[:0] for _, t := range out.Tiers { if len(t) > 0 { @@ -199,39 +182,49 @@ func (r Reader) Tiers(revision uint64) (Tiers, error) { return out, nil } -// TakeInStep and TakeInOwner are the step and the owner of a wait on the indexer a source revision or a group is held for -// (ADR 0633 §5, design 47 G §512): the pending revision's wait is the seat mesh-catalog's step take-in. -const ( - TakeInStep = "take-in" - TakeInOwner = "mesh-catalog" -) +// HeldTakeIn is one take-in the indexer holds, as its tool indexer_pending answers it (design 47 H §744, H-A-102): the seat +// mesh-catalog's form with since, when it was held. +type HeldTakeIn struct { + meshcatalog.TakeInPending + Since time.Time `json:"since"` +} -// heldBack are the modules the indexer holds back, by module, each with its wait, read through the indexer's tool -// indexer_pending (ADR 0633 §5), and the same modules sorted. A tool that cannot be asked says so in out.Pending. -func (r Reader) heldBack(out *Tiers) (map[string]TierWait, []string) { - held := map[string]TierWait{} +// HeldTakeIns is the answer of indexer_pending (design 47 H-A-102): every branch's held take-in. +type HeldTakeIns struct { + Held []HeldTakeIn `json:"held"` +} + +// DecodeHeldTakeIns reads the answer of indexer_pending, refusing a held take-in with no branch, source or since. +func DecodeHeldTakeIns(raw []byte) (HeldTakeIns, error) { + var a HeldTakeIns + if err := json.Unmarshal(raw, &a); err != nil { + return HeldTakeIns{}, fmt.Errorf("not an answer of indexer_pending: %w", err) + } + for _, h := range a.Held { + if h.Branch == "" || h.Source == 0 || h.Since.IsZero() { + return HeldTakeIns{}, fmt.Errorf("indexer_pending names a held take-in with no branch, source or since: %+v", h) + } + } + return a, nil +} + +// heldTakeIns says each take-in the indexer holds in out.Pending, read through its tool indexer_pending: its branch, source, +// why and since. A held take-in names no module, since its movers are known only once it is taken in (design 47 H-A-109). +func (r Reader) heldTakeIns(out *Tiers) { if r.Pending == nil { - return held, nil + return } a, err := r.Pending() if err != nil { - out.Pending = "the indexer's pending revisions cannot be read, so no module is named waiting for its revision's indexer: " + err.Error() - return held, nil + out.Pending = "the indexer's held take-ins cannot be read: " + err.Error() + return } - for _, w := range a.Waits { - words := "the indexer holds back " + w.Key + " (its message is unread or lost, or it is held for room)" - if w.What == takein.TakeInGroup { - words = "the indexer gathers the group " + w.Group + " and its end has not come" - } else if w.Behind != "" { - words = "the indexer holds back " + w.Key + " behind " + w.Behind - } - for _, module := range w.Holds { - if _, ok := held[module]; !ok { // the oldest wait names it - held[module] = TierWait{Owner: TakeInOwner, Step: TakeInStep, Words: words, Since: w.Since} - } - } + var said []string + for _, h := range a.Held { + said = append(said, fmt.Sprintf("the indexer holds the take-in of source revision %d of %s since %s: %s", + h.Source, h.Branch, h.Since.UTC().Format(time.RFC3339), h.Why)) } - return held, slices.Sorted(maps.Keys(held)) + out.Pending = strings.Join(said, "; ") } // waitsHeld are the waits the parts hold, by module, from the view's own state waits (written from their wait-held and wait-ended, diff --git a/modules/mesh-delivery-view/internal/view/view.go b/modules/mesh-delivery-view/internal/view/view.go index f48b30dd..21a96290 100644 --- a/modules/mesh-delivery-view/internal/view/view.go +++ b/modules/mesh-delivery-view/internal/view/view.go @@ -102,15 +102,14 @@ type Snapshot struct { // The states of a want against the have of its node. const ( - WantApplied = "applied" // the node runs the want's fingerprint, running and healthy - WantPending = "pending" // the node has not yet run the want's fingerprint, or not healthy yet - WantFailed = "failed" // the node runs the want's fingerprint and its health check failed - WantHeldBack = "held back" // the assigner holds the node back from the newest fingerprint (Rule), or set it back - WantRemoved = "removed" // the node's want is removed: the module is no longer assigned to it + WantApplied = "applied" // the node runs the want's fingerprint, running and healthy + WantPending = "pending" // the node has not yet run the want's fingerprint, or not healthy yet + WantFailed = "failed" // the node runs the want's fingerprint and its health check failed + WantRemoved = "removed" // the node's want is removed: the module is no longer assigned to it ) // WantRow is a want of the assigner beside the have of its node: the fingerprint wanted, the one the node runs with its phase and -// health, the state of the two, and for a want held back the newest fingerprint, the rule and the assigner's words. +// health, the state of the two, and the assigner's words. type WantRow struct { Node string `json:"node"` Module string `json:"module"` @@ -119,8 +118,6 @@ type WantRow struct { Phase string `json:"phase,omitempty"` Health string `json:"health,omitempty"` State string `json:"state"` - Newest string `json:"newest,omitempty"` - Rule int `json:"rule,omitempty"` Words string `json:"words,omitempty"` // Judgement is the node agent's judgement of the move that waits for a person's yes (its have in waiting-yes, ADR 0547 // §3), and Judged its words; empty otherwise. The controller's composed copy is no longer read (ADR 0571 §6). @@ -340,7 +337,6 @@ type wantEntry struct { type sourceEntry struct { branch string // the branch's name revision uint64 - group string heads map[string]string err string } @@ -490,17 +486,16 @@ func (m *Model) unsay(ev DeliveredEvent) { } // DeliveredEvent is what the view says when the source revision is delivered (event `delivered` of the view, issue 1906 D9, ADR -// 0539 §17): the revision of the gate's source key, the group that moved it and every repository's merged head at it. A +// 0539 §17): the revision of the gate's source key and every repository's merged head at it. A // consumer takes every earlier revision as covered by it, and takes the same revision twice as once (after a restart of the view). // // The same event says a repository's reached head (ADR 0556 clause 3): Repository names it, Heads holds its head alone, Revision -// is the source revision that named that head and Group is empty; a consumer takes every earlier merge of that repository as on +// is the source revision that named that head; a consumer takes every earlier merge of that repository as on // the machines. type DeliveredEvent struct { // Branch is the watched branch whose source revision it is (design 47 G A-173). Branch string `json:"branch"` Revision uint64 `json:"revision"` - Group string `json:"group"` Heads map[string]string `json:"heads"` Repository string `json:"repository,omitempty"` // NotYet are, in the per-repository form, the merges at or before the reached head that are not yet on the machines: the @@ -532,7 +527,7 @@ func (m *Model) deliveredNow() []DeliveredEvent { continue } m.said[b] = src.revision - out = append(out, DeliveredEvent{Branch: src.branch, Revision: src.revision, Group: src.group, Heads: src.heads}) + out = append(out, DeliveredEvent{Branch: src.branch, Revision: src.revision, Heads: src.heads}) } return out } @@ -659,7 +654,7 @@ func (m *Model) apply(e Entry) { return } src, err := meshdeliveryclient.DecodeSource(e.Value) - m.sources[e.Key] = &sourceEntry{branch: name, revision: e.Revision, group: src.Group, heads: src.Heads, err: errText(err)} + m.sources[e.Key] = &sourceEntry{branch: name, revision: e.Revision, heads: src.Heads, err: errText(err)} if err == nil && e.Revision != 0 { // the history the reach reads: each revision heard since the start (A-225) if m.srcHist[e.Key] == nil { m.srcHist[e.Key] = map[uint64]map[string]string{} @@ -1090,7 +1085,7 @@ func (m *Model) wantRows() []WantRow { } node, module := splitKey(key) v := w.value - row := WantRow{Node: node, Module: module, Want: v.Fp, Newest: v.Newest, Rule: int(v.Rule), Words: v.Words} + row := WantRow{Node: node, Module: module, Want: v.Fp, Words: v.Words} h, has := m.haves[key] if has && h.err == "" { row.Have, row.Phase, row.Health = h.have.Fp, string(h.have.Phase), string(h.have.Health) @@ -1101,8 +1096,6 @@ func (m *Model) wantRows() []WantRow { switch { case v.Removed: row.State = WantRemoved - case v.Rule != 0 || v.Newest != "": - row.State = WantHeldBack case row.Have == v.Fp && h.have.Health == nodeengineclient.HealthFailed: row.State = WantFailed case row.Have == v.Fp && h.have.Phase == nodeengineclient.PhaseRunning && h.have.Health == nodeengineclient.HealthOK: @@ -1237,7 +1230,6 @@ type MotionBody struct { Module string `json:"module"` FromFP string `json:"from_fp"` ToFP string `json:"to_fp"` - Composed string `json:"composed"` Since time.Time `json:"since"` BoundSeconds int `json:"bound_seconds"` // At is when the have or the want last changed, the time the event is about. @@ -1247,7 +1239,7 @@ type MotionBody struct { } // MotionEvent is an event to say: its type (moving, settled or stuck), its id (the bus's dedup id and the event id header, one for -// a type, a node, a module and a composition) and its body. +// a type, a node, a module and the fingerprint wanted, design 47 H-A-78) and its body. type MotionEvent struct { Type string ID string @@ -1342,7 +1334,7 @@ func (m *Model) motionOf(hk string) []MotionEvent { node, module := splitKey(hk) h, has := m.haves[hk] has = has && h.err == "" - body := MotionBody{Node: node, Module: module, ToFP: w.value.Fp, Composed: w.value.Composed, Since: w.at, BoundSeconds: MotionBoundSeconds} + body := MotionBody{Node: node, Module: module, ToFP: w.value.Fp, Since: w.at, BoundSeconds: MotionBoundSeconds} body.At = w.at if has { body.FromFP = h.have.Fp @@ -1351,7 +1343,7 @@ func (m *Model) motionOf(hk string) []MotionEvent { } } id := func(kind string) string { - return kind + "." + node + "." + module + "." + strings.TrimPrefix(w.value.Composed, "sha256:") + return kind + "." + node + "." + module + "." + w.value.Fp } var out []MotionEvent say := func(kind string, b MotionBody) { diff --git a/modules/mesh-delivery-view/internal/view/view_test.go b/modules/mesh-delivery-view/internal/view/view_test.go index ce10ae92..f4e712e0 100644 --- a/modules/mesh-delivery-view/internal/view/view_test.go +++ b/modules/mesh-delivery-view/internal/view/view_test.go @@ -281,7 +281,7 @@ func statusDerivesEachPartFromItsBucket(t *testing.T) { fp1, fp2, fp3 := meshcatalogclient.SourcePrefix2+strings.Repeat("1", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("2", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("3", 64) enc := func(v any) string { b, _ := json.Marshal(v); return string(b) } want := func(fp string) string { - b, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp, Composed: composedC}) + b, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp}) return string(b) } have := func(fp string, phase string, health string, detail string) string { diff --git a/modules/mesh-delivery-view/internal/view/wants_test.go b/modules/mesh-delivery-view/internal/view/wants_test.go index f0804d9f..a6e3472c 100644 --- a/modules/mesh-delivery-view/internal/view/wants_test.go +++ b/modules/mesh-delivery-view/internal/view/wants_test.go @@ -28,9 +28,6 @@ func wantE(t *testing.T, node, module string, w meshwantsclient.Want) Entry { if err != nil { t.Fatal(err) } - if !w.Removed { - w.Composed = "sha256:" + strings.Repeat("c", 64) - } v, err := meshwantsclient.EncodeWant(w) if err != nil { t.Fatal(err) @@ -68,7 +65,7 @@ func sourceE(t *testing.T, revision uint64) Entry { return sourceOn(t, testBranc // sourceOn is one watched branch's source as the gate's verb source answers it (A-173). func sourceOn(t *testing.T, branch string, revision uint64) Entry { t.Helper() - v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Group: "g", Heads: map[string]string{"novox/web": strings.Repeat("1", 40)}}) + v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Call: "c1", Source: int64(revision), Heads: map[string]string{"novox/web": strings.Repeat("1", 40)}}) if err != nil { t.Fatal(err) } @@ -92,7 +89,7 @@ func TestEveryWantIsARowAgainstItsHave(t *testing.T) { wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "ace", "web", fpNew, nodeengineclient.HealthOK), wantE(t, "ace", "mail", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "ace", "mail", fpOld, nodeengineclient.HealthOK), wantE(t, "g14", "web", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "g14", "web", fpNew, nodeengineclient.HealthFailed), - wantE(t, "g14", "mail", meshwantsclient.Want{Fp: fpOld, Newest: fpNew, Rule: meshwantsclient.RuleCanary, Words: "the canary ace does not run it healthy yet"}), + wantE(t, "g14", "mail", meshwantsclient.Want{Fp: fpOld, Words: "awaits its hand placement"}), wantE(t, "g14", "old", meshwantsclient.Want{Removed: true}), wantE(t, "novox", "web", meshwantsclient.Want{Fp: fpNew}), ) @@ -101,14 +98,14 @@ func TestEveryWantIsARowAgainstItsHave(t *testing.T) { got[r.Node+"."+r.Module] = r } for key, state := range map[string]string{ - "ace.web": WantApplied, "ace.mail": WantPending, "g14.web": WantFailed, "g14.mail": WantHeldBack, "g14.old": WantRemoved, "novox.web": WantPending, + "ace.web": WantApplied, "ace.mail": WantPending, "g14.web": WantFailed, "g14.mail": WantPending, "g14.old": WantRemoved, "novox.web": WantPending, } { if got[key].State != state { t.Errorf("%s = %+v, want state %s", key, got[key], state) } } - if r := got["g14.mail"]; r.Rule != meshwantsclient.RuleCanary || r.Newest != fpNew || r.Words == "" { - t.Errorf("the held-back row keeps its rule and words: %+v", r) + if r := got["g14.mail"]; r.Words != "awaits its hand placement" { + t.Errorf("a row keeps the want's words: %+v", r) } if r := got["ace.mail"]; r.Want != fpNew || r.Have != fpOld { t.Errorf("a pending row shows both: %+v", r) @@ -246,8 +243,8 @@ func TestTheViewSaysOnceThatASourceRevisionIsDelivered(t *testing.T) { t.Fatalf("said = %+v though the bus refused it", said) } fill(m, wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew})) - if len(said) != 1 || said[0].Revision != 14355 || said[0].Group != "g" || said[0].Heads["novox/web"] == "" { - t.Fatalf("said = %+v, want revision 14355 once with its group and heads", said) + if len(said) != 1 || said[0].Revision != 14355 || said[0].Heads["novox/web"] == "" { + t.Fatalf("said = %+v, want revision 14355 once with its heads", said) } fill(m, haveFP(t, "ace", "web", fpNew, nodeengineclient.HealthOK), wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew})) if len(said) != 1 { @@ -331,8 +328,8 @@ func TestAModuleInMotionIsSaidMovingThenSettledOnceEach(t *testing.T) { t.Fatalf("said %q, want moving", types(*said)) } mv := (*said)[0] - if mv.Body.Node != "ace" || mv.Body.Module != "web" || mv.Body.FromFP != fpOld || mv.Body.ToFP != fpNew || mv.Body.Composed != "sha256:"+strings.Repeat("c", 64) || - mv.Body.Since.IsZero() || mv.Body.At.IsZero() || mv.Body.BoundSeconds != 1800 || mv.ID != "moving.ace.web."+strings.Repeat("c", 64) { + if mv.Body.Node != "ace" || mv.Body.Module != "web" || mv.Body.FromFP != fpOld || mv.Body.ToFP != fpNew || + mv.Body.Since.IsZero() || mv.Body.At.IsZero() || mv.Body.BoundSeconds != 1800 || mv.ID != "moving.ace.web."+fpNew { // keyed by the fingerprint wanted (design 47 H-A-78) t.Errorf("moving = %+v", mv) } fill(m, haveFP(t, "ace", "web", fpOld, nodeengineclient.HealthOK), wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew})) @@ -446,7 +443,7 @@ func TestTheWantsListANodesOwnWant(t *testing.T) { t.Fatal(err) } moduleKey, _ := meshwantsclient.WantKey("ace", "web") - moduleValue, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Composed: "sha256:" + strings.Repeat("c", 64)}) + moduleValue, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew}) state := map[string][]byte{own: value, moduleKey: moduleValue} r := Reader{WantsState: StateRead{ Keys: func() ([]string, error) { return []string{own, moduleKey}, nil }, diff --git a/modules/mesh-delivery-view/manifest_test.go b/modules/mesh-delivery-view/manifest_test.go index 9f56d84b..ecfbb978 100644 --- a/modules/mesh-delivery-view/manifest_test.go +++ b/modules/mesh-delivery-view/manifest_test.go @@ -18,7 +18,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" "git.novox.be/novox/mesh-sdk/go/keys" - "git.novox.be/novox/mesh-sdk/go/views" ) // The controller's manifest reader is mesh-controller internal/catalogue (ParseManifest), an internal package of another @@ -141,9 +140,11 @@ func load(t *testing.T) (manifest, map[string]json.RawMessage) { func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 m, top := load(t) - for _, a := range m.Build.Artifacts { - if a.Name == "tools" && a.Env[views.CallersEnv("answers")] != "mesh-delivery-teller" { - t.Errorf("the tools' env = %v, want the callers of answers mesh-delivery-teller", a.Env) + for _, a := range m.Build.Artifacts { // every account may call every verb: no tool names its callers (design 47 H §752, H-A-66) + for k := range a.Env { + if strings.Contains(k, "CALLERS") { + t.Errorf("the %s artifact's env names callers: %s", a.Name, k) + } } } // Design 47 G §717: it claims the seat mesh-delivery-view, scope mesh, serving no verb, and its first-view tool answers. @@ -172,16 +173,16 @@ func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 {Verb: "mesh-delivery-indexer.indexer_read_packages"}, {Verb: "mesh-delivery-indexer.indexer_read_predefined"}, {Verb: "mesh-delivery-indexer.indexer_read_taken"}, {Verb: "mesh-delivery-teller.teller_read_answers"}, // A-175: the teller's answers by their views family {Verb: "seat:mesh-catalog.revision", Fields: []string{"none-yet"}}, - {Verb: "seat:mesh-catalog.registrations"}, // §614: the watched branches of the registrations, then registration-changed - {Verb: "seat:mesh-catalog.entry", Fields: []string{"manifest-digest"}}, // §558: the module's value is the entry's manifest-digest (§506) - {Verb: "seat:mesh-delivery.source", Fields: []string{"branches", "group", "repositories", "revision"}}, // §507, §614, A-173: the branches before the first registrations, and each watched branch's source (§558: fields G adds) // ADR 0663: the modules are the catalog half's, read through the seat's verb revision, never the indexer's - {Verb: "seat:mesh-catalog.seat-definitions"}, // design 47 G A-82, §204: the build seats are read from the seat list - {Verb: "seat:mesh-broker.show"}, // A-274: the binding of its finding-events - {Verb: "seat:mesh-hand-acts.hand-act"}, // the join: its first view asked again by hand is a hand act (views.StatusTools) - {Verb: "seat:mesh-module-assigner.assignments"}, // A-82: the holder of each build seat - {Verb: "seat:mesh-wants.revision"}, // §512, A-242: view_tiers compares kept assignment revisions - {Verb: "seat:mesh-wants.difference"}, // §512, A-242: the tiers and each change's after are the assigner's - {Verb: "seat:node-engine.manifest-reads"}}; !reflect.DeepEqual(m.Invokes, want) { // ADR 0618 §3: node_manifest_reads asks the node-engine seat's verb of every node; 1585/T24: view_tiers asks indexer_pending, a verb edge (ADR 0614 §2) + {Verb: "seat:mesh-catalog.registrations"}, // §614: the watched branches of the registrations, then registration-changed + {Verb: "seat:mesh-catalog.entry", Fields: []string{"manifest-digest"}}, // §558: the module's value is the entry's manifest-digest (§506) + {Verb: "seat:mesh-delivery.source", Fields: []string{"branches", "call", "repositories", "revision"}}, // §507, §614, A-173: the branches before the first registrations, and each watched branch's source with its call, no group (design 47 H §737, §764) // ADR 0663: the modules are the catalog half's, read through the seat's verb revision, never the indexer's + {Verb: "seat:mesh-catalog.seat-definitions"}, // design 47 G A-82, §204: the build seats are read from the seat list + {Verb: "seat:mesh-broker.show"}, // A-274: the binding of its finding-events + {Verb: "seat:mesh-hand-acts.hand-act"}, // the join: its first view asked again by hand is a hand act (views.StatusTools) + {Verb: "seat:mesh-module-assigner.assignments"}, // A-82: the holder of each build seat + {Verb: "seat:mesh-wants.revision"}, // §512, A-242: view_tiers compares kept assignment revisions + {Verb: "seat:mesh-wants.difference"}, // §512, A-242: the tiers and each change's after are the assigner's + {Verb: "seat:node-engine.manifest-reads"}}; !reflect.DeepEqual(m.Invokes, want) { // ADR 0618 §3: node_manifest_reads asks the node-engine seat's verb of every node; 1585/T24: view_tiers asks indexer_pending, a verb edge (ADR 0614 §2) t.Errorf("invokes = %v, want %v", m.Invokes, want) } // design 47 G §387: the keeper's ask for the findings is heard, the finding stream declared (§383), and §368: version is MAJOR.MINOR. diff --git a/modules/mesh-delivery-view/module.json b/modules/mesh-delivery-view/module.json index 5161ae9f..607a9bb1 100644 --- a/modules/mesh-delivery-view/module.json +++ b/modules/mesh-delivery-view/module.json @@ -109,7 +109,7 @@ {"verb": "seat:mesh-catalog.revision", "fields": ["none-yet"]}, "seat:mesh-catalog.registrations", {"verb": "seat:mesh-catalog.entry", "fields": ["manifest-digest"]}, - {"verb": "seat:mesh-delivery.source", "fields": ["branches", "group", "repositories", "revision"]}, + {"verb": "seat:mesh-delivery.source", "fields": ["branches", "call", "repositories", "revision"]}, "seat:mesh-catalog.seat-definitions", "seat:mesh-broker.show", "seat:mesh-hand-acts.hand-act", @@ -229,10 +229,7 @@ "binary": "mesh-delivery-view-tools", "loads": [ "mesh-delivery-view-tools" - ], - "env": { - "MESH_VIEW_CALLERS_ANSWERS": "mesh-delivery-teller" - } + ] }, { "name": "files", diff --git a/modules/mesh-delivery-view/viewstate/reach.go b/modules/mesh-delivery-view/viewstate/reach.go index b2b837ca..229a50b2 100644 --- a/modules/mesh-delivery-view/viewstate/reach.go +++ b/modules/mesh-delivery-view/viewstate/reach.go @@ -67,7 +67,8 @@ type ModuleReach struct { } // Change is one fingerprint of a module, the merge commit it first appeared at (Module.Commit), and the source revision -// that named that commit as the repository's head (Module.Src, or the source's history), 0 when not known. +// that named that commit as the repository's head (the source's history; a module carries no source stamp, design 47 +// H-A-48), 0 when not known. type Change struct { Commit string `json:"commit"` FP string `json:"fp"` -- 2.54.0 From 6b43adafca51fbb57ae46271ee04ff8acd708830 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:28:04 +0100 Subject: [PATCH 030/104] G1 (in progress): the grants part reads no callers and no verdicts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every account may call every verb: the grants part reads no definition's callers (callerOf, the verb and accept callers, admits) and grants every module's account every verb of every seat (mesh.seat.*.tool.> and its caller-named form), a sent store to every module invoking a verb of its claimant's seat, and every queue's named ask to every asker. grants_callers goes; grants_why_refused answers the bus's own verdict. The indexer keeps no verdicts: their first view, events, invoke and the engine's read go, and a want names its build alone (no newest). internal/... and cmd/... tests are green; the root package's grants_test.go still reads the verdicts (rows at grants_test.go:303-307, 741, 1184, 3700-3870, 4560-4615) and does not compile. Builds: design 47 H §745, §750, §752, §764 (every seat contract: the callers lists); lead answers H-A-37, H-A-66, H-A-79, H-A-113 (hq f599b761) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- modules/mesh-grants/cmd/mesh-grants/main.go | 24 +---- modules/mesh-grants/cmd/mesh-grants/tools.go | 14 +-- .../internal/buscompose/composed.go | 8 +- .../internal/buscompose/named_asks_test.go | 63 ++++-------- .../mesh-grants/internal/buscompose/names.go | 1 - .../internal/buscompose/names_test.go | 1 - .../mesh-grants/internal/buscompose/nats.go | 44 ++------- .../internal/buscompose/seattraffic.go | 10 +- .../buscompose/testdata/composed.conf | 10 +- .../buscompose/testdata/user-lists.json | 10 +- .../mesh-grants/internal/grants/callers.go | 88 +++-------------- .../internal/grants/callers_test.go | 21 ++-- .../mesh-grants/internal/grants/firstviews.go | 97 ++----------------- modules/mesh-grants/internal/grants/follow.go | 2 +- modules/mesh-grants/internal/grants/inputs.go | 87 +++-------------- modules/mesh-grants/internal/grants/kept.go | 52 ---------- .../internal/grants/named_asks_test.go | 27 +----- .../internal/grants/namedpurge_test.go | 4 +- .../mesh-grants/internal/grants/records.go | 9 +- .../mesh-grants/internal/grants/rootfree.go | 10 +- .../internal/grants/sentobjects.go | 45 ++------- .../internal/grants/sentobjects_test.go | 17 +--- modules/mesh-grants/internal/grants/tools.go | 2 +- modules/mesh-grants/module.json | 4 - 24 files changed, 114 insertions(+), 536 deletions(-) diff --git a/modules/mesh-grants/cmd/mesh-grants/main.go b/modules/mesh-grants/cmd/mesh-grants/main.go index 7c7c68af..7ccd151a 100644 --- a/modules/mesh-grants/cmd/mesh-grants/main.go +++ b/modules/mesh-grants/cmd/mesh-grants/main.go @@ -39,7 +39,6 @@ import ( mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/announce" @@ -123,7 +122,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } bus := newBusReader(ctx, js) // The module has one durable consumer of EVENTS: one hub pulls it and hands each message to the part that hears it (the - // owners' views events, the seat mesh-catalog's verdicts and seat list events, the other seats' events the follower hears), + // owners' views events, the seat mesh-catalog's seat list events, the other seats' events the follower hears), // started once all are registered. hub := process.NewEventHub(logger.Printf) defer hub.Stop() @@ -233,19 +232,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro f.ConsumerMade(ctx, created) } }) - // The seat mesh-catalog's verdict events go to the verdicts' first view (ADR 0622 §2), which takes each at its revision. - for _, event := range []string{meshcatalog.EventManifestAccepted, meshcatalog.EventManifestRefused} { - if err := hub.Handle("mesh.seat."+meshcatalog.Seat+".event."+event, func(m jetstream.Msg) { - if err := fv.HearVerdict(ctx, strings.TrimPrefix(m.Subject(), "mesh.seat."+meshcatalog.Seat+".event."), m.Data(), logger.Printf); err != nil { - logger.Printf("views: %s is not a verdict event, dropped: %v", m.Subject(), err) - _ = m.Term() - return - } - _ = m.Ack() - }); err != nil { - return err - } - } // The other seats' events the part follows its passes by (Consumes). for _, subject := range grants.SeatEventSubjects() { if err := hub.Handle(subject, func(m jetstream.Msg) { @@ -369,13 +355,9 @@ func hearRunning(ctx context.Context, account process.Account, js jetstream.JetS // list holds, which the part makes each kept event's stream from. type seatGate struct{ *seatlist.Part } -// seatListAgainCallers may read the seat list again (ADR 0636 §7): every operator's session and the healers. A call through -// the mesh MCP server is proved only as its machine's tool runner (.node-tools, issue 627), so node-tools stands for an -// operator's session until a session is proved (issue 1966). -var seatListAgainCallers = []string{stdio.AnyPerson, "node-tools", "mesh-healers"} - +// newSeatGate's seat-list tools are open to every caller (design 47 H §752, H-A-66). func newSeatGate() *seatGate { - return &seatGate{seatlist.NewPart("grants", seatListAgainCallers)} + return &seatGate{seatlist.NewPart("grants")} } // Definitions are the seat definitions the reader holds; none before it has started. diff --git a/modules/mesh-grants/cmd/mesh-grants/tools.go b/modules/mesh-grants/cmd/mesh-grants/tools.go index 94955e71..804287c7 100644 --- a/modules/mesh-grants/cmd/mesh-grants/tools.go +++ b/modules/mesh-grants/cmd/mesh-grants/tools.go @@ -240,17 +240,17 @@ func toolsOf(p *grants.Part) []stdio.Tool { return p.AcceptHashes(stdio.CallerOf(a), users, grants.Answer(a, "why")) }}, {Name: grants.ToolFirstViews, Description: "The grants part's first views of the owners' states (novox/hq ADR 0615 §4 to §6, " + - "ADR 0622): the assigner's assignments and wants, the indexer's manifests, modules and verdicts, each with its owner, tool " + + "ADR 0622): the assigner's assignments and wants, the indexer's manifests and modules, each with its owner, tool " + "and the revision its picture holds, when it asked and when it was answered, how many asks and hand acts, and whether " + "its condition is raised, as the part's process last kept them; and the first view of the bindings, asked of the seat " + "mesh-broker's list: how many entries it listed, how many bindings it wrote and rewrote, and the bindings it found " + "unlisted (design 25 bindings-first-view). Read-only.", Run: func(map[string]any) (any, error) { return p.FirstViewsOf() }}, {Name: grants.ToolFirstViewAgain, Description: "Ask one of the grants part's first views once more now (assignments, wants, " + - "manifests, modules, verdicts or bindings, the bus module's list of every entry's binding; none for all), by a person's act with why, recorded as a hand act: the step after an " + + "manifests, modules or bindings, the bus module's list of every entry's binding; none for all), by a person's act with why, recorded as a hand act: the step after an " + "owner's state was written again from its sources (an empty answer at revision 0, condition " + "mesh-grants.first-view-empty). Asks the part's process, which alone follows them; grants_first_views shows the answer.", - Input: schema(map[string]string{"state": "assignments, wants, manifests, modules, verdicts or bindings; none for all", "why": "why, kept in the hand act"}, "why"), + Input: schema(map[string]string{"state": "assignments, wants, manifests, modules or bindings; none for all", "why": "why, kept in the hand act"}, "why"), Run: func(a map[string]any) (any, error) { return p.AskFirstViewAgain(stdio.CallerOf(a), grants.Answer(a, "state"), grants.Answer(a, "why"), recordHandAct) }}, @@ -258,14 +258,8 @@ func toolsOf(p *grants.Part) []stdio.Tool { "composed yet by this version of the part, with its step, the acting part, its version, since when, its bound (10 minutes) and " + "clock-from (the start of this version's first pass), and which have passed their bound. Read-only.", Run: func(map[string]any) (any, error) { return p.WaitsOf() }}, - {Name: grants.ToolCallers, Description: "The callers each verb and each accepted kind of the seat definitions admits (design 47 G §83): " + - "the list the definition names, or the default of the verb's class. Name a seat, or a seat and a verb, or neither for every one. Read-only.", - Input: schema(map[string]string{"seat": "a seat's name (default: every seat)", "verb": "a verb or accepted kind (default: every one)"}), - Run: func(a map[string]any) (any, error) { - return p.Callers(grants.Answer(a, "seat"), grants.Answer(a, "verb")) - }}, {Name: grants.ToolWhyRefused, Description: "Why an account's call of a seat's verb is refused (design 47 G §83): the call subject the account " + - "lacks a grant for (the bus's own answer, nats_user_can) and the definition's callers that leave it out. Read-only.", + "lacks a grant for, the bus's own answer (nats_user_can); every account may call every verb (design 47 H §752). Read-only.", Input: schema(map[string]string{"account": "the bus user, e.g. g14.node-tools", "verb": "the verb as .", "node": "the node, for a node seat"}, "account", "verb"), Run: func(a map[string]any) (any, error) { return p.WhyRefused(grants.Answer(a, "account"), grants.Answer(a, "verb"), grants.Answer(a, "node")) diff --git a/modules/mesh-grants/internal/buscompose/composed.go b/modules/mesh-grants/internal/buscompose/composed.go index 5940a69e..aeb40c9d 100644 --- a/modules/mesh-grants/internal/buscompose/composed.go +++ b/modules/mesh-grants/internal/buscompose/composed.go @@ -27,10 +27,10 @@ func ComposedReads(node string) ([]string, error) { return append(out, CandidateReads...), nil } -// CandidateReads is what a node's engine is granted of the indexer's candidates and manifest verdicts to answer -// `compose-candidate` (ADR 0593 §7, ADR 0578 §3): each bucket read whole as the builder's builds are (a key is read -// through a short consumer), never written. -var CandidateReads = append(readGrants(CandidatesBucket, ""), readGrants(VerdictsBucket, "")...) +// CandidateReads is what a node's engine is granted of the indexer's candidates to answer `compose-candidate` (ADR 0593 +// §7): the bucket read whole as the builder's builds are (a key is read through a short consumer), never written. The +// indexer keeps no verdicts (design 47 H-A-79). +var CandidateReads = readGrants(CandidatesBucket, "") // EngineComposedBuckets are the composition buckets of every node, as the node-engine's state (ADR 0593 §6): the grants // part creates each, create-only, with the history ADR 0539 clause 4 keeps (ComposedHistory), as it creates a diff --git a/modules/mesh-grants/internal/buscompose/named_asks_test.go b/modules/mesh-grants/internal/buscompose/named_asks_test.go index 1767bade..5a7ba4f0 100644 --- a/modules/mesh-grants/internal/buscompose/named_asks_test.go +++ b/modules/mesh-grants/internal/buscompose/named_asks_test.go @@ -8,12 +8,7 @@ import ( // Design 47 G §543, §544, §600: a build seat's ask names its asker and each queue has a named worker beside main's; any module may // put any ask (principle 6, the operator 2026-11-15). func TestNamedAsks(t *testing.T) { - build := Seat{Name: "node-build-go", Scope: "node", Accepts: []string{"delivery", "check", "recheck"}, PulledByKind: true, - AcceptCallers: map[string][]string{ - "delivery": {"mesh-builds"}, - "check": {"mesh-pipeline-runner", "mesh-catalog", "mesh-delivery-checker"}, - "recheck": {"mesh-delivery-checker"}, - }} + build := Seat{Name: "node-build-go", Scope: "node", Accepts: []string{"delivery", "check", "recheck"}, PulledByKind: true} asker := func(module string, held ...string) Principal { p := Principal{Kind: KindModule, Node: "one", Module: module, Uses: []Seat{build}} for _, h := range held { @@ -70,47 +65,26 @@ func TestNamedAsks(t *testing.T) { } } -// Design 47 G §610, A-179 (test 60's case of §271): a user of a seat is granted a verb's call subject only where the verb's -// effective callers name it, so a kept-artifact call is composed for the module that invokes it and for no other user of -// the build seat; `module:` and `seat:` entries name theirs, and a seat whose definition is unread grants its users no verb. -func TestAVerbIsGrantedToItsEffectiveCallersAlone(t *testing.T) { - build := Seat{Name: "node-build-go", Scope: "node", Serves: []string{"kept-artifact", "freed", "run"}, - VerbCallers: map[string][]string{ - "kept-artifact": {"invokers", "persons", "sessions"}, - "freed": {"module:a-checker"}, - "run": {"seat:mesh-pipeline-runner"}, - }} - user := func(module string, invokes []string, held ...string) Principal { - p := Principal{Kind: KindModule, Node: "one", Module: module, Uses: []Seat{build}, Invokes: invokes} - for _, h := range held { - p.Holds = append(p.Holds, Seat{Name: h}) - } - return p - } - unread := build - unread.VerbCallers = nil - const base = "mesh.seat.node-build-go.tool." - for _, c := range []struct { - who Principal - want map[string]bool - }{ - {user("an-invoker", []string{"seat:node-build-go.kept-artifact"}), map[string]bool{ - base + "kept-artifact.ace": true, base + "freed.ace": false, base + "run.ace": false}}, - {user("a-runner", nil, "mesh-pipeline-runner"), map[string]bool{ - base + "kept-artifact.ace": false, base + "freed.ace": false, base + "run.ace": true}}, - {user("a-checker", nil), map[string]bool{base + "kept-artifact.ace": false, base + "freed.ace": true}}, - {Principal{Kind: KindModule, Node: "one", Module: "a-checker", Uses: []Seat{unread}}, map[string]bool{ - base + "freed.ace": false, base + "kept-artifact.ace": false}}, - } { - perms, err := PermissionsFor(c.who) +// Design 47 H §752, H-A-113 (2): every module's account may call every verb of every seat, invoked or not, in its own name, +// so no definition's callers withhold one; another account's name it may not take. +func TestEveryModuleMayCallEveryVerb(t *testing.T) { + build := Seat{Name: "node-build-go", Scope: "node", Serves: []string{"kept-artifact", "freed", "run"}} + invoker := Principal{Kind: KindModule, Node: "one", Module: "an-invoker", Uses: []Seat{build}, Invokes: []string{"seat:node-build-go.kept-artifact"}} + stranger := Principal{Kind: KindModule, Node: "one", Module: "a-stranger"} + for _, who := range []Principal{invoker, stranger} { + perms, err := PermissionsFor(who) if err != nil { t.Fatal(err) } - for subject, want := range c.want { - if got := MayPublish(perms, subject); got != want { - t.Errorf("%s may publish %s: %v, want %v", c.who.Module, subject, got, want) + for _, subject := range []string{"mesh.seat.node-build-go.tool.freed.ace", "mesh.seat.node-build-go.tool.run", + "mesh.seat.mesh-wants.tool.upgrade", "mesh.seat.mesh-wants.call.upgrade." + CallerToken(who.Username())} { + if !MayPublish(perms, subject) { + t.Errorf("%s may not publish %s", who.Module, subject) } } + if MayPublish(perms, "mesh.seat.mesh-wants.call.upgrade.someone~else") { + t.Errorf("%s may call in another's name", who.Module) + } } } @@ -144,8 +118,7 @@ func TestTheGrantsPartAlonePurgesTheNamedAsks(t *testing.T) { // holder is granted the verb's subject without the machine (tool and call forms) beside its machine's, and a caller of the // verb may publish on it; a verb of a seat held once for the mesh gains nothing, and a stranger is granted nothing. func TestANodeSeatVerbIsAlsoGrantedWithoutTheMachine(t *testing.T) { - build := Seat{Name: "node-build-go", Scope: "node", Serves: []string{"steps"}, - VerbCallers: map[string][]string{"steps": {"invokers"}}} + build := Seat{Name: "node-build-go", Scope: "node", Serves: []string{"steps"}} holder := Principal{Kind: KindModule, Node: "shanks", Module: "mesh-build-go", Holds: []Seat{build}} caller := Principal{Kind: KindModule, Node: "shanks", Module: "an-indexer", Uses: []Seat{build}, Invokes: []string{"seat:node-build-go.steps"}} @@ -165,7 +138,7 @@ func TestANodeSeatVerbIsAlsoGrantedWithoutTheMachine(t *testing.T) { {"caller asks the node-less tool", caller, tool, false, true}, {"caller asks a machine's", caller, tool + ".shanks", false, true}, {"caller asks the node-less call in its name", caller, call + CallerToken(caller.Username()), false, true}, - {"stranger asks the node-less tool", stranger, tool, false, false}, + {"stranger asks the node-less tool: every account may call every verb (design 47 H §752)", stranger, tool, false, true}, } { perms, err := PermissionsFor(c.who) if err != nil { diff --git a/modules/mesh-grants/internal/buscompose/names.go b/modules/mesh-grants/internal/buscompose/names.go index 06eaac5e..b19e7323 100644 --- a/modules/mesh-grants/internal/buscompose/names.go +++ b/modules/mesh-grants/internal/buscompose/names.go @@ -28,7 +28,6 @@ const ( CandidatesBucket = IndexerModule + "_candidates" ModulesBucket = IndexerModule + "_modules" ManifestsBucket = IndexerModule + "_manifests" - VerdictsBucket = IndexerModule + "_verdicts" EnrolmentsState = "enrolments" EnrolmentsBucket = EnrolmentModule + "_" + EnrolmentsState diff --git a/modules/mesh-grants/internal/buscompose/names_test.go b/modules/mesh-grants/internal/buscompose/names_test.go index 285b6b18..f38f8e79 100644 --- a/modules/mesh-grants/internal/buscompose/names_test.go +++ b/modules/mesh-grants/internal/buscompose/names_test.go @@ -36,7 +36,6 @@ func namesAreTheManifests(t *testing.T) { {"invokes", AssignerModule + ".wants", AssignerWantsBucket}, {"invokes", IndexerModule + ".modules", ModulesBucket}, {"invokes", IndexerModule + ".manifests", ManifestsBucket}, - {"invokes", IndexerModule + ".verdicts", VerdictsBucket}, } { list := m.Reads if c.list == "invokes" { diff --git a/modules/mesh-grants/internal/buscompose/nats.go b/modules/mesh-grants/internal/buscompose/nats.go index a0e7ebe9..a62f8c81 100644 --- a/modules/mesh-grants/internal/buscompose/nats.go +++ b/modules/mesh-grants/internal/buscompose/nats.go @@ -28,7 +28,6 @@ import ( sdkbc "git.novox.be/novox/mesh-sdk/go/buscompose" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/membership" - "git.novox.be/novox/mesh-sdk/go/seatdef" ) // A Kind is what a principal is, which decides the shape of its authority rather than its @@ -107,15 +106,6 @@ type Seat struct { // PulledByKind says each accepted kind is a worker of its own on the seat's queue, filtered to that kind, which // every holder pulls in the order Accepts lists them: the build seats' (novox/hq ADR 0525 §2, ADR 0536 §4). PulledByKind bool - // AcceptCallers are, for a seat pulled by kind, the seats that may ask each of its queues, by queue: the `seat:` - // entries of the callers of the accepted kinds the definition puts on that queue (design 47 G §543, §600). The asker - // in a named ask's subject is the asking seat's name (A-163). Empty where the seat list is unread. - AcceptCallers map[string][]string - // VerbCallers are, by verb, the callers each verb the seat serves admits: its definition's effective list - // (seatdef.Verb.EffectiveCallers, the class defaults of design 47 G §610). A user of the seat is granted a verb's call - // subject only where that list names it (A-179), so the bus holds every other caller out. Empty where the seat list is - // unread, and then no verb of the seat is granted to its users. - VerbCallers map[string][]string // NoNamedAsks says no entry of the revision invokes a queue of a build seat (`seat:.accept.`), so its queues // have no named worker: the grants part purges their named asks and deletes those workers (design 47 G §544, A-231). NoNamedAsks bool @@ -804,6 +794,10 @@ const StreamNamesSubject = "$JS.API.STREAM.NAMES" // G on dropping fine-grained permissions decides the whole shape). A seat's events and its verbs keep their own rules. const AnySeatSubject = "mesh.seat.*.accept.>" +// anySeatVerbSubject is every verb of every seat, in each of its subjects (with a machine and without): every account may call +// every verb (design 47 H §752, H-A-113 (2)). +const anySeatVerbSubject = "mesh.seat.*.tool.>" + func permissionsFor(p Principal) (Permissions, error) { for _, part := range []struct{ what, value string }{ {"node", p.Node}, {"module", p.Module}, {"process", p.Process}, @@ -1211,12 +1205,13 @@ func permissionsFor(p Principal) (Permissions, error) { pub = append(pub, seatSubject(s, "accept", a)) } for _, t := range s.Serves { - // Only a verb whose effective callers name this module (design 47 G A-179, §610). - if callerOf(p, s, t) { - pub = append(pub, seatToolSubjects(s, t, "*")...) - } + // Every verb the seat serves: every account may call every verb (design 47 H §752, H-A-66). + pub = append(pub, seatToolSubjects(s, t, "*")...) } } + // And every verb of every seat, invoked or not: every module's account may call every verb (design 47 H §752, H-A-113 + // (2)); its caller-named form is derived below with the others. + pub = append(pub, anySeatVerbSubject) // 4a. The ends of its calls of a marked verb, on the seat's gated-ended, its own alone (design 47 G §677, A-264). gp, gs := gatedEndedGrants(p.Username(), p.MarkedVerbs, p.Invokes, p.AnswersSeat) pub, sub = append(pub, gp...), append(sub, gs...) @@ -1518,27 +1513,6 @@ func seatSubject(s Seat, kind, verb string) string { return "mesh.seat." + s.Name + "." + kind + "." + verb } -// callerOf says whether a verb's effective callers (Seat.VerbCallers) name the module principal p: `invokers` where its -// manifest invokes the verb (`seat:.`, or every tool by `*`), `module:` naming it, or `seat:` -// naming a seat it holds (design 47 G §336, §610, A-179). `operator`, `persons` and `sessions` name no module. -func callerOf(p Principal, s Seat, verb string) bool { - for _, c := range s.VerbCallers[verb] { - switch { - case c == seatdef.CallerInvokers: - if slices.Contains(p.Invokes, "*") || slices.Contains(p.Invokes, "seat:"+s.Name+"."+verb) { - return true - } - case c == seatdef.CallerModulePrefix+p.Module: - return true - } - if seat, ok := strings.CutPrefix(c, seatdef.CallerSeatPrefix); ok && - slices.ContainsFunc(p.Holds, func(h Seat) bool { return h.Name == seat }) { - return true - } - } - return false -} - // seatToolSubject is where a role's tool is asked. Mesh-wide for a mesh-scoped seat; a node-scoped // seat carries the node it is asked of, because a flat subject would reach every machine's holder // and the queue group would silently pick a winner (novox/hq ADR 0132, design 33 §4). A holder diff --git a/modules/mesh-grants/internal/buscompose/seattraffic.go b/modules/mesh-grants/internal/buscompose/seattraffic.go index 1c8c0853..a10d0265 100644 --- a/modules/mesh-grants/internal/buscompose/seattraffic.go +++ b/modules/mesh-grants/internal/buscompose/seattraffic.go @@ -222,14 +222,12 @@ func SeatTrafficOf(module string, holds, uses, watches []Seat) SeatTraffic { continue } if s.PulledByKind { - // **An ask names its asker** (§543, §600): each asker is granted `accept..` for the queues whose - // kinds it is a caller of, its name the seat it holds, and main's `accept.` is the checker's and the - // builder's alone. + // **An ask names its asker** (§543, §600): each asker is granted `accept..` for every queue, its + // name the seat it holds (every account may call every verb, design 47 H §752, H-A-66), and main's + // `accept.` is the checker's and the builder's alone. for _, q := range s.Accepts { for _, h := range holds { - if namesVerb(s.AcceptCallers[q], h.Name) { - t.Publish = append(t.Publish, seatSubject(s, "accept", q+"."+h.Name)) - } + t.Publish = append(t.Publish, seatSubject(s, "accept", q+"."+h.Name)) if namesVerb(MainAskers, h.Name) { t.Publish = append(t.Publish, seatSubject(s, "accept", q)) } diff --git a/modules/mesh-grants/internal/buscompose/testdata/composed.conf b/modules/mesh-grants/internal/buscompose/testdata/composed.conf index 167db687..213fee91 100644 --- a/modules/mesh-grants/internal/buscompose/testdata/composed.conf +++ b/modules/mesh-grants/internal/buscompose/testdata/composed.conf @@ -33,12 +33,12 @@ accounts { subscribe: { allow: ["_INBOX.enrol.one.>"] } } } { user: "node.one", password: "$2a$11$nnnnnnnnnnnnnnnnnnnnnn", permissions: { - publish: { allow: ["$JS.ACK.NODES.one.>", "$JS.API.CONSUMER.CREATE.KV_composed-one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one", "$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one", "$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.>", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.>", "$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*", "$JS.API.CONSUMER.DELETE.KV_composed-one.>", "$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_data.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_health.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.>", "$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.>", "$JS.API.CONSUMER.DELETE.KV_node-engine_have.>", "$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*", "$JS.API.CONSUMER.INFO.NODES.one", "$JS.API.DIRECT.GET.KV_composed-one.>", "$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_bounds.>", "$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one", "$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one", "$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.>", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.>", "$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*", "$JS.API.STREAM.INFO.KV_composed-one", "$JS.API.STREAM.INFO.KV_mesh-config_resolved", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants", "$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts", "$JS.API.STREAM.INFO.KV_mesh-host_acts", "$JS.API.STREAM.INFO.KV_mesh-host_bounds", "$JS.API.STREAM.INFO.KV_mesh-host_data", "$JS.API.STREAM.INFO.KV_mesh-host_findings", "$JS.API.STREAM.INFO.KV_mesh-host_health", "$JS.API.STREAM.INFO.KV_mesh-host_packages", "$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions", "$JS.API.STREAM.INFO.KV_node-engine_have", "$JS.API.STREAM.NAMES", "$JS.FC.KV_composed-one.>", "$JS.FC.KV_mesh-config_resolved.>", "$JS.FC.KV_mesh-delivery-assigner_assignments.>", "$JS.FC.KV_mesh-delivery-assigner_candidates.>", "$JS.FC.KV_mesh-delivery-assigner_wants.>", "$JS.FC.KV_mesh-delivery-builder_builds.>", "$JS.FC.KV_mesh-delivery-indexer_candidates.>", "$JS.FC.KV_mesh-delivery-indexer_manifests.>", "$JS.FC.KV_mesh-delivery-indexer_modules.>", "$JS.FC.KV_mesh-delivery-indexer_verdicts.>", "$JS.FC.KV_mesh-host_acts.>", "$JS.FC.KV_mesh-host_bounds.>", "$JS.FC.KV_mesh-host_data.>", "$JS.FC.KV_mesh-host_findings.>", "$JS.FC.KV_mesh-host_health.>", "$JS.FC.KV_mesh-host_packages.>", "$JS.FC.KV_mesh-provisioner_provisions.>", "$JS.FC.KV_node-engine_have.>", "$JS.FC.OBJ_declaration-files-one.>", "$KV.composed-one.>", "$KV.mesh-host_acts.one.>", "$KV.mesh-host_bounds.>", "$KV.mesh-host_data.one.>", "$KV.mesh-host_findings.machine.one.>", "$KV.mesh-host_health.one", "$KV.mesh-host_packages.one", "$KV.node-engine_have.one.>", "$SRV.INFO", "$SRV.INFO.>", "$SRV.PING", "$SRV.PING.*.one", "$SRV.PING.>", "mesh.control.one.>", "mesh.seat.*.accept.>", "mesh.seat.node-backup.call.backed-up.one.node~one", "mesh.seat.node-backup.call.now.one.node~one", "mesh.seat.node-backup.tool.backed-up.one", "mesh.seat.node-backup.tool.now.one", "mesh.seat.node-engine.event.*.one"] } + publish: { allow: ["$JS.ACK.NODES.one.>", "$JS.API.CONSUMER.CREATE.KV_composed-one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one", "$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one", "$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.>", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.>", "$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*", "$JS.API.CONSUMER.DELETE.KV_composed-one.>", "$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_data.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_health.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.>", "$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.>", "$JS.API.CONSUMER.DELETE.KV_node-engine_have.>", "$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*", "$JS.API.CONSUMER.INFO.NODES.one", "$JS.API.DIRECT.GET.KV_composed-one.>", "$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.>", "$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_bounds.>", "$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one", "$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one", "$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.>", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.>", "$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*", "$JS.API.STREAM.INFO.KV_composed-one", "$JS.API.STREAM.INFO.KV_mesh-config_resolved", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants", "$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules", "$JS.API.STREAM.INFO.KV_mesh-host_acts", "$JS.API.STREAM.INFO.KV_mesh-host_bounds", "$JS.API.STREAM.INFO.KV_mesh-host_data", "$JS.API.STREAM.INFO.KV_mesh-host_findings", "$JS.API.STREAM.INFO.KV_mesh-host_health", "$JS.API.STREAM.INFO.KV_mesh-host_packages", "$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions", "$JS.API.STREAM.INFO.KV_node-engine_have", "$JS.API.STREAM.NAMES", "$JS.FC.KV_composed-one.>", "$JS.FC.KV_mesh-config_resolved.>", "$JS.FC.KV_mesh-delivery-assigner_assignments.>", "$JS.FC.KV_mesh-delivery-assigner_candidates.>", "$JS.FC.KV_mesh-delivery-assigner_wants.>", "$JS.FC.KV_mesh-delivery-builder_builds.>", "$JS.FC.KV_mesh-delivery-indexer_candidates.>", "$JS.FC.KV_mesh-delivery-indexer_manifests.>", "$JS.FC.KV_mesh-delivery-indexer_modules.>", "$JS.FC.KV_mesh-host_acts.>", "$JS.FC.KV_mesh-host_bounds.>", "$JS.FC.KV_mesh-host_data.>", "$JS.FC.KV_mesh-host_findings.>", "$JS.FC.KV_mesh-host_health.>", "$JS.FC.KV_mesh-host_packages.>", "$JS.FC.KV_mesh-provisioner_provisions.>", "$JS.FC.KV_node-engine_have.>", "$JS.FC.OBJ_declaration-files-one.>", "$KV.composed-one.>", "$KV.mesh-host_acts.one.>", "$KV.mesh-host_bounds.>", "$KV.mesh-host_data.one.>", "$KV.mesh-host_findings.machine.one.>", "$KV.mesh-host_health.one", "$KV.mesh-host_packages.one", "$KV.node-engine_have.one.>", "$SRV.INFO", "$SRV.INFO.>", "$SRV.PING", "$SRV.PING.*.one", "$SRV.PING.>", "mesh.control.one.>", "mesh.seat.*.accept.>", "mesh.seat.node-backup.call.backed-up.one.node~one", "mesh.seat.node-backup.call.now.one.node~one", "mesh.seat.node-backup.tool.backed-up.one", "mesh.seat.node-backup.tool.now.one", "mesh.seat.node-engine.event.*.one"] } subscribe: { allow: ["$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments", "$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates", "$SRV.INFO", "$SRV.INFO.node-engine", "$SRV.INFO.node-engine.>", "$SRV.PING", "$SRV.PING.node-engine", "$SRV.PING.node-engine.>", "$SRV.STATS", "$SRV.STATS.node-engine", "$SRV.STATS.node-engine.>", "_DELIVER.one", "_DELIVER.one.>", "_INBOX.node.one.>", "mesh.node.one.ask.access-act", "mesh.node.one.ask.hand-over", "mesh.node.one.ask.judge-directories", "mesh.node.one.ask.move-secret", "mesh.node.one.ask.report", "mesh.node.one.ask.setuid-search", "mesh.node.one.declare", "mesh.seat.node-engine.call.*.one.*", "mesh.seat.node-engine.tool.*.one"] } allow_responses: { max: 1, ttl: "1m" } } } { user: "one.mesh-delivery-watchman", password: "$2a$11$wwwwwwwwwwwwwwwwwwwwww", permissions: { - publish: { allow: ["$JS.ACK.DEAD_LETTER_NOTICES.mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman_tools.>", "$JS.API.CONSUMER.CREATE.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.controller", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman_tools", "$JS.API.CONSUMER.MSG.NEXT.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.DIRECT.GET.PROV_APPLIED.>", "$JS.API.STREAM.INFO.DEAD_LETTERS", "$JS.API.STREAM.INFO.DEAD_LETTER_NOTICES", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.INFO.PROV_APPLIED", "$JS.API.STREAM.MSG.GET.DEAD_LETTERS", "$JS.API.STREAM.MSG.GET.PROV_APPLIED", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.bus.connz", "mesh.events.dead.>", "mesh.seat.*.accept.>"] } + publish: { allow: ["$JS.ACK.DEAD_LETTER_NOTICES.mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman_tools.>", "$JS.API.CONSUMER.CREATE.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.controller", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman_tools", "$JS.API.CONSUMER.MSG.NEXT.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.DIRECT.GET.PROV_APPLIED.>", "$JS.API.STREAM.INFO.DEAD_LETTERS", "$JS.API.STREAM.INFO.DEAD_LETTER_NOTICES", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.INFO.PROV_APPLIED", "$JS.API.STREAM.MSG.GET.DEAD_LETTERS", "$JS.API.STREAM.MSG.GET.PROV_APPLIED", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.bus.connz", "mesh.events.dead.>", "mesh.seat.*.accept.>", "mesh.seat.*.call.*.*.one~mesh-delivery-watchman", "mesh.seat.*.call.*.one~mesh-delivery-watchman", "mesh.seat.*.tool.>"], deny: ["mesh.seat.node-launcher.tool.secret", "mesh.seat.node-launcher.tool.secret.*", "mesh.seat.node-launcher.call.secret.>", "mesh.seat.mesh-broker.call.apply.>", "mesh.seat.mesh-broker.call.create.>", "mesh.seat.mesh-broker.call.drop.>", "mesh.seat.mesh-broker.call.recreate.>", "mesh.seat.mesh-broker.tool.apply", "mesh.seat.mesh-broker.tool.create", "mesh.seat.mesh-broker.tool.drop", "mesh.seat.mesh-broker.tool.recreate"] } subscribe: { allow: ["$JS.EVENT.ADVISORY.CONSUMER.DELETED.>", "$SRV.INFO", "$SRV.INFO.mesh-delivery-watchman", "$SRV.INFO.mesh-delivery-watchman.>", "$SRV.PING", "$SRV.PING.mesh-delivery-watchman", "$SRV.PING.mesh-delivery-watchman.>", "$SRV.STATS", "$SRV.STATS.mesh-delivery-watchman", "$SRV.STATS.mesh-delivery-watchman.>", "_INBOX.one.mesh-delivery-watchman.>", "mesh.bus.connect", "mesh.bus.disconnect", "mesh.control.*.tools-alive", "mesh.events.dead.>", "mesh.mod.*.event.provisioner.failing", "mesh.mod.*.event.provisioner.recovered", "mesh.mod.mesh-delivery-watchman.call.>", "mesh.mod.mesh-delivery-watchman.tool.>", "mesh.mod.nats.event.bus.connection-closed", "mesh.mod.nats.event.bus.slow-consumer", "mesh.mod.power.event.*", "mesh.seat.mesh-self-check.event.checked", "prov.applied.>"] } allow_responses: { max: 1, ttl: "1m" } } } @@ -47,17 +47,17 @@ accounts { subscribe: { allow: ["_INBOX.one.nats.>"] } } } { user: "one.telegram", password: "$2a$11$tttttttttttttttttttttt", permissions: { - publish: { allow: ["$JS.ACK.EVENTS.one_telegram.>", "$JS.ACK.EVENTS.one_telegram_tools.>", "$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools", "$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools", "$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.*.accept.>", "mesh.seat.telegram-sender.event.delivered", "mesh.seat.telegram-sender.event.failed"] } + publish: { allow: ["$JS.ACK.EVENTS.one_telegram.>", "$JS.ACK.EVENTS.one_telegram_tools.>", "$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools", "$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools", "$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.*.accept.>", "mesh.seat.*.call.*.*.one~telegram", "mesh.seat.*.call.*.one~telegram", "mesh.seat.*.tool.>", "mesh.seat.telegram-sender.event.delivered", "mesh.seat.telegram-sender.event.failed"], deny: ["mesh.seat.node-launcher.tool.secret", "mesh.seat.node-launcher.tool.secret.*", "mesh.seat.node-launcher.call.secret.>", "mesh.seat.mesh-broker.call.apply.>", "mesh.seat.mesh-broker.call.create.>", "mesh.seat.mesh-broker.call.drop.>", "mesh.seat.mesh-broker.call.recreate.>", "mesh.seat.mesh-broker.tool.apply", "mesh.seat.mesh-broker.tool.create", "mesh.seat.mesh-broker.tool.drop", "mesh.seat.mesh-broker.tool.recreate"] } subscribe: { allow: ["$SRV.INFO", "$SRV.INFO.telegram", "$SRV.INFO.telegram.>", "$SRV.PING", "$SRV.PING.telegram", "$SRV.PING.telegram.>", "$SRV.STATS", "$SRV.STATS.telegram", "$SRV.STATS.telegram.>", "_INBOX.one.telegram.>", "mesh.mod.telegram.call.>", "mesh.mod.telegram.tool.>", "mesh.seat.telegram-sender.accept.send"] } allow_responses: { max: 1, ttl: "1m" } } } { user: "two.audit", password: "$2a$11$aaaaaaaaaaaaaaaaaaaaaa", permissions: { - publish: { allow: ["$JS.ACK.EVENTS.two_audit.>", "$JS.ACK.EVENTS.two_audit_tools.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.audit", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_audit", "$JS.API.CONSUMER.INFO.EVENTS.two_audit_tools", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.audit", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.*.accept.>"] } + publish: { allow: ["$JS.ACK.EVENTS.two_audit.>", "$JS.ACK.EVENTS.two_audit_tools.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.audit", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_audit", "$JS.API.CONSUMER.INFO.EVENTS.two_audit_tools", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.audit", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.*.accept.>", "mesh.seat.*.call.*.*.two~audit", "mesh.seat.*.call.*.two~audit", "mesh.seat.*.tool.>"], deny: ["mesh.seat.node-launcher.tool.secret", "mesh.seat.node-launcher.tool.secret.*", "mesh.seat.node-launcher.call.secret.>", "mesh.seat.mesh-broker.call.apply.>", "mesh.seat.mesh-broker.call.create.>", "mesh.seat.mesh-broker.call.drop.>", "mesh.seat.mesh-broker.call.recreate.>", "mesh.seat.mesh-broker.tool.apply", "mesh.seat.mesh-broker.tool.create", "mesh.seat.mesh-broker.tool.drop", "mesh.seat.mesh-broker.tool.recreate"] } subscribe: { allow: ["$SRV.INFO", "$SRV.INFO.audit", "$SRV.INFO.audit.>", "$SRV.PING", "$SRV.PING.audit", "$SRV.PING.audit.>", "$SRV.STATS", "$SRV.STATS.audit", "$SRV.STATS.audit.>", "_INBOX.two.audit.>", "mesh.mod.audit.call.>", "mesh.mod.audit.tool.>", "mesh.mod.shop.event.order.placed"] } allow_responses: { max: 1, ttl: "1m" } } } { user: "two.shop", password: "$2a$11$ssssssssssssssssssssss", permissions: { - publish: { allow: ["$JS.ACK.EVENTS.two_shop.>", "$JS.ACK.EVENTS.two_shop_tools.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_shop", "$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.mod.shop.event.order.placed", "mesh.seat.*.accept.>", "mesh.seat.telegram-sender.accept.send"] } + publish: { allow: ["$JS.ACK.EVENTS.two_shop.>", "$JS.ACK.EVENTS.two_shop_tools.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_shop", "$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.mod.shop.event.order.placed", "mesh.seat.*.accept.>", "mesh.seat.*.call.*.*.two~shop", "mesh.seat.*.call.*.two~shop", "mesh.seat.*.tool.>", "mesh.seat.telegram-sender.accept.send"], deny: ["mesh.seat.node-launcher.tool.secret", "mesh.seat.node-launcher.tool.secret.*", "mesh.seat.node-launcher.call.secret.>", "mesh.seat.mesh-broker.call.apply.>", "mesh.seat.mesh-broker.call.create.>", "mesh.seat.mesh-broker.call.drop.>", "mesh.seat.mesh-broker.call.recreate.>", "mesh.seat.mesh-broker.tool.apply", "mesh.seat.mesh-broker.tool.create", "mesh.seat.mesh-broker.tool.drop", "mesh.seat.mesh-broker.tool.recreate"] } subscribe: { allow: ["$SRV.INFO", "$SRV.INFO.shop", "$SRV.INFO.shop.>", "$SRV.PING", "$SRV.PING.shop", "$SRV.PING.shop.>", "$SRV.STATS", "$SRV.STATS.shop", "$SRV.STATS.shop.>", "_INBOX.two.shop.>", "mesh.mod.shop.call.>", "mesh.mod.shop.tool.>"] } allow_responses: { max: 1, ttl: "1m" } } } diff --git a/modules/mesh-grants/internal/buscompose/testdata/user-lists.json b/modules/mesh-grants/internal/buscompose/testdata/user-lists.json index d3ebf49f..26a615d3 100644 --- a/modules/mesh-grants/internal/buscompose/testdata/user-lists.json +++ b/modules/mesh-grants/internal/buscompose/testdata/user-lists.json @@ -8,7 +8,7 @@ }, { "Name": "the controller's someRecords", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.EVENTS.one_telegram_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.mesh-catalog.call.catalog_tools.*.person~ada\", \"mesh.mod.mesh-catalog.call.catalog_tools.person~ada\", \"mesh.mod.mesh-catalog.tool.catalog_tools\", \"mesh.mod.mesh-catalog.tool.catalog_tools.*\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.ACK.EVENTS.two_shop_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.EVENTS.one_telegram_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.one~telegram\", \"mesh.seat.*.call.*.one~telegram\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.mesh-catalog.call.catalog_tools.*.person~ada\", \"mesh.mod.mesh-catalog.call.catalog_tools.person~ada\", \"mesh.mod.mesh-catalog.tool.catalog_tools\", \"mesh.mod.mesh-catalog.tool.catalog_tools.*\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.ACK.EVENTS.two_shop_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.two~shop\", \"mesh.seat.*.call.*.two~shop\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { @@ -46,7 +46,7 @@ }, { "Name": "seats, consumers, people and a hashless user", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_user-list.*.$KV.mesh-grants_user-list.sealed\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_user-list.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_user-list.$KV.mesh-grants_user-list.sealed\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.$O.mesh-grants-user-list.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-grants_user-list\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-grants_user-list.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-grants\", password: \"$2a$11$one.mesh-grantsone.mesfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-grants.\u003e\", \"$JS.ACK.EVENTS.one_mesh-grants_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit_tools\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants_tools\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants_tools\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.one.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-watchman\", password: \"$2a$11$one.mesh-watchmanone.mfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-watchman.\u003e\", \"$JS.ACK.EVENTS.one_mesh-watchman_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-watchman\", \"$SRV.INFO.mesh-watchman.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-watchman\", \"$SRV.PING.mesh-watchman.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-watchman\", \"$SRV.STATS.mesh-watchman.\u003e\", \"_INBOX.one.mesh-watchman.\u003e\", \"mesh.mod.mesh-watchman.call.\u003e\", \"mesh.mod.mesh-watchman.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.nats\", password: \"$2a$11$one.natsone.natsone.nafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.API.STREAM.INFO.*\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.SNAPSHOT.*\", \"$JS.SNAPSHOT.ACK.\u003e\"] }\n subscribe: { allow: [\"_INBOX.one.nats.\u003e\"] }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.EVENTS.one_telegram_tools.\u003e\", \"$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.telegram-sender.event.delivered\", \"mesh.seat.telegram-sender.event.failed\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\", \"mesh.seat.telegram-sender.accept.send\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.*.call.*.*.person~ada\", \"mesh.mod.*.call.*.person~ada\", \"mesh.mod.*.tool.\u003e\", \"mesh.seat.*.call.*.*.person~ada\", \"mesh.seat.*.call.*.person~ada\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.mod.*.tool.node-launcher.secret\", \"mesh.mod.*.tool.node-launcher.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.mod.*.call.node-launcher.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"person.bob\", password: \"$2a$11$person.bobperson.bobpefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.shop.call.status.*.person~bob\", \"mesh.mod.shop.call.status.person~bob\", \"mesh.mod.shop.tool.status\", \"mesh.mod.shop.tool.status.*\"] }\n subscribe: { allow: [\"_INBOX.person.bob.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.ACK.EVENTS.two_shop_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.telegram-sender.accept.send\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_user-list.*.$KV.mesh-grants_user-list.sealed\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_user-list.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_user-list.$KV.mesh-grants_user-list.sealed\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.$O.mesh-grants-user-list.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-grants_user-list\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-grants_user-list.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-grants\", password: \"$2a$11$one.mesh-grantsone.mesfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-grants.\u003e\", \"$JS.ACK.EVENTS.one_mesh-grants_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit_tools\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants_tools\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants_tools\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.one~mesh-grants\", \"mesh.seat.*.call.*.one~mesh-grants\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.one.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-watchman\", password: \"$2a$11$one.mesh-watchmanone.mfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-watchman.\u003e\", \"$JS.ACK.EVENTS.one_mesh-watchman_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.one~mesh-watchman\", \"mesh.seat.*.call.*.one~mesh-watchman\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-watchman\", \"$SRV.INFO.mesh-watchman.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-watchman\", \"$SRV.PING.mesh-watchman.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-watchman\", \"$SRV.STATS.mesh-watchman.\u003e\", \"_INBOX.one.mesh-watchman.\u003e\", \"mesh.mod.mesh-watchman.call.\u003e\", \"mesh.mod.mesh-watchman.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.nats\", password: \"$2a$11$one.natsone.natsone.nafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.API.STREAM.INFO.*\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.SNAPSHOT.*\", \"$JS.SNAPSHOT.ACK.\u003e\"] }\n subscribe: { allow: [\"_INBOX.one.nats.\u003e\"] }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.EVENTS.one_telegram_tools.\u003e\", \"$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.one~telegram\", \"mesh.seat.*.call.*.one~telegram\", \"mesh.seat.*.tool.\u003e\", \"mesh.seat.telegram-sender.event.delivered\", \"mesh.seat.telegram-sender.event.failed\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\", \"mesh.seat.telegram-sender.accept.send\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.*.call.*.*.person~ada\", \"mesh.mod.*.call.*.person~ada\", \"mesh.mod.*.tool.\u003e\", \"mesh.seat.*.call.*.*.person~ada\", \"mesh.seat.*.call.*.person~ada\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.mod.*.tool.node-launcher.secret\", \"mesh.mod.*.tool.node-launcher.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.mod.*.call.node-launcher.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"person.bob\", password: \"$2a$11$person.bobperson.bobpefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.shop.call.status.*.person~bob\", \"mesh.mod.shop.call.status.person~bob\", \"mesh.mod.shop.tool.status\", \"mesh.mod.shop.tool.status.*\"] }\n subscribe: { allow: [\"_INBOX.person.bob.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.ACK.EVENTS.two_shop_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.two~shop\", \"mesh.seat.*.call.*.two~shop\", \"mesh.seat.*.tool.\u003e\", \"mesh.seat.telegram-sender.accept.send\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": [ "two.audit" ], @@ -152,7 +152,7 @@ }, { "Name": "state, logs, streams, queues and processes", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.plex\", password: \"$2a$11$ace.plexace.plexace.plfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_plex.\u003e\", \"$JS.ACK.EVENTS.ace_plex_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.plex\", \"$SRV.INFO.plex.\u003e\", \"$SRV.PING\", \"$SRV.PING.plex\", \"$SRV.PING.plex.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.plex\", \"$SRV.STATS.plex.\u003e\", \"_INBOX.ace.plex.\u003e\", \"mesh.mod.plex.call.\u003e\", \"mesh.mod.plex.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.mod.plex.call.plex_status.ace.node~ace\", \"mesh.mod.plex.tool.plex_status.ace\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-builder.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-builder_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder_tools\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$KV.mesh-delivery-builder_presence.novox\", \"$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.log.mesh-delivery-builder.builds.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.seat.*.accept.\u003e\", \"mesh.stream.mesh-delivery-builder.event.ask\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-builder\", \"$SRV.INFO.mesh-delivery-builder.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-builder\", \"$SRV.PING.mesh-delivery-builder.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-builder\", \"$SRV.STATS.mesh-delivery-builder.\u003e\", \"_INBOX.novox.mesh-delivery-builder.\u003e\", \"mesh.mod.mesh-delivery-builder.call.\u003e\", \"mesh.mod.mesh-delivery-builder.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder.worker\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.asks.novox_mesh-delivery-builder_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"_INBOX.novox.mesh-delivery-builder.worker.\u003e\"] }\n } }\n { user: \"novox.mesh-delivery-view\", password: \"$2a$11$novox.mesh-delivery-vifixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-view.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-view_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view_tools\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_RECHECK_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view_tools\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-view\", \"$SRV.INFO.mesh-delivery-view.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-view\", \"$SRV.PING.mesh-delivery-view.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-view\", \"$SRV.STATS.mesh-delivery-view.\u003e\", \"_INBOX.novox.mesh-delivery-view.\u003e\", \"mesh.mod.mesh-delivery-view.call.\u003e\", \"mesh.mod.mesh-delivery-view.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-grants\", password: \"$2a$11$novox.mesh-grantsnovoxfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-grants.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-grants_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.CREATE.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants_tools\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants_tools\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_assertions.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.CREATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.CREATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.CREATE.asks\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_assertions\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.asks\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.UPDATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.UPDATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.UPDATE.asks\", \"$JS.FC.KV_mesh-grants_assertions.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.mesh-grants_assertions.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.mod.mesh-grants.event.states\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-grants_assertions\", \"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.novox.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.plex\", password: \"$2a$11$ace.plexace.plexace.plfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_plex.\u003e\", \"$JS.ACK.EVENTS.ace_plex_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.ace~plex\", \"mesh.seat.*.call.*.ace~plex\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.plex\", \"$SRV.INFO.plex.\u003e\", \"$SRV.PING\", \"$SRV.PING.plex\", \"$SRV.PING.plex.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.plex\", \"$SRV.STATS.plex.\u003e\", \"_INBOX.ace.plex.\u003e\", \"mesh.mod.plex.call.\u003e\", \"mesh.mod.plex.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.mod.plex.call.plex_status.ace.node~ace\", \"mesh.mod.plex.tool.plex_status.ace\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-builder.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-builder_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder_tools\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$KV.mesh-delivery-builder_presence.novox\", \"$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.log.mesh-delivery-builder.builds.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.novox~mesh-delivery-builder\", \"mesh.seat.*.call.*.novox~mesh-delivery-builder\", \"mesh.seat.*.tool.\u003e\", \"mesh.stream.mesh-delivery-builder.event.ask\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-builder\", \"$SRV.INFO.mesh-delivery-builder.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-builder\", \"$SRV.PING.mesh-delivery-builder.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-builder\", \"$SRV.STATS.mesh-delivery-builder.\u003e\", \"_INBOX.novox.mesh-delivery-builder.\u003e\", \"mesh.mod.mesh-delivery-builder.call.\u003e\", \"mesh.mod.mesh-delivery-builder.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder.worker\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.asks.novox_mesh-delivery-builder_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"_INBOX.novox.mesh-delivery-builder.worker.\u003e\"] }\n } }\n { user: \"novox.mesh-delivery-view\", password: \"$2a$11$novox.mesh-delivery-vifixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-view.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-view_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view_tools\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_RECHECK_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view_tools\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.novox~mesh-delivery-view\", \"mesh.seat.*.call.*.novox~mesh-delivery-view\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-view\", \"$SRV.INFO.mesh-delivery-view.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-view\", \"$SRV.PING.mesh-delivery-view.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-view\", \"$SRV.STATS.mesh-delivery-view.\u003e\", \"_INBOX.novox.mesh-delivery-view.\u003e\", \"mesh.mod.mesh-delivery-view.call.\u003e\", \"mesh.mod.mesh-delivery-view.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-grants\", password: \"$2a$11$novox.mesh-grantsnovoxfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-grants.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-grants_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.CREATE.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants_tools\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants_tools\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_assertions.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.CREATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.CREATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.CREATE.asks\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_assertions\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.asks\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.UPDATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.UPDATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.UPDATE.asks\", \"$JS.FC.KV_mesh-grants_assertions.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.mesh-grants_assertions.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.mod.mesh-grants.event.states\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.novox~mesh-grants\", \"mesh.seat.*.call.*.novox~mesh-grants\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-grants_assertions\", \"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.novox.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { @@ -288,7 +288,7 @@ }, { "Name": "a node-engine that consumes", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.web\", password: \"$2a$11$ace.webace.webace.webafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_web.\u003e\", \"$JS.ACK.EVENTS.ace_web_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.web\", \"$SRV.INFO.web.\u003e\", \"$SRV.PING\", \"$SRV.PING.web\", \"$SRV.PING.web.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.web\", \"$SRV.STATS.web.\u003e\", \"_INBOX.ace.web.\u003e\", \"mesh.mod.web.call.\u003e\", \"mesh.mod.web.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.mod.mesh-catalog.event.seat-definition-changed\", \"mesh.mod.mesh-catalog.event.seat-definition-removed\", \"mesh.mod.mesh-delivery-view.event.settled\", \"mesh.mod.restic.event.backed-up\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.web\", password: \"$2a$11$ace.webace.webace.webafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_web.\u003e\", \"$JS.ACK.EVENTS.ace_web_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.ace~web\", \"mesh.seat.*.call.*.ace~web\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.web\", \"$SRV.INFO.web.\u003e\", \"$SRV.PING\", \"$SRV.PING.web\", \"$SRV.PING.web.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.web\", \"$SRV.STATS.web.\u003e\", \"_INBOX.ace.web.\u003e\", \"mesh.mod.web.call.\u003e\", \"mesh.mod.web.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.mod.mesh-catalog.event.seat-definition-changed\", \"mesh.mod.mesh-catalog.event.seat-definition-removed\", \"mesh.mod.mesh-delivery-view.event.settled\", \"mesh.mod.restic.event.backed-up\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { @@ -311,7 +311,7 @@ }, { "Name": "a node seat's events, by machine and flat", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.pause\", password: \"$2a$11$ace.pauseace.pauseace.fixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_pause.\u003e\", \"$JS.ACK.EVENTS.ace_pause_tools.\u003e\", \"$JS.ACK.SEAT_NODE_POWER.SEAT_NODE_POWER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause_tools\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause_tools\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-power.event.paused.ace\", \"mesh.seat.node-power.event.slept\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.pause\", \"$SRV.INFO.pause.\u003e\", \"$SRV.PING\", \"$SRV.PING.pause\", \"$SRV.PING.pause.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.pause\", \"$SRV.STATS.pause.\u003e\", \"_INBOX.ace.pause.\u003e\", \"mesh.mod.pause.call.\u003e\", \"mesh.mod.pause.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-assigner\", password: \"$2a$11$novox.mesh-delivery-asfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-assigner.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-assigner_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-assigner\", \"$SRV.INFO.mesh-delivery-assigner.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-assigner\", \"$SRV.PING.mesh-delivery-assigner.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-assigner\", \"$SRV.STATS.mesh-delivery-assigner.\u003e\", \"_INBOX.novox.mesh-delivery-assigner.\u003e\", \"mesh.mod.mesh-delivery-assigner.call.\u003e\", \"mesh.mod.mesh-delivery-assigner.tool.\u003e\", \"mesh.seat.node-engine.event.manifest-reads-changed.*\", \"mesh.seat.node-power.event.slept\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.pause\", password: \"$2a$11$ace.pauseace.pauseace.fixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_pause.\u003e\", \"$JS.ACK.EVENTS.ace_pause_tools.\u003e\", \"$JS.ACK.SEAT_NODE_POWER.SEAT_NODE_POWER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause_tools\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause_tools\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.ace~pause\", \"mesh.seat.*.call.*.ace~pause\", \"mesh.seat.*.tool.\u003e\", \"mesh.seat.node-power.event.paused.ace\", \"mesh.seat.node-power.event.slept\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.pause\", \"$SRV.INFO.pause.\u003e\", \"$SRV.PING\", \"$SRV.PING.pause\", \"$SRV.PING.pause.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.pause\", \"$SRV.STATS.pause.\u003e\", \"_INBOX.ace.pause.\u003e\", \"mesh.mod.pause.call.\u003e\", \"mesh.mod.pause.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-assigner\", password: \"$2a$11$novox.mesh-delivery-asfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-assigner.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-assigner_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.*.call.*.*.novox~mesh-delivery-assigner\", \"mesh.seat.*.call.*.novox~mesh-delivery-assigner\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-assigner\", \"$SRV.INFO.mesh-delivery-assigner.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-assigner\", \"$SRV.PING.mesh-delivery-assigner.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-assigner\", \"$SRV.STATS.mesh-delivery-assigner.\u003e\", \"_INBOX.novox.mesh-delivery-assigner.\u003e\", \"mesh.mod.mesh-delivery-assigner.call.\u003e\", \"mesh.mod.mesh-delivery-assigner.tool.\u003e\", \"mesh.seat.node-engine.event.manifest-reads-changed.*\", \"mesh.seat.node-power.event.slept\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { diff --git a/modules/mesh-grants/internal/grants/callers.go b/modules/mesh-grants/internal/grants/callers.go index 677f053b..06f3c805 100644 --- a/modules/mesh-grants/internal/grants/callers.go +++ b/modules/mesh-grants/internal/grants/callers.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "slices" - "sort" "strings" "git.novox.be/novox/mesh-sdk/go/seatdef" @@ -13,31 +12,15 @@ import ( "mesh-grants/internal/buscompose" ) -// The tools that say who may call and why a call is refused (design 47 G §83, GR2). -const ( - ToolCallers = "grants_callers" - ToolWhyRefused = "grants_why_refused" -) - -// CallerLine is one verb's, or one accepted kind's, callers as a seat definition gives them. -type CallerLine struct { - Seat string `json:"seat"` - // Verb is the verb's name, or the accepted kind's. - Verb string `json:"verb"` - // Kind is `verb` or `accepts`. - Kind string `json:"kind"` - Class string `json:"class,omitempty"` - // Callers are the entries the verb admits: the list the definition names, or its class's default. - Callers []string `json:"callers"` - // Named says the definition names the list; false is the class's default (§391). - Named bool `json:"named"` -} +// The tool that says why a call is refused at the bus (design 47 G §83): every account may call every verb, so no +// definition names callers and the bus's own verdict is the answer (design 47 H §752, H-A-113). +const ToolWhyRefused = "grants_why_refused" // definitions are the seat definitions the part composes from, or why it has none. func (p *Part) definitions() (map[string]seatdef.Definition, error) { d, ok := p.SeatList.(SeatDefinitions) if !ok { - return nil, errors.New("the seat list is not read here: the definitions' callers are unknown") + return nil, errors.New("the seat list is not read here: the seats' verbs are unknown") } defs := d.Definitions() if len(defs) == 0 { @@ -46,53 +29,8 @@ func (p *Part) definitions() (map[string]seatdef.Definition, error) { return defs, nil } -// CallerLines are the callers each verb and each accepted kind admits, from the definitions, of the seat named (every seat -// when empty) and the verb named (every verb when empty). -func CallerLines(defs map[string]seatdef.Definition, seat, verb string) []CallerLine { - var out []CallerLine - for _, d := range defs { - if seat != "" && d.Seat != seat { - continue - } - for _, v := range d.Verbs { - if verb == "" || v.Name == verb { - out = append(out, CallerLine{Seat: d.Seat, Verb: v.Name, Kind: "verb", Class: v.Class, - Callers: v.EffectiveCallers(), Named: v.Callers != nil && !v.Callers.IsText()}) - } - } - for _, a := range d.Accepts { - if verb == "" || a.Name == verb { - l := CallerLine{Seat: d.Seat, Verb: a.Name, Kind: "accepts"} - if a.Callers != nil && !a.Callers.IsText() { - l.Callers, l.Named = a.Callers.List, true - } - out = append(out, l) - } - } - } - sort.Slice(out, func(i, j int) bool { - a, b := out[i], out[j] - return a.Seat+"\x00"+a.Kind+"\x00"+a.Verb < b.Seat+"\x00"+b.Kind+"\x00"+b.Verb - }) - return out -} - -// Callers answers the tool grants_callers. -func (p *Part) Callers(seat, verb string) (any, error) { - defs, err := p.definitions() - if err != nil { - return nil, err - } - lines := CallerLines(defs, seat, verb) - if len(lines) == 0 { - return nil, fmt.Errorf("no seat definition names a verb or an accepted kind matching seat %q verb %q", seat, verb) - } - return map[string]any{"callers": lines, "count": len(lines)}, nil -} - -// WhyRefused answers the tool grants_why_refused: the grant an account lacks to call address (`.`), and the -// definition's line that leaves it out. The bus answers whether the account may publish the verb's call subject -// (nats.nats_user_can, the account's grants as the server holds them); the definition's callers say who was meant to. +// WhyRefused answers the tool grants_why_refused: whether the bus grants an account the call subject of address +// (`.`), the bus's own answer (nats.nats_user_can, the account's grants as the server holds them). func (p *Part) WhyRefused(account, address, node string) (any, error) { seat, verb, ok := strings.Cut(address, ".") if account == "" || !ok || seat == "" || verb == "" { @@ -102,17 +40,16 @@ func (p *Part) WhyRefused(account, address, node string) (any, error) { if err != nil { return nil, err } - lines := CallerLines(defs, seat, verb) - if len(lines) == 0 { + def, defined := defs[seat] + if !defined || !slices.ContainsFunc(def.Verbs, func(v seatdef.Verb) bool { return v.Name == verb }) { return nil, fmt.Errorf("no seat definition names the verb %s", address) } - def := defs[seat] s := buscompose.Seat{Name: seat, Scope: def.Scope} subject := buscompose.CalledSubject(buscompose.SeatToolSubject(s, verb, node), account) if subject == "" { return nil, fmt.Errorf("%s is not the name of a bus user", account) } - out := map[string]any{"account": account, "verb": address, "subject": subject, "definition": lines} + out := map[string]any{"account": account, "verb": address, "subject": subject} raw, err := p.Call.Call(CallUserCan, map[string]any{"user": account, "action": "publish", "subject": subject}) if err != nil { out["bus"] = "not read: " + err.Error() @@ -125,15 +62,12 @@ func (p *Part) WhyRefused(account, address, node string) (any, error) { out["bus"] = json.RawMessage(raw) switch { case can.Allowed == nil: - out["says"] = "the bus's answer names no verdict; read it beside the definition's line" + out["says"] = "the bus's answer names no verdict" case *can.Allowed: out["says"] = "not refused at the bus: the account holds the grant to publish " + subject default: - callers := lines[0].Callers - out["says"] = fmt.Sprintf("the account lacks the grant to publish %s; the definition admits %s (%s), and the grants part grants a call only to a caller one of those entries names", - subject, strings.Join(callers, ", "), map[bool]string{true: "named by the definition", false: "the class's default"}[lines[0].Named]) + out["says"] = "the account lacks the grant to publish " + subject out["lacks"] = subject - out["admitted_by"] = slices.Clone(callers) } return out, nil } diff --git a/modules/mesh-grants/internal/grants/callers_test.go b/modules/mesh-grants/internal/grants/callers_test.go index c6977e93..402999d8 100644 --- a/modules/mesh-grants/internal/grants/callers_test.go +++ b/modules/mesh-grants/internal/grants/callers_test.go @@ -2,6 +2,7 @@ package grants import ( "encoding/json" + "slices" "strings" "testing" @@ -23,20 +24,13 @@ func (c *canCall) Call(key string, body any) (json.RawMessage, error) { return json.Marshal(map[string]any{"allowed": c.allowed}) } -// grants_callers and grants_why_refused read the definitions' callers (design 47 G §83): every verb takes its class's -// default (§610: no verb names its callers; an act's are the operator, sessions and invokers, a read's invokers, persons -// and sessions), and a refused account is told the call subject it lacks and the callers the definition admits. -func TestCallersAndWhyRefused(t *testing.T) { +// grants_why_refused answers the bus's own verdict on an account's call subject, naming no callers (design 47 H §752, +// H-A-113): a refused account is told the subject it lacks; grants_callers is gone. +func TestWhyRefusedIsTheBussVerdict(t *testing.T) { defs := map[string]seatdef.Definition{"mesh-wants": {Seat: "mesh-wants", Scope: "mesh", Verbs: []seatdef.Verb{ {Name: "upgrade", Class: seatdef.ClassAct}, {Name: "entry", Class: seatdef.ClassRead}, }}} - lines := CallerLines(defs, "mesh-wants", "") - if len(lines) != 2 || lines[0].Verb != "entry" || lines[0].Named || lines[1].Named || - strings.Join(lines[0].Callers, ",") != "invokers,persons,sessions" || - strings.Join(lines[1].Callers, ",") != "operator,sessions,invokers" { - t.Fatalf("lines: %+v", lines) - } can := &canCall{} p := &Part{SeatList: defsGate{defs}, Call: can} got, err := p.WhyRefused("one.shop", "mesh-wants.upgrade", "") @@ -44,8 +38,8 @@ func TestCallersAndWhyRefused(t *testing.T) { t.Fatal(err) } out := got.(map[string]any) - if out["lacks"] != "mesh.seat.mesh-wants.call.upgrade.one~shop" || can.asked["subject"] != out["lacks"] || - !strings.Contains(out["says"].(string), "operator, sessions, invokers") { + if out["lacks"] != "mesh.seat.mesh-wants.call.upgrade.one~shop" || can.asked["subject"] != out["lacks"] || out["definition"] != nil || + out["admitted_by"] != nil || strings.Contains(out["says"].(string), "definition") { t.Errorf("a refused caller: %+v", out) } can.allowed = true @@ -56,4 +50,7 @@ func TestCallersAndWhyRefused(t *testing.T) { if _, err := p.WhyRefused("one.shop", "mesh-wants.nothing", ""); err == nil { t.Error("a verb no definition names was explained") } + if slices.Contains(Tools, "grants_callers") { + t.Error("the tool grants_callers is still listed") + } } diff --git a/modules/mesh-grants/internal/grants/firstviews.go b/modules/mesh-grants/internal/grants/firstviews.go index 7ba2fce0..b42c2702 100644 --- a/modules/mesh-grants/internal/grants/firstviews.go +++ b/modules/mesh-grants/internal/grants/firstviews.go @@ -14,18 +14,14 @@ import ( occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/views" ) // **The grants part's first views** (novox/hq ADR 0615 §1, §4 to §6, ADR 0621, ADR 0622; design 25 § 12.2; DLV-F4r, -// DLV-R1). The part reads the assigner's assignments and wants and the indexer's manifests, modules and verdicts no longer +// DLV-R1). The part reads the assigner's assignments and wants and the indexer's manifests and modules no longer // from their buckets, but by each owner's first-view tool, asked once at its start, then from the owner's views family // alone (each event one changed key with its revision), asking once more only on a gap in revisions, never on a timer. -// The verdicts alone are followed on the seat mesh-catalog's manifest-accepted and manifest-refused, which carry the revision -// (ADR 0622 §2), not on its views family (HearVerdict). +// The indexer keeps no verdicts (design 47 H §745, H-A-79): a manifest is validated by its pipeline's step. // Started while an owner is down it keeps asking and never reads the owner's state; past the bound (two minutes) it // raises FirstViewUnanswered naming the owner and the tool, cleared by the answer. // @@ -48,14 +44,13 @@ const ( IndexerModule = "mesh-delivery-indexer" ) -// FirstViews are the five (ADR 0615 §3 as ADR 0622 §1 amends it: the grants part's assignments, wants, manifests, -// modules and verdicts). +// FirstViews are the four (ADR 0615 §3 as ADR 0622 §1 amends it: the grants part's assignments, wants, manifests and +// modules; the verdicts go with the indexer's state, design 47 H-A-79). var FirstViews = []FirstView{ {Owner: AssignerModule, Tool: AssignerModule + ".assignments", State: "assignments", Read: ReadAssignments}, {Owner: AssignerModule, Tool: AssignerModule + ".wants", State: "wants", Read: ReadWants}, {Owner: IndexerModule, Tool: IndexerModule + ".manifests", State: "manifests", Read: ReadManifests}, {Owner: IndexerModule, Tool: IndexerModule + ".modules", State: "modules", Read: ReadModules}, - {Owner: IndexerModule, Tool: IndexerModule + ".verdicts", State: "verdicts", Read: ReadVerdicts}, } // The conditions of the first views, each naming the owner and its state. @@ -261,91 +256,11 @@ func (v *Views) Again(ctx context.Context, state, why string) ([]string, error) asked = append(asked, fv.Tool) } if len(asked) == 0 { - return nil, fmt.Errorf("%q is no first view of the grants part: one of assignments, wants, manifests, modules, verdicts, bindings, or none for all", state) + return nil, fmt.Errorf("%q is no first view of the grants part: one of assignments, wants, manifests, modules, bindings, or none for all", state) } return asked, nil } -// VerdictEvents are the seat mesh-catalog's two events the part follows the verdicts on after their first view (ADR 0622 §2), as its -// manifest's consumes name them. -var VerdictEvents = []string{meshcatalog.Seat + "." + meshcatalog.EventManifestAccepted, meshcatalog.Seat + "." + meshcatalog.EventManifestRefused} - -// HearVerdict takes one of the seat mesh-catalog's manifest-accepted or manifest-refused (event, its name) into the verdicts' first -// view, as one change of the verdicts state at the revision it carries (ADR 0622 §2): the manifest's digest its key, the -// verdict it says its value. A revision past the one after the picture's is a gap, and so is an event carrying no -// revision (an indexer that does not say it) or one saying no manifest above the picture's revision (the empty accepted -// verdict of a module leaving the trunk): the first view is asked once more on its own goroutine, said in the log. A -// revision already in the picture is passed over. Data that does not read is answered as an error, and nothing is asked. -func (v *Views) HearVerdict(ctx context.Context, event string, data []byte, logf func(string, ...any)) error { - f := v.Followers[ReadVerdicts] - if f == nil { - return nil - } - var verdict meshcatalog.VerdictsByDigestValue - var digest string - var revision uint64 - switch event { - case meshcatalog.EventManifestAccepted: - var a meshcatalog.ManifestAcceptedEvent - if err := json.Unmarshal(data, &a); err != nil { - return fmt.Errorf("%s does not read: %w", event, err) - } - verdict = meshcatalog.VerdictsByDigestValue{V: keys.Version, Module: a.Module, State: meshcatalogclient.VerdictAccepted, Judge: a.Judge} - digest, revision = a.Digest, uint64(a.Revision) - case meshcatalog.EventManifestRefused: - var r meshcatalog.ManifestRefusedEvent - if err := json.Unmarshal(data, &r); err != nil { - return fmt.Errorf("%s does not read: %w", event, err) - } - verdict = meshcatalog.VerdictsByDigestValue{V: keys.Version, Module: r.Module, State: meshcatalogclient.VerdictRefused, Judge: r.Judge, Problems: r.Problems} - digest, revision = r.Digest, uint64(r.Revision) - default: - return fmt.Errorf("%q is not a verdict event of the indexer", event) - } - held := f.Status() - gap := func(why string) error { - logf("views: a gap in %s (%s): its first view %s is asked once more", f.State, why, f.Tool) - go func() { _ = f.Gap(ctx, why) }() - return nil - } - if revision == 0 { - return gap(fmt.Sprintf("the indexer's %s of %s carries no revision", event, verdict.Module)) - } - key, err := meshcatalogclient.VerdictsKey(digest) - if err != nil { - if revision <= held.Revision { - return nil - } - return gap(fmt.Sprintf("the indexer's %s of %s at revision %d names no manifest", event, verdict.Module, revision)) - } - // A revision below the picture's is a gap (ADR 0615 §5): the verdict events carry no mark of when the indexer's verdicts - // were made, so one made again shows only as revisions starting low. A redelivery of a verdict the picture already - // holds for its manifest is passed over, so a consumer's backlog after a restart asks nothing. - if revision < held.Revision { - if raw, found := f.Get(key); found { - if was, err := meshcatalogclient.DecodeVerdict(raw); err == nil && sameVerdict(was, verdict) { - return nil - } - } - return gap(fmt.Sprintf("the indexer's %s of %s at revision %d, below the picture's %d: its verdicts were made again, or this verdict was missed", - event, verdict.Module, revision, held.Revision)) - } - value, err := json.Marshal(verdict) - if err != nil { - return err - } - if g, why := f.Apply(views.Event{V: 1, Owner: f.Owner, State: f.State, Key: key, Revision: revision, Created: held.Created, - Value: value, At: time.Now().UTC()}); g { - return gap(why) - } - return nil -} - -// sameVerdict says two verdicts of one manifest say the same: its module, accepted or refused, the judge and the problems. -func sameVerdict(a, b meshcatalog.VerdictsByDigestValue) bool { - return a.Module == b.Module && a.State == b.State && a.Judge == b.Judge && slices.Equal(a.Problems, b.Problems) -} - // unansweredCondition is FirstViewUnanswered for one first view, raised or cleared. func unansweredCondition(fv FirstView, s views.Status, raised bool) oc.Condition { c := oc.Condition{Key: FirstViewUnanswered + "." + fv.Owner + "." + fv.State, Subject: oc.ConditionSubject{Scope: "module", ID: Module}} @@ -515,7 +430,7 @@ func (p *Part) AskFirstViewAgain(caller, state, why string, record func(what, wh } } if which == "" { - return nil, fmt.Errorf("%q is no first view of the grants part: one of assignments, wants, manifests, modules, verdicts, bindings, or none for all", state) + return nil, fmt.Errorf("%q is no first view of the grants part: one of assignments, wants, manifests, modules, bindings, or none for all", state) } } if strings.TrimSpace(why) == "" { diff --git a/modules/mesh-grants/internal/grants/follow.go b/modules/mesh-grants/internal/grants/follow.go index 87e534c8..ab657691 100644 --- a/modules/mesh-grants/internal/grants/follow.go +++ b/modules/mesh-grants/internal/grants/follow.go @@ -21,7 +21,7 @@ type Watcher interface { // // And the seat mesh-enrolment's keys (ADR 0587 §4, §5): a key at live composes enrol., and its end, by the holder or by // the bus's expiry, is a change of the key that takes the user out; no event is needed beside the watch. -var Followed = []string{ReadModules, ReadVerdicts, ReadResolved, ReadHave, ReadWants, ReadAccounts, ReadAssignments, ReadEnrolments, +var Followed = []string{ReadModules, ReadResolved, ReadHave, ReadWants, ReadAccounts, ReadAssignments, ReadEnrolments, ReadNodeLogins} // Follower composes again on every change it hears, never on a timer. It never stops for a refusal: a watch it cannot diff --git a/modules/mesh-grants/internal/grants/inputs.go b/modules/mesh-grants/internal/grants/inputs.go index 7bc118a9..80a0a0c6 100644 --- a/modules/mesh-grants/internal/grants/inputs.go +++ b/modules/mesh-grants/internal/grants/inputs.go @@ -40,12 +40,9 @@ import ( const ( ReadModules = "mesh-delivery-indexer.modules" ReadManifests = "mesh-delivery-indexer.manifests" - // ReadVerdicts is the indexer's verdicts, one key per manifest digest: a manifest it has not judged yet has none, and is - // held like a refused one (ADR 0614 §8). - ReadVerdicts = "mesh-delivery-indexer.verdicts" - ReadHave = "node-engine.have" - ReadResolved = "mesh-config.resolved" - ReadWants = "mesh-delivery-assigner.wants" + ReadHave = "node-engine.have" + ReadResolved = "mesh-config.resolved" + ReadWants = "mesh-delivery-assigner.wants" // ReadAccounts is the vault's bcrypt hashes of the bus accounts it holds, by bus user (ADR 0547 clause 9). ReadAccounts = "mesh-vault.bus-accounts" // ReadAssignments is the seat mesh-module-assigner's assignments (ADR 0567 §1, §9): each node's modules and the seats @@ -65,7 +62,7 @@ var Reads = []string{ReadResolved, ReadHave, ReadAccounts, ReadEnrolments, ReadN // ViewReads are the owners' states the part reads by their first views and views families, never their buckets // (firstviews.go, ADR 0615): each read in Reads' place. -var ViewReads = []string{ReadModules, ReadManifests, ReadVerdicts, ReadWants, ReadAssignments} +var ViewReads = []string{ReadModules, ReadManifests, ReadWants, ReadAssignments} // The bus module's tools the part calls, as its manifest's invokes name them: read-only, each. const ( @@ -201,10 +198,6 @@ type Inputs struct { // EventSubjects are, by seat, the subjects of its events that carry parts, by the event's local name, as the definitions // give them: where a node-scoped seat's event names its machine (buscompose.Seat.EventSubjects). EventSubjects map[string]map[string]string - // AcceptCallers are, by pulled-by-kind seat and queue, the seats that may ask it (acceptCallersOf). - AcceptCallers map[string]map[string][]string - // VerbCallers are, by seat and verb, the callers each verb of the definitions admits (verbCallersOf). - VerbCallers map[string]map[string][]string // Defined are the events a seat definition of the seat list defines, by local name, and mesh-sdk's finding events: the // events a `*` emitter before them reaches each declaring module's own stream for (design 47 G §386, §474, §644). Defined map[string]bool @@ -395,8 +388,6 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { in.AskStreams = buscompose.AskStreamsOf(d.Definitions()) in.Chunked = buscompose.ChunkVerbsOf(d.Definitions()) in.EventSubjects = eventSubjectsOf(d.Definitions()) - in.AcceptCallers = acceptCallersOf(d.Definitions()) - in.VerbCallers = verbCallersOf(d.Definitions()) in.Defined = definedEventsOf(d.Definitions()) } nodes := map[string]bool{} @@ -527,17 +518,8 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { } in.NoFingerprint[module] = why } + // No verdict holds a manifest here: it is validated by its pipeline's step validate (design 47 H §745, H-A-79). var m catalogue.Manifest - if err == nil { - // The indexer's refusal, or its wait for a judge that knows a field, carried in its value (ADR 0578 §3): held and named as a refused manifest. - if verdict := meshcatalogclient.ModuleVerdict(module, v); verdict != nil && meshcatalogclient.VerdictHeld(*verdict) { - err = errors.New(meshcatalogclient.VerdictWhy(*verdict)) - } else if verdict == nil { - // The indexer writes a changed manifest's value before it judges it, and a new digest has no verdict: until - // the verdict is written the manifest is held (ADR 0614 §8). - err = noVerdictYet(r, v.Manifest) - } - } if err == nil { m, err = cache.get(r, v.Manifest) } @@ -606,7 +588,7 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { in.Gaps = append(in.Gaps, Gap{Input: ReadWants, Why: "not read: the modules are placed by the node-engines' haves this pass, so what runs is composed from each have's fingerprint"}) fromTrunk = runningByHaves(r, &in, cache, in.Running) } - var viaNewest, noNewest []string + var noEntry []string for key, raw := range wants { node, module, err := meshwantsclient.ParseWantKey(key) if err != nil || !slices.Contains(in.Assigned[node], module) { @@ -620,36 +602,21 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { if w.Removed || w.Fp == "" { continue } - // The manifest of the build the want names is the catalog graph's entry of its fingerprint (design 47 G §444, §614). + // The manifest of the build the want names is the catalog graph's entry of its fingerprint (design 47 G §444, §614); + // a want names that build alone (design 47 H §750, H-A-37), so one with no entry is composed from the trunk's. m, _, err := cache.entryManifest(r, w.Fp) - switch { - case err == nil: - in.Running[node+"."+module] = m - continue - case w.Newest == "" || w.Newest == w.Fp: + if err != nil { fromTrunk = append(fromTrunk, node+"."+module) - noNewest = append(noNewest, node+"."+module+" (its want names no newer build; "+err.Error()+")") + noEntry = append(noEntry, node+"."+module+" ("+err.Error()+")") continue } - // A running build with no catalog entry (from before the catalog graph) is composed from the entry of the build its want - // says is being built, for its account's grants, membership and seat traffic alone (A-414, as A-407 does for the node). - nm, _, nerr := cache.entryManifest(r, w.Newest) - if nerr != nil { - fromTrunk = append(fromTrunk, node+"."+module) - noNewest = append(noNewest, node+"."+module+" (the entry of its want's newest build is not held: "+nerr.Error()+"; "+err.Error()+")") - continue - } - in.Running[node+"."+module] = nm - viaNewest = append(viaNewest, node+"."+module) + in.Running[node+"."+module] = m } - if len(noNewest) > 0 { - sort.Strings(noNewest) - in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "the running build has no catalog entry and its want's newest build gave none: " + strings.Join(noNewest, ", ")}) - } - if len(viaNewest) > 0 { - sort.Strings(viaNewest) - in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "no catalog entry holds the running build, so its account is composed from the entry of the build its want says is being built: " + strings.Join(viaNewest, ", ")}) + if len(noEntry) > 0 { + sort.Strings(noEntry) + in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "the running build has no catalog entry: " + strings.Join(noEntry, ", ")}) } + if len(fromTrunk) > 0 { sort.Strings(fromTrunk) in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "no build record names the manifest at the wanted fingerprint, so the trunk's is used: " + strings.Join(fromTrunk, ", ")}) @@ -928,27 +895,3 @@ func (in Inputs) declared() map[string]catalogue.Manifest { } return out } - -// noVerdictYet is nil when the indexer's verdicts state holds an accepted verdict on the manifest, and the reason it is held -// when it holds none yet, cannot be read, or refuses it. -func noVerdictYet(r Reader, digest string) error { - key, err := meshcatalogclient.VerdictsKey(digest) - if err != nil { - return nil - } - raw, found, err := r.Get(ReadVerdicts, key) - if err != nil { - return fmt.Errorf("its verdict cannot be read: %w", err) - } - if !found { - return errors.New("the indexer has written no verdict on this manifest yet") - } - v, err := meshcatalogclient.DecodeVerdict(raw) - if err != nil { - return fmt.Errorf("its verdict does not read: %w", err) - } - if meshcatalogclient.VerdictHeld(v) { - return errors.New(meshcatalogclient.VerdictWhy(v)) - } - return nil -} diff --git a/modules/mesh-grants/internal/grants/kept.go b/modules/mesh-grants/internal/grants/kept.go index 05832155..2cad491a 100644 --- a/modules/mesh-grants/internal/grants/kept.go +++ b/modules/mesh-grants/internal/grants/kept.go @@ -138,58 +138,6 @@ func withEventSubjects(subjects map[string]map[string]string, d *buscompose.Decl } } -// acceptCallersOf is, by pulled-by-kind seat and then by queue, the seats that may ask the queue: the `seat:` entries -// of the callers of every accepted kind the definition puts on it (a kind's `stream` is its queue, else its name is). Never a -// name of the grants part's own: it reads the definitions' lists (design 47 G §543, §600, A-163). -func acceptCallersOf(defs map[string]seatdef.Definition) map[string]map[string][]string { - out := map[string]map[string][]string{} - for _, d := range defs { - if !d.PulledByKind { - continue - } - for _, a := range d.Accepts { - if a.Callers == nil || a.Callers.IsText() { - continue - } - queue := a.Name - if a.Stream != "" { - queue = a.Stream - } - for _, e := range a.Callers.List { - if seat, ok := strings.CutPrefix(e, seatdef.CallerSeatPrefix); ok && !slices.Contains(out[d.Seat][queue], seat) { - if out[d.Seat] == nil { - out[d.Seat] = map[string][]string{} - } - out[d.Seat][queue] = append(out[d.Seat][queue], seat) - } - } - } - } - return out -} - -// withAcceptCallers gives each pulled-by-kind seat a declaration holds or uses the askers of its queues (Seat.AcceptCallers). -func withAcceptCallers(askers map[string]map[string][]string, d *buscompose.Declared) { - if len(askers) == 0 { - return - } - for _, list := range []*[]buscompose.Seat{&d.Holds, &d.Uses, &d.Watches} { - for i := range *list { - (*list)[i].AcceptCallers = askers[(*list)[i].Name] - } - } -} - -// withVerbCallers gives each seat a declaration holds, uses or watches the effective callers of its verbs -// (Seat.VerbCallers, design 47 G §610, A-179), as withAcceptCallers gives the askers of its queues. -func withVerbCallers(callers map[string]map[string][]string, d *buscompose.Declared) { - for _, list := range []*[]buscompose.Seat{&d.Holds, &d.Uses, &d.Watches} { - for i := range *list { - (*list)[i].VerbCallers = callers[(*list)[i].Name] - } - } -} - // createAskStreams makes each seat's ask stream the bus lacks (buscompose.AskStreamsOf), as createKept makes a kept event's: only // where the bus was read and holds no stream of that name, never changed where it holds one. func createAskStreams(c Creator, done *creations, asks []jetstream.StreamConfig, held map[string]Limits, force bool) (made, notMade []string) { diff --git a/modules/mesh-grants/internal/grants/named_asks_test.go b/modules/mesh-grants/internal/grants/named_asks_test.go index 5d48e79c..dc50d9f7 100644 --- a/modules/mesh-grants/internal/grants/named_asks_test.go +++ b/modules/mesh-grants/internal/grants/named_asks_test.go @@ -8,32 +8,9 @@ import ( "git.novox.be/novox/mesh-sdk/go/seatdef" ) -// The askers of a build seat's queue are read from the definition's callers lists (design 47 G §543, §600, A-163): a kind's -// `stream` is its queue, a text callers names none, and only `seat:` entries are askers. +// A build seat's queues (A-170, A-184): every account may ask each one (design 47 H §752), so no callers list names askers. func TestAcceptCallersOf(t *testing.T) { - msg := func(name, stream string, callers ...string) seatdef.Message { - m := seatdef.Message{Name: name, Stream: stream} - if callers != nil { - m.Callers = &seatdef.Callers{List: callers} - } - return m - } - got := acceptCallersOf(map[string]seatdef.Definition{ - "node-build-go": {Seat: "node-build-go", PulledByKind: true, Accepts: []seatdef.Message{ - msg("check", "", "seat:mesh-catalog", "operator"), - msg("step", "check", "seat:mesh-pipeline-runner"), - msg("delivery", "", "seat:mesh-builds"), - {Name: "recheck", Callers: &seatdef.Callers{Text: "the checker"}}, - }}, - "other": {Seat: "other", Accepts: []seatdef.Message{msg("go", "", "seat:x")}}, - }) - if len(got) != 1 { - t.Fatalf("seats: %v, want node-build-go alone", got) - } - q := got["node-build-go"] - if !slices.Equal(q["check"], []string{"mesh-catalog", "mesh-pipeline-runner"}) || !slices.Equal(q["delivery"], []string{"mesh-builds"}) || len(q) != 2 { - t.Errorf("queues: %v", q) - } + msg := func(name, stream string) seatdef.Message { return seatdef.Message{Name: name, Stream: stream} } // A-170, A-184: the seat's workers are per queue, never per kind: step and run ride check or delivery. build := catalogue.SeatFromDefinition(seatdef.Definition{Seat: "node-build-go", PulledByKind: true, Accepts: []seatdef.Message{ msg("delivery", ""), msg("check", ""), msg("step", "check"), msg("step", "delivery"), msg("recheck", ""), msg("run", "check")}}) diff --git a/modules/mesh-grants/internal/grants/namedpurge_test.go b/modules/mesh-grants/internal/grants/namedpurge_test.go index 6db99f05..36354abc 100644 --- a/modules/mesh-grants/internal/grants/namedpurge_test.go +++ b/modules/mesh-grants/internal/grants/namedpurge_test.go @@ -92,11 +92,11 @@ func TestTheNamedAsksArePurgedAtTheFirstRevisionThatLeavesThem(t *testing.T) { t.Errorf("a named worker composed %v, want %v (%v)", has, c.named, c.in.Manifests["runner"].Invokes) } } - // A-413: an account granted a named ask (it uses the seat's queue and holds a seat its AcceptCallers name) keeps the named + // A-413: an account granted a named ask (it uses the seat's queue and holds a seat: every account may ask every queue, design 47 H §752) keeps the named // workers though no entry invokes the queue; with neither, they go out and the purge runs. asker := buscompose.Declared{Module: "asker", Holds: []buscompose.Seat{{Name: "node-delivery", Scope: "node"}}, - Uses: []buscompose.Seat{{Name: "node-build-go", Scope: "node", Accepts: []string{"check"}, PulledByKind: true, AcceptCallers: map[string][]string{"check": {"node-delivery"}}}}} + Uses: []buscompose.Seat{{Name: "node-build-go", Scope: "node", Accepts: []string{"check"}, PulledByKind: true}}} granted := buscompose.Records{Nodes: []string{"one"}, Assigned: map[string][]buscompose.Declared{"one": {recs.Assigned["one"][0], asker}}} for _, c := range []struct { r buscompose.Records diff --git a/modules/mesh-grants/internal/grants/records.go b/modules/mesh-grants/internal/grants/records.go index 44691e97..25ed30cd 100644 --- a/modules/mesh-grants/internal/grants/records.go +++ b/modules/mesh-grants/internal/grants/records.go @@ -127,15 +127,12 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { d.Watches, d.Consumes, d.Hears, keptHeard = keptOutOfHearing(in.Kept, d.Watches, d.Consumes, d.Hears) d.HearsAStream = d.HearsAStream || keptHeard d.Reads, d.ReadsObjects, d.ReadsRefused = readsOfObjects(m.Module, node, d.Reads, d.ReadsRefused, declared, values) - // The sent stores of the modules it is for (design 47 G §59, §124), read from the catalog graph's manifests and the - // definitions' callers. - d.ReadsObjects = append(d.ReadsObjects, sentStoresRead(m, in.Manifests, in.VerbCallers)...) + // The sent stores of the modules it is for (design 47 G §59, §124), read from the catalog graph's manifests. + d.ReadsObjects = append(d.ReadsObjects, sentStoresRead(m, in.Manifests)...) // Its bindings as kept (bindings.go): the same source its membership's `bindings` is written from in this pass, // so a grant and its binding are written together, never one before the other (issue 1966, the kind of issue 249). d.Bindings = in.Bindings[m.Module] withEventSubjects(in.EventSubjects, &d) - withAcceptCallers(in.AcceptCallers, &d) - withVerbCallers(in.VerbCallers, &d) return d } d := declare(m) @@ -175,8 +172,6 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { out.Engine = &buscompose.Declared{Module: m.Module, Consumes: m.Consumes, Watches: watches, Invokes: m.Invokes, State: bucketsFor(m, in.Nodes), Logs: logsOf(m), Streams: streamsOf(m)} withEventSubjects(in.EventSubjects, out.Engine) - withAcceptCallers(in.AcceptCallers, out.Engine) - withVerbCallers(in.VerbCallers, out.Engine) } return out, gaps } diff --git a/modules/mesh-grants/internal/grants/rootfree.go b/modules/mesh-grants/internal/grants/rootfree.go index e1e37fef..91fa6948 100644 --- a/modules/mesh-grants/internal/grants/rootfree.go +++ b/modules/mesh-grants/internal/grants/rootfree.go @@ -63,8 +63,7 @@ var seatEvents = []string{EventKeeperRaised, EventKeeperCleared, EventAccountIss meshbroker.Seat + "." + BrokerDropped, meshbroker.Seat + "." + BrokerRecreated, meshrecovery.Seat + "." + meshrecovery.EventEnded, meshrecovery.Seat + "." + meshrecovery.EventPointRemoved, meshrecovery.Seat + "." + meshrecovery.EventExpiryEnded} -// SeatEventSubjects are the subjects of the seats' events the part follows its passes by besides the verdicts' and the -// views': the keeper's condition events, the vault's account-issued and the seat mesh-broker's, each `.` of +// SeatEventSubjects are the subjects of the seats' events the part follows its passes by besides the views': the keeper's condition events, the vault's account-issued and the seat mesh-broker's, each `.` of // Consumes on the seat's own subject. func SeatEventSubjects() []string { var out []string @@ -75,15 +74,10 @@ func SeatEventSubjects() []string { return out } -// viewsEvents are the owners' events the part follows its first views by: `.views.`, but the verdicts by -// the indexer's manifest-accepted and manifest-refused (VerdictEvents, ADR 0622 §2). +// viewsEvents are the owners' events the part follows its first views by: `.views.`. func viewsEvents() []string { var out []string for _, fv := range FirstViews { - if fv.Read == ReadVerdicts { - out = append(out, VerdictEvents...) - continue - } out = append(out, fv.Owner+".views."+fv.State) } return out diff --git a/modules/mesh-grants/internal/grants/sentobjects.go b/modules/mesh-grants/internal/grants/sentobjects.go index fc0082f1..2aad745c 100644 --- a/modules/mesh-grants/internal/grants/sentobjects.go +++ b/modules/mesh-grants/internal/grants/sentobjects.go @@ -5,48 +5,17 @@ import ( "strings" "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/seatdef" ) // **A module's sent store is read by the modules it is for** (design 47 G §59, §124): the grants part derives, from the -// catalog graph and the seat definitions, never from a manifest field, a standing read of `_sent-objects` for the -// callers the module's seat definition names for the verbs it serves, and for the consumers whose `consumes` declare its -// events. The grant follows the catalog graph, so it is composed with each module's declaration at every pass. - -// verbCallersOf is, by seat and verb, the callers each verb of the definitions admits (a verb naming none takes its class's -// default). -func verbCallersOf(defs map[string]seatdef.Definition) map[string]map[string][]string { - out := map[string]map[string][]string{} - for _, d := range defs { - for _, v := range d.Verbs { - if out[d.Seat] == nil { - out[d.Seat] = map[string][]string{} - } - out[d.Seat][v.Name] = v.EffectiveCallers() - } - } - return out -} - -// admits says whether a verb's callers name the module: `invokers` (every module whose manifest invokes the verb), the module -// itself, or a seat it claims. -func admits(callers []string, m catalogue.Manifest) bool { - for _, c := range callers { - switch { - case c == seatdef.CallerInvokers, c == seatdef.CallerModulePrefix+m.Module: - return true - } - if seat, ok := strings.CutPrefix(c, seatdef.CallerSeatPrefix); ok && slices.ContainsFunc(m.Claims, func(x catalogue.Claim) bool { return x.Name == seat }) { - return true - } - } - return false -} +// catalog graph, never from a manifest field, a standing read of `_sent-objects` for every module invoking a verb of a +// seat it claims (every account may call every verb, design 47 H §752, H-A-66), and for the consumers whose `consumes` declare +// its events. The grant follows the catalog graph, so it is composed with each module's declaration at every pass. // sentStoresRead are the bus names of the sent stores the module m reads: of each module whose event it consumes (the module's -// own, or the seat a module claims), and of each module claiming a seat whose verb m invokes where the verb's callers admit m. +// own, or the seat a module claims), and of each module claiming a seat whose verb m invokes. // Never m's own store, which its binding grants it. -func sentStoresRead(m catalogue.Manifest, all map[string]catalogue.Manifest, callers map[string]map[string][]string) []string { +func sentStoresRead(m catalogue.Manifest, all map[string]catalogue.Manifest) []string { claimants := func(name string) []string { var out []string if _, ok := all[name]; ok { @@ -70,8 +39,8 @@ func sentStoresRead(m catalogue.Manifest, all map[string]catalogue.Manifest, cal } } for _, in := range m.Invokes { - seat, verb, ok := catalogue.SeatInvoke(in) - if !ok || !admits(callers[seat][verb], m) { + seat, _, ok := catalogue.SeatInvoke(in) + if !ok { continue } for module, x := range all { diff --git a/modules/mesh-grants/internal/grants/sentobjects_test.go b/modules/mesh-grants/internal/grants/sentobjects_test.go index 59e97976..6cbec45d 100644 --- a/modules/mesh-grants/internal/grants/sentobjects_test.go +++ b/modules/mesh-grants/internal/grants/sentobjects_test.go @@ -5,7 +5,6 @@ import ( "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/seatdef" "mesh-grants/internal/buscompose" ) @@ -23,8 +22,6 @@ func TestSentStoresRead(t *testing.T) { } holder := catalogue.Manifest{Module: "shop", Claims: []catalogue.Claim{{Name: "orders-seat"}}} all := map[string]catalogue.Manifest{"shop": holder, "bank": {Module: "bank"}, "plain": {Module: "plain"}} - callers := map[string]map[string][]string{"orders-seat": { - "place": {"seat:billing", "module:plain"}, "list": seatdef.DefaultCallers(seatdef.ClassRead), "wipe": seatdef.DefaultCallers(seatdef.ClassAct)}} for _, c := range []struct { name string m catalogue.Manifest @@ -35,21 +32,15 @@ func TestSentStoresRead(t *testing.T) { {"invokes a verb that names its seat", catalogue.Manifest{Module: "bank", Claims: []catalogue.Claim{{Name: "billing"}}, Invokes: []string{"seat:orders-seat.place"}}, []string{"shop_sent-objects"}}, {"invokes a verb that names it", catalogue.Manifest{Module: "plain", Invokes: []string{"seat:orders-seat.place"}}, []string{"shop_sent-objects"}}, - {"invokes a read, its callers include invokers", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.list"}}, []string{"shop_sent-objects"}}, - {"invokes an act, its callers include invokers (§610)", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.wipe"}}, []string{"shop_sent-objects"}}, - {"invokes a verb that names others", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.place"}}, nil}, + {"invokes a read", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.list"}}, []string{"shop_sent-objects"}}, + {"invokes an act", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.wipe"}}, []string{"shop_sent-objects"}}, + {"invokes a verb no callers list names: every account may call every verb (design 47 H §752)", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.place"}}, []string{"shop_sent-objects"}}, {"declares neither", catalogue.Manifest{Module: "bank"}, nil}, {"its own store is its binding's", holder, nil}, } { - if got := sentStoresRead(c.m, all, callers); !slices.Equal(got, c.want) { + if got := sentStoresRead(c.m, all); !slices.Equal(got, c.want) { t.Errorf("%s: %v, want %v", c.name, got, c.want) } - } // The same callers reach each seat a declaration holds, uses or watches, from which its users' call subjects are - // composed (design 47 G A-179). - d := buscompose.Declared{Module: "bank", Uses: []buscompose.Seat{{Name: "orders-seat"}}, Holds: []buscompose.Seat{{Name: "billing"}}} - withVerbCallers(callers, &d) - if !slices.Equal(d.Uses[0].VerbCallers["place"], callers["orders-seat"]["place"]) || d.Holds[0].VerbCallers != nil { - t.Errorf("a used seat's verbs carry %v, a held seat no definition names %v", d.Uses[0].VerbCallers, d.Holds[0].VerbCallers) } } diff --git a/modules/mesh-grants/internal/grants/tools.go b/modules/mesh-grants/internal/grants/tools.go index fcbfa019..882f231b 100644 --- a/modules/mesh-grants/internal/grants/tools.go +++ b/modules/mesh-grants/internal/grants/tools.go @@ -40,7 +40,7 @@ const ( // Tools is every tool, in the manifest's order. var Tools = []string{ToolGrants, ToolMembership, ToolUserList, ToolComposeNow, ToolAssert, ToolAccounts, ToolConsumerMatch, - ToolAcceptHashes, ToolFirstViews, ToolFirstViewAgain, ToolRunning, ToolWaits, ToolRelease, ToolSeatList, ToolSeatListAgain, ToolCallers, ToolWhyRefused, ToolNamedPurge} + ToolAcceptHashes, ToolFirstViews, ToolFirstViewAgain, ToolRunning, ToolWaits, ToolRelease, ToolSeatList, ToolSeatListAgain, ToolWhyRefused, ToolNamedPurge} // WritesGrants is what grants says of the part's own grants: written once the list the bus loaded carries a build's // accounts, and the one key the assigner reads (ADR 0571 clause 9, which changes ADR 0547 clause 5). diff --git a/modules/mesh-grants/module.json b/modules/mesh-grants/module.json index 092031a6..006e07cf 100644 --- a/modules/mesh-grants/module.json +++ b/modules/mesh-grants/module.json @@ -35,8 +35,6 @@ "mesh-delivery-indexer.views.manifests", "mesh-delivery-indexer.views.modules", "mesh-catalog.catalog-revision", - "mesh-catalog.manifest-accepted", - "mesh-catalog.manifest-refused", "mesh-catalog.registration-changed", "mesh-catalog.seat-definition-changed", "mesh-catalog.seat-definition-removed", @@ -56,7 +54,6 @@ "mesh-delivery-assigner.wants", "mesh-delivery-indexer.manifests", "mesh-delivery-indexer.modules", - "mesh-delivery-indexer.verdicts", "seat:mesh-catalog.entry", "seat:mesh-catalog.registrations", "seat:mesh-catalog.revision", @@ -90,7 +87,6 @@ "grants_release", "grants_seat_list", "grants_seat_list_again", - "grants_callers", "grants_why_refused", "grants_named_purge" ], -- 2.54.0 From ffb5c48dd2c0d321360bbb3aaaf70529c5ac46e7 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:28:59 +0100 Subject: [PATCH 031/104] SDK-C: a composer case carries no verdicts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The composer judges no manifest and the assigner's composition step sets no verdicts, so Case.Verdicts goes with its words; a case carrying verdicts was read before and is refused by a strict reader now. Builds: design 47 H §745, §764 (the indexer: the validation at the take-in); lead answer H-A-112 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- modules/mesh-delivery-sdk/composer/composer.go | 14 +++++--------- .../mesh-delivery-sdk/composer/composer_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-sdk/composer/composer.go b/modules/mesh-delivery-sdk/composer/composer.go index fb214a52..01970807 100644 --- a/modules/mesh-delivery-sdk/composer/composer.go +++ b/modules/mesh-delivery-sdk/composer/composer.go @@ -55,8 +55,8 @@ type Request struct { // Declarations asks each composed machine's declared paths (DepthCompose only). Declarations bool `json:"declarations,omitempty"` // Predefined is the list of predefined keys at the catalogue's root (predefined.json, novox/hq ADR 0348 §7). No - // longer read: the composer judges no manifest (novox/hq ADR 0578 §5), the indexer's judge does, and its verdicts - // come in each case's Verdicts. Kept so an asker that still sends it is read. + // longer read: the composer judges no manifest (novox/hq ADR 0578 §5); a manifest is validated by its pipeline's step + // validate (design 47 H §745). Kept so an asker that still sends it is read. Predefined catalogue.PredefinedList `json:"predefined,omitempty"` // Packages are the known packages a manifest's `packages` may name, each by its name in its own ecosystem (design 32: // a Go package's go.mod module path, a TypeScript package's package.json name), for the indexer's judge (novox/hq ADR @@ -80,14 +80,11 @@ type Request struct { // own assignments files, so a check composes a catalogue pull request's assignments (issue 1126, frombus.Placed); a null // assignments leaves nothing placed on the node. A case without them composes Input's. // -// Verdicts are, by module, as raw JSON (this package is seat-neutral, novox/hq ADR 0635 §4; the node-engine's composer decodes the -// mesh-catalog seat's manifest verdict, and Assignments the mesh-module-assigner seat's assignments), the indexer's judge's verdict on its manifest in Manifests (novox/hq ADR 0578 §5), put in by -// the assigner or the checker that runs the composer: a refused one is held, composed as its stub so what it offers -// still shapes the rest, and named in the case's verdict. A module without one is accepted (the mesh-catalog seat's ManifestVerdict, taken by its readers). +// Assignments are raw JSON (this package is seat-neutral, novox/hq ADR 0635 §4; the node-engine's composer decodes the +// mesh-module-assigner seat's assignments). A case carries no verdicts (design 47 H-A-112). type Case struct { Name string `json:"name"` Manifests map[string]Manifest `json:"manifests"` - Verdicts map[string]json.RawMessage `json:"verdicts,omitempty"` Kept map[string]map[string]Manifest `json:"kept,omitempty"` Assignments map[string]json.RawMessage `json:"assignments,omitempty"` // None is, by module, the words of the revision's none for each module of the case the revision gives no fingerprint @@ -164,8 +161,7 @@ type CaseVerdict struct { Machines map[string]Machine `json:"machines,omitempty"` } -// ManifestRead is one manifest as this mesh-sdk reads it: accepted, or refused with why: the indexer's verdict -// (Case.Verdicts) or bytes that do not decode. A field the decoder does not know is set aside, named in SetAside, and +// ManifestRead is one manifest as this mesh-sdk reads it: accepted, or refused with why: bytes that do not decode. A field the decoder does not know is set aside, named in SetAside, and // the manifest still accepted (novox/hq ADR 0578 §6). type ManifestRead struct { Accepted bool `json:"accepted"` diff --git a/modules/mesh-delivery-sdk/composer/composer_test.go b/modules/mesh-delivery-sdk/composer/composer_test.go index 209f456a..c8c80c30 100644 --- a/modules/mesh-delivery-sdk/composer/composer_test.go +++ b/modules/mesh-delivery-sdk/composer/composer_test.go @@ -107,3 +107,13 @@ func TestAManifestIsItsBytesOrItsDigest(t *testing.T) { t.Fatalf("a digest the indexer does not hold: %v", err) } } + +// design 47 H-A-112: a case carries no verdicts; the composer judges no manifest and the assigner's composition step sets none. +func TestACaseCarriesNoVerdicts(t *testing.T) { + var c Case + dec := json.NewDecoder(strings.NewReader(`{"name":"c","manifests":{},"verdicts":{"demo":{}}}`)) + dec.DisallowUnknownFields() + if err := dec.Decode(&c); err == nil { + t.Error("a case's verdicts are read") + } +} -- 2.54.0 From 2bb08b93065742dbc2de5f680d56c5424706e6bd Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:39:46 +0100 Subject: [PATCH 032/104] G1: the grants part's tests read no verdicts and no callers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The root package's tests and the part's whole test no longer write or read the indexer's verdicts: a value whose verdict field says refused is composed as ever (a module in a revision is accepted by being there), and a held module is one whose manifest the part cannot read. The verdicts' first view row reads the four first views; the no-verdict window and the want's newest build rows go; the compare rows carry the denies every account now has, being granted every verb of every seat; the seat list's again tool's caller row goes with the callers; the captured nats manifest consumes catalog-revision, as the catalog's does, not the retired manifest-accepted. Builds: design 47 H §745, §752, §764 (every seat contract: the callers lists); lead answers H-A-66, H-A-79, H-A-113 (hq f599b761) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../cmd/mesh-grants/integration_test.go | 13 -- .../cmd/mesh-grants/testdata/nats.module.json | 2 +- modules/mesh-grants/grants_test.go | 207 ++++++------------ 3 files changed, 71 insertions(+), 151 deletions(-) diff --git a/modules/mesh-grants/cmd/mesh-grants/integration_test.go b/modules/mesh-grants/cmd/mesh-grants/integration_test.go index d84b24ee..225309db 100644 --- a/modules/mesh-grants/cmd/mesh-grants/integration_test.go +++ b/modules/mesh-grants/cmd/mesh-grants/integration_test.go @@ -32,7 +32,6 @@ import ( "git.novox.be/novox/mesh-sdk/go/membership" "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/seal" - "git.novox.be/novox/mesh-sdk/go/seatlist" "git.novox.be/novox/mesh-sdk/go/views" "mesh-grants/internal/buscompose" @@ -108,8 +107,6 @@ func TestTheGrantsPartWhole(t *testing.T) { put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: module, Manifest: raw}) put(grants.ReadModules, module, meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), Manifest: digest, Repository: "novox/x", Commit: "c"}) - verdict, _ := meshcatalogclient.EncodeVerdict(meshcatalog.VerdictsByDigestValue{Module: module, State: meshcatalogclient.VerdictAccepted, Judge: "j", At: new(time.Now())}) - put(grants.ReadVerdicts, digest, json.RawMessage(verdict)) } manifest("nats", `{"module":"nats","version":"1","claims":[{"name":"mesh-broker"}],"own-secrets":{"broker":"/var/lib/nats/broker"},`+ `"emits":["created","done","dropped","recreated"],"streams":[{"name":"broker-events","events":["created","dropped","recreated"],"max-age-days":30,"max-mib":256}]}`) @@ -543,16 +540,6 @@ func TestTheGrantsPartWhole(t *testing.T) { t.Errorf("the bucket %s: %v, want none", bucket, err) } } - // Issue 1966: the seat list's again tool answers an operator's session, which the mesh MCP server proves as its - // machine's tool runner (issue 627), and the healers; no other module. - t.Run("the seat list's again tool answers an operator's session", func(t *testing.T) { - for caller, refused := range map[string]bool{"person.jochen": false, "shanks.node-tools": false, "ace.mesh-healers": false, - "ace.messenger": true} { - if err := seatlist.Refusal(grants.ToolSeatListAgain, seatListAgainCallers, caller); (err != nil) != refused { - t.Errorf("%s: refused=%v, err %v", caller, refused, err) - } - } - }) // ADR 0640 §5: the real additions change the subjects and the filters and nothing else, and recreate nothing. t.Run("adding subjects and filters changes only those", func(t *testing.T) { stream, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "ADDS", Subjects: []string{"a.>"}, MaxAge: time.Hour, MaxMsgs: 100, diff --git a/modules/mesh-grants/cmd/mesh-grants/testdata/nats.module.json b/modules/mesh-grants/cmd/mesh-grants/testdata/nats.module.json index af929ebe..a73846ef 100644 --- a/modules/mesh-grants/cmd/mesh-grants/testdata/nats.module.json +++ b/modules/mesh-grants/cmd/mesh-grants/testdata/nats.module.json @@ -57,7 +57,7 @@ "mesh-delivery-indexer.indexer_bus_state" ], "consumes": [ - "mesh-catalog.manifest-accepted" + "mesh-catalog.catalog-revision" ], "uses": [ "operator-channel" diff --git a/modules/mesh-grants/grants_test.go b/modules/mesh-grants/grants_test.go index ce7f8560..1e45fdc3 100644 --- a/modules/mesh-grants/grants_test.go +++ b/modules/mesh-grants/grants_test.go @@ -300,12 +300,6 @@ func (b *fakeBus) put(state, key string, v any) { b.states[state] = map[string][]byte{} } b.states[state][key] = raw - // A modules value that carries no verdict is accepted by the indexer's verdict on its digest, as the indexer writes it; - // a row that wants the window before the judge deletes that key. - if m, ok := v.(meshcatalog.ModulesByModuleValue); ok && state == grants.ReadModules && m.Verdict == "" && m.Manifest != "" { - verdict, _ := meshcatalogclient.EncodeVerdict(meshcatalog.VerdictsByDigestValue{Module: key, State: meshcatalogclient.VerdictAccepted, Judge: "j", At: new(time.Now())}) - b.put(grants.ReadVerdicts, m.Manifest, json.RawMessage(verdict)) - } } func (b *fakeBus) Keys(state string) ([]string, error) { @@ -484,11 +478,11 @@ func (b *fakeBus) manifestOf(module, raw string) { b.put(grants.ReadModules, module, meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), Manifest: digest, Repository: "novox/x", Commit: "c"}) } -// refuse marks the indexer's refusal of module's manifest in its value (novox/hq ADR 0578 §1). -func (b *fakeBus) refuse(module, raw, problem string) { +// unreadable writes module's value naming a manifest the indexer's manifests do not hold, so the part cannot read it and +// holds the module (inputs.go, Refused): no verdict holds a manifest any more (design 47 H §745, H-A-79). +func (b *fakeBus) unreadable(module, raw string) { b.put(grants.ReadModules, module, meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), - Manifest: meshcatalogclient.ManifestDigest([]byte(raw)), Repository: "novox/x", Commit: "c", Verdict: meshcatalogclient.VerdictRefused, - Problems: []string{problem}}) + Manifest: meshcatalogclient.ManifestDigest([]byte(raw + " (not held)")), Repository: "novox/x", Commit: "c"}) } // assign places module on node in the seat's assignments, the one place the part reads it (ADR 0549 §5; issue 774). @@ -738,7 +732,7 @@ func TestGrants(t *testing.T) { digest := meshcatalogclient.ManifestDigest([]byte(built)) b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: built}) fp := "src2:" + strings.Repeat("cd", 32) - b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Composed: "sha256:" + strings.Repeat("ef", 32)}) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp}) b.entry(fp, digest) }, []string{"a.mod-x", "a.nats", "b.mod-y", "node.a", "node.b"}, "people"}, // Issue 1966: refused, each module is placed where its have says it runs (the bootstrap fallback); a has nats. @@ -883,12 +877,11 @@ func TestGrants(t *testing.T) { if slices.Contains(web.Publish, "$JS.API.DIRECT.GET.KV_mesh-knowledge_sections.>") { t.Error("the object bucket's read is granted as a state's") } - // ADR 0601 clause 3: the owner's trunk manifest now waits for a field; its running build's manifest still declares the - // bucket, so web keeps its object grant. + // ADR 0601 clause 3: the owner's trunk manifest cannot be read (its value names a manifest the indexer does not hold); + // its running build's manifest still declares the bucket, so web keeps its object grant. fp := "src2:" + strings.Repeat("cd", 32) b.put(grants.ReadModules, "mesh-knowledge", meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), - Manifest: meshcatalogclient.ManifestDigest([]byte(`{"module":"mesh-knowledge","version":"2"}`)), Repository: "novox/x", Commit: "c", - Verdict: meshcatalogclient.VerdictRefused, Problems: []string{"it waits"}, Unknown: []string{"core-credentials"}}) + Manifest: meshcatalogclient.ManifestDigest([]byte(`{"module":"mesh-knowledge","version":"2"}`)), Repository: "novox/x", Commit: "c"}) b.put(grants.ReadHave, "a.mesh-knowledge", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, Fp: fp}) b.entry(fp, meshcatalogclient.ManifestDigest([]byte(knowledge))) if heldWeb := (func() grants.User { @@ -989,10 +982,10 @@ func TestGrants(t *testing.T) { b.assign("a", "messenger") b.assign("b", "telegram") if held { - // The trunk's manifest waits for a field; the build that runs was judged on the manifest before. + // The trunk's manifest cannot be read (its value names a manifest the indexer does not hold); the build that runs + // carries the manifest before. b.put(grants.ReadModules, "messenger", meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), - Manifest: meshcatalogclient.ManifestDigest([]byte(`{"module":"messenger","version":"2"}`)), Repository: "novox/x", Commit: "c", - Verdict: meshcatalogclient.VerdictRefused, Problems: []string{"it waits"}, Unknown: []string{"core-credentials"}}) + Manifest: meshcatalogclient.ManifestDigest([]byte(`{"module":"messenger","version":"2"}`)), Repository: "novox/x", Commit: "c"}) if runs { fp := "src2:" + strings.Repeat("cd", 32) digest := meshcatalogclient.ManifestDigest([]byte(router)) @@ -1122,14 +1115,14 @@ func TestGrants(t *testing.T) { t.Run("a predefined-key fallback is read with no list; every refused manifest listed", func(t *testing.T) { // mod-p's value falls back to a predefined key, as claude-code's managed_settings does, and no list is on the bus - // (issue 1945); mod-z's manifest the indexer's judge refused (ADR 0578 §3), and mod-z is assigned nowhere. + // (issue 1945); mod-z's manifest the part cannot read (no verdict holds one, design 47 H H-A-79), and mod-z is assigned nowhere. const pManifest = `{"module":"mod-p","version":"1","own-secrets":{"broker":"/var/lib/p/broker"},` + `"config":{"size":{"type":"number","description":"The size text shows in, in points.","predefined":"font-size","default":12,"runtime":true}}}` const zManifest = `{"module":"mod-z","version":"1","no-such-key":true}` b := fixture() b.manifestOf("mod-p", pManifest) b.manifestOf("mod-z", zManifest) - b.refuse("mod-z", zManifest, "it carries no-such-key") + b.unreadable("mod-z", zManifest) b.assign("b", "mod-p") // mesh-wireguard is provided by the mesh, not read from a repository: no manifest in the indexer, none refused, // no gap, and its manifest is the one mesh-sdk provides (issue 1945). @@ -1181,7 +1174,7 @@ func TestGrants(t *testing.T) { `"provides":[{"name":"smtp","scope":"mesh"}],"serves":{"smtp":{"port":587,"domain":"${config:domain}"}}}`) bt.assign("b", "mod-s") runsFP := "src2:" + strings.Repeat("cd", 32) - bt.put(grants.ReadWants, "want.b.mod-s", meshwantsclient.Want{V: keys.Version, Fp: runsFP, Composed: "sha256:" + strings.Repeat("ef", 32)}) + bt.put(grants.ReadWants, "want.b.mod-s", meshwantsclient.Want{V: keys.Version, Fp: runsFP}) bt.entry(runsFP, oldDigest) for _, u := range shadowOf(t, bt) { if u.User == "node.a" && !slices.Contains(u.Publish, served) { @@ -1320,10 +1313,15 @@ func TestGrants(t *testing.T) { // the loaded list says none, as nats_users answers today, on a user whose grants differ: it cannot be compared. denied := slices.Clone(shadow) denied[x].PublishDeny = []string{"mesh.seat.node-launcher.tool.secret"} + // Every account is granted every seat's verbs (design 47 H §752, H-A-113), so every module's user carries the denies + // that allow reaches: the loaded list says each user's own, a.mod-x's empty; and in unsaid it says none for a.mod-x. readable := slices.Clone(fewer) for i := range readable { - readable[i].PublishDeny = []string{} + readable[i].PublishDeny = append([]string{}, shadow[i].PublishDeny...) } + readable[x].PublishDeny = []string{} + unsaid := slices.Clone(fewer) + unsaid[x].PublishDeny = nil // A subscribe the shadow withholds (design 46 approval mark §6) where the loaded list withholds none, as on the first // composition after the release: a narrowing, no right lost. Its reverse, a node gaining approval-mark/1: a right added. withheld := slices.Clone(shadow) @@ -1371,7 +1369,7 @@ func TestGrants(t *testing.T) { {"grants differ", changed, nil, nil, nil, []string{"a.mod-x"}, false, nil, []string{"a.mod-x"}, 1}, {"only a right added", fewer, nil, nil, nil, []string{"a.mod-x"}, false, nil, nil, 1}, {"a deny added refuses", readable, nil, nil, nil, []string{"a.mod-x"}, false, nil, []string{"a.mod-x"}, 1}, - {"a deny the loaded list cannot say refuses a user whose grants differ", fewer, nil, nil, nil, []string{"a.mod-x"}, false, nil, []string{"a.mod-x"}, 1}, + {"a deny the loaded list cannot say refuses a user whose grants differ", unsaid, nil, nil, nil, []string{"a.mod-x"}, false, nil, []string{"a.mod-x"}, 1}, {"a subscribe withheld passes as no right lost", shadow, nil, nil, nil, []string{"a.mod-x"}, false, nil, nil, 0}, {"a subscribe no longer withheld is a right added", withheld, nil, nil, nil, []string{"a.mod-x"}, false, nil, nil, 1}, {"captured 21:19: only added rights", nil, nil, nil, nil, nil, false, captured(nil), nil, 41}, @@ -2895,7 +2893,7 @@ func TestGrants(t *testing.T) { }, ""}, // The ledger of a held module stays with its module's users, whatever the seat list (held.go). {"the ledger of a module whose manifest is refused", func(b *fakeBus, p *grants.Part) { - b.refuse("mod-x", ledgerX, "it is held") + b.unreadable("mod-x", ledgerX) }, ""}, // The union cannot give a login a loaded user has no hash for: held, naming it. {"a loaded user with no hash, the seat list unread", func(b *fakeBus, p *grants.Part) { @@ -3695,10 +3693,10 @@ func TestGrants(t *testing.T) { } }) - // DLV-F4r, DLV-R1 (novox/hq ADR 0615 §4 to §6, ADR 0622; design 25 § 12.2): the five owners' states are read by their + // DLV-F4r, DLV-R1 (novox/hq ADR 0615 §4 to §6, ADR 0622; design 25 § 12.2): the four owners' states are read by their // first views; an answer empty at revision 0 drops no login and raises first-view-empty with the operator's step until an // answer above 0; an owner down past the bound raises first-view-unanswered, cleared by its answer; an event applies a - // change with no ask; grants_first_view_again refuses a state that is none of the five and records the hand act. + // change with no ask; grants_first_view_again refuses a state that is none of the four and records the hand act. t.Run("first views: the owners' states by their first views, an empty answer at revision 0 dropping no login", func(t *testing.T) { b := fixture() b.loaded = shadowOf(t, b) @@ -3707,7 +3705,7 @@ func TestGrants(t *testing.T) { empty.Store(true) owner := func(tool string) func(context.Context, string) (views.Answer, error) { return func(context.Context, string) (views.Answer, error) { - if down.Load() && strings.HasSuffix(tool, ".verdicts") { + if down.Load() && strings.HasSuffix(tool, ".wants") { return views.Answer{}, errors.New("no responders") } for _, fv := range grants.FirstViews { @@ -3754,7 +3752,7 @@ func TestGrants(t *testing.T) { down.Store(true) fv.Start(ctx, func() {}) for _, f := range fv.Followers { - if f.Tool != grants.IndexerModule+".verdicts" { + if f.Tool != grants.AssignerModule+".wants" { <-f.Ready() } } @@ -3774,7 +3772,7 @@ func TestGrants(t *testing.T) { p.Read, p.Views, p.Say, p.SayFinding = fv, fv, say, say before := p.Compose() // The raise the condition keeper did not take was said again by the pass. - if !raised(grants.FirstViewUnanswered+".mesh-delivery-indexer.verdicts", occ.StateRaised) { + if !raised(grants.FirstViewUnanswered+".mesh-delivery-assigner.wants", occ.StateRaised) { t.Fatalf("the refused raise was not said again at the pass: %+v", said) } // Not answered above revision 0, the modules are placed by the node-engines' haves (issue 1966), said as its gap. @@ -3793,7 +3791,7 @@ func TestGrants(t *testing.T) { } waitFor(t, func() bool { return fv.Followers[grants.ReadAssignments].Status().Revision == 7 }) waitFor(t, func() bool { - return raised(grants.FirstViewUnanswered+".mesh-delivery-indexer.verdicts", occ.StateCleared) + return raised(grants.FirstViewUnanswered+".mesh-delivery-assigner.wants", occ.StateCleared) }) after := p.Compose() if slices.ContainsFunc(after.UserList.Gaps, func(g grants.Gap) bool { return g.Input == grants.ReadAssignments }) || @@ -3813,61 +3811,16 @@ func TestGrants(t *testing.T) { if _, found, _ := fv.Get(grants.ReadAssignments, "c.node"); !found || fv.Followers[grants.ReadAssignments].Status().Asks != asksBefore { t.Error("the event did not reach the picture, or asked") } - // The verdicts follow the indexer's manifest-accepted and manifest-refused at the revision each carries (ADR 0622 §2): - // the next revision changes the picture with no ask; one already in it is passed over; one carrying no revision, or - // past the next, asks the first view once more. - verdicts := fv.Followers[grants.ReadVerdicts] - digest := strings.Repeat("ab", 32) - heard := func(event string, body any) { - t.Helper() - raw, _ := json.Marshal(body) - if err := fv.HearVerdict(ctx, event, raw, t.Logf); err != nil { - t.Fatalf("%s: %v", event, err) - } - } - verdictOf := func() meshcatalog.VerdictsByDigestValue { - raw, _, _ := fv.Get(grants.ReadVerdicts, digest) - v, _ := meshcatalogclient.DecodeVerdict(raw) - return v - } - asked := verdicts.Status().Asks - heard(meshcatalog.EventManifestAccepted, meshcatalog.ManifestAcceptedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j", Revision: 8}) - if v := verdictOf(); v.State != meshcatalogclient.VerdictAccepted || v.Module != "mod-z" || verdicts.Status().Revision != 8 { - t.Errorf("manifest-accepted at the next revision: %+v at %d", v, verdicts.Status().Revision) - } - heard(meshcatalog.EventManifestRefused, meshcatalog.ManifestRefusedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j", Problems: []string{"p"}, Revision: 9}) - heard(meshcatalog.EventManifestAccepted, meshcatalog.ManifestAcceptedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j", Revision: 9}) - if v := verdictOf(); !meshcatalogclient.VerdictRefuses(v) || !slices.Equal(v.Problems, []string{"p"}) || verdicts.Status().Asks != asked { - t.Errorf("manifest-refused, then a revision already held: %+v, asks %d (was %d)", v, verdicts.Status().Asks, asked) - } - // A revision below the picture's (ADR 0615 §5; the verdicts made again restart low): the same verdict again is a - // redelivery, passed over; another verdict asks the first view once more. - heard(meshcatalog.EventManifestRefused, meshcatalog.ManifestRefusedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j", Problems: []string{"p"}, Revision: 3}) - if verdicts.Status().Asks != asked { - t.Errorf("a held verdict redelivered at a lower revision asked: asks %d (was %d)", verdicts.Status().Asks, asked) - } - heard(meshcatalog.EventManifestAccepted, meshcatalog.ManifestAcceptedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j", Revision: 2}) - waitFor(t, func() bool { return verdicts.Status().Asks > asked }) - waitFor(t, func() bool { s := verdicts.Status(); return !s.Answered.Before(s.Asked) }) - asked = verdicts.Status().Asks - heard(meshcatalog.EventManifestAccepted, meshcatalog.ManifestAcceptedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j"}) - waitFor(t, func() bool { return verdicts.Status().Asks > asked }) - asked = verdicts.Status().Asks - heard(meshcatalog.EventManifestAccepted, meshcatalog.ManifestAcceptedEvent{V: 1, Module: "mod-z", Digest: digest, Judge: "j", Revision: 12}) - waitFor(t, func() bool { return verdicts.Status().Asks > asked }) - if err := fv.HearVerdict(ctx, "manifest-judged", []byte("{}"), t.Logf); err == nil { - t.Error("an event that is no verdict was taken") - } - // The tools: a state that is none of the five is refused; one is asked with its hand act. + // The tools: a state that is none of the four is refused; one is asked with its hand act. var acts []string record := func(what, why string) error { acts = append(acts, what+": "+why); return nil } if _, err := p.AskFirstViewAgain("jochen@shanks", "builds", "x", record); err == nil || len(acts) != 0 { t.Errorf("a state that is no first view was asked: %v %v", err, acts) } - if _, err := p.AskFirstViewAgain("jochen@shanks", "verdicts", "after the take-in", record); err != nil || len(acts) != 1 { - t.Errorf("verdicts again: %v %v", err, acts) + if _, err := p.AskFirstViewAgain("jochen@shanks", "modules", "after the take-in", record); err != nil || len(acts) != 1 { + t.Errorf("modules again: %v %v", err, acts) } - if got, err := p.FirstViewsOf(); err != nil || !strings.Contains(fmt.Sprint(got), "mesh-delivery-indexer.verdicts") { + if got, err := p.FirstViewsOf(); err != nil || !strings.Contains(fmt.Sprint(got), "mesh-delivery-indexer.modules") { t.Errorf("grants_first_views = %v, %v", got, err) } }) @@ -4514,10 +4467,10 @@ func TestGrants(t *testing.T) { } }) - // Clause 3 of the record on a release's Approve (issue 774): a module whose manifest waits for a judge that knows a field - // of it, or is refused, and whose want names no build, keeps its users of the list in force and is said in a condition; - // the rest of the list is written as ever, and the users go the day the manifest is accepted and the module unassigned. - t.Run("a module whose manifest waits or is refused keeps its users of the list in force", func(t *testing.T) { + // Clause 3 of the record on a release's Approve (issue 774): a module whose manifest the part cannot read, and whose want + // names no build, keeps its users of the list in force and is said in a condition; the rest of the list is written as + // ever, and the users go the day the manifest is read and the module unassigned. No verdict holds one (design 47 H H-A-79). + t.Run("a module whose manifest cannot be read keeps its users of the list in force; a verdict holds none", func(t *testing.T) { b := fixture() const ctl = `{"module":"mod-r","version":"1","own-secrets":{"broker":"/var/lib/r/broker","broker-mod-r-tools":"${dir:tools-secret}/broker-mod-r-tools"},` + `"resources":[{"id":"tools-secret","type":"directory","path":"/var/lib/mesh/mod-r-tools","mode":"0711"}],"build":{"artifacts":[{"name":"tools",` + @@ -4554,38 +4507,40 @@ func TestGrants(t *testing.T) { if !ok || len(said) != 1 || said[0].State != occ.StateCleared { t.Fatalf("the list in force keeps no grants of b.mod-r.mod-r-tools (%v), or a held module was said before: %+v", ok, said) } - for gen, held := range []struct{ name, unknown string }{{"waits", "core-credentials"}, {"refused", ""}} { + // No verdict holds a manifest (design 47 H §745, H-A-79): a module in the revision is accepted by being there, so a value + // whose verdict field an indexer of the earlier form wrote as refused is composed as ever and raises no hold. + b.put(grants.ReadModules, "mod-r", meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), + Manifest: meshcatalogclient.ManifestDigest([]byte(ctl)), Repository: "novox/x", Commit: "c", Verdict: meshcatalogclient.VerdictRefused, + Problems: []string{"it is held"}, Unknown: []string{"core-credentials"}}) + if res := p.Compose(); len(res.Refused) != 0 || said[len(said)-1].State != occ.StateCleared { + t.Errorf("a verdict of the earlier form held the manifest: refused %v, said %+v", res.Refused, said[len(said)-1]) + } + // A manifest the part cannot read (the value names a digest the indexer's manifests do not hold) is held: its module's + // users stay as the list in force holds them, said, and the rest of the list is written. + { // Another user's hash changes in the same pass, so a list that is written shows the held module did not hold it. - b.put(grants.ReadAccounts, "a.mod-x", map[string]any{"user": "a.mod-x", "hash": fmt.Sprintf("$2a$10$gen%d", gen), "generation": gen + 2, "fingerprint": fmt.Sprintf("sha256:%d", gen+2)}) + b.put(grants.ReadAccounts, "a.mod-x", map[string]any{"user": "a.mod-x", "hash": "$2a$10$gen0", "generation": 2, "fingerprint": "sha256:2"}) was, _, _ := p.Sealed() - var unknown []string - if held.unknown != "" { - unknown = []string{held.unknown} - } - b.put(grants.ReadModules, "mod-r", meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), - Manifest: meshcatalogclient.ManifestDigest([]byte(ctl)), Repository: "novox/x", Commit: "c", Verdict: meshcatalogclient.VerdictRefused, - Problems: []string{"it is held"}, Unknown: unknown}) + b.unreadable("mod-r", ctl) b.put(grants.ReadModules, "mod-q", meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), Manifest: meshcatalogclient.ManifestDigest([]byte(ctl)), Repository: "novox/x", Commit: "c"}) res := p.Compose() now, _, _ := p.Sealed() after, _, ok, _ := b.ownGet(grants.StateUserList, grants.SealedUserKey(now.Digest, "b.mod-r.mod-r-tools")) if now.Digest == was.Digest || slices.ContainsFunc(res.Errors, func(e string) bool { return strings.Contains(e, "composed whole") }) { - t.Errorf("%s: a held module held the whole list: sealed %+v", held.name, res.Sealed) + t.Errorf("a held module held the whole list: sealed %+v", res.Sealed) } if !ok || string(after) != string(before) || len(res.PrincipalsRefused) != 0 { - t.Errorf("%s: b.mod-r.mod-r-tools did not keep its grants of the list in force: %s, was %s", held.name, after, before) + t.Errorf("b.mod-r.mod-r-tools did not keep its grants of the list in force: %s, was %s", after, before) } if last := said[len(said)-1]; last.State != occ.StateRaised || !strings.Contains(last.Summary, "b.mod-r.mod-r-tools (stays in the list") { - t.Errorf("%s: the kept user was not said: %+v", held.name, last) + t.Errorf("the kept user was not said: %+v", last) } } // A held module that runs no build the part can read declares nothing to anyone: only its own users stay as the list in // force holds them, said unreadable; the others move (ADR 0614 §8). delete(b.states[grants.ReadHave], "b.mod-r") - b.put(grants.ReadModules, "mod-r", meshcatalog.ModulesByModuleValue{V: keys.Version, Fp2: "src2:" + strings.Repeat("ab", 32), - Manifest: meshcatalogclient.ManifestDigest([]byte(ctl)), Repository: "novox/x", Commit: "c", Verdict: meshcatalogclient.VerdictRefused, - Problems: []string{"it is held"}, Unknown: []string{"core-credentials"}}) + b.unreadable("mod-r", ctl) b.put(grants.ReadAccounts, "a.mod-x", map[string]any{"user": "a.mod-x", "hash": "$2a$10$gen9", "generation": 9, "fingerprint": "sha256:9"}) wasList, _, _ := p.Sealed() res := p.Compose() @@ -4599,24 +4554,10 @@ func TestGrants(t *testing.T) { if last := said[len(said)-1]; last.State != occ.StateRaised || !strings.Contains(last.Summary, "the manifest of mod-r is unreadable") { t.Errorf("the unreadable manifest was not said: %+v", last) } - // The window before the judge: the indexer wrote a changed manifest's value and no verdict on its digest yet. Only that - // module's users stay (named unreadable); the others move. - b.manifestOf("mod-r", ctl) - delete(b.states[grants.ReadVerdicts], meshcatalogclient.ManifestDigest([]byte(ctl))) - b.put(grants.ReadAccounts, "a.mod-x", map[string]any{"user": "a.mod-x", "hash": "$2a$10$gen11", "generation": 11, "fingerprint": "sha256:11"}) - wasList, _, _ = p.Sealed() - res = p.Compose() - nowList, _, _ = p.Sealed() - if nowList.Digest == wasList.Digest || strings.Contains(fmt.Sprint(res.Sealed), "kept while a read") { - t.Errorf("a manifest with no verdict yet held the whole list: %+v", res.Sealed) - } - if last := said[len(said)-1]; last.State != occ.StateRaised || !strings.Contains(last.Summary, "no verdict on this manifest yet") { - t.Errorf("a manifest with no verdict yet was not said: %+v", last) - } - // Accepted again: the users compose from the manifest and the condition clears. + // Readable again: the users compose from the manifest and the condition clears. b.manifestOf("mod-r", ctl) if p.Compose(); said[len(said)-1].State != occ.StateCleared { - t.Errorf("the condition was not cleared once the manifest is accepted: %+v", said[len(said)-1]) + t.Errorf("the condition was not cleared once the manifest is readable: %+v", said[len(said)-1]) } // ADR 0601 §4: a tool runner whose manifest does not say so yet (an older build's) keeps its user as the list in force // holds it, known by what it runs (it says the runner is alive), and the held condition says so; never composed as a @@ -4910,7 +4851,7 @@ func TestPassBeforeTheCatalogHalfsFirstViews(t *testing.T) { digest := meshcatalogclient.ManifestDigest([]byte(built)) b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: built}) fp := "src2:" + strings.Repeat("cd", 32) - b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Composed: "sha256:" + strings.Repeat("ef", 32)}) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp}) b.entry(fp, digest) waiting(b) in := grants.ReadInputs(b, &grants.Manifests{}) @@ -5223,20 +5164,18 @@ func TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo(t *testing.T) { name string entry bool // the want's entry is answered (the older build); else it is not answered wantsOld bool - newest string // "entry": the want names a newest build whose entry is answered; "none": it names one with no entry + noEntry bool // the want names a build no entry holds: a want names that build alone (design 47 H §750, H-A-37) }{ - {"the want's entry is not answered", false, false, ""}, - {"the want names an entry that is asked", false, false, ""}, - {"the want's entry is an older build", true, true, ""}, - // A-414: a running build with no entry composes from its want's newest build's entry; with neither entry it carries as today. - {"no entry for the fingerprint but one for newest", false, true, "entry"}, - {"neither entry", false, false, "none"}, + {"the want's entry is not answered", false, false, false}, + {"the want names an entry that is asked", false, false, false}, + {"the want's entry is an older build", true, true, false}, + {"no entry for the want's build", false, false, true}, } for _, row := range rows { t.Run(row.name, func(t *testing.T) { b := fixture() if strings.Contains(row.name, "asked") { - b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: "src2:" + strings.Repeat("cd", 32), Composed: "sha256:" + strings.Repeat("ef", 32)}) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: "src2:" + strings.Repeat("cd", 32)}) b.put(grants.ReadHave, "a.mod-x", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, Fp: "src2:" + strings.Repeat("cd", 32)}) b.entriesAsked = true @@ -5245,17 +5184,11 @@ func TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo(t *testing.T) { digest := meshcatalogclient.ManifestDigest([]byte(older)) b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: older}) fp := "src2:" + strings.Repeat("cd", 32) - b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Composed: "sha256:" + strings.Repeat("ef", 32)}) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp}) b.entry(fp, digest) } - if row.newest != "" { - fp, newest := "src2:"+strings.Repeat("cd", 32), "src2:"+strings.Repeat("ab", 32) - b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Newest: newest, Rule: meshwantsclient.RuleStep, Composed: "sha256:" + strings.Repeat("ef", 32)}) - if row.newest == "entry" { - digest := meshcatalogclient.ManifestDigest([]byte(older)) - b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: older}) - b.entry(newest, digest) - } + if row.noEntry { + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: "src2:" + strings.Repeat("cd", 32)}) } b.mu.Lock() b.catalogWaited = []string{"the catalog half of the branch main"} @@ -5264,10 +5197,10 @@ func TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo(t *testing.T) { if in.CatalogUnread == "" { t.Fatal("the catalog half is not unread") } - if row.newest == "none" && !slices.ContainsFunc(in.Gaps, func(g grants.Gap) bool { - return g.Input == "wanted manifests" && strings.Contains(g.Why, "newest build is not held") + if row.noEntry && !slices.ContainsFunc(in.Gaps, func(g grants.Gap) bool { + return g.Input == "wanted manifests" && strings.Contains(g.Why, "the running build has no catalog entry") }) { - t.Errorf("no gap says why the want's newest build was not taken: %+v", in.Gaps) + t.Errorf("no gap says the want's build has no entry: %+v", in.Gaps) } // An entry asked and not answered is no failed read while the catalog half is unread: the trunk's manifest composes the // account and the list is not held for it. @@ -5403,7 +5336,7 @@ func TestAKeptAccountGainsTheRightEveryAccountCarries(t *testing.T) { u.Publish = slices.DeleteFunc(slices.Clone(u.Publish), func(s string) bool { return s == names }) b.own[grants.StateUserList][key], _ = json.Marshal(u) // Its manifest is now held, the catalog half is unread, and the list changes (mod-x runs on b too). - b.refuse("mod-y", yManifest, "held for the test") + b.unreadable("mod-y", yManifest) b.mu.Lock() b.catalogWaited = []string{"the catalog half of the branch main"} b.mu.Unlock() @@ -5470,7 +5403,7 @@ func TestAHeldRunnerIsWrittenAsTheUnionOfTheListInForceAndWhatIsComposed(t *test fp := "src2:" + strings.Repeat("cd", 32) b.put(grants.ReadHave, "a.node-tools", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, Fp: fp}) b.entry(fp, digest) - b.refuse("node-tools", runner, "held for the test") + b.unreadable("node-tools", runner) b.mu.Lock() b.catalogWaited = []string{"the catalog half of the branch main"} b.mu.Unlock() -- 2.54.0 From 90f53608bc497e30711baf7966aff32be3ada235 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:43:10 +0100 Subject: [PATCH 033/104] B-src (in progress): the builder reads no source stamp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A module value carries no source stamp (C1d): ModuleOf takes none from the entry's inputs, a build's claim is numbered per fingerprint naming no source revision and no merge, and the log's started entry names none. The seat list's parts take no callers and resolve no caller's holder (mesh-sdk's NewPart without callers, SDK-C). internal/... is green; cmd/mesh-delivery-builder still hears manifest-accepted (names.go:21, versions.go:192, module.json:57), which the seat mesh-catalog no longer defines: its floor's wake is H-A-49's, asked of the lead. Builds: design 47 H §764 (the indexer: the field pull, the source numbering); lead answers H-A-48, H-A-66 (hq f599b761) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../cmd/mesh-delivery-builder-tools/main.go | 5 ++--- .../cmd/mesh-delivery-builder/integration_test.go | 2 +- .../cmd/mesh-delivery-builder/main.go | 4 ++-- .../cmd/mesh-delivery-builder/seatlist.go | 9 +++------ .../internal/build/entry_test.go | 9 +++++++-- .../mesh-delivery-builder/internal/build/numbers.go | 10 +++------- modules/mesh-delivery-builder/internal/build/run.go | 11 +++++------ 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go index bfc658dc..37a94c66 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go @@ -408,9 +408,8 @@ func main() { pk.Start(context.Background()) // The build modules are no names (design 47 G A-82): the build seats on the seat list, each held by the module the catalog // half's manifests say; the seat list and its two tools wired once by mesh-sdk (§204). - // Its callers name seats, never a module, resolved from the seat-holders view the catalog half's claimant serves (A-295, A-298). - gate := seatlist.NewPart("builder", []string{stdio.AnyPerson, stdio.CallerSeatPrefix + "node-tool-runner", stdio.CallerSeatPrefix + "mesh-healers"}) - gate.Holders(branches.SeatHolders(context.Background())) + // Its tools are open to every caller, so the part resolves no caller's seat to its holder (design 47 H H-A-66). + gate := seatlist.NewPart("builder") go func() { <-stdio.Served() gate.Follow(seatlist.StdioBus(), nil, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-builder-tools] "+f+"\n", a...) }) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go index d7760233..58afc2be 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go @@ -414,7 +414,7 @@ func (b *bed) manifestOf(t *testing.T, fixture string) map[string]any { // entry is the catalog graph entry of a module as the holder answers it. func (b *bed) entry(name, path, at, fp2, digest string, manifest map[string]any, toolchains map[string]builds.ToolchainUsed, src uint64) meshcatalog.CatalogEntry { return meshcatalog.CatalogEntry{Module: name, Repository: "novox/mesh-catalog", Commit: at, Fp: fp2, Path: path, ManifestDigest: digest, Manifest: manifest, - Inputs: &meshcatalog.EntryInputs{Toolchains: build.CatalogToolchains(toolchains), Src: int64(src)}} + Inputs: &meshcatalog.EntryInputs{Toolchains: build.CatalogToolchains(toolchains)}} } // archive writes modules. as the real indexer does for a module of an archive only: its fingerprint names no diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index d813037b..3ec551b5 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -121,9 +121,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // The part's own buckets are `_` of the credential's module (design 47 G A-296). own := ownBucketsOf(cred.Module) seatGate := newSeatGate() - // The part's one holder function (A-298): the seat list's callers and the views found by their seat (§717) read it. + // The part's one holder function (A-298): the views found by their seat (§717) read it; the seat list names no callers + // (design 47 H H-A-66). holders := branches.SeatHolders(ctx) - seatGate.Holders(holders) seats := buildrun.NewBuildSeats(seatGate.definitions, versions.HolderOf(branches)) bound := defaultStepBound if v := strings.TrimSpace(getenv("MESH_BUILDER_STEP_BOUND")); v != "" { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seatlist.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seatlist.go index 73afe11a..8c4f963b 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seatlist.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seatlist.go @@ -3,20 +3,17 @@ package main import ( "git.novox.be/novox/mesh-sdk/go/seatdef" "git.novox.be/novox/mesh-sdk/go/seatlist" - - stdio "git.novox.be/novox/mesh-sdk/go" ) // The builder reads the seat list as every part does, through mesh-sdk's one wiring (go/seatlist.Part; design 47 G §204): its // definitions name the build seats (the seats whose acting rule is the step build), its tools `builder_seat_list` and -// `builder_seat_list_again`. A call through the mesh MCP server is proved only as its machine's tool runner (issue 627). The -// list names seats, never a module, resolved by the holder function meshcatalogclient's SeatHolders answers (A-295, A-298). -var seatListAgainCallers = []string{stdio.AnyPerson, stdio.CallerSeatPrefix + "node-tool-runner", stdio.CallerSeatPrefix + "mesh-healers"} +// `builder_seat_list_again`, open to every caller (design 47 H H-A-66). The list names seats, never a module, resolved by the +// holder function meshcatalogclient's SeatHolders answers (A-295, A-298). // seatGate is the builder's wiring of the seat list. type seatGate struct{ *seatlist.Part } -func newSeatGate() *seatGate { return &seatGate{seatlist.NewPart("builder", seatListAgainCallers)} } +func newSeatGate() *seatGate { return &seatGate{seatlist.NewPart("builder")} } // definitions are the seat definitions the list holds, none before it is read. func (g *seatGate) definitions() map[string]seatdef.Definition { diff --git a/modules/mesh-delivery-builder/internal/build/entry_test.go b/modules/mesh-delivery-builder/internal/build/entry_test.go index dbf0432e..5ccbf04f 100644 --- a/modules/mesh-delivery-builder/internal/build/entry_test.go +++ b/modules/mesh-delivery-builder/internal/build/entry_test.go @@ -13,15 +13,20 @@ import ( func TestAnEntryOfTheCatalogHalfIsTheFormTheBuilderBuildsBy(t *testing.T) { e := meshcatalog.CatalogEntry{Module: "netcheck", Repository: "novox/mesh-catalog", Path: "modules/netcheck", Commit: "abc", Fp: "src2:f", ManifestDigest: "sha256:m", Bases: []string{"base"}, Packages: map[string]string{"p": "1"}, Needs: []string{"n"}, - Inputs: &meshcatalog.EntryInputs{Src: 7, Toolchains: map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1", Recipe: "1"}}, + Inputs: &meshcatalog.EntryInputs{Toolchains: map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1", Recipe: "1"}}, Paths: map[string][]string{"lib": {"a/b", "c"}}}} got := ModuleOf(e) - if got.Fp2 != "src2:f" || got.Manifest != "m" || got.Path != "modules/netcheck" || got.Commit != "abc" || got.Src != 7 || + if got.Fp2 != "src2:f" || got.Manifest != "m" || got.Path != "modules/netcheck" || got.Commit != "abc" || got.Toolchains["go"].Version != "go1" || got.Packages["p"] != "1" || !reflect.DeepEqual(got.Needs, []string{"n"}) || got.Inputs2 == nil || !reflect.DeepEqual(got.Inputs2.Bases, []string{"base"}) || !reflect.DeepEqual(got.Inputs2.Paths, map[string]string{"a/b": "lib", "c": "lib"}) { t.Errorf("ModuleOf = %+v", got) } + // A module value carries no source stamp (design 47 H H-A-48): its claim is numbered per fingerprint, naming no source + // revision and no merge. + if c := ClaimOf("netcheck", got, Plan{}); c.Revision != "" || c.Merge != 0 || c.Fingerprint != "src2:f" { + t.Errorf("ClaimOf = %+v", c) + } if bare := ModuleOf(meshcatalog.CatalogEntry{Module: "m"}); bare.Inputs2 != nil || bare.Fp2 != "" { t.Errorf("ModuleOf of an entry with none = %+v, want nothing set", bare) } diff --git a/modules/mesh-delivery-builder/internal/build/numbers.go b/modules/mesh-delivery-builder/internal/build/numbers.go index 9200129a..2aeefc0e 100644 --- a/modules/mesh-delivery-builder/internal/build/numbers.go +++ b/modules/mesh-delivery-builder/internal/build/numbers.go @@ -6,7 +6,6 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "git.novox.be/novox/mesh-sdk/go/catalogue" - "strconv" "strings" "time" @@ -30,14 +29,11 @@ type VersionNumbers struct { N *versions.Numberer } -// ClaimOf is the claim a module value's trunk build is numbered by: a package per source revision (Src), the rest per -// fingerprint, in merge order (Src). +// ClaimOf is the claim a module value's trunk build is numbered by, per fingerprint: a module value carries no source stamp +// (design 47 H H-A-48), so the claim names no source revision and no merge. func ClaimOf(module string, m meshcatalog.ModulesByModuleValue, plan Plan) versions.BuildClaim { c := versions.BuildClaim{Module: module, Path: m.Path, Repository: trunk.RepositoryName(m.Repository), Fingerprint: m.Fp2, - Commit: m.Commit, Merge: uint64(m.Src)} - if uint64(m.Src) != 0 { - c.Revision = strconv.FormatUint(uint64(m.Src), 10) - } + Commit: m.Commit} for _, t := range plan.Tasks { c.Artifacts = append(c.Artifacts, versions.ClaimArtifact{Artifact: t.Artifact, Kind: t.Kind, Language: t.Language}) } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 9b923a6a..fcabe73a 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -9,7 +9,6 @@ import ( "maps" "slices" "sort" - "strconv" "strings" "sync" "time" @@ -266,7 +265,7 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog. } // ModuleOf is a catalog entry in the form the builder builds by: its fingerprint, manifest digest, source (repository, -// directory, commit, the source revision it was taken in at), the toolchains its fingerprint was computed with, the bases it is +// directory, commit; no source stamp, design 47 H H-A-48), the toolchains its fingerprint was computed with, the bases it is // built against, its packages and needs, and the named paths of its artifacts. func ModuleOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue { m := meshcatalog.ModulesByModuleValue{Repository: e.Repository, Path: e.Path, Commit: e.Commit, Fp2: e.Fp, None2: e.None, @@ -275,7 +274,7 @@ func ModuleOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue { m.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{Bases: e.Bases} } if in := e.Inputs; in != nil { - m.Src, m.Toolchains, m.Problems = in.Src, in.Toolchains, in.Problems + m.Toolchains, m.Problems = in.Toolchains, in.Problems if len(in.Paths) > 0 { if m.Inputs2 == nil { m.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{} @@ -1217,15 +1216,15 @@ func (b *Builder) logBuild(e builds.BuildLogEntry) { b.Log(e) } -// LogStarted is the log's entry of a build of module's fingerprint starting (ADR 0571 §1): the module, the fingerprint, the -// source revision, where it is built from (repository, directory, commit, the candidate's ref), the node of the builder +// LogStarted is the log's entry of a build of module's fingerprint starting (ADR 0571 §1): the module, the fingerprint (no +// source stamp, design 47 H H-A-48), where it is built from (repository, directory, commit, the candidate's ref), the node of the builder // that asked it and the time. func LogStarted(module string, m meshcatalog.ModulesByModuleValue, ref, by string, at time.Time) builds.BuildLogEntry { dir := m.Path if dir == "" { dir = meshcatalogclient.RootPath } - return builds.BuildLogEntry{Event: builds.BuildStartedEvent, Module: module, FP: m.Fp2, Source: strconv.FormatUint(uint64(m.Src), 10), + return builds.BuildLogEntry{Event: builds.BuildStartedEvent, Module: module, FP: m.Fp2, Repository: m.Repository, Directory: dir, Commit: m.Commit, Ref: ref, Node: by, At: at.UTC()} } -- 2.54.0 From 11a22fdff79c12a053258c4ba9a897c970245ca8 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:47:03 +0100 Subject: [PATCH 034/104] X1: the checker goes: its module, its seat definition and its readers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The module mesh-delivery-checker goes whole with its manifest, and its seat's definition leaves the seat list. The status view reads no tries: build_usage answers no tries running and counts no step as a try. The grants part grants main's accept subject to the builder alone. The tests name no checker as an asker or a seat. The seat's generated packages, the indexer's readers and the assigner's verdict constants go in the join's cleanup, once those branches stand on this one (the lead, 2026-11-20). Builds: design 47 H §764 (the checker (H1): mesh-delivery-checker whole); lead answer H-A-57 (hq f599b761) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../checkermsg/checkermsg.go | 56 - .../mesh-delivery-checker/checkermsg/go.mod | 22 - .../mesh-delivery-checker/checkermsg/go.sum | 12 - .../cmd/mesh-checking-program/main.go | 52 - .../cmd/mesh-checking-program/main_test.go | 342 ---- .../cmd/mesh-delivery-checker-tools/main.go | 575 ------ .../mesh-delivery-checker-tools/main_test.go | 366 ---- .../cmd/mesh-delivery-checker/bus.go | 197 -- .../cmd/mesh-delivery-checker/couldnotrun.go | 47 - .../cmd/mesh-delivery-checker/engines.go | 167 -- .../mesh-delivery-checker/findingwriter.go | 77 - .../cmd/mesh-delivery-checker/forge.go | 59 - .../cmd/mesh-delivery-checker/forge_test.go | 109 -- .../mesh-delivery-checker/integration_test.go | 1373 -------------- .../cmd/mesh-delivery-checker/judge.go | 604 ------ .../cmd/mesh-delivery-checker/judge_test.go | 258 --- .../cmd/mesh-delivery-checker/judgeseats.go | 60 - .../cmd/mesh-delivery-checker/kept_test.go | 57 - .../cmd/mesh-delivery-checker/main.go | 538 ------ .../cmd/mesh-delivery-checker/nodes_test.go | 22 - .../cmd/mesh-delivery-checker/packages.go | 108 -- .../cmd/mesh-delivery-checker/refused_test.go | 62 - .../cmd/mesh-delivery-checker/renames.go | 36 - .../seatlist_wiring_test.go | 29 - .../cmd/mesh-delivery-checker/seats_test.go | 23 - .../cmd/mesh-delivery-checker/settings.go | 73 - .../mesh-delivery-checker/settings_test.go | 53 - .../catalogue-835bf22b-xterm.module.json | 236 --- .../cmd/mesh-delivery-checker/toolchains.go | 108 -- .../cmd/mesh-delivery-checker/trunk.go | 57 - .../cmd/mesh-delivery-checker/trunk_test.go | 38 - .../mesh-delivery-checker/try_candidates.go | 70 - .../cmd/mesh-delivery-checker/verdictsay.go | 43 - .../mesh-delivery-checker/files/settings.json | 4 - modules/mesh-delivery-checker/go.mod | 67 - modules/mesh-delivery-checker/go.sum | 25 - .../internal/check/adr548_test.go | 279 --- .../internal/check/askagain.go | 277 --- .../internal/check/beside.go | 218 --- .../internal/check/binaries.go | 27 - .../internal/check/binaries_test.go | 57 - .../internal/check/bounded.go | 79 - .../internal/check/build_change.go | 144 -- .../internal/check/builds.go | 169 -- .../internal/check/buildseats.go | 56 - .../internal/check/buildseats_test.go | 58 - .../internal/check/case.go | 292 --- .../internal/check/checker.go | 1126 ----------- .../internal/check/checker_test.go | 761 -------- .../internal/check/composition_test.go | 344 ---- .../internal/check/couldnotrun.go | 275 --- .../internal/check/declared.go | 115 -- .../internal/check/digestform_test.go | 84 - .../internal/check/doc.go | 6 - .../internal/check/engines.go | 261 --- .../internal/check/engines_test.go | 392 ---- .../internal/check/every_failure_test.go | 119 -- .../internal/check/examiner_test.go | 1671 ----------------- .../internal/check/failure_words_test.go | 108 -- .../internal/check/fakes_test.go | 81 - .../internal/check/gate_test.go | 89 - .../internal/check/graph_edges.go | 116 -- .../internal/check/heard.go | 21 - .../internal/check/judge.go | 992 ---------- .../internal/check/judged_test.go | 208 -- .../internal/check/kept.go | 101 - .../internal/check/kept_test.go | 130 -- .../internal/check/line.go | 394 ---- .../internal/check/line_test.go | 193 -- .../internal/check/lostask.go | 36 - .../internal/check/lostask_test.go | 418 ----- .../internal/check/manifests_judge.go | 401 ---- .../internal/check/manifests_judge_test.go | 23 - .../internal/check/names.go | 83 - .../internal/check/owed.go | 49 - .../internal/check/package_cause_test.go | 109 -- .../internal/check/pins.go | 76 - .../internal/check/pins_test.go | 301 --- .../internal/check/preview.go | 87 - .../internal/check/preview_named_test.go | 24 - .../internal/check/programs.go | 294 --- .../internal/check/rank_test.go | 117 -- .../internal/check/read.go | 791 -------- .../internal/check/read_test.go | 446 ----- .../internal/check/renames.go | 100 - .../internal/check/requests.go | 299 --- .../internal/check/results.go | 43 - .../internal/check/seatdefs.go | 41 - .../internal/check/series.go | 150 -- .../internal/check/store.go | 24 - .../internal/check/testdata/captured/README | 17 - .../captured/forge-get-file-go-mod.json | 9 - .../check/testdata/captured/go-digest.json | 11 - .../testdata/captured/go-fetch-clean.json | 1 - .../testdata/captured/go-fetch-conflict.json | 1 - .../testdata/captured/go-test-empty.json | 21 - .../testdata/captured/go-test-failing.json | 45 - .../check/testdata/captured/go-test-slow.json | 30 - .../testdata/captured/node-fetch-clean.json | 1 - .../internal/check/trunkview.go | 31 - .../internal/check/try.go | 852 --------- .../internal/check/try_test.go | 505 ----- .../internal/check/verdictevent.go | 44 - .../mesh-delivery-checker/manifest_test.go | 325 ---- modules/mesh-delivery-checker/module.json | 214 --- modules/mesh-delivery-checker/reads-outside | 1 - modules/mesh-delivery-checker/rules/facts.go | 306 --- modules/mesh-delivery-checker/rules/graph.go | 114 -- modules/mesh-delivery-checker/rules/judged.go | 288 --- .../mesh-delivery-checker/rules/language.go | 8 - modules/mesh-delivery-checker/rules/names.go | 38 - .../mesh-delivery-checker/rules/program.go | 54 - .../mesh-delivery-checker/rules/refusals.go | 99 - .../mesh-delivery-checker/rules/results.go | 63 - modules/mesh-delivery-checker/rules/seats.go | 343 ---- modules/mesh-delivery-checker/rules/words.go | 281 --- .../fixtures/events.json | 77 - .../fixtures/states.json | 84 - .../mesh-delivery-checker/fixtures/verbs.json | 17 - .../seats/mesh-delivery-checker/seat.json | 862 --------- .../mesh-delivery-forge-bridge/gate_test.go | 2 +- .../cmd/mesh-delivery-view-tools/main.go | 8 +- .../cmd/mesh-delivery-view-tools/main_test.go | 6 +- .../mesh-delivery-view/integration_test.go | 2 +- .../internal/view/backlog_test.go | 2 +- .../mesh-delivery-view/internal/view/usage.go | 90 +- .../internal/view/usage_test.go | 26 +- modules/mesh-delivery-view/manifest_test.go | 2 +- modules/mesh-delivery-view/module.json | 1 - .../internal/buscompose/buscompose_test.go | 24 +- .../internal/buscompose/named_asks_test.go | 12 +- .../internal/buscompose/seattraffic.go | 6 +- .../internal/grants/statecap_test.go | 4 +- 133 files changed, 52 insertions(+), 24055 deletions(-) delete mode 100644 modules/mesh-delivery-checker/checkermsg/checkermsg.go delete mode 100644 modules/mesh-delivery-checker/checkermsg/go.mod delete mode 100644 modules/mesh-delivery-checker/checkermsg/go.sum delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-checking-program/main.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-checking-program/main_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/bus.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/couldnotrun.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/engines.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/findingwriter.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/integration_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judgeseats.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/kept_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/nodes_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/packages.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/refused_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/renames.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seatlist_wiring_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seats_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/testdata/catalogue-835bf22b-xterm.module.json delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/toolchains.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk_test.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/try_candidates.go delete mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/verdictsay.go delete mode 100644 modules/mesh-delivery-checker/files/settings.json delete mode 100644 modules/mesh-delivery-checker/go.mod delete mode 100644 modules/mesh-delivery-checker/go.sum delete mode 100644 modules/mesh-delivery-checker/internal/check/adr548_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/askagain.go delete mode 100644 modules/mesh-delivery-checker/internal/check/beside.go delete mode 100644 modules/mesh-delivery-checker/internal/check/binaries.go delete mode 100644 modules/mesh-delivery-checker/internal/check/binaries_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/bounded.go delete mode 100644 modules/mesh-delivery-checker/internal/check/build_change.go delete mode 100644 modules/mesh-delivery-checker/internal/check/builds.go delete mode 100644 modules/mesh-delivery-checker/internal/check/buildseats.go delete mode 100644 modules/mesh-delivery-checker/internal/check/buildseats_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/case.go delete mode 100644 modules/mesh-delivery-checker/internal/check/checker.go delete mode 100644 modules/mesh-delivery-checker/internal/check/checker_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/composition_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/couldnotrun.go delete mode 100644 modules/mesh-delivery-checker/internal/check/declared.go delete mode 100644 modules/mesh-delivery-checker/internal/check/digestform_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/doc.go delete mode 100644 modules/mesh-delivery-checker/internal/check/engines.go delete mode 100644 modules/mesh-delivery-checker/internal/check/engines_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/every_failure_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/examiner_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/failure_words_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/fakes_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/gate_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/graph_edges.go delete mode 100644 modules/mesh-delivery-checker/internal/check/heard.go delete mode 100644 modules/mesh-delivery-checker/internal/check/judge.go delete mode 100644 modules/mesh-delivery-checker/internal/check/judged_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/kept.go delete mode 100644 modules/mesh-delivery-checker/internal/check/kept_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/line.go delete mode 100644 modules/mesh-delivery-checker/internal/check/line_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/lostask.go delete mode 100644 modules/mesh-delivery-checker/internal/check/lostask_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/manifests_judge.go delete mode 100644 modules/mesh-delivery-checker/internal/check/manifests_judge_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/names.go delete mode 100644 modules/mesh-delivery-checker/internal/check/owed.go delete mode 100644 modules/mesh-delivery-checker/internal/check/package_cause_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/pins.go delete mode 100644 modules/mesh-delivery-checker/internal/check/pins_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/preview.go delete mode 100644 modules/mesh-delivery-checker/internal/check/preview_named_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/programs.go delete mode 100644 modules/mesh-delivery-checker/internal/check/rank_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/read.go delete mode 100644 modules/mesh-delivery-checker/internal/check/read_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/renames.go delete mode 100644 modules/mesh-delivery-checker/internal/check/requests.go delete mode 100644 modules/mesh-delivery-checker/internal/check/results.go delete mode 100644 modules/mesh-delivery-checker/internal/check/seatdefs.go delete mode 100644 modules/mesh-delivery-checker/internal/check/series.go delete mode 100644 modules/mesh-delivery-checker/internal/check/store.go delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/README delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/forge-get-file-go-mod.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/go-digest.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-clean.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-conflict.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-empty.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-failing.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-slow.json delete mode 100644 modules/mesh-delivery-checker/internal/check/testdata/captured/node-fetch-clean.json delete mode 100644 modules/mesh-delivery-checker/internal/check/trunkview.go delete mode 100644 modules/mesh-delivery-checker/internal/check/try.go delete mode 100644 modules/mesh-delivery-checker/internal/check/try_test.go delete mode 100644 modules/mesh-delivery-checker/internal/check/verdictevent.go delete mode 100644 modules/mesh-delivery-checker/manifest_test.go delete mode 100644 modules/mesh-delivery-checker/module.json delete mode 100644 modules/mesh-delivery-checker/reads-outside delete mode 100644 modules/mesh-delivery-checker/rules/facts.go delete mode 100644 modules/mesh-delivery-checker/rules/graph.go delete mode 100644 modules/mesh-delivery-checker/rules/judged.go delete mode 100644 modules/mesh-delivery-checker/rules/language.go delete mode 100644 modules/mesh-delivery-checker/rules/names.go delete mode 100644 modules/mesh-delivery-checker/rules/program.go delete mode 100644 modules/mesh-delivery-checker/rules/refusals.go delete mode 100644 modules/mesh-delivery-checker/rules/results.go delete mode 100644 modules/mesh-delivery-checker/rules/seats.go delete mode 100644 modules/mesh-delivery-checker/rules/words.go delete mode 100644 modules/mesh-delivery-contracts/seats/mesh-delivery-checker/fixtures/events.json delete mode 100644 modules/mesh-delivery-contracts/seats/mesh-delivery-checker/fixtures/states.json delete mode 100644 modules/mesh-delivery-contracts/seats/mesh-delivery-checker/fixtures/verbs.json delete mode 100644 modules/mesh-delivery-contracts/seats/mesh-delivery-checker/seat.json diff --git a/modules/mesh-delivery-checker/checkermsg/checkermsg.go b/modules/mesh-delivery-checker/checkermsg/checkermsg.go deleted file mode 100644 index 978f52f2..00000000 --- a/modules/mesh-delivery-checker/checkermsg/checkermsg.go +++ /dev/null @@ -1,56 +0,0 @@ -// Package checkermsg is the checker's own published layouts (as forgemsg is the forge bridge's): the bodies of its events on the -// stream checks and the answer of its tool checker_tries. It is what the checker says on its stream checks when a whole try (a try of a delivery group, not narrowed -// to a level or to some tests) starts and ends (issue 1921), and what the indexer, which hears it, reads: a try has no pull -// request, so the indexer writes the candidate of its group from the members at their commits, and deletes it at the end. -// The events carry the members, so no part reads the checker's state. -package checkermsg - -import ( - "encoding/json" - "fmt" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" -) - -// The events of the checker's stream checks. -const ( - Started = "try.started" - Ended = "try.ended" -) - -// Member is one repository of the try: the exact commit and the trunk commit it is merged onto. -type Member struct { - Repository string `json:"repository"` - Head string `json:"head"` - Trunk string `json:"trunk"` -} - -// Event is the body of both events: the try, and for Started its members; for Ended the state it ended in. -type Event struct { - ID string `json:"id"` - Members []Member `json:"members,omitempty"` - State string `json:"state,omitempty"` -} - -// Decode reads an event body; a started event names its members. -func Decode(event string, body []byte) (Event, error) { - var e Event - if err := json.Unmarshal(body, &e); err != nil { - return e, err - } - if !meshcatalogclient.IsTryGroup(e.ID) { - return e, fmt.Errorf("%q is not a try's id, try-", e.ID) - } - if event == Started && len(e.Members) == 0 { - return e, fmt.Errorf("the try %s starts with no member", e.ID) - } - return e, nil -} - -// Open is one try that waits or runs, as the checker's tool checker_tries answers it. -type Open struct { - ID string `json:"id"` - State string `json:"state"` - Whole bool `json:"whole"` - Members []Member `json:"members"` -} diff --git a/modules/mesh-delivery-checker/checkermsg/go.mod b/modules/mesh-delivery-checker/checkermsg/go.mod deleted file mode 100644 index 48e0db10..00000000 --- a/modules/mesh-delivery-checker/checkermsg/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg - -go 1.26.0 - -require git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient v0.0.0-00010101000000-000000000000 - -require ( - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 // indirect -) - -require git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery v0.0.0-00010101000000-000000000000 // indirect - -require ( - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk v0.0.0-00010101000000-000000000000 // indirect - github.com/klauspost/compress v1.20.1 // indirect - github.com/nats-io/nats.go v1.54.0 // indirect - github.com/nats-io/nkeys v0.4.16 // indirect - github.com/nats-io/nuid v1.0.1 // indirect - golang.org/x/crypto v0.57.0 // indirect - golang.org/x/sys v0.48.0 // indirect -) diff --git a/modules/mesh-delivery-checker/checkermsg/go.sum b/modules/mesh-delivery-checker/checkermsg/go.sum deleted file mode 100644 index 0daef11f..00000000 --- a/modules/mesh-delivery-checker/checkermsg/go.sum +++ /dev/null @@ -1,12 +0,0 @@ -github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ= -github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= -github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA= -github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k= -github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg= -github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs= -github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M= -golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA= -golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo= -golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= diff --git a/modules/mesh-delivery-checker/cmd/mesh-checking-program/main.go b/modules/mesh-delivery-checker/cmd/mesh-checking-program/main.go deleted file mode 100644 index fc829bc8..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-checking-program/main.go +++ /dev/null @@ -1,52 +0,0 @@ -// Command mesh-checking-program is the checker's checking program (novox/hq ADR 0644, ADR 0656; design 47's bootstrap -// delivery): built from a check's heads and run in the build seat's sandbox through the seat node-build-go's ask run, -// with no network and no bus account, it reads the check's facts from the file MESH_RUN_INPUT names and answers the -// verdict the judging rules give them, as one JSON line on its standard output (rules.Answer). -// -// mesh-checking-program -verdict -// mesh-checking-program -seats -// -// Asked -seats, it answers the seat list of the heads laid in the directory MESH_RUN_HEADS names (rules.SeatsAnswer). -// It refuses facts of a version it does not read, naming it, with exit 2. -package main - -import ( - "fmt" - "io" - "io/fs" - "os" - "slices" - - "mesh-delivery-checker/rules" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -func main() { - os.Exit(run(os.Args[1:], os.Getenv, os.Stdout, os.Stderr)) -} - -// run is the command over its arguments, environment and outputs, answering its exit. -func run(args []string, getenv func(string) string, stdout, stderr io.Writer) int { - var heads fs.FS - if dir := getenv(buildstep.RunHeadsEnv); dir != "" { - heads = os.DirFS(dir) - } - input := func() ([]byte, error) { - file := getenv(buildstep.RunInputEnv) - if file == "" { - return nil, fmt.Errorf("%s names no file", buildstep.RunInputEnv) - } - return os.ReadFile(file) - } - line, err := rules.Program(args, input, heads) - if err != nil { - if heads == nil && slices.Contains(args, "-seats") { - err = fmt.Errorf("no heads: %s names no directory", buildstep.RunHeadsEnv) - } - fmt.Fprintf(stderr, "mesh-checking-program: %v\n", err) - return 2 - } - fmt.Fprintf(stdout, "%s\n", line) - return 0 -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-checking-program/main_test.go b/modules/mesh-delivery-checker/cmd/mesh-checking-program/main_test.go deleted file mode 100644 index 972fa7d8..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-checking-program/main_test.go +++ /dev/null @@ -1,342 +0,0 @@ -package main - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "io/fs" - "os" - "path" - "path/filepath" - "reflect" - "strings" - "testing" - - "mesh-delivery-checker/rules" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/seatdefs" - "git.novox.be/novox/mesh-sdk/go/seatdef" -) - -// 1921 (B0, D2): the checking program answers, on its last line, the verdict the rules give the facts in its input, and -// refuses facts of a version it does not read, an input it is not given, and a question it is not asked, naming each. -// 1921 (B0, D3): asked -seats, it answers the seat list of the heads laid for it: a definition a head adds, resolved with -// the parts it includes; what it left out, and why; and an empty list for heads with no definition. -func TestTheCheckingProgramAnswersTheVerdictOfItsFacts(t *testing.T) { - failing, _ := json.Marshal(rules.Tested{Level: buildstep.LevelUnit, Tests: 3, Failed: []rules.Failure{{Package: "x/a", Test: "TestA", Cause: "a_test.go:9: boom"}}}) - facts := rules.Facts{V: rules.FactsVersion, Group: "feat/x", Heads: "0123456789ab", Members: []rules.Member{{Repository: "novox/x", Number: 3, Head: "h"}}, - Steps: []rules.Step{ - {Repository: "novox/x", Number: 3, Module: "mesh-build-go", Node: "laptop", Level: &buildstep.LevelAnswer{Level: buildstep.LevelUnit, Tests: []json.RawMessage{failing}}}, - {Repository: "novox/x", Number: 3, Failed: &rules.FailedFirst{Machine: "laptop", Words: "novox/x#3 has files in conflict: go.mod"}}, - }} - dir := t.TempDir() - write := func(name string, v any) string { - data, _ := json.Marshal(v) - p := filepath.Join(dir, name) - if err := os.WriteFile(p, data, 0o600); err != nil { - t.Fatal(err) - } - return p - } - v1 := write("v1.json", facts) - later := facts - later.V = rules.FactsVersion + 1 - v2 := write("v2.json", later) - // The heads as the build node lays them, each at its repository's path: a contracts module of its own defining a seat - // with a part, and the mesh's own contracts module defining a seat of a domain that is not its (ADR 0636 §5). - lay := func(name string, files map[string]string) string { - root := filepath.Join(dir, name) - for p, body := range files { - if err := os.MkdirAll(filepath.Dir(filepath.Join(root, p)), 0o755); err != nil { - t.Fatal(err) - } - if err := os.WriteFile(filepath.Join(root, p), []byte(body), 0o600); err != nil { - t.Fatal(err) - } - } - return root - } - contracts := func(module string) string { - return `{"module": "` + module + `", "build": {"artifacts": [{"name": "go", "kind": "package", "language": "go", "generated-from": "."}]}}` - } - heads := lay("heads", map[string]string{ - "novox/x/x-contracts/module.json": contracts("x-contracts"), - "novox/x/x-contracts/seats/node-build-x/seat.json": `{"format":1,"seat":"node-build-x","scope":"node","grain":"whole","domain":"Delivery","decision":"ADR 1","description":"kept","includes":["build"],"verbs":[{"name":"own","input":{"type":"object","properties":{"credentials":{"$ref":"#/defs/Sealed"}}},"answer":{"type":"object"}}],"defs":{"Sealed":{"type":"object"}}}`, - "novox/x/x-contracts/parts/build.json": `{"format":1,"part":"build","verbs":[{"name":"current","input":{"type":"object"},"answer":{"type":"object"}}],"events":[{"name":"ended","body":{"type":"object"}}]}`, - "novox/x/contracts/module.json": contracts("mesh-contracts"), - "novox/x/contracts/seats/mesh-catalog/seat.json": `{"format":1,"seat":"mesh-catalog","scope":"mesh","grain":"whole","domain":"Delivery","decision":"ADR 1"}`, - }) - broken := lay("broken", map[string]string{ - "novox/x/x-contracts/module.json": contracts("x-contracts"), - "novox/x/x-contracts/seats/broken/seat.json": `{"format":1,"seat":"broken","scope":"nowhere"}`, - }) - none := filepath.Join(dir, "no-heads") - if err := os.MkdirAll(filepath.Join(none, "novox/x"), 0o755); err != nil { - t.Fatal(err) - } - for name, c := range map[string]struct { - args []string - input, heads string - exit int - said string - }{ - "the seats": {args: []string{"-seats"}, input: v1, heads: heads}, - "no seats": {args: []string{"-seats"}, input: v1, heads: none}, - "a seat unparsed": {args: []string{"-seats"}, input: v1, heads: broken, exit: 2, said: "the seat definition of broken (module x-contracts) at the head of novox/x is not taken"}, - "no heads laid": {args: []string{"-seats"}, exit: 2, said: buildstep.RunHeadsEnv + " names no directory"}, - "the facts": {args: []string{"-verdict"}, input: v1}, - "a later version": {args: []string{"-verdict"}, input: v2, exit: 2, said: "facts of version 2, this checking program reads version 1"}, - "no input": {args: []string{"-verdict"}, exit: 2, said: buildstep.RunInputEnv + " names no file"}, - "nothing asked": {input: v1, exit: 2, said: "nothing asked"}, - "an unknown asking": {args: []string{"-judge"}, input: v1, exit: 2, said: "-judge"}, - } { - var out, errs bytes.Buffer - exit := run(c.args, func(k string) string { - switch k { - case buildstep.RunInputEnv: - return c.input - case buildstep.RunHeadsEnv: - return c.heads - } - return "" - }, &out, &errs) - if exit != c.exit || !strings.Contains(errs.String(), c.said) { - t.Errorf("%s: exit %d, said %q; want %d and %q", name, exit, errs.String(), c.exit, c.said) - continue - } - if c.exit != 0 { - continue - } - lines := strings.Split(strings.TrimSpace(out.String()), "\n") - if c.heads != "" { - var sa rules.SeatsAnswer - if err := json.Unmarshal([]byte(lines[len(lines)-1]), &sa); err != nil || sa.V != rules.SeatsVersion || sa.Seats == nil { - t.Fatalf("%s: the last line %q: %v", name, lines[len(lines)-1], err) - } - if c.heads == none { - if len(sa.Seats) != 0 || len(sa.Left) != 0 { - t.Errorf("%s: %+v, want an empty list", name, sa) - } - continue - } - var d struct { - Seat string `json:"seat"` - Verbs []struct { - Name string `json:"name"` - } `json:"verbs"` - } - if len(sa.Seats) == 1 { - _ = json.Unmarshal(sa.Seats[0], &d) - } - if d.Seat != "node-build-x" || len(d.Verbs) != 2 || len(sa.Left) != 1 || !strings.Contains(sa.Left[0].Why, "whose seats mesh-delivery-contracts defines") { - t.Errorf("%s: seats %s, left %+v; want node-build-x with its part's verb, and mesh-catalog left out", name, sa.Seats, sa.Left) - } - // The group check of 616c42434ac2: a checker from before G (no digests in these facts) writes the answer into the - // build seat's step state, whose writer refuses a value with a field named like a credential, here a schema's - // property name; the answer carries no verb's or message's schema and no type only they referred to. - if len(sa.Seats) == 1 && (bytes.Contains(sa.Seats[0], []byte("credentials")) || bytes.Contains(sa.Seats[0], []byte("Sealed"))) { - t.Errorf("%s: %s carries a verb's schema to a checker that hands no digests", name, sa.Seats[0]) - } - continue - } - var a rules.Answer - if err := json.Unmarshal([]byte(lines[len(lines)-1]), &a); err != nil || a.V != rules.AnswerVersion { - t.Fatalf("%s: the last line %q: %v", name, lines[len(lines)-1], err) - } - if want := rules.Judge(facts); !reflect.DeepEqual(a.Verdict, want) || a.Verdict.State != meshdeliverycheckerclient.VerdictFail || len(a.Verdict.Failures) != 2 || - a.Verdict.Failures[1].Words != "novox/x#3 has files in conflict: go.mod" || a.Verdict.Machines[0] != "laptop" || a.Verdict.Levels[buildstep.LevelUnit].Run != 3 { - t.Errorf("%s: the verdict %+v, want %+v", name, a.Verdict, want) - } - } - // Review finding 3 of milestone 47/G: the heads of a real group carry every seat definition the reader holds, unchanged - // (this repository's own contracts, laid as its head): the answer leaves them all to the checker's list and stays - // far below the whole list. - t.Run("heads carrying every definition the reader holds unchanged answer none of them", func(t *testing.T) { - real := under{prefix: "novox/mesh-delivery", fs: os.DirFS("../../../..")} - group := rules.Facts{V: rules.FactsVersion, Members: []rules.Member{{Repository: "novox/mesh-delivery", Head: "h"}}} - // An empty list of digests answers every definition whole (a checker that hands its list's digests, holding none). - whole, err := rules.SeatsOf(real, rules.Facts{V: rules.FactsVersion, Members: group.Members, SeatDigests: map[string]string{}}) - if err != nil || len(whole.Seats) < 10 { - t.Fatalf("the repository's own definitions: %d, %v", len(whole.Seats), err) - } - // The reader's digests are of each definition whole, as the seat mesh-catalog answers it; the answer is its judging view. - group.SeatDigests = wholeDigests(t, real, "novox/mesh-delivery") - same, err := rules.SeatsOf(real, group) - answer, _ := json.Marshal(same) - if err != nil || len(same.Seats) != 0 || same.Same != len(whole.Seats) { - t.Errorf("unchanged heads answer %d definitions (%d the same), %d bytes; want none, all %d the same: %v", - len(same.Seats), same.Same, len(answer), len(whole.Seats), err) - } - // Review round 2 of G: a checker from before G (B0's, which makes G's own check) hands no digests, and the answer - // then keeps each seat's own description only, so a group's whole list stays within the bound; each still parses. - b0, err := rules.SeatsOf(real, rules.Facts{V: rules.FactsVersion, Members: group.Members}) - if err != nil || len(b0.Seats) != len(whole.Seats) { - t.Fatalf("B0-shaped facts: %d definitions, %v", len(b0.Seats), err) - } - for i, raw := range b0.Seats { - var own struct { - Description string `json:"description"` - } - _ = json.Unmarshal(whole.Seats[i], &own) - var d struct { - Description string `json:"description"` - Verbs []json.RawMessage `json:"verbs"` - Events []json.RawMessage `json:"events"` - } - _ = json.Unmarshal(raw, &d) - inner := 0 - for _, m := range append(d.Verbs, d.Events...) { - inner += strings.Count(string(m), `"description":"`) - } - parsed, perr := seatdef.Parse(raw) - for _, v := range parsed.Verbs { - if len(v.Input) != 0 || len(v.Answer) != 0 { - t.Errorf("B0-shaped facts answer %s's verb %s with its schemas; want none", parsed.Seat, v.Name) - } - } - for name := range parsed.Defs { - if !bytes.Contains(raw, []byte(`"#/defs/`+name+`"`)) { - t.Errorf("B0-shaped facts answer %s with the type %s, which nothing it keeps refers to", parsed.Seat, name) - } - } - if inner > 0 || d.Description != own.Description || perr != nil { - t.Errorf("B0-shaped facts answer %s with %d inner descriptions, its own %q: %v; want only its own", raw[:min(len(raw), 80)], inner, d.Description, perr) - } - } - if answer, _ := json.Marshal(b0); len(answer) >= len(mustJSON(t, whole))*3/4 { - t.Errorf("B0-shaped facts answer %d bytes (whole %d), want far below the whole", len(answer), len(mustJSON(t, whole))) - } - // One definition the heads change is answered alone. - for seat := range group.SeatDigests { - group.SeatDigests[seat] = "changed" - break - } - if one, err := rules.SeatsOf(real, group); err != nil || len(one.Seats) != 1 { - t.Errorf("one changed definition: answered %d, %v", len(one.Seats), err) - } - }) - // The lead's ruling after G's group check of 616c42434ac2: with digests given too, a changed definition whose verb input - // has a property named credentials is answered as the validator and the composer read it, with no such field. - changed, err := rules.SeatsOf(os.DirFS(heads), rules.Facts{V: rules.FactsVersion, Members: facts.Members, - SeatDigests: map[string]string{"node-build-x": "changed"}}) - if err != nil || len(changed.Seats) != 1 || bytes.Contains(changed.Seats[0], []byte("credentials")) || bytes.Contains(changed.Seats[0], []byte("Sealed")) { - t.Errorf("a changed definition with digests given: %d answered, %s, %v; want it alone, with no verb's schema", len(changed.Seats), changed.Seats, err) - } - // Review round 1 of milestone 47/B0: the module graph's cycle rule is the program's (ADR 0603 §2, ADR 0656 §5), over the - // edges the running checker gathers. A cycle the change makes fails; one the trunk has among the same modules is noted. - web, mail := rules.Edge{From: "web", To: "mail", Kind: rules.EdgeAwaits}, rules.Edge{From: "mail", To: "web", Kind: rules.EdgeAwaits} - only := func(e rules.Edge, where string) rules.Edge { e.Only = where; return e } - for _, row := range []struct { - name string - graph rules.Graph - fails string - note string - }{ - {name: "no cycle", graph: rules.Graph{Trunk: true, Edges: []rules.Edge{web}}, note: "has no cycle"}, - {name: "a cycle the change makes", graph: rules.Graph{Trunk: true, Edges: []rules.Edge{mail, only(web, rules.EdgeChange)}}, fails: "has the cycle mail -> web -> mail"}, - {name: "a cycle the trunk has", graph: rules.Graph{Trunk: true, Edges: []rules.Edge{mail, web}}, note: "which the trunk already has"}, - {name: "the trunk unread", graph: rules.Graph{Edges: []rules.Edge{mail, web}}, fails: "has the cycle mail -> web -> mail"}, - {name: "a base on itself", graph: rules.Graph{Trunk: true, Edges: []rules.Edge{only(rules.Edge{From: "web", To: "web", Kind: rules.EdgeBase}, rules.EdgeChange)}}, fails: "has the cycle web -> web"}, - {name: "an edge only the trunk has", graph: rules.Graph{Trunk: true, Edges: []rules.Edge{mail, only(web, rules.EdgeTrunk)}}, note: "has no cycle"}, - } { - g := row.graph - a := rules.Judged(rules.Facts{V: rules.FactsVersion, Steps: []rules.Step{{Graph: &g}}}) - if row.fails != "" && (a.Verdict.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(a.Verdict.Failed.Words, row.fails)) { - t.Errorf("%s: verdict %+v, want a fail saying %q", row.name, a.Verdict, row.fails) - } - if row.note != "" && (a.Verdict.State != meshdeliverycheckerclient.VerdictPass || !strings.Contains(strings.Join(a.Notes, "\n"), row.note)) { - t.Errorf("%s: verdict %s, notes %q, want a pass noting %q", row.name, a.Verdict.State, a.Notes, row.note) - } - } -} - -// under is a directory laid at a repository's path of the heads, as the build node lays a head. -type under struct { - prefix string - fs fs.FS -} - -func (u under) Open(name string) (fs.File, error) { - if name == u.prefix { - return u.fs.Open(".") - } - if rest, ok := strings.CutPrefix(name, u.prefix+"/"); ok { - return u.fs.Open(rest) - } - return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist} -} - -func mustJSON(t *testing.T, v any) []byte { - t.Helper() - out, err := json.Marshal(v) - if err != nil { - t.Fatal(err) - } - return out -} - -// wholeDigests are the digests of a head's seat definitions whole (rules.SeatDigest), read by the domain SDK as the -// indexer reads them: what a checker's reader holds for heads that change none. -func wholeDigests(t *testing.T, root fs.FS, repository string) map[string]string { - t.Helper() - head, err := fs.Sub(root, repository) - if err != nil { - t.Fatal(err) - } - manifests := map[string]string{} - _ = fs.WalkDir(head, ".", func(p string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - if d.IsDir() && (d.Name() == ".git" || d.Name() == "testdata" || d.Name() == "node_modules") { - return fs.SkipDir - } - if !d.IsDir() && d.Name() == "module.json" { - raw, _ := fs.ReadFile(head, p) - manifests[path.Dir(p)] = string(raw) - } - return nil - }) - forge := seatdefs.Forge{ - Files: func(_ context.Context, _, _ string, dirs []string) (map[string]map[string]string, error) { - out := map[string]map[string]string{} - for _, dir := range dirs { - files := map[string]string{} - if err := fs.WalkDir(head, dir, func(p string, d fs.DirEntry, err error) error { - if err == nil && !d.IsDir() { - files[strings.TrimPrefix(p, dir+"/")] = "" - } - return err - }); err == nil { - out[dir] = files - } - } - return out, nil - }, - File: func(_ context.Context, _, _, file string) ([]byte, error) { - raw, err := fs.ReadFile(head, file) - if errors.Is(err, fs.ErrNotExist) { - return nil, nil - } - return raw, err - }, - } - out := map[string]string{} - if len(manifests) == 0 { - t.Fatalf("no manifest at the head of %s", repository) - } - for _, c := range seatdefs.ContractsModules(manifests) { - defs, _, err := forge.Read(context.Background(), repository, "h", c) - if err != nil { - t.Fatal(err) - } - for seat, d := range defs { - raw, _ := json.Marshal(d) - out[seat] = rules.SeatDigest(raw) - } - } - return out -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main.go deleted file mode 100644 index eceea22b..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main.go +++ /dev/null @@ -1,575 +0,0 @@ -// Command mesh-delivery-checker-tools serves the checker's read tools (novox/hq ADR 0484 clause 13, issue 1686): the runtime -// launches it for a call, it reads the checker's verdicts and kept states through the checker's state and reads, and the -// indexer's candidates and modules through the indexer's read tools. It writes only the tries (the try's tools) and, asking a check again by hand, one verdict. The checker is the other program: it serves no tool (ADR 0437 §4). -package main - -import ( - "encoding/json" - "fmt" - "os" - "strings" - "sync/atomic" - "time" - - "mesh-delivery-checker/internal/check" - - "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/buscalls" - "git.novox.be/novox/mesh-sdk/go/seatdef" - "git.novox.be/novox/mesh-sdk/go/seatlist" - "git.novox.be/novox/mesh-sdk/go/views" -) - -// reads counts the values this call read from the bus: the runtime launches the tools for one call, so the count is the call's. -var reads atomic.Int64 - -// cutAnswer says in the answer that it was cut, and how to narrow it. -func cutAnswer(answer map[string]any, cut string) map[string]any { - if cut != "" { - answer["cut"], answer["note"] = true, cut - } - return answer -} - -// logged runs every tool with one line to stderr per call: the tool, the values it read and the time it took. -func logged(tools []stdio.Tool) []stdio.Tool { - for i := range tools { - name, run := tools[i].Name, tools[i].Run - tools[i].Run = func(args map[string]any) (any, error) { - reads.Store(0) - start := time.Now() - out, err := run(args) - fmt.Fprintf(os.Stderr, "[mesh-delivery-checker-tools] %s read %d values in %s (error: %v)\n", name, reads.Load(), time.Since(start).Round(time.Millisecond), err) - return out, err - } - } - return tools -} - -func read(s stdio.KeptState) check.StateRead { - return check.StateRead{Keys: s.Keys, Get: func(key string) (json.RawMessage, error) { - reads.Add(1) - e, err := s.Get(key) - if err != nil || e == nil { - return nil, err - } - return e.Value, nil - }} -} - -// ownerRead is a state of another module read through that module's ordinary read tool (views.ReadTool), asked through ask -// (stdio.Ask, or a test's): its keys with no argument, one key's value with key. Another module's data is asked through its -// tools, never read from its bus state (novox/hq ADR 0596); the manifest invokes the tool, and the owner answers every reader -// that invokes it. Each read is asked when it is read: the owner's state is the truth, and the tools keep no copy. -func ownerRead(ask func(string, any) (json.RawMessage, error), tool string) check.StateRead { - call := func(args map[string]any, into any) error { - reads.Add(1) - raw, err := ask(tool, args) - if err != nil { - return fmt.Errorf("%s does not answer: %w", tool, err) - } - answer, said, ok := buscalls.Unwrap(raw) - if !ok { - return fmt.Errorf("%s answered: %s", tool, said) - } - if err := json.Unmarshal(answer, into); err != nil { - return fmt.Errorf("%s answered what does not decode: %w", tool, err) - } - return nil - } - return check.StateRead{ - Keys: func() ([]string, error) { - var a views.ReadAnswer - if err := call(map[string]any{}, &a); err != nil { - return nil, err - } - return a.Keys, nil - }, - Get: func(key string) (json.RawMessage, error) { - var a views.KeyAnswer - if err := call(map[string]any{"key": key}, &a); err != nil { - return nil, err - } - if !a.Found { - return nil, nil - } - return a.Value, nil - }} -} - -// The indexer's read tools the tools ask for its candidates and modules (the manifest's invokes name them under the indexer's -// module; the call goes to the holder of the seat mesh-catalog, atHolder). -const ( - indexerCandidatesTool = "indexer_read_candidates" - indexerModulesTool = "indexer_read_modules" -) - -// atHolder asks a tool of the module that holds the seat when it is asked (design 47 G A-210, §428), as the view's tools do: -// the holder is found by the seat list for each call, and a seat with no holder is an error that says so. -func atHolder(ask func(string, any) (json.RawMessage, error), holder func(seat string) (string, bool), seat string) func(string, any) (json.RawMessage, error) { - return func(tool string, body any) (json.RawMessage, error) { - module, ok := holder(seat) - if !ok { - return nil, fmt.Errorf("the holder of %s is not found, so %s is not asked", seat, tool) - } - return ask(module+"."+tool, body) - } -} - -// runsOf says which commit the mesh runs of a module from the indexer's modules state, as the checker's own record of it does -// (the commit the module's record was computed at); "" when the record is not readable. -type runsOf struct{ modules check.StateRead } - -func (r runsOf) CommitOf(module string) string { - if r.modules.Get == nil { - return "" - } - raw, err := r.modules.Get(module) - if err != nil || len(raw) == 0 { - return "" - } - m, err := meshcatalogclient.DecodeModule(raw) - if err != nil { - return "" - } - return m.Commit -} - -// stateStore is a state the tools write: the tries. -type stateStore struct { - check.StateRead - create func(key string, value []byte) error - entry func(key string) (json.RawMessage, uint64, error) - update func(key string, value []byte, revision uint64) error -} - -func (s stateStore) Entry(key string) (json.RawMessage, uint64, error) { return s.entry(key) } -func (s stateStore) Update(key string, value []byte, revision uint64) error { - return s.update(key, value, revision) -} - -func (s stateStore) Keys() ([]string, error) { return s.StateRead.Keys() } -func (s stateStore) Get(key string) (json.RawMessage, error) { return s.StateRead.Get(key) } -func (s stateStore) Create(key string, value []byte) error { return s.create(key, value) } - -// Trying is what the try's tools work on: the tries, and the gate's trunk heads. -type Trying struct { - Tries check.TryStore - Ender check.TryEnder - Trunks func() (map[string]string, error) - Now func() time.Time -} - -// TryTools are the try's tools (ADR 0501 §5): ask one, read one, and end one by hand (issue 734). mesh-controller's try calls them. -func TryTools(tr Trying) []stdio.Tool { - str := func(args map[string]any, k string) string { s, _ := args[k].(string); return s } - return []stdio.Tool{ - {Name: check.TryTool, - Description: "Try a delivery group, or one pushed head, before its pull requests are opened (try a group, group try, try several repositories): " + - "name the members, each a repository and the exact commit asked (never the branch's head now, so a push after the ask changes nothing of what is tried), " + - "or one repository and its head for a try of one member (the seat verb try of mesh-delivery-checker takes the same members, ADR 0637 §6). The checker judges it by the code a group's pull-request check runs, so the two cannot drift: " + - "each member merged onto its trunk's head, the unit and the integration level of every member through the build modules, the manifest validator over " + - "the members' manifests, the module graph, and the composition on every placed node. Every failure is named (each member, level, test, manifest and node), not " + - "the first. A try owes the forge nothing (no status, no Approve asked) and writes no verdict of a pull request; what its passing levels prove is kept, so a pull request's " + - "check of the same heads on the same trunk runs only what the try did not pass. A try narrowed to a level or to some tests judges only those, no manifest and no composition, and keeps nothing of tests. " + - "Answers the try's id at once; " + check.TryReadTool + " reads where it stands, " + check.TryEndTool + " ends it by hand. A try of the same commits that waits or runs is the answer to a second ask " + - "(whatever the order of the members); at most 4 run on a build node, and 8 wait for one, mesh-wide. A repository the checker checks no level of (one whose trunk the gate does not name) " + - "is refused. A try whose ask no build node took within the step bound ends as error; its ask stays in the build seat's stream and may still run later, judged by nobody (issue 734).", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "members": map[string]any{"type": "array", "description": "the group: one repository at most once, each at the exact commit asked and the trunk commit it is merged onto", - "items": map[string]any{"type": "object", "required": []string{"repository", "head"}, "properties": map[string]any{ - "repository": map[string]any{"type": "string", "description": "/"}, - "head": map[string]any{"type": "string", "description": "the full commit to try, 40 or 64 hex digits"}, - "trunk": map[string]any{"type": "string", "description": "the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent"}}}}, - "repository": map[string]any{"type": "string", "description": "/, for a try of one member (instead of members)"}, - "head": map[string]any{"type": "string", "description": "the full commit to try, 40 or 64 hex digits (with repository)"}, - "trunk": map[string]any{"type": "string", "description": "the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent (with repository)"}, - "tests": map[string]any{"type": "string", "description": "a go test -run pattern: only those tests run, and nothing is kept"}, - "level": map[string]any{"type": "string", "enum": []string{"unit", "integration"}, "description": "only this level; both when absent"}}}, - Run: func(args map[string]any) (any, error) { - if tr.Tries == nil || tr.Trunks == nil { - return nil, fmt.Errorf("the tries state cannot be written here") - } - trunks, err := tr.Trunks() - if err != nil { - return nil, fmt.Errorf("the trunk heads cannot be read: %w", err) - } - now := time.Now - if tr.Now != nil { - now = tr.Now - } - var members []check.TryAskMember - if raw, ok := args["members"]; ok { - list, isList := raw.([]any) - if !isList { - return nil, fmt.Errorf("members is a list of {repository, head, trunk}") - } - for _, item := range list { - m, isMap := item.(map[string]any) - if !isMap { - return nil, fmt.Errorf("a member is {repository, head, trunk}") - } - members = append(members, check.TryAskMember{Repository: str(m, "repository"), Head: str(m, "head"), Trunk: str(m, "trunk")}) - } - } - id, err := check.AskTry(tr.Tries, trunks, check.TryAsk{Repository: str(args, "repository"), Head: str(args, "head"), - Trunk: str(args, "trunk"), Tests: str(args, "tests"), Level: str(args, "level"), Members: members}, now()) - if err != nil { - return nil, err - } - return map[string]any{"id": id}, nil - }}, - {Name: check.TryReadTool, - Description: "Where a try (of a group or of one head) stands, read whole, as stored: queued, running, or its end (pass, fail, or error when it could not run, or " + - "when its manifests and composition could not be judged), with what was said of it, every member's commit and the trunk commit it was merged onto, the time it took, " + - "every failure one line each (members, levels, tests, manifests, the composition per node), the levels' tests run and kept, the composition on every placed node, " + - "the notes of the check (manifests judged, module graph, kept verdicts); while it runs, each ask it put as soon as it is put, " + - "with the node that took it, its state and the phase its step says (fetch and merge, a level's digest, lint, tests) and since when. Read-only.", - Input: map[string]any{"type": "object", "required": []string{"id"}, "properties": map[string]any{ - "id": map[string]any{"type": "string", "description": "the try's id, try-"}}}, - Run: func(args map[string]any) (any, error) { - if tr.Tries == nil { - return nil, fmt.Errorf("the tries state cannot be read here") - } - return check.ReadTry(tr.Tries, str(args, "id")) - }}, - {Name: check.TryEndTool, - Description: "End a try of a group (or of one head) that waits or runs, as error, by hand: say why (kept in what it says). Its place among the 4 is free at once, " + - "the checker stops waiting for its asks, and the next " + check.TryTool + " of its head asks anew with a new id. For a try whose ask " + - "was lost (no step runs for it in checker_status); the checker ends one by itself when the build seat gives its ask up, or no node " + - "takes it within the step bound. A try that ended already is refused.", - Input: map[string]any{"type": "object", "required": []string{"id", "why"}, "properties": map[string]any{ - "id": map[string]any{"type": "string", "description": "the try's id, try-"}, - "why": map[string]any{"type": "string", "description": "why it is ended, in words"}}}, - Run: func(args map[string]any) (any, error) { - if tr.Ender == nil { - return nil, fmt.Errorf("the tries state cannot be written here") - } - now := time.Now - if tr.Now != nil { - now = tr.Now - } - t, err := check.EndTry(tr.Ender, str(args, "id"), str(args, "why"), now()) - if err != nil { - return nil, err - } - return map[string]any{"id": t.ID, "state": t.State, "said": t.Said}, nil - }}, - } -} - -// OpenTriesTools is the tool that lists the tries that wait or run, each with its members at their commits, and whether it is -// a whole try (the indexer writes the candidate of a whole try's group): the read a part uses at its start to find the tries -// whose start event it missed, instead of reading the checker's state. -func OpenTriesTools(tr Trying) []stdio.Tool { - return []stdio.Tool{{Name: check.TriesTool, - Description: "The tries that wait or run now (a try of a group or of one head; try.started and try.ended on the checker's stream say the same), each with its id, state, its members at their exact commits and " + - "trunk commits, and whether it is a whole try (not narrowed to a level or to tests, so it is composed and its manifests judged). For a part that " + - "missed the checker's try.started or try.ended event (the indexer at its start); checker_try_read reads one try whole. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{}}, - Run: func(map[string]any) (any, error) { - if tr.Tries == nil { - return nil, fmt.Errorf("the tries state cannot be read here") - } - open, err := check.OpenTries(tr.Tries) - return map[string]any{"tries": open}, err - }}} -} - -// Seat is the seat the checker holds (novox/hq ADR 0547 §10, issue 774); its verbs are served as tools named .. -const Seat = "mesh-delivery-checker" - -// SeatTryTools are the try's tools as the seat's verbs: try, try-read and try-end, run by the same code as checker_try, -// checker_try_read and checker_try_end, so the answer is the same. The module tools stay beside them. -func SeatTryTools(tr Trying) []stdio.Tool { - verbs := map[string]string{check.TryTool: "try", check.TryReadTool: "try-read", check.TryEndTool: "try-end"} - var out []stdio.Tool - for _, t := range TryTools(tr) { - t.Name = Seat + "." + verbs[t.Name] - out = append(out, t) - } - return out -} - -// SeatInputTools are the seat's verb input (check.InputVerb): a checking program's input as the checker keeps it, asked by -// the Go build module that runs the program (buildstep.RunInput.Read), never read from the checker's state by it. -func SeatInputTools(r check.Reader) []stdio.Tool { - return []stdio.Tool{{Name: Seat + "." + meshdeliverychecker.VerbInput, - Description: "A checking program's input the checker keeps, by the sha256 of its exact bytes, as a run ask names it: the digest " + - "and the bytes, base64. A digest it keeps no input of, or bytes that read back as another digest, is an error. Read-only.", - Input: map[string]any{"type": "object", "required": []string{"digest"}, "properties": map[string]any{ - "digest": map[string]any{"type": "string", "description": "the input's sha256, 64 lowercase hex digits"}}}, - Run: func(args map[string]any) (any, error) { - digest, _ := args["digest"].(string) - return r.Input(digest) - }}} -} - -// Tools are the read tools over the checker's states. -func Tools(r check.Reader) []stdio.Tool { - return []stdio.Tool{ - {Name: check.VerdictsReadTool, - Description: "The verdicts the checker holds, each as stored under verdicts..: its state, every failure it names one line each (every member's failed tests, refused steps and conflicts, the manifests' refusals and the composition), the tests run, kept and skipped per level, the time of each part, the trunk heads it judged against, the composition and which checking program judged it (judged: its build and the heads it read), with the full " + - "report of the status each pull request carries (the line the forge shows is cut at 140 characters, this is not). With a group, that group's only. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "group": map[string]any{"type": "string", "description": "the delivery group's branch name"}}}, - Run: func(args map[string]any) (any, error) { - group, _ := args["group"].(string) - vs, cut, err := r.Verdicts(group) - return cutAnswer(map[string]any{"verdicts": vs}, cut), err - }}, - {Name: check.PullReadTool, - Description: "The verdict that judges one pull request, every failure it names one line each (all of them, not only the first the status line shows), which checking program judged it (judged: its build, its key and the heads it read), and the full report of its status mesh/check. Read-only.", - Input: map[string]any{"type": "object", "required": []string{"repository", "number"}, "properties": map[string]any{ - "repository": map[string]any{"type": "string", "description": "/"}, - "number": map[string]any{"type": "integer", "description": "the pull request's number"}}}, - Run: func(args map[string]any) (any, error) { - repository, _ := args["repository"].(string) - n, _ := args["number"].(float64) - return r.Pull(repository, int(n)) - }}, - {Name: check.KeptReadTool, - Description: "The kept verdicts of passing packages, each as stored under kept..: the package, its tests, the time they took, the toolchain " + - "and when it was kept. With a level, that level's; with a level and a digest, that one. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "level": map[string]any{"type": "string", "enum": []string{"unit", "integration"}, "description": "the level"}, - "digest": map[string]any{"type": "string", "description": "the package's digest, with a level"}}}, - Run: func(args map[string]any) (any, error) { - level, _ := args["level"].(string) - digest, _ := args["digest"].(string) - kept, cut, err := r.Kept(level, digest) - return cutAnswer(map[string]any{"kept": kept}, cut), err - }}, - {Name: check.InputsReadTool, - Description: "The checking program's inputs the checker keeps, each under the sha256 of its exact bytes (inputs., kept a day): " + - "the facts of a check its verdict is asked of, or the heads its seat list is asked of. With a digest, that input as kept; " + - "without, every digest and its size. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "digest": map[string]any{"type": "string", "description": "the input's sha256, as a run ask names it"}}}, - Run: func(args map[string]any) (any, error) { - digest, _ := args["digest"].(string) - inputs, cut, err := r.Inputs(digest) - return cutAnswer(map[string]any{"inputs": inputs}, cut), err - }}, - {Name: check.PreviewsReadTool, - Description: "The merge previews the checker holds, each as stored under previews...: the merge commit, per module directory " + - "its tree, manifest digest and lock hashes, or the files in conflict. With a repository, that repository's; with a head (7 or more characters) " + - "only that head's. Keys that are no preview key are listed as unreadable. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "repository": map[string]any{"type": "string", "description": "/"}, - "head": map[string]any{"type": "string", "description": "a pull request head commit, or a prefix of at least 7 characters"}}}, - Run: func(args map[string]any) (any, error) { - repository, _ := args["repository"].(string) - head, _ := args["head"].(string) - if head != "" && len(head) < 7 { - return nil, fmt.Errorf("the head %q is too short: give at least 7 characters", head) - } - ps, bad, cut, err := r.Previews(repository, head) - return cutAnswer(map[string]any{"previews": ps, "unreadable": bad}, cut), err - }}, - {Name: check.StatusReadTool, - Description: "What runs: the steps in flight on the build modules by node, the candidates without a verdict for their heads, " + - "and the candidates whose check is owed by kind (waiting_by_kind: new, nodes, and trunk, a re-judge pulled after the other two). A key a " + - "build module left running (started past the step bound, or its build module not running on its node) is listed apart under " + - "left_running with why, and not counted. Nothing holds the checker and it has no capacity of its own: a check is an ask on the " + - "build seats' streams, whose backlog the delivery view shows (novox/hq ADR 0525). No merge holds a check off (novox/hq ADR 0661). could_not_run names each check " + - "that could not run because a part of the mesh was not heard: the part, since when, the running that asked it again, and whether it " + - "is the finding check-could-not-run (an hour unasked); it is asked again when that part runs. " + - "dead_letters says whether the checker hears the asks the build seats give up on (issue 734), and why not: " + - "deaf, a try or check whose ask is given up waits until its bound. builds_not_ended names, of each running check, the builder's builds of " + - "its candidate's changed modules that are neither done nor failed: the check waits on them before it composes, within its build-wait-bound " + - "(novox/hq ADR 0603 §10); a failed one fails the check: rebuild it with the builder's builder_build_again, and the check asks itself again when the build is done. Read-only.", - Input: map[string]any{"type": "object", "properties": map[string]any{}}, - Run: func(map[string]any) (any, error) { return r.Status() }}, - } -} - -// RequestTools is the tool that reads the composition requests the checker sent to nodes (issue 1921). -func RequestTools(r check.StateRead) []stdio.Tool { - return []stdio.Tool{{Name: check.RequestsReadTool, - Description: "The composition request a check sent to a node: the composer's whole input for that node (the node-engine's composition input, the case's " + - "manifests and verdicts, the seat list), kept exactly as sent so a session reproduces the check's composition (the composer run by hand over the same " + - "request gives the check's answer). Kept in the checker's state compositions, per check key (group.heads, the 12-digit heads hash) and node, " + - "0.7 to 0.8 MB each (kept compressed, in pieces that each fit the state's 256 KiB value), for 3 days (the state's ttl-seconds), the state holding at most 256 MiB (max-mib, which mesh-grants raises a held bucket to). With a check and a node, that request whole; with a check, " + - "the nodes it kept one for; with neither, every kept request, each with its size, digest and when it was kept. Read-only; " + check.RequestsDropTool + " drops a check's.", - Input: map[string]any{"type": "object", "properties": map[string]any{ - "check": map[string]any{"type": "string", "description": "the check's key, ., as the verdict and composition name it"}, - "node": map[string]any{"type": "string", "description": "the node the request was sent for, with a check"}}}, - Run: func(args map[string]any) (any, error) { - key, _ := args["check"].(string) - node, _ := args["node"].(string) - return check.ReadRequests(r, key, node) - }}} -} - -// RequestDropTools is the tool that drops a check's kept composition requests by hand, which frees the state when it is -// full (tools-are-how-a-module-is-spoken-to): it records the hand act through the seat mesh-hand-acts first. -func RequestDropTools(s check.StateDrop, acts views.HandActs) []stdio.Tool { - return []stdio.Tool{{Name: check.RequestsDropTool, - Description: "Drop the composition requests the checker kept for one check (" + check.RequestsReadTool + " lists them): every node's, and the pieces " + - "no other kept request names. The hand act is recorded through the seat mesh-hand-acts first, and a drop whose act could not be recorded is not made. " + - "Answers the nodes and pieces dropped. Use it when a check's words say its request could not be kept in the state compositions because it is full; " + - "the state itself drops a request 3 days after it was kept.", - Input: map[string]any{"type": "object", "required": []string{"check", "why"}, "properties": map[string]any{ - "check": map[string]any{"type": "string", "description": "the check's key, ., whose kept requests are dropped"}, - "why": map[string]any{"type": "string", "description": "why they are dropped, in words; recorded as the hand act"}}}, - Run: func(args map[string]any) (any, error) { - key, _ := args["check"].(string) - why, _ := args["why"].(string) - return check.DropRequests(s, key, why, func(what string) error { - return acts.RecordHandAct(views.HandAct{What: what, Why: why, Cause: "requests-drop", Verb: check.RequestsDropTool}) - }) - }}} -} - -// RecoveryTools are the tools that steer a check by hand (tools-are-how-a-module-is-spoken-to): ask a check again whose -// wait judged nothing (the lost check of 2026-10-28). They write the checker's verdicts through w. -func RecoveryTools(r check.Reader, w check.VerdictEntry) []stdio.Tool { - str := func(args map[string]any, k string) string { s, _ := args[k].(string); return s } - return []stdio.Tool{{Name: check.AskAgainTool, - Description: "Ask a candidate's check again by hand, whose verdict stays running while nothing runs for it (" + check.StatusReadTool + " names it " + - "under lost): its verdict is ended as asked again, saying why, and the checker, which hears its verdicts, stops the wait that judged nothing " + - "and asks the check anew, whole. Refused for a group with no candidate, a verdict that is not running or a failure whose failing steps did not all end on a transport fault (a pass, or any other failure, stands until a push or " + - "a trunk move), and while a step of its pull requests can still run on a build module (its end judges it). The checker reads a step that " + - "ended while its watch was deaf by itself at the next step end of its build module; this is for what that does not reach.", - Input: map[string]any{"type": "object", "required": []string{"group", "why"}, "properties": map[string]any{ - "group": map[string]any{"type": "string", "description": "the delivery group's branch name"}, - "why": map[string]any{"type": "string", "description": "why it is asked again, in words; kept in the verdict it ends"}}}, - Run: func(args map[string]any) (any, error) { - return r.AskAgain(w, str(args, "group"), str(args, "why")) - }}} -} - -// stepBound is the checker's step bound as the checker reads it (MESH_CHECKER_STEP_BOUND), its default when unset or not a -// duration. -func stepBound() time.Duration { - if d, err := time.ParseDuration(os.Getenv("MESH_CHECKER_STEP_BOUND")); err == nil && d > 0 { - return d - } - return check.DefaultStepBound -} - -// seatListAgainCallers are who may ask the seat list again by hand (design 47 G §204). -var seatListAgainCallers = []string{stdio.AnyPerson, "node-tools", "mesh-healers"} - -// holderOf is a seat's holder as the seat that places modules answers it (seatlist.HolderOf, design 47 G A-126): false while the -// seat has none or the answer cannot be read. -func holderOf(seat string) (string, bool) { - module, err := seatlist.HolderOf(stdio.Ask, seat) - return module, err == nil -} - -func main() { - // The build modules are no names (design 47 G A-82): the build seats on the seat list, each held by the module the seat - // that places modules names for it; the seat list and its two tools are wired once by mesh-sdk (§204). - gate := seatlist.NewPart("checker", seatListAgainCallers) - go func() { - <-stdio.Served() - gate.Follow(seatlist.StdioBus(), nil, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-checker-tools] "+f+"\n", a...) }) - }() - seats := buildrun.NewBuildSeats(func() map[string]seatdef.Definition { - if rd := gate.Reader(); rd != nil { - return rd.Definitions() - } - return nil - }, holderOf) - r := check.Reader{VerdictState: read(stdio.State("verdicts")), KeptState: read(stdio.State("kept")), CandidateState: ownerRead(atHolder(stdio.Ask, holderOf, meshcatalog.Seat), indexerCandidatesTool), - PreviewState: read(stdio.State("previews")), InputState: read(stdio.State(check.InputsStateName)), - StepStates: func() map[string]check.StateRead { - out := map[string]check.StateRead{} - for _, m := range seats.All() { - if m.Module != "" && m.Toolchain != "" { - out[m.Module] = read(stdio.State(m.Module + ".steps")) - } - } - return out - }, - HaveState: read(stdio.State("node-engine.have")), StepBound: stepBound(), - CouldNotRunState: read(stdio.State(check.CouldNotRunState)), HearingState: read(stdio.State(buildrun.HearingState)), - AskState: read(stdio.State(check.AsksState)), BuildState: read(stdio.State("mesh-delivery-builder.builds"))} - r.Runs = runsOf{ownerRead(atHolder(stdio.Ask, holderOf, meshcatalog.Seat), indexerModulesTool)} // the node-engine at the commit the mesh runs, as the checker reads it - tries := stdio.State(check.TriesState) - trunks := func() (map[string]string, error) { - raw, err := stdio.Ask(check.TrunkVerb, meshcatalog.RevisionInput{}) - if err != nil { - return nil, err - } - return check.TrunkHeads(raw) - } - r.Trunks = trunks - store := stateStore{StateRead: read(tries), create: func(key string, value []byte) error { - _, err := tries.Create(key, json.RawMessage(value)) - return err - }, entry: func(key string) (json.RawMessage, uint64, error) { - reads.Add(1) - e, err := tries.Get(key) - if err != nil || e == nil { - return nil, 0, err - } - return e.Value, e.Revision, nil - }, update: func(key string, value []byte, revision uint64) error { - _, err := tries.Update(key, json.RawMessage(value), revision) - return err - }} - trying := Trying{Tries: store, Ender: store, Trunks: trunks} - r.Backlog = backlogOf(stdio.Ask) // the build seats' streams, for checker_ask_again (issue 1373) - verdicts := stdio.State("verdicts") - written := stateStore{entry: func(key string) (json.RawMessage, uint64, error) { - reads.Add(1) - e, err := verdicts.Get(key) - if err != nil || e == nil { - return nil, 0, err - } - return e.Value, e.Revision, nil - }, update: func(key string, value []byte, revision uint64) error { - _, err := verdicts.Update(key, json.RawMessage(value), revision) - return err - }} - tools := append(append(append(append(Tools(r), TryTools(trying)...), OpenTriesTools(trying)...), SeatTryTools(trying)...), RecoveryTools(r, written)...) - // checker_first_views and checker_first_view_again: where the checker's first views of the indexer's and the assigner's - // states stand, and asking one again by hand (ADR 0615, DLV-M2). - tools = append(tools, views.StatusTools(os.Getenv(stdio.ServedAs), "checker_first_views", "checker_first_view_again", stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) - tools = append(tools, gate.Tools()...) - tools = append(tools, SeatInputTools(r)...) - tools = append(tools, RequestTools(read(stdio.State(check.RequestsStateName)))...) - requests := stdio.State(check.RequestsStateName) - tools = append(tools, RequestDropTools(check.StateDrop{StateRead: read(requests), Delete: requests.Delete}, meshhandactsclient.Recorder{Ask: stdio.Ask})...) - if err := stdio.Serve("", logged(tools)); err != nil { - fmt.Fprintf(os.Stderr, "[mesh-delivery-checker-tools] %v\n", err) - os.Exit(1) - } -} - -// buildUsageTool is the delivery view's tool of the build nodes' use, whose backlog is the build seats' streams (issue 1373). -const buildUsageTool = "mesh-delivery-view.build_usage" - -// backlogOf reads the build seats' backlog through the view's tool, asked through ask (stdio.Ask, or a test's). -func backlogOf(ask func(string, any) (json.RawMessage, error)) func() ([]check.BacklogRow, error) { - return func() ([]check.BacklogRow, error) { - reads.Add(1) - raw, err := ask(buildUsageTool, map[string]any{}) - if err != nil { - return nil, fmt.Errorf("%s does not answer: %w", buildUsageTool, err) - } - answer, said, ok := buscalls.Unwrap(raw) - if !ok { - return nil, fmt.Errorf("%s answered: %s", buildUsageTool, said) - } - var a struct { - Backlog []check.BacklogRow `json:"backlog"` - Notes []string `json:"notes"` - } - if err := json.Unmarshal(answer, &a); err != nil { - return nil, fmt.Errorf("%s answered what does not decode: %w", buildUsageTool, err) - } - if len(a.Notes) > 0 { // the backlog was not read: unread is never empty - return nil, fmt.Errorf("%s did not read the backlog: %s", buildUsageTool, strings.Join(a.Notes, "; ")) - } - return a.Backlog, nil - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main_test.go deleted file mode 100644 index b42ad7e3..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker-tools/main_test.go +++ /dev/null @@ -1,366 +0,0 @@ -package main - -import ( - "context" - "encoding/base64" - "encoding/json" - "errors" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "math/rand" - "os" - "regexp" - "slices" - "strings" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - - "mesh-delivery-checker/internal/check" -) - -func TestTheToolsServedAreTheFiveReadTools(t *testing.T) { - var names []string - for _, tl := range Tools(check.Reader{}) { - names = append(names, tl.Name) - if tl.Description == "" || tl.Run == nil { - t.Errorf("%s has no description or no run", tl.Name) - } - } - want := []string{check.VerdictsReadTool, check.PullReadTool, check.KeptReadTool, check.InputsReadTool, check.PreviewsReadTool, check.StatusReadTool} - if !slices.Equal(names, want) { - t.Errorf("tools = %v, want %v", names, want) - } - // The recovery tool beside them asks a lost check again; with nothing to write it refuses. - recovery := RecoveryTools(check.Reader{}, nil) - if len(recovery) != 1 || recovery[0].Name != check.AskAgainTool || recovery[0].Description == "" { - t.Errorf("recovery tools = %+v", recovery) - } - if _, err := recovery[0].Run(map[string]any{"group": "feat/x", "why": "lost"}); err == nil { - t.Errorf("%s answered with no state to write", check.AskAgainTool) - } - // Issue 1921: the composition requests kept by the checker are read by check and node; the tool refuses a node with no check - // and a state it cannot read, and lists a check's nodes without their bodies. - store := &memStore{vals: map[string]json.RawMessage{}} - keeper := check.RequestKeeper{Store: memPut{store}} - for _, k := range [][2]string{{"g.0123456789ab", "anchor"}, {"g.0123456789ab", "ace"}, {"h.0123456789ab", "ace"}} { - if err := keeper.Keep(context.Background(), k[0], k[1], []byte(`{"input":{"nodes":[]}}`)); err != nil { - t.Fatal(err) - } - } - // Issue 1966: a request whose compressed bytes pass the state's value limit is kept in pieces and read back whole; the - // pieces are no requests in the list. - rnd := make([]byte, 600<<10) - _, _ = rand.New(rand.NewSource(1)).Read(rnd) - big := []byte(`{"input":"` + base64.StdEncoding.EncodeToString(rnd) + `"}`) - if err := keeper.Keep(context.Background(), "big.0123456789ab", "anchor", big); err != nil { - t.Fatalf("a request of %d bytes: %v", len(big), err) - } - rt := RequestTools(check.StateRead{Keys: store.Keys, Get: store.Get}) - if one, err := rt[0].Run(map[string]any{"check": "big.0123456789ab", "node": "anchor"}); err != nil || !strings.Contains(func() string { b, _ := json.Marshal(one); return string(b) }(), base64.StdEncoding.EncodeToString(rnd)[:64]) { - t.Errorf("the big request read back: %v", err) - } - // Listing reads no piece, and a request of another version is refused by name. - store.vals["v1.0123456789ab/anchor"] = json.RawMessage(`{"v":1,"check":"v1.0123456789ab","node":"anchor","gzip":"x"}`) - noPieces := check.StateRead{Keys: store.Keys, Get: func(k string) (json.RawMessage, error) { - if strings.HasPrefix(k, "pieces/") { - return nil, errors.New("a piece was read") - } - return store.Get(k) - }} - if _, err := RequestTools(noPieces)[0].Run(map[string]any{}); err != nil { - t.Errorf("listing: %v", err) - } - if _, err := rt[0].Run(map[string]any{"check": "v1.0123456789ab", "node": "anchor"}); err == nil || !strings.Contains(err.Error(), "version 1") { - t.Errorf("a version 1 request: %v", err) - } - delete(store.vals, "v1.0123456789ab/anchor") - if all, _ := rt[0].Run(map[string]any{}); strings.Count(func() string { b, _ := json.Marshal(all); return string(b) }(), `"node"`) != 4 { - t.Errorf("the list holds a piece as a request: %v", all) - } - if len(rt) != 1 || rt[0].Name != check.RequestsReadTool || !strings.Contains(rt[0].Description, "composition request a check sent to a node") { - t.Fatalf("request tools = %+v", rt) - } - one, err := rt[0].Run(map[string]any{"check": "g.0123456789ab", "node": "anchor"}) - if b, _ := json.Marshal(one); err != nil || !strings.Contains(string(b), `"request":{"input":{"nodes":[]}}`) { - t.Errorf("one request = %s, %v", b, err) - } - list, _ := rt[0].Run(map[string]any{"check": "g.0123456789ab"}) - if b, _ := json.Marshal(list); strings.Count(string(b), `"node"`) != 2 || strings.Contains(string(b), "h.0123") || strings.Contains(string(b), `"request"`) { - t.Errorf("list of a check = %s", b) - } - for _, args := range []map[string]any{{"node": "anchor"}, {"check": "g.0123456789ab", "node": "gone"}} { - if _, err := rt[0].Run(args); err == nil { - t.Errorf("%v answered", args) - } - } - if _, err := RequestTools(check.StateRead{})[0].Run(map[string]any{}); err == nil { - t.Errorf("answered with no state to read") - } - // Issue 1966: another module's state is asked of its read tool, never read from its bus state (ADR 0596). Every - // stdio.State this program names of another module is one its manifest declares under reads, which the runtime grants; - // the indexer's candidates and modules are asked of indexer_read_candidates and indexer_read_modules, which it invokes. - t.Run("1966: another module's state is read only where the manifest declares it", func(t *testing.T) { - raw, err := os.ReadFile("../../module.json") - if err != nil { - t.Fatal(err) - } - var man struct { - Reads []string `json:"reads"` - Invokes []string `json:"invokes"` - } - if err := json.Unmarshal(raw, &man); err != nil { - t.Fatal(err) - } - src, err := os.ReadFile("main.go") - if err != nil { - t.Fatal(err) - } - for _, m := range regexp.MustCompile(`stdio\.State\("([^"]+\.[^"]+)"\)`).FindAllStringSubmatch(string(src), -1) { - if !slices.Contains(man.Reads, m[1]) { - t.Errorf("main.go reads %s, which the manifest does not declare under reads: the runtime refuses it", m[1]) - } - } - for _, tool := range []string{indexerCandidatesTool, indexerModulesTool} { - if !slices.Contains(man.Invokes, check.IndexerModule+"."+tool) { - t.Errorf("the manifest does not invoke %s", tool) - } - } - }) - for _, c := range []struct { - name, key, answer, want string - failed bool - }{ - {name: "the keys", answer: `{"owner":"mesh-delivery-indexer","state":"candidates","keys":["a","b"]}`, want: "[a b]"}, - {name: "one key, wrapped as the tool runner hands it", key: "a", - answer: `{"content":[{"type":"text","text":"{\"key\":\"a\",\"found\":true,\"value\":{\"commit\":\"c\"}}"}]}`, want: `{"commit":"c"}`}, - {name: "a key the indexer does not hold", key: "gone", answer: `{"key":"gone","found":false}`, want: ""}, - {name: "the tool refused", key: "a", answer: `{"content":[{"type":"text","text":"refused"}],"isError":true}`, failed: true}, - } { - t.Run("1966: the indexer's read tool, "+c.name, func(t *testing.T) { - var asked []string - holder := func(seat string) (string, bool) { return "acme-indexer", seat == meshcatalog.Seat } // found at the seat list's holder - r := ownerRead(atHolder(func(key string, body any) (json.RawMessage, error) { - b, _ := json.Marshal(body) - asked = append(asked, key+" "+string(b)) - return json.RawMessage(c.answer), nil - }, holder, meshcatalog.Seat), indexerCandidatesTool) - var got string - var err error - if c.key == "" { - var keys []string - keys, err = r.Keys() - got = strings.Trim(strings.Join([]string{"[", strings.Join(keys, " "), "]"}, ""), " ") - } else { - var raw json.RawMessage - raw, err = r.Get(c.key) - got = string(raw) - } - want := []string{"acme-indexer." + indexerCandidatesTool + " {}"} - if c.key != "" { - want = []string{"acme-indexer." + indexerCandidatesTool + ` {"key":"` + c.key + `"}`} - } - if (err != nil) != c.failed || (!c.failed && got != c.want) || !slices.Equal(asked, want) { - t.Errorf("read %q, %v, asking %v; want %q, failed %v, asking %v", got, err, asked, c.want, c.failed, want) - } - }) - } - // 1373: the build seats' backlog is read through build_usage; one it says it did not read is never taken for empty. - for _, c := range []struct { - name, answer string - rows int - failed bool - }{ - {name: "a backlog read", answer: `{"backlog":[{"language":"go","kind":"check","waiting":2}]}`, rows: 1}, - {name: "a backlog with a note says it was not read", answer: `{"backlog":[],"notes":["the seats' streams cannot be read here"]}`, failed: true}, - } { - rows, err := backlogOf(func(string, any) (json.RawMessage, error) { return json.RawMessage(c.answer), nil })() - if (err != nil) != c.failed || len(rows) != c.rows || (c.failed && !strings.Contains(err.Error(), "cannot be read here")) { - t.Errorf("1373 backlog, %s: %v, %v", c.name, rows, err) - } - } - // With nothing to read from a tool says so and changes nothing. - for _, tl := range Tools(check.Reader{}) { - if tl.Name == check.StatusReadTool { - continue // it answers from what it can read, and says what it could not - } - if _, err := tl.Run(map[string]any{"repository": "novox/x", "number": float64(1)}); err == nil { - t.Errorf("%s answered with no state to read", tl.Name) - } - } -} - -// memStore is a tries state in memory. -type memStore struct{ vals map[string]json.RawMessage } - -func (m *memStore) Keys() ([]string, error) { - var out []string - for k := range m.vals { - out = append(out, k) - } - return out, nil -} -func (m *memStore) Get(key string) (json.RawMessage, error) { return m.vals[key], nil } -func (m *memStore) Create(key string, value []byte) error { - if _, ok := m.vals[key]; ok { - return errors.New("exists") - } - m.vals[key] = value - return nil -} - -func (m *memStore) Entry(key string) (json.RawMessage, uint64, error) { return m.vals[key], 1, nil } -func (m *memStore) Update(key string, value []byte, revision uint64) error { - m.vals[key] = value - return nil -} - -func TestTheTryToolsAskAndReadATry(t *testing.T) { // ADR 0501 §5, the agreed interface with mesh-controller's try - store := &memStore{vals: map[string]json.RawMessage{}} - tools := TryTools(Trying{Tries: store, Ender: store, Now: func() time.Time { return time.Unix(1, 5) }, - Trunks: func() (map[string]string, error) { - return map[string]string{"novox/mesh-delivery": strings.Repeat("a", 40)}, nil - }}) - if len(tools) != 3 || tools[0].Name != "checker_try" || tools[1].Name != "checker_try_read" || tools[2].Name != "checker_try_end" { - t.Fatalf("tools = %+v", tools) - } - out, err := tools[0].Run(map[string]any{"repository": "novox/mesh-delivery", "head": strings.Repeat("1", 40), "trunk": "main"}) - if err != nil { - t.Fatal(err) - } - id := out.(map[string]any)["id"].(string) - if id != "try-1000000005" { - t.Errorf("id = %q", id) - } - raw, err := tools[1].Run(map[string]any{"id": id}) - if err != nil || !strings.Contains(string(raw.(json.RawMessage)), `"state":"queued"`) { - t.Errorf("read = %s, %v", raw, err) - } - // The seat's verbs answer as the tools do (ADR 0547 §10, issue 774): the same ask is the same try, and the read is alike. - verbs := SeatTryTools(Trying{Tries: store, Ender: store, Now: func() time.Time { return time.Unix(1, 5) }, - Trunks: func() (map[string]string, error) { - return map[string]string{"novox/mesh-delivery": strings.Repeat("a", 40)}, nil - }}) - if len(verbs) != 3 || verbs[0].Name != Seat+".try" || verbs[1].Name != Seat+".try-read" || verbs[2].Name != Seat+".try-end" { - t.Fatalf("verbs = %+v", verbs) - } - again, err := verbs[0].Run(map[string]any{"repository": "novox/mesh-delivery", "head": strings.Repeat("1", 40), "trunk": "main"}) - if err != nil || again.(map[string]any)["id"] != id { - t.Errorf("verb try = %v, %v, want the waiting try %s", again, err, id) - } - if viaVerb, err := verbs[1].Run(map[string]any{"id": id}); err != nil || string(viaVerb.(json.RawMessage)) != string(raw.(json.RawMessage)) { - t.Errorf("verb try-read = %s, %v; tool = %s", viaVerb, err, raw) - } - if _, err := verbs[0].Run(map[string]any{"repository": "novox/hq", "head": strings.Repeat("1", 40)}); err == nil { - t.Error("the verb tried a repository nothing checks") - } - // The seat's definition of the verb try gives the members the verb serves (ADR 0637 §6), as the tool takes them, and says so. - def, err := os.ReadFile("../../../mesh-delivery-contracts/seats/mesh-delivery-checker/seat.json") - if err != nil { - t.Fatal(err) - } - var seat struct { - Verbs []struct { - Name string `json:"name"` - Description string `json:"description"` - Input struct { - Properties map[string]any `json:"properties"` - Required []string `json:"required"` - } `json:"input"` - } `json:"verbs"` - } - if err := json.Unmarshal(def, &seat); err != nil { - t.Fatal(err) - } - for _, v := range seat.Verbs { - if v.Name != "try" { - continue - } - toolProps := verbs[0].Input["properties"].(map[string]any) - for name := range toolProps { - if _, ok := v.Input.Properties[name]; !ok { - t.Errorf("the verb try serves no %q, which the tool takes", name) - } - } - const limit = "at most 4 run on a build node, and 8 wait for one, mesh-wide" - if !strings.Contains(v.Description, limit) || !strings.Contains(verbs[0].Description, limit) { - t.Errorf("the verb and the tool state one limit %q", limit) - } - if len(v.Input.Required) != 0 || !strings.Contains(v.Description, "members") { - t.Errorf("the verb try requires %v and says %q: want members as an alternative to one repository and head", v.Input.Required, v.Description) - } - } - // The seat's verb input (issue 1921, ADR 0596 §2): a checking program's input as kept, which the Go build module asks. - body := []byte(`{"v":1}`) - in, _ := buildstep.RunInputOf(check.InputVerb, body) - inputs := SeatInputTools(check.Reader{InputState: check.StateRead{Get: func(key string) (json.RawMessage, error) { - if key == in.Digest { - return body, nil - } - return nil, nil - }}}) - if len(inputs) != 1 || inputs[0].Name != Seat+".input" { - t.Fatalf("input verbs = %+v", inputs) - } - if a, err := inputs[0].Run(map[string]any{"digest": in.Digest}); err != nil || a.(meshdeliverychecker.InputAnswer).Input != base64.StdEncoding.EncodeToString(body) { - t.Errorf("verb input = %+v, %v", a, err) - } - // A group try (issue 1921): the members, each an exact commit; members and one repository together are refused; the - // description says what it does in the words a search for "try a group" finds. - later := TryTools(Trying{Tries: store, Ender: store, Now: func() time.Time { return time.Unix(2, 5) }, - Trunks: func() (map[string]string, error) { - return map[string]string{"novox/mesh-delivery": strings.Repeat("a", 40)}, nil - }}) - g, err := later[0].Run(map[string]any{"members": []any{map[string]any{"repository": "novox/mesh-delivery", "head": strings.Repeat("2", 40)}}}) - if err != nil || g.(map[string]any)["id"] == id { - t.Errorf("a group try = %v, %v, want a try of its own", g, err) - } - if _, err := tools[0].Run(map[string]any{"members": []any{map[string]any{"repository": "novox/mesh-delivery", "head": strings.Repeat("2", 40)}}, - "repository": "novox/mesh-delivery", "head": strings.Repeat("1", 40)}); err == nil { - t.Error("members and a repository were both taken") - } - if _, err := tools[0].Run(map[string]any{"members": "novox/mesh-delivery"}); err == nil { - t.Error("members that are no list were taken") - } - for _, tl := range tools { - for _, words := range []string{"group"} { - if !strings.Contains(strings.ToLower(tl.Description), words) { - t.Errorf("%s says nothing of a %s: %q", tl.Name, words, tl.Description) - } - } - } - if d := strings.ToLower(tools[0].Description); !strings.Contains(d, "try a group") || !strings.Contains(d, "exact commit") || !strings.Contains(d, "every failure") || - !strings.Contains(d, "composition on every placed node") || !strings.Contains(d, "owes the forge nothing") || !strings.Contains(d, "kept") { - t.Errorf("the try's description does not say what a group try does: %q", d) - } - if open := OpenTriesTools(Trying{Tries: store}); len(open) != 1 || open[0].Name != check.TriesTool || !strings.Contains(open[0].Description, "try.started") { - t.Errorf("open tries tool = %+v", open) - } else if out, err := open[0].Run(nil); err != nil || len(out.(map[string]any)["tries"].([]checkermsg.Open)) != 2 { - t.Errorf("open tries = %v, %v, want the two tries asked", out, err) - } - // Issue 734: a try whose ask was lost is ended by hand with why, and its head is asked anew. - ended, err := tools[2].Run(map[string]any{"id": id, "why": "its ask was lost"}) - if err != nil || ended.(map[string]any)["state"] != "error" { - t.Errorf("end = %v, %v", ended, err) - } - if _, err := tools[2].Run(map[string]any{"id": id, "why": "again"}); err == nil { - t.Error("an ended try was ended again") - } - if _, err := tools[0].Run(map[string]any{"repository": "novox/hq", "head": strings.Repeat("1", 40)}); err == nil || - err.Error() != "no level of novox/hq is checked by the checker" { - t.Errorf("hq: %v", err) - } -} - -// memPut writes a memStore as the checker's kept-request state is written. -type memPut struct{ m *memStore } - -func (p memPut) Put(_ context.Context, key string, value []byte) (uint64, error) { - if len(value) > 262144 { // the state's value limit, headers included (issue 1966) - return 0, errors.New("the value is over the 262144 bytes the bucket takes") - } - p.m.vals[key] = value - return 1, nil -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/bus.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/bus.go deleted file mode 100644 index 4342f010..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/bus.go +++ /dev/null @@ -1,197 +0,0 @@ -package main - -import ( - "context" - "errors" - "fmt" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/process" - - "mesh-delivery-checker/internal/check" -) - -// bucketOpener is the part of the bus the watches use. -type bucketOpener interface { - KeyValue(ctx context.Context, bucket string) (jetstream.KeyValue, error) -} - -// kvStore is the builds bucket as the builder's store: create and compare-and-set. -type kvStore struct{ kv jetstream.KeyValue } - -func conflict(err error) error { - if errors.Is(err, jetstream.ErrKeyExists) || errors.Is(err, jetstream.ErrKeyRevisionMismatch) { - return check.ErrConflict - } - return err -} - -func (s kvStore) Get(ctx context.Context, key string) ([]byte, uint64, bool, error) { - e, err := s.kv.Get(ctx, key) - if errors.Is(err, jetstream.ErrKeyNotFound) { - return nil, 0, false, nil - } - if err != nil { - return nil, 0, false, err - } - return e.Value(), e.Revision(), true, nil -} - -func (s kvStore) Create(ctx context.Context, key string, value []byte) (uint64, error) { - rev, err := s.kv.Create(ctx, key, value) - return rev, conflict(err) -} - -func (s kvStore) Update(ctx context.Context, key string, value []byte, revision uint64) (uint64, error) { - rev, err := s.kv.Update(ctx, key, value, revision) - return rev, conflict(err) -} - -func (s kvStore) Keys(ctx context.Context) ([]string, error) { - keys, err := s.kv.Keys(ctx) - if errors.Is(err, jetstream.ErrNoKeysFound) { - return nil, nil - } - return keys, err -} - -// Delete removes a key (an ended try past its keeping). -func (s kvStore) Delete(ctx context.Context, key string) error { return s.kv.Delete(ctx, key) } - -func opOf(e jetstream.KeyValueEntry) bool { return e.Operation() == jetstream.KeyValuePut } - -// settle reads the entries a watcher holds now, up to its mark of the last values, and returns the watcher for the -// changes that follow. -func settle(ctx context.Context, kv jetstream.KeyValue, each func(jetstream.KeyValueEntry)) (jetstream.KeyWatcher, error) { - w, err := kv.WatchAll(ctx) - if err != nil { - return nil, err - } - for { - select { - case <-ctx.Done(): - w.Stop() - return nil, ctx.Err() - case e, ok := <-w.Updates(): - if !ok { - return nil, errors.New("the watch ended") - } - if e == nil { - return w, nil - } - each(e) - } - } -} - -// follow hands each change of a watcher to each until ctx ends; a watch that ends is an error, and the process manager -// starts the program again. -func follow(ctx context.Context, w jetstream.KeyWatcher, each func(jetstream.KeyValueEntry)) error { - defer w.Stop() - for { - select { - case <-ctx.Done(): - return nil - case e, ok := <-w.Updates(): - if !ok { - return errors.New("a watch ended") - } - if e != nil { - each(e) - } - } - } -} - -// manifestReader reads manifests. of the indexer and parses the manifest it holds. -type manifestReader struct{ kv jetstream.KeyValue } - -func (m manifestReader) Manifest(ctx context.Context, digest string) (catalogue.Manifest, error) { - key, err := meshcatalogclient.ManifestsKey(digest) - if err != nil { - return catalogue.Manifest{}, err - } - e, err := m.kv.Get(ctx, key) - if err != nil { - return catalogue.Manifest{}, fmt.Errorf("manifests.%s: %w", key, err) - } - kept, err := meshcatalogclient.DecodeManifest(e.Value()) - if err != nil { - return catalogue.Manifest{}, err - } - return parseManifest(kept.Manifest) -} - -// parseManifest decodes a manifest the indexer kept, as every reader does (novox/hq ADR 0578 §3): judged by nothing here, -// a field it does not know set aside. The checker judges a change's manifests with the indexer's judge, run as a step -// (judge.go). -func parseManifest(raw string) (catalogue.Manifest, error) { - return catalogue.Decode([]byte(raw)) -} - -// awaitedKV is a bucket that may appear after the start (process.AwaitBucket) as a check.KV: a call while it is not on the -// bus fails saying so. -type awaitedKV struct{ b *process.AwaitedBucket } - -func (a awaitedKV) kv() (kvStore, error) { - kv := a.b.KV() - if kv == nil { - return kvStore{}, errors.New("the bucket is not on the bus yet") - } - return kvStore{kv}, nil -} - -func (a awaitedKV) Get(ctx context.Context, key string) ([]byte, uint64, bool, error) { - s, err := a.kv() - if err != nil { - return nil, 0, false, err - } - return s.Get(ctx, key) -} - -func (a awaitedKV) Create(ctx context.Context, key string, value []byte) (uint64, error) { - s, err := a.kv() - if err != nil { - return 0, err - } - return s.Create(ctx, key, value) -} - -func (a awaitedKV) Update(ctx context.Context, key string, value []byte, revision uint64) (uint64, error) { - s, err := a.kv() - if err != nil { - return 0, err - } - return s.Update(ctx, key, value, revision) -} - -func (a awaitedKV) Keys(ctx context.Context) ([]string, error) { - s, err := a.kv() - if err != nil { - return nil, err - } - return s.Keys(ctx) -} - -func (a awaitedKV) Delete(ctx context.Context, key string) error { - s, err := a.kv() - if err != nil { - return err - } - return s.Delete(ctx, key) -} - -// runInputs keeps the checking program's inputs in the checker's state inputs (check.InputsBucket), each under the -// sha256 of its exact bytes: an input already kept under its digest is the same bytes, so a second keep is no error. -type runInputs struct{ a awaitedKV } - -func (r runInputs) Keep(ctx context.Context, digest string, body []byte) error { - _, err := r.a.Create(ctx, digest, body) - if errors.Is(err, check.ErrConflict) { - return nil - } - return err -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/couldnotrun.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/couldnotrun.go deleted file mode 100644 index e747f8dd..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/couldnotrun.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "time" - - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - - "mesh-delivery-checker/internal/check" -) - -// waitCouldNotRun raises each check that could not run as the finding check-could-not-run once its bound passed -// (check.CouldNotRunBound): it waits for the next one due, read from the checker's state could-not-run, and reads again -// each time one is kept. The bound is the only wait: a check is asked again on its part's running, never here. -func waitCouldNotRun(ctx context.Context, ch *check.Checker, kept <-chan struct{}) { - for ctx.Err() == nil { - // The wait is a context's bound (ADR 0437 §8): none while no check waits for its bound. - wait, done := ctx, func() {} - if next := ch.CouldNotRunDue(ctx, time.Now()); !next.IsZero() { - wait, done = context.WithDeadline(ctx, next) - } - select { - case <-wait.Done(): - case <-kept: - } - done() - } -} - -// partRunner is what a `running` is handed to: check.Checker's PartRunning. -type partRunner interface { - PartRunning(ctx context.Context, node, module, fingerprint string) -} - -// heardRunning takes one node-engine seat's `running..` in, as the checker's durable consumer of its stream -// hands it (module.json consumes node-engine.running): the part named runs at its fingerprint, so every check that could not -// run for want of it is asked again once (check.Checker.PartRunning). A body that names no node, module or fingerprint asks -// nothing, said in the log. -func heardRunning(ctx context.Context, ch partRunner, body []byte, logf func(string, ...any)) { - var r nodeengine.RunningEvent - if err := json.Unmarshal(body, &r); err != nil || r.Node == "" || r.Module == "" || r.Fingerprint == "" { - logf("a running of the node-engine seat that names no node, module or fingerprint asks no check again: %s (%v)", body, err) - return - } - ch.PartRunning(ctx, r.Node, r.Module, r.Fingerprint) -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/engines.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/engines.go deleted file mode 100644 index 64932370..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/engines.go +++ /dev/null @@ -1,167 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "sort" - "sync" - "sync/atomic" - "time" - - nodeengineseat "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" - "git.novox.be/novox/mesh-sdk/go/views" -) - -// The checker's composition of a check on the bus (novox/hq ADR 0593 §7, §9; check.EngineCompositions): each placed -// node's engine asked `node-engine.compose-candidate` on that node, and, for a group that changes the node-engine's -// composition code, the composer built from its head run on the Go build seat. - -// composeCandidateKey is the seat verb's call key, asked of one node (process.Conn.CallOn). -var composeCandidateKey = "seat:" + nodeengineseat.Seat + "." + ne.VerbComposeCandidate - -// engineAsks asks one node's engine over the bus, its answer waited for at most ctx's deadline (the answer bound). -type engineAsks struct { - call func(node, key string, body any) (json.RawMessage, error) -} - -func (e engineAsks) ComposeCandidate(ctx context.Context, node string, ask ne.ComposeCandidateInput) (ne.ComposeCandidateAnswer, error) { - type answer struct { - raw json.RawMessage - err error - } - got := make(chan answer, 1) - go func() { - raw, err := e.call(node, composeCandidateKey, ask) - got <- answer{raw, err} - }() - select { - case <-ctx.Done(): - return ne.ComposeCandidateAnswer{}, fmt.Errorf("no answer within its bound: %w", ctx.Err()) - case a := <-got: - if a.err != nil { - return ne.ComposeCandidateAnswer{}, a.err - } - return nec.DecodeAnswer(a.raw) - } -} - -// assignedNodes is the placedNodes' read of the assignments' picture, which is followed once the holder of the seat mesh-module-assigner -// is known: an error says so until then, so a check never passes with no node asked. -func assignedNodes(p *atomic.Pointer[views.Picture]) func(context.Context) (jetstream.KeyValue, error) { - return func(context.Context) (jetstream.KeyValue, error) { - pic := p.Load() - if pic == nil { - return nil, errors.New("the seat that places modules has no holder known yet") - } - return pic, nil - } -} - -// placedNodes names every node the seat mesh-module-assigner places now, read from its state when a check composes (no -// watch: a check reads it once). A state that cannot be read is an error, so the check says its composition was not -// made rather than passing with no node asked (review finding 4). -type placedNodes struct { - kv func(ctx context.Context) (jetstream.KeyValue, error) -} - -func (p placedNodes) Placed() ([]string, error) { - ctx, cancel := context.WithTimeout(context.Background(), nec.AnswerBound) - defer cancel() - kv, err := p.kv(ctx) - if err != nil { - return nil, fmt.Errorf("the assignments cannot be read: %w", err) - } - lister, err := kv.ListKeys(ctx) - if errors.Is(err, jetstream.ErrNoKeysFound) { - return nil, nil // assignments that places nothing - } - if err != nil { - return nil, fmt.Errorf("the assignments cannot be listed: %w", err) - } - seen := map[string]bool{} - for key := range lister.Keys() { - if node, _, _, err := meshmoduleassignerclient.ParseKey(key); err == nil { - seen[node] = true - } - } - out := make([]string, 0, len(seen)) - for n := range seen { - out = append(out, n) - } - sort.Strings(out) - return out, nil -} - -// seatSandbox runs a compose job on the Go build seat's check stream, as the checker's own ask, and answers the -// composer's verdict from the step's result (buildstep.ComposeAnswer). -type seatSandbox struct { - // module is the checker's own, the credential's: the asker of the compose ask. - module string - asker buildrun.Asker -} - -func (s seatSandbox) Compose(ctx context.Context, job buildstep.ComposeJob) (composer.Verdict, error) { - ask := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: s.module, - At: time.Now().UTC(), Compose: &job} - step, err := s.asker.Ask(ctx, ask) - if err != nil { - return composer.Verdict{}, err - } - if step.State != buildstep.StepPassed { - return composer.Verdict{}, fmt.Errorf("the compose ask %s ended %s: %s", ask.ID, step.State, step.Reason) - } - var a buildstep.ComposeAnswer - if err := json.Unmarshal(step.Result, &a); err != nil { - return composer.Verdict{}, fmt.Errorf("the compose ask %s answered no compose answer: %w", ask.ID, err) - } - var v composer.Verdict - if err := json.Unmarshal(a.Verdict, &v); err != nil || v.V != composer.Version { - return composer.Verdict{}, fmt.Errorf("the compose ask %s answered no composer verdict of version %d (%v)", ask.ID, composer.Version, err) - } - return v, nil -} - -// manifestVerdicts are the indexer's refusals of the trunk's manifests, by module, from its modules' values -// (meshcatalog.ModulesByModuleValue.VerdictOf, ADR 0578 §3): what the sandbox's composer holds a refused module by. -type manifestVerdicts struct { - mu sync.Mutex - by map[string]meshcatalog.VerdictsByDigestValue -} - -func (m *manifestVerdicts) put(module string, v *meshcatalog.VerdictsByDigestValue) { - m.mu.Lock() - defer m.mu.Unlock() - if m.by == nil { - m.by = map[string]meshcatalog.VerdictsByDigestValue{} - } - if v == nil { - delete(m.by, module) - return - } - // The sandbox's composer may be the node-engine of an older delivery, which does not know the verdict waits: it is handed a - // wait as the refusal it is held as. - m.by[module] = meshcatalogclient.VerdictAsRefused(*v) -} - -func (m *manifestVerdicts) all() map[string]meshcatalog.VerdictsByDigestValue { - m.mu.Lock() - defer m.mu.Unlock() - out := make(map[string]meshcatalog.VerdictsByDigestValue, len(m.by)) - for k, v := range m.by { - out[k] = v - } - return out -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/findingwriter.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/findingwriter.go deleted file mode 100644 index 996b94c8..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/findingwriter.go +++ /dev/null @@ -1,77 +0,0 @@ -package main - -import ( - "context" - - "github.com/nats-io/nats.go" - "github.com/nats-io/nats.go/jetstream" - - condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" - "git.novox.be/novox/mesh-sdk/go/keys" - "git.novox.be/novox/mesh-sdk/go/process" - "git.novox.be/novox/mesh-sdk/go/views" - - "mesh-delivery-checker/internal/check" -) - -type findingWriterOf = views.Writer[condseat.Finding, condseat.FindingCleared, condseat.FindingsStated, condseat.FindingsAskedEvent] - -// checkerFindings is the checker's finding writer (design 47 G §461, §689): it owns the finding check-could-not-run beside -// its views reader's, observes the raised ones of its kept checks, and writes both as the generated contract type. The -// writer forms its subjects itself (A-13). -type checkerFindings struct { - w *findingWriterOf - node string -} - -// newCheckerFindings makes and starts the writer; observe says the checks that could not run and whose finding is -// written (check.Checker.RaisedCouldNotRun). -func newCheckerFindings(ctx context.Context, cred process.Account, conn *nats.Conn, js jetstream.JetStream, state process.State, - observe func(context.Context) ([]check.Finding, error), logf func(string, ...any)) (*checkerFindings, error) { - c := &checkerFindings{node: cred.Node} - w, err := views.NewWriter(views.WriterConfig[condseat.Finding, condseat.FindingCleared, condseat.FindingsStated, condseat.FindingsAskedEvent]{ - Module: cred.Module, State: state, Node: cred.Node, Asked: condseat.SubjectFindingsAsked, JS: js, Conn: conn, Logf: logf, - Kinds: []string{check.CouldNotRunKind}, - Observe: func(ctx context.Context) (views.Observed[condseat.Finding], error) { - found, err := observe(ctx) - if err != nil { - return views.Observed[condseat.Finding]{}, err - } - var out views.Observed[condseat.Finding] - for _, f := range found { - out.Findings = append(out.Findings, c.body(f)) - } - return out, nil - }, - }) - if err != nil { - return nil, err - } - c.w = w - // A writer that cannot start (the stream of its asks is not there yet) is said; its findings are then kept in the - // state alone and said by the next start (as the node-engine's is). - if err := w.Start(ctx); err != nil { - logf("the finding writer cannot start, its findings are kept in the state alone: %v", err) - } - return c, nil -} - -// body lays the checker's finding out as the seat's contract type: a finding of the module, about the module on its node. -func (c *checkerFindings) body(f check.Finding) condseat.Finding { - module, _ := c.w.ModuleNode() - return condseat.Finding{Kind: f.Kind, Scope: views.FindingScope, ID: keys.EscapeName(f.ID), At: f.At, Since: f.At, - Severity: condseat.FindingSeverityWarning, Source: f.Kind, Summary: f.Summary, Headline: f.Headline, Explanation: f.Explanation, - Subject: condseat.Subject{Scope: views.FindingScope, ID: module, Machine: c.node}} -} - -// Put writes one finding; its `since` stays where its key exists. -func (c *checkerFindings) Put(f check.Finding) error { - return c.w.Write(context.Background(), c.body(f)) -} - -// Delete clears one finding. -func (c *checkerFindings) Delete(f check.Finding) error { - return c.w.Clear(context.Background(), views.FindingScope, keys.EscapeName(f.ID), f.Kind, "the checker no longer observes it") -} - -var _ check.FindingWriter = (*checkerFindings)(nil) diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge.go deleted file mode 100644 index e00b1958..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge.go +++ /dev/null @@ -1,59 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "fmt" - - "github.com/nats-io/nats.go" - - gitseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" - - "mesh-delivery-checker/internal/check" -) - -// The checker reads the forge through the seat git's read verbs (design 47 *The seat git*; milestone 47/G W6.14), as its -// manifest's invokes names them, never by a module's tool: whichever module holds the seat answers. It writes nothing to -// the forge: what the checker owes the forge is the forge bridge's to perform (ADR 0484 clause 2). - -// fileVerb is the seat git's verb file, as invokes names it. -var fileVerb = "seat:" + gitseat.Seat + "." + gitseat.VerbFile - -// forgeReads reads the forge through call (mesh-sdk process.Conn.Call as the checker's own account). -type forgeReads struct { - call func(key string, body any) (json.RawMessage, error) -} - -// ask calls a verb of the seat git; a call that reached nobody (no responders: the holder's tool runner re-serving, or the -// forge down) is marked Unheard, so the check says it could not run and is asked again when the part it could not hear -// runs (issue 1373, issue 1624). -func (f forgeReads) ask(key string, body any) (json.RawMessage, error) { - raw, err := f.call(key, body) - if errors.Is(err, nats.ErrNoResponders) || errors.Is(err, nats.ErrTimeout) || errors.Is(err, context.DeadlineExceeded) { - return nil, &check.Unheard{Err: err} - } - return raw, err -} - -// File is the text of a file of a repository at a ref. A file the forge says the ref does not hold wraps -// check.ErrNotFound (issue 1845); the seat's error is a failure, never an absent file. -func (f forgeReads) File(_ context.Context, repository, path, ref string) (string, error) { - raw, err := f.ask(fileVerb, gitseat.FileInput{Repository: repository, Path: path, Ref: ref}) - if err != nil { - return "", err - } - var a gitseat.FileAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return "", fmt.Errorf("the answer of %s is not its answer: %v", fileVerb, err) - } - switch { - case a.Error != "": - return "", fmt.Errorf("%s of %s at %s: %s", fileVerb, path, ref, a.Error) - case a.Absent: - return "", fmt.Errorf("%w: %s holds no %s at %s", check.ErrNotFound, repository, path, ref) - case a.Path == "" && a.Blob == "" && a.Content == "": - return "", fmt.Errorf("the answer of %s names no file and no error", fileVerb) - } - return a.Content, nil -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge_test.go deleted file mode 100644 index 1803122e..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/forge_test.go +++ /dev/null @@ -1,109 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "os" - "path/filepath" - "strings" - "testing" - - "github.com/nats-io/nats.go" - - "mesh-delivery-checker/internal/check" -) - -// seatAnswer is an answer of the seat git's verb file as its fixtures give it (modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json). -func seatAnswer(t *testing.T, name string) json.RawMessage { - t.Helper() - raw, err := os.ReadFile(filepath.Join("..", "..", "..", "mesh-delivery-contracts", "seats", "git", "fixtures", "verbs.json")) - if err != nil { - t.Fatal(err) - } - var fixtures []struct { - Name string `json:"name"` - Of string `json:"of"` - Given json.RawMessage `json:"given"` - } - if err := json.Unmarshal(raw, &fixtures); err != nil { - t.Fatal(err) - } - for _, f := range fixtures { - if f.Of == "verb:file.answer" && strings.Contains(string(f.Given), name) { - return f.Given - } - } - t.Fatalf("no file answer of the seat git's fixtures holds %q", name) - return nil -} - -func TestTheForgeReadsParseWhatTheForgeAnswered(t *testing.T) { // 1624/AC4; milestone 47/G W6.14: through the seat git - var asked []string - f := forgeReads{call: func(key string, body any) (json.RawMessage, error) { - b, _ := json.Marshal(body) - asked = append(asked, key+" "+string(b)) - return seatAnswer(t, "seats/index.json"), nil - }} - text, err := f.File(context.Background(), "novox/mesh-contracts", "seats/index.json", "main") - if err != nil || text != `{"format":1,"seats":["mesh-broker"]}` { - t.Errorf("file = %q, %v", text, err) - } - if want := `seat:git.file {"path":"seats/index.json","ref":"main","repository":"novox/mesh-contracts"}`; len(asked) != 1 || asked[0] != want { - t.Errorf("asked %v, want %s", asked, want) - } - bad := forgeReads{call: func(string, any) (json.RawMessage, error) { return json.RawMessage(`{}`), nil }} - if _, err := bad.File(context.Background(), "novox/x", "go.mod", "main"); err == nil { - t.Error("an answer with no file was taken") - } -} - -func TestAFileTheRefDoesNotHoldIsNotFoundAndOtherFailuresAreNot(t *testing.T) { // 1845/AC1, AC4 - f := forgeReads{call: func(string, any) (json.RawMessage, error) { return seatAnswer(t, "seats/gone.json"), nil }} - if _, err := f.File(context.Background(), "novox/mesh-contracts", "seats/gone.json", "aaaa"); !errors.Is(err, check.ErrNotFound) { - t.Errorf("an absent file is %v, want ErrNotFound", err) - } - f = forgeReads{call: func(string, any) (json.RawMessage, error) { return seatAnswer(t, "over 512 KiB"), nil }} - if _, err := f.File(context.Background(), "novox/mesh-contracts", "seats/big.json", "main"); err == nil || errors.Is(err, check.ErrNotFound) { - t.Errorf("the seat's error is %v, want a failure that is not ErrNotFound", err) - } - f = forgeReads{call: func(string, any) (json.RawMessage, error) { return nil, errors.New("the holder failed") }} - if _, err := f.File(context.Background(), "novox/mesh-catalog", "go.mod", "main"); err == nil || errors.Is(err, check.ErrNotFound) { - t.Errorf("a failed call is %v, want a failure that is not ErrNotFound", err) - } -} - -func TestAForgeReadThatReachesNobodyIsUnheard(t *testing.T) { // 1624 C7: "nats: no responders" on mesh-catalog #293 - f := forgeReads{call: func(string, any) (json.RawMessage, error) { return nil, nats.ErrNoResponders }} - _, err := f.File(context.Background(), "novox/mesh-catalog", "checks/agenthome/go.mod", "950e37a46e8d") - var u *check.Unheard - if !errors.As(err, &u) { - t.Errorf("err = %v, want it marked as reaching nobody", err) - } - // Issue 1373, milestone 47/G W6.9: the check that could not run is asked again when the part runs, heard as the - // node-engine seat's running.. on the checker's consumer; a running that names no part asks nothing. - t.Run("asked again on running", func(t *testing.T) { - for _, c := range []struct { - body string - want []string - }{ - {`{"v":1,"node":"novox","module":"gitea","fingerprint":"src2:ab","manifest":"sha256:cd","at":"2026-11-09T20:00:00Z"}`, []string{"novox gitea src2:ab"}}, - {`{"v":1,"node":"novox","module":"gitea"}`, nil}, - {`not json`, nil}, - } { - var got []string - heardRunning(context.Background(), runnerFunc(func(_ context.Context, node, module, fp string) { - got = append(got, node+" "+module+" "+fp) - }), []byte(c.body), t.Logf) - if strings.Join(got, ",") != strings.Join(c.want, ",") { - t.Errorf("%s asked %v, want %v", c.body, got, c.want) - } - } - }) -} - -type runnerFunc func(ctx context.Context, node, module, fingerprint string) - -func (f runnerFunc) PartRunning(ctx context.Context, node, module, fingerprint string) { - f(ctx, node, module, fingerprint) -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/integration_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/integration_test.go deleted file mode 100644 index 546fef66..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/integration_test.go +++ /dev/null @@ -1,1373 +0,0 @@ -//go:build integration - -package main - -import ( - "bytes" - "context" - "crypto/sha256" - "encoding/json" - "errors" - "fmt" - "maps" - "os" - "path/filepath" - "slices" - "sort" - "strings" - "sync" - "sync/atomic" - "testing" - "testing/fstest" - "time" - - "github.com/nats-io/nats-server/v2/server" - "github.com/nats-io/nats.go" - "github.com/nats-io/nats.go/jetstream" - - "mesh-delivery-checker/internal/check" - - "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshwatchdogs" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - gitseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - gobuild "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" - "git.novox.be/novox/mesh-sdk/go/announce" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/keys" - "git.novox.be/novox/mesh-sdk/go/process" - "git.novox.be/novox/mesh-sdk/go/seatdef" - "git.novox.be/novox/mesh-sdk/go/seatlist" - "git.novox.be/novox/mesh-sdk/go/seatlist/seatlisttest" - "git.novox.be/novox/mesh-sdk/go/views/viewstest" - - "mesh-delivery-checker/rules" -) - -// busConf is the shape of the composed accounts file (mesh-controller internal/broker): one account with JetStream, the -// controller's user and the checker's own principal .. It carries no per-principal permissions: the grants -// the controller composes from the manifest's state and reads (only the checker writes its buckets) are the controller's, -// and are proved by its own module check, not here. -const busConf = ` -listen: 127.0.0.1:-1 -jetstream { store_dir: %q } -accounts { - MESH { - jetstream: enabled - users = [ - { user: "ctl", password: "pw" } - { user: "n1.mesh-delivery-checker", password: "pw" } - ] - } -} -` - -const ( - repo = "novox/mesh-delivery" - head1 = "1111111111111111111111111111111111111111" - head2 = "2222222222222222222222222222222222222222" - trunk = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - merged = "fedcba9876543210fedcba9876543210fedcba98" // the merge commit of the captured fetch answer - digU = "aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11" - digI = "bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22" -) - -var captured = filepath.Join("..", "..", "internal", "check", "testdata", "captured") - -func readCaptured(t *testing.T, name string) map[string]any { - t.Helper() - raw, err := os.ReadFile(filepath.Join(captured, name+".json")) - if err != nil { - t.Fatal(err) - } - var v map[string]any - if err := json.Unmarshal(raw, &v); err != nil { - t.Fatal(err) - } - return v -} - -// fakeBuildModules serve the tools of mesh-build-go and mesh-build-node as the real ones do (ADR 0469 clause 2): a call on -// mesh.mod..call... answers at once with the step and its key, and the step's end is written to -// the key . of the module's steps bucket. What the steps end with are the results the build modules' own code -// marshalled (internal/check/testdata/captured, README). -type fakeBuildModules struct { - js jetstream.JetStream - ctx context.Context - conflict atomic.Bool - // hold is a commit whose fetch never answers: its ask stays taken, as one lost in a bus reload (issue 734). - hold atomic.Value - mu sync.Mutex - calls map[string]int // by `.` - testTool *testing.T - // beside is, by workspace, the siblings the fetch placed in it as ` `, sorted: a digest echoes them - // (1929/AC2; mesh-build-go buildstep.besideOf), or the level runs whole and keeps nothing. - beside map[string][]string - // names are the nodes' names the last check ask carried, for the names check (ADR 0567 §12). - names []string - // packages are, by repository, the package versions the last Go check ask of it carried (StepAsk.Packages). - packages map[string]buildstep.PackageVersions - // runs counts the run asks answered, and broken, when set, is why the checking program does not build (issue 1921). - runs atomic.Int32 - broken atomic.Value - // drop, when set, drops every run ask unanswered and counts it in dropped, as a build module that does not know the job - // run (the lead's ruling on milestone 47/B0). - drop atomic.Bool - dropped atomic.Int32 -} - -// droppingAsks is the seat's asks as a build module that does not know the job run takes them: a run ask is acknowledged and -// never begun while the fake drops them. -type droppingAsks struct { - gobuild.AskSource - f *fakeBuildModules -} - -func (d droppingAsks) Next(ctx context.Context, kind string, wait time.Duration) (*gobuild.Pulled, error) { - msg, err := d.AskSource.Next(ctx, kind, wait) - if err != nil || msg == nil || !d.f.drop.Load() { - return msg, err - } - var a buildstep.StepAsk - if json.Unmarshal(msg.Data, &a) == nil && a.Run != nil { - d.f.dropped.Add(1) - return nil, msg.Ack() - } - return msg, nil -} - -// run answers a run ask as mesh-build-go does: the checking program's work (rules.Program) over the input the ask names, -// asked of the seat verb it names on the bus and checked against its digest (buildstep.RunInput.Read, as mesh-build-go -// reads it), with no heads of its own laid. -func (f *fakeBuildModules) run(ctx context.Context, a buildstep.StepAsk) (any, error) { - f.runs.Add(1) - if why, _ := f.broken.Load().(string); why != "" { - return nil, errors.New(why) - } - answer := buildstep.RunAnswer{Built: true, Key: "program-0123456789abcdef"} - // As mesh-build-go does, the input is asked before the program runs, and a step whose input cannot be had fails. - body, err := meshdeliverycheckerclient.ReadInput(func(key string, body any) (json.RawMessage, error) { return askVerb(f.js.Conn(), key, body) }, a.Run.Input.Digest) - if err == nil { - err = a.Run.Input.Verify(body) - } - if err != nil { - return nil, err - } - out, err := rules.Program(a.Run.Args, func() ([]byte, error) { return body, nil }, fstest.MapFS{}) - if err != nil { - answer.Exit, answer.Said = 2, err.Error() - } - answer.Output = out - return answer, nil -} - -// askVerb asks a seat verb on the subject that names no caller and reads the runtime's reply, {result, error}. -func askVerb(nc *nats.Conn, key string, body any) (json.RawMessage, error) { - seat, verb, ok := strings.Cut(strings.TrimPrefix(key, "seat:"), ".") - if !ok || !strings.HasPrefix(key, "seat:") { - return nil, fmt.Errorf("%q names no seat verb", key) - } - data, err := json.Marshal(body) - if err != nil { - return nil, err - } - msg, err := nc.Request("mesh.seat."+seat+".tool."+verb, data, 5*time.Second) - if err != nil { - return nil, err - } - var r struct { - Result json.RawMessage `json:"result"` - Error string `json:"error"` - } - if err := json.Unmarshal(msg.Data, &r); err != nil { - return nil, err - } - if r.Error != "" { - return nil, errors.New(r.Error) - } - return r.Result, nil -} - -// serveInputVerb answers the checker seat's verb input on the bus as the checker's tools do (check.Reader.Input over the -// checker's state inputs), and counts what it answered (issue 1921, ADR 0596 §2). -func (b *bed) serveInputVerb(t *testing.T, nc *nats.Conn) { - t.Helper() - kv := b.buckets[testBucket(check.InputsStateName)] - r := check.Reader{InputState: check.StateRead{Get: func(key string) (json.RawMessage, error) { - e, err := kv.Get(b.ctx, key) - if errors.Is(err, jetstream.ErrKeyNotFound) { - return nil, nil - } - if err != nil { - return nil, err - } - return e.Value(), nil - }}} - if _, err := nc.Subscribe("mesh.seat.mesh-delivery-checker.tool."+meshdeliverychecker.VerbInput, func(m *nats.Msg) { - var ask meshdeliverychecker.InputInput - reply := map[string]any{} - if err := json.Unmarshal(m.Data, &ask); err != nil { - reply["error"] = err.Error() - } else if a, err := r.Input(ask.Digest); err != nil { - reply["error"] = err.Error() - } else { - reply["result"] = a - b.inputsAnswered.Add(1) - } - data, _ := json.Marshal(reply) - _ = m.Respond(data) - }); err != nil { - t.Fatal(err) - } -} - -func (f *fakeBuildModules) count(tool string) int { - f.mu.Lock() - defer f.mu.Unlock() - return f.calls[tool] -} - -func (f *fakeBuildModules) result(t *testing.T, tool string, args map[string]any) json.RawMessage { - level, _ := args["level"].(string) - var v any - switch { - case strings.HasSuffix(tool, "_fetch"): - if h, _ := f.hold.Load().(string); h != "" && args["commit"] == h { - <-f.ctx.Done() - } - name := "go-fetch-clean" - if f.conflict.Load() { - name = "go-fetch-conflict" - } - fetched := readCaptured(t, name) - fetched["commit"], fetched["base"] = args["commit"], args["base"] - var refs []struct { - Repository string `json:"repository"` - Commit string `json:"commit"` - } - raw, _ := json.Marshal(args["beside"]) - _ = json.Unmarshal(raw, &refs) - var lines []string - for _, r := range refs { - lines = append(lines, r.Repository+" "+r.Commit) - } - sort.Strings(lines) - f.mu.Lock() - if f.beside == nil { - f.beside = map[string][]string{} - } - f.beside[fmt.Sprint(fetched["workspace"])] = lines - f.mu.Unlock() - v = fetched - case strings.HasSuffix(tool, "_digest"): - d := map[string]string{"unit": digU, "integration": digI}[level] - f.mu.Lock() - beside := f.beside[fmt.Sprint(args["workspace"])] - f.mu.Unlock() - v = map[string]any{"level": level, "packages": map[string]string{"fixture/slow": d}, "beside": beside} - case strings.HasSuffix(tool, "_test"): - r := readCaptured(t, "go-test-slow") - r["level"] = level - v = r - } - data, _ := json.Marshal(v) - return data -} - -// serve makes module's steps bucket and its build seat's stream and workers, and pulls its asks on n1 as the real module -// does since R4g (ADR 0525; issue 1887 A5): each ask's job runs with step bodies answering the captured results, and a -// check takes the kept verdicts of the checker's kept bucket by their digests. -func (f *fakeBuildModules) serve(t *testing.T, module string, kept jetstream.KeyValue) { - kv, err := f.js.CreateKeyValue(f.ctx, jetstream.KeyValueConfig{Bucket: buildrun.StepsBucket(module), History: 1}) - if err != nil { - t.Fatal(err) - } - language := strings.TrimPrefix(module, "mesh-build-") - if err := gobuild.DeclareAskWorkers(f.ctx, f.js, language, 30*time.Second); err != nil { - t.Fatal(err) - } - prefix := map[string]string{goBuildModule: "build_go_", nodeBuildModule: "build_node_"}[module] - call := func(name string) gobuild.StepFunc { - return func(ctx context.Context, args map[string]any) (any, error) { - tool := prefix + name - f.mu.Lock() - f.calls[module+"."+tool]++ - f.mu.Unlock() - return f.result(t, tool, args), nil - } - } - steps := gobuild.AskSteps{Fetch: call("fetch"), Test: call("test"), - Kept: func(ctx context.Context, level, digest string) (int, bool, error) { - key, err := meshdeliverycheckerclient.KeptKey(level, digest) - if err != nil { - return 0, false, err - } - e, err := kept.Get(ctx, key) - if errors.Is(err, jetstream.ErrKeyNotFound) { - return 0, false, nil - } - if err != nil { - return 0, false, err - } - v, err := meshdeliverycheckerclient.DecodeKept(e.Value()) - return int(v.Tests), err == nil, err - }} - if module == goBuildModule { - steps.Digest = call("digest") - } - put := func(key string, value any) (uint64, error) { - raw, _ := value.(json.RawMessage) - return kv.Put(f.ctx, key, raw) - } - p := &gobuild.Puller{Source: droppingAsks{&gobuild.JetStreamAsks{JS: f.js, Language: language}, f}, Language: language, Node: "n1", Put: put, - Capacity: func() int { return 2 }, PullWait: 200 * time.Millisecond, - Run: func(ctx context.Context, a buildstep.StepAsk) (any, error) { - if a.Check != nil { - f.mu.Lock() - f.names = a.Check.NodeNames - if repository := a.Check.Fetch.Repository; a.Language == buildstep.AskGo { - if f.packages == nil { - f.packages = map[string]buildstep.PackageVersions{} - } - f.packages[repository] = a.Packages - } - f.mu.Unlock() - } - if a.Run != nil { - return f.run(ctx, a) - } - return gobuild.RunAsk(ctx, steps, a) - }} - go func() { _ = p.Pull(f.ctx) }() -} - -// serveForge answers the seat git's verb file as its holder does (milestone 47/G W6.14), with the go.mod the forge gave -// (internal/check/testdata/captured), whose mesh-sdk pin is cb54756c3865 unless the test set it as stale, and a member's -// manifest at its head as the bed holds it, else absent. -func (b *bed) serveForge(t *testing.T, nc *nats.Conn) { - var captured struct { - File struct { - Content string `json:"content"` - } `json:"file"` - } - if err := json.Unmarshal(mustRead(t, "forge-get-file-go-mod"), &captured); err != nil { - t.Fatal(err) - } - respond := func(m *nats.Msg, a gitseat.FileAnswer) { - answer, _ := json.Marshal(map[string]any{"result": a, "node": "n0"}) - _ = m.Respond(answer) - } - for _, subject := range []string{"mesh.seat.git.call.file", "mesh.seat.git.call.file.>"} { - sub, err := nc.Subscribe(subject, func(m *nats.Msg) { - var in gitseat.FileInput - _ = json.Unmarshal(m.Data, &in) - switch { - case strings.HasSuffix(in.Path, "module.json"): - // A manifest at a member's head (design 51 *Tagged versions*): the bed's own, else absent. - if content, ok := b.heads.Load(in.Repository + " " + in.Path + " " + in.Ref); ok { - respond(m, gitseat.FileAnswer{Path: in.Path, Ref: in.Ref, Content: content.(string)}) - return - } - respond(m, gitseat.FileAnswer{Path: in.Path, Ref: in.Ref, Absent: true}) - case b.stalePin.Load(): - respond(m, gitseat.FileAnswer{Path: in.Path, Ref: in.Ref, Content: strings.Replace(captured.File.Content, "cb54756c3865", "9aaa5c80ac5c", 1)}) - default: - respond(m, gitseat.FileAnswer{Path: in.Path, Ref: in.Ref, Content: captured.File.Content}) - } - }) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { _ = sub.Unsubscribe() }) - } -} - -func mustRead(t *testing.T, name string) []byte { - t.Helper() - raw, err := os.ReadFile(filepath.Join(captured, name+".json")) - if err != nil { - t.Fatal(err) - } - return raw -} - -type bed struct { - stalePin atomic.Bool - // heads are the manifests the forge holds at a member's head, by " ". - heads sync.Map - ctx context.Context - js jetstream.JetStream - buckets map[string]jetstream.KeyValue - tools map[string]jetstream.KeyValue - // inputsAnswered counts the inputs the seat's verb input answered (issue 1921). - inputsAnswered atomic.Int32 - fake *fakeBuildModules - srvURL string - // trunk is the catalog half's trunk revision the bed's seat answers `revision` with (design 47 G section 197). - trunkNow *atomic.Value - announce []string - mu sync.Mutex - logs saidLog -} - -// saidLog is what the program said, safe for its goroutines and the test's. -type saidLog struct { - mu sync.Mutex - b strings.Builder -} - -func (l *saidLog) Write(p []byte) (int, error) { l.mu.Lock(); defer l.mu.Unlock(); return l.b.Write(p) } -func (l *saidLog) String() string { l.mu.Lock(); defer l.mu.Unlock(); return l.b.String() } - -// said waits until the program said words, within 20 s: an event to wait on, not a pause a loaded machine can outlast. -func (b *bed) said(t *testing.T, words string) { - t.Helper() - for deadline := time.Now().Add(20 * time.Second); !strings.Contains(b.logs.String(), words); time.Sleep(10 * time.Millisecond) { - if time.Now().After(deadline) { - t.Fatalf("the checker did not say %q within 20 s:\n%s", words, b.logs.String()) - } - } -} - -// engine places each node and serves compose-candidate for the first one, as its node-engine does on the bus (answered on -// the seat verb's caller-named and plain subjects); the others never answer. It answers what it was asked. -func (b *bed) engine(t *testing.T, nodes ...string) func() []ne.ComposeCandidateInput { - t.Helper() - kv, err := b.js.CreateKeyValue(b.ctx, jetstream.KeyValueConfig{Bucket: testAssigner + "_assignments", History: 1}) - if err != nil { - t.Fatal(err) - } - for _, n := range nodes { - pk, _ := meshmoduleassignerclient.NodeKey(n) - raw, _ := meshmoduleassignerclient.EncodeNode(meshmoduleassigner.AssignmentsByNodeNodeValue{Node: n}) - if _, err := kv.Put(b.ctx, pk, raw); err != nil { - t.Fatal(err) - } - } - nc, err := nats.Connect(b.srvURL, nats.UserInfo("ctl", "pw")) - if err != nil { - t.Fatal(err) - } - t.Cleanup(nc.Close) - var mu sync.Mutex - var asked []ne.ComposeCandidateInput - answer := func(m *nats.Msg) { - ask, err := nec.DecodeAsk(m.Data) - if err != nil { - _ = m.Respond([]byte(`{"error":"` + err.Error() + `"}`)) - return - } - mu.Lock() - asked = append(asked, ask) - mu.Unlock() - a := ne.ComposeCandidateAnswer{Node: nodes[0], Candidate: ask.Candidate, Verdict: nec.Composed, - Own: ne.Module{Module: nec.Own, State: nec.ModuleComposed, Digest: "sha256:" + strings.Repeat("b", 64)}} - raw, err := nec.EncodeAnswer(a) - if err != nil { - t.Error(err) - } - out, _ := json.Marshal(map[string]any{"result": json.RawMessage(raw), "node": nodes[0]}) - _ = m.Respond(out) - } - for _, subject := range []string{"mesh.seat.node-engine.call.compose-candidate." + nodes[0] + ".>", "mesh.seat.node-engine.tool.compose-candidate." + nodes[0]} { - if _, err := nc.Subscribe(subject, answer); err != nil { - t.Fatal(err) - } - } - return func() []ne.ComposeCandidateInput { - mu.Lock() - defer mu.Unlock() - return slices.Clone(asked) - } -} - -// startBed starts the bus, the buckets the controller makes from the checker's and the other parts' manifests, the build -// modules' streams and the checker's durable consumers on them, one node's toolchains, the gate's source naming the trunk, and -// the fake build modules. It runs no checker. -func startBed(t *testing.T) *bed { - dir, err := os.MkdirTemp(os.Getenv("TMPDIR"), "c") - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { os.RemoveAll(dir) }) - conf := filepath.Join(dir, "bus.conf") - if err := os.WriteFile(conf, []byte(fmt.Sprintf(busConf, filepath.Join(dir, "js"))), 0o600); err != nil { - t.Fatal(err) - } - opts, err := server.ProcessConfigFile(conf) - if err != nil { - t.Fatal(err) - } - opts.NoLog, opts.NoSigs = true, true - srv, err := server.NewServer(opts) - if err != nil { - t.Fatal(err) - } - go srv.Start() - if !srv.ReadyForConnections(10 * time.Second) { - t.Fatal("the bus did not come up") - } - t.Cleanup(srv.Shutdown) - ctl, err := nats.Connect(srv.ClientURL(), nats.UserInfo("ctl", "pw")) - if err != nil { - t.Fatal(err) - } - t.Cleanup(ctl.Close) - js, err := jetstream.New(ctl) - if err != nil { - t.Fatal(err) - } - // The seat mesh-catalog's holder answers the seat list with no trunk seat named: the checker's reader has then heard the seat - // and holds the bootstrapped definitions, which the judge is handed (ADR 0636 §1). - // It lists the build seats (design 47 G A-82): the seat whose acting rule builds Go and the one that builds TypeScript, from - // which the checker finds its build modules. - for _, subject := range []string{"mesh.seat.mesh-catalog.call.seat-definitions", "mesh.seat.mesh-catalog.call.seat-definitions.>"} { - if _, err := ctl.Subscribe(subject, func(m *nats.Msg) { _ = m.Respond(seatDefinitionsAnswer(m.Data)) }); err != nil { - t.Fatal(err) - } - } - trunkView := &atomic.Value{} - trunkView.Store(map[string]string{}) - for _, subject := range []string{"mesh.seat.mesh-catalog.call.revision", "mesh.seat.mesh-catalog.call.revision.>"} { - if _, err := ctl.Subscribe(subject, func(m *nats.Msg) { - var heads []meshcatalog.Head - for repo, commit := range trunkView.Load().(map[string]string) { - heads = append(heads, meshcatalog.Head{Repository: repo, Commit: commit}) - } - // Design 47 G §717, A-298: the trunk's entry of testAssigner claims mesh-module-assigner, so the catalog half names it - // the claimant whose seat-holders view the checker follows. - body, _ := json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Kind: "trunk", Branch: "main", Revision: 1, Trunk: heads}, - Entries: []meshcatalog.CatalogEntry{{Module: testAssigner, ManifestDigest: "sha256:" + strings.Repeat("a", 64), - Manifest: map[string]any{"module": testAssigner, "claims": []any{map[string]any{"name": meshmoduleassigner.Seat}}}}}}) - reply, _ := json.Marshal(map[string]any{"result": json.RawMessage(body), "node": "ctl"}) - _ = m.Respond(reply) - }); err != nil { - t.Fatal(err) - } - } - ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second) - t.Cleanup(cancel) - b := &bed{trunkNow: trunkView, ctx: ctx, js: js, buckets: map[string]jetstream.KeyValue{}, tools: map[string]jetstream.KeyValue{}, srvURL: srv.ClientURL()} - for _, module := range []string{goBuildModule, nodeBuildModule} { - kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: buildrun.ToolchainsBucket(module), History: 1}) - if err != nil { - t.Fatal(err) - } - b.tools[module] = kv - } - // What the controller keeps of the messages a consumer gave up on (issue 734). - if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buildrun.DeadLettersStream, Subjects: []string{"mesh.events.dead.>"}}); err != nil { - t.Fatal(err) - } - // The checker's streams as its manifest declares them (ADR 0619, ADR 0620), read from it so the bed holds every event - // it declares: checks, which the indexer and the forge bridge hear (preview, owed and a whole try's start and end, whose - // say would otherwise wait out its retries on a subject no stream holds), and asks, with verdict and tag-wanted. - raw, err := os.ReadFile("../../module.json") - if err != nil { - t.Fatal(err) - } - m, err := catalogue.Decode(raw) - if err != nil { - t.Fatal(err) - } - for _, s := range m.Streams { - var subjects []string - for _, e := range s.Events { - subjects = append(subjects, process.ModuleStreamSubject(testChecker, strings.ReplaceAll(e, "**", ">"))) - } - if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: s.BusName(), Subjects: subjects}); err != nil { - t.Fatal(err) - } - } - if !slices.ContainsFunc(m.Streams, func(s catalogue.StreamDeclaration) bool { return s.Name == "checks" }) || - meshdeliverychecker.HolderSubjectVerdict(testChecker) != process.ModuleStreamSubject(testChecker, "verdict") { - t.Fatalf("the checker's manifest declares the streams %+v, want checks, and asks at the definition's subjects", m.Streams) - } - // The shared events stream with the seats' and modules' events (the package registry seats' published among them), and the checker's durable consumer of it. - if _, err := js.CreateOrUpdateStream(ctx, jetstream.StreamConfig{Name: process.EventsStream, Subjects: []string{"mesh.mod.*.event.>", "mesh.seat.*.event.>"}}); err != nil { - t.Fatal(err) - } - if _, err := js.CreateOrUpdateConsumer(ctx, process.EventsStream, jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-checker", AckPolicy: jetstream.AckExplicitPolicy}); err != nil { - t.Fatal(err) - } - for name, history := range map[string]int{testBucket(meshdeliverychecker.StateVerdicts): 5, testBucket(meshdeliverychecker.StateKept): 1, - testBucket(meshdeliverychecker.StateOwed): 5, testBucket(meshdeliverychecker.StatePreviews): 5, check.CandidatesBucket: 10, - check.ModulesBucket: 20, check.ManifestsBucket: 1, - check.PresenceBucket: 20, check.HaveBucket: 20, testBucket(check.TriesState): 1, - builds.BuildsBucket(builds.BuilderModule): 1, testBucket(check.InputsStateName): 1} { - kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: name, History: uint8(history)}) - if err != nil { - t.Fatal(err) - } - b.buckets[name] = kv - } - // The indexer and the assigner as the owners of the states the checker follows: their read tools and views families - // (ADR 0615, DLV-M2). - for _, st := range []string{candidatesState, modulesState, manifestsState, meshcatalog.StatePackages, check.IndexerPredefinedState, seatDefinitionsState} { - viewstest.Serve(t, ctx, js, ctl, check.IndexerModule, st, check.IndexerModule+".indexer_read_"+strings.ReplaceAll(st, "-", "_"), "n1_"+testChecker) - } - // The catalog half's registrations and the gate's source branch (design 47 G §614), and the claimant's seat-holders view naming - // testAssigner the holder of mesh-module-assigner (§717): nothing answers the seat's verb assignments. - for subject, result := range map[string]any{"mesh.seat.mesh-catalog.call.registrations": meshcatalog.RegistrationsAnswer{Registrations: []meshcatalog.Registration{}}, - "mesh.seat.mesh-delivery.call.source": map[string]any{"branches": []string{"main"}}} { - reply, _ := json.Marshal(map[string]any{"result": result, "node": "ctl"}) - for _, s := range []string{subject, subject + ".>"} { - if _, err := ctl.Subscribe(s, func(m *nats.Msg) { _ = m.Respond(reply) }); err != nil { - t.Fatal(err) - } - } - } - seatHolders := viewstest.Serve(t, ctx, js, ctl, testAssigner, meshmoduleassigner.StateSeatHolders, testAssigner+"."+meshmoduleassigner.StateSeatHolders, "n1_"+testChecker) - if _, err := seatHolders.Put(ctx, meshmoduleassigner.Seat, []byte(`{"seat":"`+meshmoduleassigner.Seat+`","holders":[{"module":"`+testAssigner+`","node":"n1"}]}`)); err != nil { - t.Fatal(err) - } - viewstest.Serve(t, ctx, js, ctl, testAssigner, meshmoduleassigner.StateAssignments, testAssigner+"."+meshmoduleassigner.StateAssignments, "n1_"+testChecker) - // 1929/AC1: the indexer's value of the repository's module, with no TypeScript manifest, so the Go build module alone - // judges the repository (an unknown repository is judged by both, issue 1887 A12). - known, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: repo, Commit: trunk, Path: "modules/m", None2: "the fingerprint is computed with its chain"}) - if err != nil { - t.Fatal(err) - } - if _, err := b.buckets[check.ModulesBucket].Put(ctx, "m", known); err != nil { - t.Fatal(err) - } - b.setOnline(t, "n1", true) - b.setNode(t, "n1") - // The indexer's modules name the holders of the build seats, by the seats their manifests claim. - b.putBuildModule(t, goBuildModule, "node-build-go") - b.putBuildModule(t, nodeBuildModule, "node-build-node") - for _, module := range []string{goBuildModule, nodeBuildModule} { - b.setHealth(t, "n1", module) - } - b.serveForge(t, ctl) - b.serveInputVerb(t, ctl) - b.fake = &fakeBuildModules{js: js, ctx: ctx, calls: map[string]int{}} - b.fake.serve(t, goBuildModule, b.buckets[testBucket(meshdeliverychecker.StateKept)]) - b.fake.serve(t, nodeBuildModule, b.buckets[testBucket(meshdeliverychecker.StateKept)]) - b.report(t, goBuildModule, "n1", "go", "go1.27.1", "1") - b.report(t, nodeBuildModule, "n1", "typescript", "tsc5", "1") - b.setTrunk(t, map[string]string{repo: trunk}) - return b -} - -func (b *bed) setTrunk(t *testing.T, heads map[string]string) { - t.Helper() - b.trunkNow.Store(heads) - body, _ := json.Marshal(meshcatalog.CatalogRevisionEvent{Kind: "trunk", Branch: "main", Revision: 1, V: 1}) - if _, err := b.js.Publish(b.ctx, meshcatalog.SubjectCatalogRevision("main"), body); err != nil { - t.Fatal(err) - } -} - -func (b *bed) setOnline(t *testing.T, node string, online bool) { - t.Helper() - data, _ := json.Marshal(meshwatchdogs.PresenceByNodeValue{V: keys.Version, Online: online}) - if _, err := b.buckets[check.PresenceBucket].Put(b.ctx, node, data); err != nil { - t.Fatal(err) - } -} - -// setNode writes the node's record in the node-engine's have, as the node-engine does, so the checker names it in each -// check ask (ADR 0567 §12); with no record the checker asks no check. -func (b *bed) setNode(t *testing.T, node string) { - t.Helper() - data, err := nodeengineclient.EncodeHaveNode(nodeengine.HaveByNodeNodeValue{Record: &nodeengine.NodeRecord{Node: node}}) - if err != nil { - t.Fatal(err) - } - key, _ := nodeengineclient.HaveNodeKey(node) - if _, err := b.buckets[check.HaveBucket].Put(b.ctx, key, data); err != nil { - t.Fatal(err) - } -} - -func (b *bed) setHealth(t *testing.T, node, module string) { - t.Helper() - data, err := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}) - if err != nil { - t.Fatal(err) - } - key, _ := nodeengineclient.HaveKey(node, module) - if _, err := b.buckets[check.HaveBucket].Put(b.ctx, key, data); err != nil { - t.Fatal(err) - } -} - -func (b *bed) report(t *testing.T, module, node, language, version, recipe string) { - t.Helper() - data, err := buildstep.EncodeToolchain(buildstep.Toolchain{Language: language, Version: version, Recipe: recipe, At: time.Now().UTC()}) - if err != nil { - t.Fatal(err) - } - key, _ := buildstep.ToolchainKey(node, language) - if _, err := b.tools[module].Put(b.ctx, key, data); err != nil { - t.Fatal(err) - } - seat := "node-build-go" - if module == nodeBuildModule { - seat = "node-build-node" - } - if _, err := b.js.Publish(b.ctx, "mesh.seat."+seat+".event.toolchain-reported."+node, []byte(`{}`)); err != nil { - t.Fatal(err) - } -} - -// candidate writes candidates. as the indexer does (the SDK's EncodeCandidate is the indexer's own encoder). -func (b *bed) candidate(t *testing.T, group string, pulls ...meshcatalog.CandidatesByGroupValuePullsItem) string { - t.Helper() - heads := make([]meshdeliveryclient.Head, len(pulls)) - for i, p := range pulls { - heads[i] = meshdeliveryclient.Head{Repository: p.Repository, Number: int(p.Number), Head: p.Head} - } - hash, err := meshdeliveryclient.HeadsHash(heads) - if err != nil { - t.Fatal(err) - } - data, err := json.Marshal(meshcatalog.CandidatesByGroupValue{V: keys.Version, Group: group, Heads: hash, Pulls: pulls, Fpset: meshcatalogclient.FingerprintSet(pulls)}) - if err != nil { - t.Fatal(err) - } - key, _ := meshcatalogclient.CandidatesKey(group) - if _, err := b.buckets[check.CandidatesBucket].Put(b.ctx, key, data); err != nil { - t.Fatal(err) - } - vk, _ := meshdeliverycheckerclient.VerdictKey(group, hash) - return vk -} - -func pull(repository string, number int, head string) meshcatalog.CandidatesByGroupValuePullsItem { - return meshcatalog.CandidatesByGroupValuePullsItem{Repository: repository, Number: int64(number), Head: head, Modules: []string{}} -} - -// start runs the program as the checker of a node. -func (b *bed) start(t *testing.T, env map[string]string) { - t.Helper() - broker := filepath.Join(t.TempDir(), "broker") - cred, _ := json.Marshal(process.Account{URL: b.srvURL, Node: "n1", Module: "mesh-delivery-checker", User: "n1.mesh-delivery-checker", Password: "pw"}) - if err := os.WriteFile(broker, cred, 0o600); err != nil { - t.Fatal(err) - } - // The settle window of a group's heads (check.DefaultSettle) is cut short: each bed's candidate is written whole. - e := map[string]string{"MESH_BROKER_FILE": broker, "MESH_CHECKER_SETTLE": "10ms"} - for k, v := range env { - e[k] = v - } - runCtx, stop := context.WithCancel(b.ctx) - done := make(chan error, 1) - go func() { done <- run(runCtx, func(k string) string { return e[k] }, &b.logs) }() - t.Cleanup(func() { stop(); <-done }) -} - -// verdict reads the verdict key until pred holds of it, within 20 s. -func (b *bed) verdict(t *testing.T, key string, pred func(meshdeliverychecker.VerdictsByGroupHeadsValue) bool) meshdeliverychecker.VerdictsByGroupHeadsValue { - t.Helper() - var last meshdeliverychecker.VerdictsByGroupHeadsValue - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - e, err := b.buckets[testBucket(meshdeliverychecker.StateVerdicts)].Get(b.ctx, key) - if err != nil { - continue - } - if last, err = meshdeliverycheckerclient.DecodeVerdict(e.Value()); err == nil && pred(last) { - return last - } - } - t.Fatalf("verdicts.%s = %+v within 20 s", key, last) - return last -} - -func ended(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State != meshdeliverycheckerclient.VerdictRunning -} - -// owed reads the status the checker owes on a head. -func (b *bed) owed(t *testing.T, number int, head, state string) meshdeliverychecker.OwedByRepositoryNumberHeadActValue { - t.Helper() - key, err := check.CheckerOwedKey(repo, number, head) - if err != nil { - t.Fatal(err) - } - var last meshdeliverychecker.OwedByRepositoryNumberHeadActValue - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - e, err := b.buckets[testBucket(meshdeliverychecker.StateOwed)].Get(b.ctx, key) - if err != nil { - continue - } - if last, err = check.DecodeCheckerOwed(e.Value()); err == nil && last.State == state { - return last - } - } - t.Fatalf("owed.%s = %+v within 20 s, want the state %s", key, last, state) - return last -} - -// TestCheckerJudgesACandidateAndOwesItsStatus: a candidate the indexer wrote, one pull request of mesh-delivery, is fetched -// merged onto the trunk the gate names, digested and tested at both levels on the node, kept, previewed; the verdict passes -// with the counts of both levels and the composition not run, and the status mesh/check is owed on the head as success. -func TestCheckerJudgesACandidateAndOwesItsStatus(t *testing.T) { // N6/AC5, 1300/AC5, 1445/AC1, 1929/AC1, ADR 0603 §10 - b := startBed(t) - // ADR 0603 §10: the candidate changes the module m, whose manifest the trunk holds; the builder has not built m's - // candidate fingerprint yet, so the check waits on the builder's key before it composes. - manifest := `{"module":"m"}` - digest := meshcatalogclient.ManifestDigest([]byte(manifest)) - stored, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "m", Manifest: manifest}) - if err != nil { - t.Fatal(err) - } - mkey, _ := meshcatalogclient.ManifestsKey(digest) - if _, err := b.buckets[check.ManifestsBucket].Put(b.ctx, mkey, stored); err != nil { - t.Fatal(err) - } - known, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: repo, Commit: trunk, Path: "modules/m", Manifest: digest, None2: "the fingerprint is computed with its chain"}) - if err != nil { - t.Fatal(err) - } - if _, err := b.buckets[check.ModulesBucket].Put(b.ctx, "m", known); err != nil { - t.Fatal(err) - } - fp := "src2:" + strings.Repeat("f", 64) - p := pull(repo, 7, head1) - p.Modules, p.Fps = []string{"m"}, map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"m": {Fp2: fp, Manifest: digest}} - key := b.candidate(t, "feat/x", p) - // ADR 0593 §7, §9 (D12): n1 and n2 are placed; n1's engine answers compose-candidate on the bus, n2's never does. - asked := b.engine(t, "n1", "n2") - b.start(t, nil) - b.said(t, "waits on the builder's builds of m before it composes") - if got := asked(); len(got) != 0 { - t.Fatalf("the engines were asked %+v before m's build ended", got) - } - bkey, _ := builds.BuilderBuildKey("m", fp) - building, _ := json.Marshal(builds.BuilderBuild{V: 1, State: builds.BuildBuilding}) - if _, err := b.buckets[builds.BuildsBucket(builds.BuilderModule)].Put(b.ctx, bkey, building); err != nil { - t.Fatal(err) - } - if v := b.verdict(t, key, func(meshdeliverychecker.VerdictsByGroupHeadsValue) bool { return true }); v.State != meshdeliverycheckerclient.VerdictRunning || len(asked()) != 0 { - t.Fatalf("verdict %s and %d asks while m builds: the check composes only once its build ended", v.State, len(asked())) - } - // m's build fails: the check fails naming it. Built again (builder_build_again writes the key done), the check asks - // itself again for the same heads, with no recheck, and passes. - failedBuild, _ := json.Marshal(builds.BuilderBuild{V: 1, State: builds.BuildFailed, Error: "go build: undefined: x"}) - if _, err := b.buckets[builds.BuildsBucket(builds.BuilderModule)].Put(b.ctx, bkey, failedBuild); err != nil { - t.Fatal(err) - } - if v := b.verdict(t, key, ended); v.State != meshdeliverycheckerclient.VerdictFail || v.Failed.Test != check.BuildFailedTest+"m" { - t.Fatalf("verdict %+v, want it failed on m's build", v) - } - built, _ := json.Marshal(builds.BuilderBuild{V: 1, State: builds.BuildDone, Manifest: digest}) - if _, err := b.buckets[builds.BuildsBucket(builds.BuilderModule)].Put(b.ctx, bkey, built); err != nil { - t.Fatal(err) - } - b.said(t, "the builds of m it failed on are done again, so it is checked again") - v := b.verdict(t, key, func(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictPass - }) - // The check asked again takes the packages the failed check ran from their kept verdicts. - if v.State != meshdeliverycheckerclient.VerdictPass || v.Levels[buildstep.LevelUnit].Kept != 2 || v.Levels[buildstep.LevelIntegration].Kept != 2 || v.Trunk[repo] != trunk { - t.Fatalf("verdict = %+v", v) - } - if c := v.Composition; c == nil || c.State != meshdeliverycheckerclient.CompositionPass || !slices.Equal(c.Machines, []string{"n1"}) || - !strings.Contains(c.Words, "n2: "+nec.NoAnswer) || len(v.Machines) != 1 || v.Machines[0] != "n1" { - t.Errorf("composition %+v machines %v", v.Composition, v.Machines) - } - if v.Composition != nil && strings.Contains(v.Composition.Words, "did not end") { - t.Errorf("the composition says %q: m's build ended within the bound", v.Composition.Words) - } - if got := asked(); len(got) == 0 || got[0].Candidate != key { - t.Errorf("n1's engine was asked %+v, want the check's candidate %s", got, key) - } - // Issue 1921 (B0): the verdict is the checking program's, built at the group's mesh-delivery head over its input kept in - // the state inputs and asked of the seat's verb input, two run asks a check (the seat list, the verdict); the verdict names the program's build. - if by := v.JudgedBy; by == nil || by.Program.Commit != head1 || by.Program.Package != check.CheckingProgramPackage || - by.Key != "program-0123456789abcdef" || len(by.Heads) != 1 || by.Heads[0].Commit != head1 { - t.Errorf("judged by %+v, want the checking program at the head %s", v.JudgedBy, head1) - } - if n := b.fake.runs.Load(); n != 4 { - t.Errorf("%d run asks, want two for each of the two checks", n) - } - // The operator's answer on B0: each run's input reached the build module through the seat's verb input on the bus. - if n := b.inputsAnswered.Load(); n != 4 { - t.Errorf("the verb input answered %d inputs, want one for each run ask", n) - } - b.fake.mu.Lock() - names := b.fake.names - b.fake.mu.Unlock() - if len(names) != 1 || names[0] != "n1" { - t.Errorf("the check ask named the nodes %v, want [n1] from the have's node record", names) - } - o := b.owed(t, 7, head1, "success") - if o.Context != meshdeliveryclient.StatusContextCheck || !strings.HasPrefix(o.Text, "pass 111111111111 on aaaaaaaaaaaa") || !strings.Contains(o.Text, "unit 0 run, 2 kept") { - t.Errorf("owed = %+v", o) - } - // Two checks of the same heads: the one failed on m's build and the one it asked itself again; the second runs no test. - for tool, want := range map[string]int{goBuildModule + ".build_go_fetch": 2, goBuildModule + ".build_go_digest": 4, goBuildModule + ".build_go_test": 2} { - if got := b.fake.count(tool); got != want { - t.Errorf("%s called %d times, want %d", tool, got, want) - } - } - // What passed is kept once under each level's digest. - for _, k := range []string{"unit." + digU, "integration." + digI} { - if _, err := b.buckets[testBucket(meshdeliverychecker.StateKept)].Get(b.ctx, k); err != nil { - t.Errorf("kept.%s: %v", k, err) - } - } - // The preview of the head merged onto the trunk, with the tree and the manifest digest the fetch named. - pk, _ := meshdeliverycheckerclient.PreviewKey(repo, head1, trunk) - e, err := b.buckets[testBucket(meshdeliverychecker.StatePreviews)].Get(b.ctx, pk) - if err != nil { - t.Fatalf("previews.%s: %v", pk, err) - } - pv, err := meshdeliverycheckerclient.DecodePreview(e.Value()) - if err != nil || pv.Merge != merged || pv.Modules["modules/m"].Tree != "1111111111111111111111111111111111111111" { - t.Errorf("preview = %+v, %v", pv, err) - } -} - -// TestACheckOrACarryOfEqualInputsRunsNothing: a second candidate (another head, the same digests) is checked with every -// package taken from the first's kept verdicts: no test step runs and no second kept key appears. Then, through the real bus -// (novox/hq ADR 0548 §3, §5): a third candidate is not claimed while the gate's merge turn on its repository stands, and is -// claimed when the turn's key is deleted; and a move of the trunk carries the first verdict on the recheck stream by its -// unchanged digests, running no test, the verdict naming the trunk it was carried from. -func TestACheckOrACarryOfEqualInputsRunsNothing(t *testing.T) { // 1287/AC5, 1288/AC6, 1929/AC2, ADR 0548 §3, §5 - b := startBed(t) - first := b.candidate(t, "feat/x", pull(repo, 7, head1)) - b.start(t, nil) - b.verdict(t, first, ended) - tests, kept := b.fake.count(goBuildModule+".build_go_test"), keptCount(t, b) - second := b.candidate(t, "feat/y", pull(repo, 8, head2)) - v := b.verdict(t, second, ended) - if v.State != meshdeliverycheckerclient.VerdictPass || v.Levels[buildstep.LevelUnit].Run != 0 || v.Levels[buildstep.LevelUnit].Kept != 2 || v.Levels[buildstep.LevelIntegration].Run != 0 { - t.Fatalf("verdict = %+v, want everything taken from the kept verdicts", v) - } - if got := b.fake.count(goBuildModule + ".build_go_test"); got != tests { - t.Errorf("build_go_test called %d times, was %d: a test ran for equal inputs", got, tests) - } - if got := keptCount(t, b); got != kept { - t.Errorf("%d kept keys, was %d", got, kept) - } - - // Design 47 G §278 (test 52): a new check is claimed at once, with no state of the gate granted to the checker. - third := b.candidate(t, "feat/z", pull(repo, 9, "3333333333333333333333333333333333333333")) - b.verdict(t, third, ended) - - // §5: the trunk moves; the first verdict is carried by its digests, nothing runs. - tests = b.fake.count(goBuildModule + ".build_go_test") - const moved = "abababababababababababababababababababab" - b.setTrunk(t, map[string]string{repo: moved}) - c := b.verdict(t, first, func(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { return ended(v) && v.Trunk[repo] == moved }) - if c.State != meshdeliverycheckerclient.VerdictPass || c.CarriedFrom[repo] != trunk || c.Levels[buildstep.LevelUnit].Run != 0 || c.Levels[buildstep.LevelIntegration].Run != 0 { - t.Fatalf("the carried verdict = %+v, want a pass carried from %s with no test run", c, trunk[:12]) - } - if got := b.fake.count(goBuildModule + ".build_go_test"); got != tests { - t.Errorf("build_go_test called %d times on the carry, was %d: a carry of unchanged digests runs nothing", got, tests) - } - if o := b.owed(t, 7, head1, "success"); !strings.HasPrefix(o.Text, "pass 111111111111 on abababababab | carried from aaaaaaaaaaaa") { - t.Errorf("the carried status says %q", o.Text) - } -} - -func keptCount(t *testing.T, b *bed) int { - t.Helper() - keys, err := b.buckets[testBucket(meshdeliverychecker.StateKept)].Keys(b.ctx) - if err != nil { - return 0 - } - return len(keys) -} - -// TestACheckThatCannotBeJudgedFailsNamingWhy: a head that does not merge fails naming the files in conflict and runs no -// test (1289/AC4); a checking program whose run asks no build node begins, and one that does not build, fail the check -// naming the checking program, never judged by the running rules (issue 1921, the lead's ruling on milestone 47/B0: the -// begin bound is the checker's setting, shortened here). -func TestACheckThatCannotBeJudgedFailsNamingWhy(t *testing.T) { // 1289/AC4, 1921 - for _, row := range []struct { - name string - set func(f *fakeBuildModules) - env map[string]string - words string - tests bool // the digest and test steps ran - dropped int32 // the run asks dropped: the seat list's, put twice, and no verdict asked after it - program bool // the checking program judged it - }{ - {name: "a head that does not merge", set: func(f *fakeBuildModules) { f.conflict.Store(true) }, words: "files in conflict: a.go, sub/b.go", program: true}, - {name: "a run ask no build node begins", set: func(f *fakeBuildModules) { f.drop.Store(true) }, env: map[string]string{"MESH_CHECKER_BEGIN_BOUND": "500ms"}, - words: "no build node began the job run of the asks", tests: true, dropped: 2}, - {name: "a program that does not build", set: func(f *fakeBuildModules) { f.broken.Store("go build: undefined: rules.Nothing") }, - words: "by the checking program: its run ask", tests: true}, - } { - t.Run(row.name, func(t *testing.T) { - b := startBed(t) - row.set(b.fake) - key := b.candidate(t, "feat/x", pull(repo, 7, head1)) - b.start(t, row.env) - v := b.verdict(t, key, ended) - if v.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(v.Failed.Words, row.words) || (v.JudgedBy != nil) != row.program { - t.Fatalf("verdict = %+v, want a fail saying %q, judged by the program %v", v, row.words, row.program) - } - if o := b.owed(t, 7, head1, "failure"); !strings.HasPrefix(o.Text, "failed") || - !strings.Contains(o.Text, map[bool]string{true: row.words, false: "the checking program"}[row.program]) { - t.Errorf("owed = %+v", o) - } - if n := b.fake.count(goBuildModule+".build_go_digest") + b.fake.count(goBuildModule+".build_go_test"); (n != 0) != row.tests { - t.Errorf("%d digest and test steps ran, want them run %v", n, row.tests) - } - if n := b.fake.dropped.Load(); n != row.dropped { - t.Errorf("%d run asks dropped, want %d", n, row.dropped) - } - if !row.tests { - pk, _ := meshdeliverycheckerclient.PreviewKey(repo, head1, trunk) - if e, err := b.buckets[testBucket(meshdeliverychecker.StatePreviews)].Get(b.ctx, pk); err != nil { - t.Errorf("previews.%s: %v", pk, err) - } else if pv, err := meshdeliverycheckerclient.DecodePreview(e.Value()); err != nil || strings.Join(pv.Conflicts, ",") != "a.go,sub/b.go" || pv.Merge != "" { - t.Errorf("preview = %+v, %v, want the files in conflict alone", pv, err) - } - } - }) - } -} - -// TestAnHqPullRequestGetsNoVerdictAndAnotherDoes: hq's pull request is judged by no one (ADR 0484 clause 8), the other one in -// the same run is. -// 1887/A10, ADR 0527 §2: a pull request into hq gets a verdict and a mesh/check from the checker, as any repository's. -func TestAnHqPullRequestGetsAVerdictAndAStatus(t *testing.T) { - b := startBed(t) - b.setTrunk(t, map[string]string{repo: trunk, "novox/hq": trunk}) - hq := b.candidate(t, "feat/hq", pull("novox/hq", 3, head1)) - b.start(t, nil) - if v := b.verdict(t, hq, ended); v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("hq's verdict = %+v", v) - } - key, _ := check.CheckerOwedKey("novox/hq", 3, head1) - for deadline := time.Now().Add(20 * time.Second); ; time.Sleep(50 * time.Millisecond) { - if e, err := b.buckets[testBucket(meshdeliverychecker.StateOwed)].Get(b.ctx, key); err == nil { - if o, err := check.DecodeCheckerOwed(e.Value()); err == nil && o.State == "success" { - return - } - } - if time.Now().After(deadline) { - t.Fatalf("hq#3 owes no success within 20 s") - } - } -} - -// TestACheckLeftRunningIsTakenOverWhenTheCheckerStarts: the verdict key holds running, left by a checker that stopped; the -// started checker judges it again and ends it (ADR 0478 clause 6, as the builder's). -func TestACheckLeftRunningIsTakenOverWhenTheCheckerStarts(t *testing.T) { // N6/AC2 - b := startBed(t) - key := b.candidate(t, "feat/x", pull(repo, 7, head1)) - group, heads, _ := meshdeliverycheckerclient.ParseVerdictKey(key) - left, err := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: group, Heads: heads, Trunk: map[string]string{repo: trunk}, State: meshdeliverycheckerclient.VerdictRunning}) - if err != nil { - t.Fatal(err) - } - if _, err := b.buckets[testBucket(meshdeliverychecker.StateVerdicts)].Create(b.ctx, key, left); err != nil { - t.Fatal(err) - } - b.start(t, nil) - if v := b.verdict(t, key, ended); v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("verdict = %+v", v) - } -} - -// TestAMemberNamingAMeshSDKCommitOffTheTrunkIsJudgedAndNotRefused: the go.mod the forge answers names a commit that main does -// not hold; the check is not refused for it, since the build takes the latest published mesh-sdk whatever go.mod names -// (novox/hq ADR 0573 §2, §4; issue 1585 S14, which retires issue 1624's pin check). -func TestAMemberNamingAMeshSDKCommitOffTheTrunkIsJudgedAndNotRefused(t *testing.T) { // 1624/AC2 as ADR 0573 §4 changes it - b := startBed(t) - b.stalePin.Store(true) - key := b.candidate(t, "feat/x", pull(repo, 7, head1)) - b.start(t, nil) - if v := b.verdict(t, key, ended); v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", v) - } - - // Design 47 G §528: a group whose mesh-sdk member declares a Go package is judged at once, with no tagged version asked - // or waited for, and its other member is built against the group's head. - const sdkRepo = "novox/mesh-sdk" - b.setTrunk(t, map[string]string{repo: trunk, sdkRepo: trunk}) - b.heads.Store(sdkRepo+" module.json "+head2, `{"module":"mesh-sdk","build":{"artifacts":[{"name":"go","kind":"package","language":"go","paths":["go"]}]}}`) - sdk := pull(sdkRepo, 12, head2) - sdk.Modules, sdk.Fps = []string{"mesh-sdk"}, map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"mesh-sdk": {Fp2: "src2:" + strings.Repeat("e", 64)}} - key = b.candidate(t, "feat/x", pull(repo, 8, head1), sdk) - if v := b.verdict(t, key, ended); v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("the group's verdict = %+v", v) - } - b.fake.mu.Lock() - got := b.fake.packages[repo] - b.fake.mu.Unlock() - if got[check.SDKModulePath] != head2 { - t.Errorf("mesh-delivery was built against %v, want mesh-sdk's Go module at the group's head %s", got, head2) - } - - // DLV-C2, DLV-C6 (design 26 *Out of step*, ADR 0620): each check's end says one verdict per pull request on the stream - // asks, at the definition's subject and in its body (decoded strictly): the lone pull request's, then the group's two. - verdicts, err := b.js.OrderedConsumer(b.ctx, "ASKS", jetstream.OrderedConsumerConfig{FilterSubjects: []string{meshdeliverychecker.HolderSubjectVerdict(testChecker)}}) - if err != nil { - t.Fatal(err) - } - said := map[int64]meshdeliverychecker.VerdictHolderEvent{} - for len(said) < 3 { - msg, err := verdicts.Next(jetstream.FetchMaxWait(20 * time.Second)) - if err != nil { - t.Fatalf("verdicts said %+v, then none: %v", said, err) - } - var e meshdeliverychecker.VerdictHolderEvent - dec := json.NewDecoder(bytes.NewReader(msg.Data())) - dec.DisallowUnknownFields() - if err := dec.Decode(&e); err != nil { - t.Fatalf("verdict %s is not the definition's body: %v", msg.Data(), err) - } - if _, twice := said[e.Pull]; twice { - t.Errorf("a second verdict of pull %d: %+v", e.Pull, e) - } - said[e.Pull] = e - } - for pull, want := range map[int64]meshdeliverychecker.VerdictHolderEvent{7: {Repository: repo, Pull: 7, Head: head1, Verdict: meshdeliverycheckerclient.VerdictPass}, - 8: {Repository: repo, Pull: 8, Head: head1, Verdict: meshdeliverycheckerclient.VerdictPass}, 12: {Repository: sdkRepo, Pull: 12, Head: head2, Verdict: meshdeliverycheckerclient.VerdictPass}} { - if got := said[pull]; got.Repository != want.Repository || got.Head != want.Head || got.Verdict != want.Verdict || len(got.OutOfStep) != 0 { - t.Errorf("verdict of pull %d = %+v, want %+v", pull, got, want) - } - } -} - -// triesStore is the tries bucket as the tools write it. -type triesStore struct { - kv jetstream.KeyValue - ctx context.Context -} - -func (s triesStore) Keys() ([]string, error) { - keys, err := s.kv.Keys(s.ctx) - if err == jetstream.ErrNoKeysFound { - return nil, nil - } - return keys, err -} -func (s triesStore) Get(key string) (json.RawMessage, error) { - e, err := s.kv.Get(s.ctx, key) - if err == jetstream.ErrKeyNotFound { - return nil, nil - } - if err != nil { - return nil, err - } - return e.Value(), nil -} -func (s triesStore) Create(key string, value []byte) error { - _, err := s.kv.Create(s.ctx, key, value) - return err -} - -// TestATryIsJudgedAndItsEndWrittenWithNoStatusOwed: a try written as checker_try writes it is taken by the running checker, -// judged through the build modules as a pull request's head merged onto its trunk, and ended pass in its key, with no -// verdict and no status owed (ADR 0501 §5). A whole try waits for the indexer's candidate of its group, which it reads on the -// key's watch, and writes the merge previews the indexer makes it from (issue 1921). -func TestATryIsJudgedAndItsEndWrittenWithNoStatusOwed(t *testing.T) { - b := startBed(t) - asked := b.engine(t, "n1") // a whole try is composed on every placed node, as a group's check is - b.start(t, nil) - store := triesStore{b.buckets[testBucket(check.TriesState)], b.ctx} - id, err := check.AskTry(store, map[string]string{repo: trunk}, check.TryAsk{Repository: repo, Head: head1}, time.Now()) - if err != nil { - t.Fatal(err) - } - var last check.Try - // The indexer's candidate of the try's group (here written by the test), at the heads of its members. - b.candidate(t, id, pull(repo, 0, head1)) - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - raw, _ := store.Get(id) - if last, err = check.DecodeTry(raw); err == nil && last.Over() { - break - } - } - if last.State != check.TryPass || last.Trunk != trunk || last.Took == "" || last.Composition == nil { - t.Fatalf("try = %+v, want passed on the trunk with its composition made", last) - } - if got := asked(); len(got) != 1 || !strings.HasPrefix(got[0].Candidate, id+".") { - t.Errorf("the placed node's engine was asked %+v, want the try's candidate %s.", got, id) - } - if b.fake.count(goBuildModule+".build_go_fetch") == 0 { - t.Errorf("the try fetched nothing") - } - // A whole try's start and end are said on the stream checks, which the indexer hears to write and delete the - // candidate of its group: said once each, never waited out on a subject no stream holds. - checks, err := b.js.Stream(b.ctx, "CHECKS") - if err != nil { - t.Fatal(err) - } - for _, event := range []string{checkermsg.Started, checkermsg.Ended} { // the end is said once the try's end is written - said, err := b.js.OrderedConsumer(b.ctx, checks.CachedInfo().Config.Name, jetstream.OrderedConsumerConfig{ - FilterSubjects: []string{process.ModuleStreamSubject(testChecker, event)}}) - if err != nil { - t.Fatal(err) - } - if m, err := said.Next(jetstream.FetchMaxWait(5 * time.Second)); err != nil || !strings.Contains(string(m.Data()), id) { - t.Errorf("the stream checks holds no %s of the try %s: %v", event, id, err) - } - } - for _, name := range []string{testBucket(meshdeliverychecker.StateOwed), testBucket(meshdeliverychecker.StateVerdicts)} { - if keys, _ := b.buckets[name].Keys(b.ctx); len(keys) != 0 { - t.Errorf("a try wrote %s: %v", name, keys) - } - } - // Issue 734: a try whose ask the build seat gives up on (the controller keeps its copy in DEAD_LETTERS with the ask's - // message id) ends as error saying so, and its head asked again is a new try. - b.fake.hold.Store(head2) - lost, err := check.AskTry(store, map[string]string{repo: trunk}, check.TryAsk{Repository: repo, Head: head2}, time.Now()) - if err != nil { - t.Fatal(err) - } - steps, err := b.js.KeyValue(b.ctx, buildrun.StepsBucket(goBuildModule)) - if err != nil { - t.Fatal(err) - } - askID := "" - for deadline := time.Now().Add(20 * time.Second); askID == "" && time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - keys, _ := steps.Keys(b.ctx) - for _, k := range keys { - if e, err := steps.Get(b.ctx, k); err == nil && strings.Contains(string(e.Value()), `"running"`) { - askID = strings.TrimPrefix(k, "n1.") - } - } - } - if askID == "" { - t.Fatal("the held try's ask was never taken") - } - dead := &nats.Msg{Subject: "mesh.events.dead.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker", Header: nats.Header{}} - dead.Header.Set(buildrun.DeadHeaderMsgID, askID) - dead.Header.Set(buildrun.DeadHeaderDeliveries, "5") - dead.Header.Set(buildrun.DeadHeaderStream, "SEAT_NODE_BUILD_GO") - dead.Header.Set(buildrun.DeadHeaderGaveUp, time.Now().UTC().Format(time.RFC3339Nano)) - if _, err := b.js.PublishMsg(b.ctx, dead); err != nil { - t.Fatal(err) - } - for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - raw, _ := store.Get(lost) - if last, err = check.DecodeTry(raw); err == nil && last.Over() { - break - } - } - if last.State != check.TryError || !strings.Contains(last.Said, buildrun.LostWords+" after 5 deliveries") { - t.Fatalf("the try whose ask was given up = %+v, want error saying so", last) - } - if again, err := check.AskTry(store, map[string]string{repo: trunk}, check.TryAsk{Repository: repo, Head: head2}, time.Now()); err != nil || again == lost { - t.Errorf("its head asked again answered %q, %v, want a new try", again, err) - } -} - -// TestTheCheckerSaysOwedReadableOnTheBus: started, the checker says on its own states subject what it keeps, owed among -// the readable ones, which is what grants the forge module its read of owed (ADR 0495 §2-§3, ADR 0521; R4e finding R2-1). -func TestTheCheckerSaysOwedReadableOnTheBus(t *testing.T) { // R2-1 - b := startBed(t) - b.start(t, nil) - events, err := b.js.Stream(b.ctx, "EVENTS") - if err != nil { - t.Fatal(err) - } - var said announce.States - for deadline := time.Now().Add(10 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - m, err := events.GetLastMsgForSubject(b.ctx, announce.Subject("mesh-delivery-checker")) - if err != nil { - continue - } - if err := json.Unmarshal(m.Data, &said); err != nil { - t.Fatal(err) - } - break - } - if said.Module != "mesh-delivery-checker" || said.Node != "n1" || !said.Keeps("owed") || !said.Readable("owed") || - !said.Readable("previews") || !said.Readable("verdicts") || !said.Readable("kept") || !said.Readable("tries") || said.Readable("hearing") || - !said.Keeps("asks") || said.Readable("asks") || !said.Keeps("first-views") || said.Readable("first-views") || !said.Keeps("findings") || !said.Keeps("inputs") || said.Readable("inputs") || !said.Keeps("compositions") || said.Readable("compositions") || !said.Keeps("could-not-run") || said.Readable("could-not-run") || len(said.States) != 12 { - t.Fatalf("the checker said %+v, want its twelve states, asks, hearing, first-views, inputs, compositions and could-not-run its own (DLV-M2; W6.9), with kept, owed, previews, tries and verdicts readable, tries by the delivery view (1929/AC4; 1887 A5b; build_usage)", said) - } - // Design 47 G §717, A-298: the assignments are followed at the holder the seat-holders view of the catalog half's claimant - // names, no seat verb asked for it. - b.said(t, "holds "+testAssigner+"'s assignments, the holder of the seat mesh-module-assigner") -} - -// testChecker is the module the bed's credential names; the checker's own buckets and events are named from it (design 47 G A-296). -const testChecker = "mesh-delivery-checker" - -func testBucket(state string) string { return check.Bucket(testChecker, state) } - -const testAssigner = "acme-assigner" // a holder of the seat mesh-module-assigner no code names - -// buildSeatDefinitions are the seat definitions the bed's seat mesh-catalog lists: the build seats, as the mesh's own definitions of -// them, whose acting rules say which language each builds. -var buildSeatDefinitions = func() map[string]seatdef.Definition { - out := map[string]seatdef.Definition{} - for _, d := range seatlisttest.Definitions() { - if d.Seat == "node-build-go" || d.Seat == "node-build-node" { - out[d.Seat] = d - } - } - return out -}() - -// seatDefinitionsAnswer is the seat mesh-catalog's answer to the seat list's asks: every trunk seat with its digest when no -// seat is named, one seat's definition when it is. -func seatDefinitionsAnswer(body []byte) []byte { - var ask struct { - Seat string `json:"seat"` - } - _ = json.Unmarshal(body, &ask) - entry := func(seat string) seatlist.Entry { - raw, _ := json.Marshal(buildSeatDefinitions[seat]) - return seatlist.Entry{Seat: seat, Source: seatlist.SourceTrunk, Digest: fmt.Sprintf("%x", sha256.Sum256(raw)), Definition: raw} - } - var out any - if ask.Seat == "" { - l := seatlist.Listing{Revision: 1} - for _, seat := range slices.Sorted(maps.Keys(buildSeatDefinitions)) { - e := entry(seat) - e.Definition = nil - l.Seats = append(l.Seats, e) - } - out = l - } else if _, ok := buildSeatDefinitions[ask.Seat]; ok { - e := entry(ask.Seat) - out = seatlist.Answer{Seat: ask.Seat, Found: true, Entry: &e, Revision: 1} - } else { - out = seatlist.Answer{Seat: ask.Seat, Revision: 1} - } - raw, _ := json.Marshal(map[string]any{"result": out, "node": "ctl"}) - return raw -} - -// putBuildModule writes the indexer's module and manifest of a module that claims a build seat, so the checker finds the seat's -// holder (design 47 G A-82). Its repository is its own, so no repository the tests judge changes the build modules it names. -func (b *bed) putBuildModule(t *testing.T, module, seat string) { - t.Helper() - manifest := fmt.Sprintf(`{"module":%q,"version":"0.1","slug":"b","claims":[{"name":%q,"scope":"node"}]}`, module, seat) - digest := fmt.Sprintf("%x", sha256.Sum256([]byte(manifest))) - mkey, err := meshcatalogclient.ManifestsKey(digest) - if err != nil { - t.Fatal(err) - } - stored, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Manifest: manifest, Module: module}) - if err != nil { - t.Fatal(err) - } - if _, err := b.buckets[check.ManifestsBucket].Put(b.ctx, mkey, stored); err != nil { - t.Fatal(err) - } - value, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/build-modules", Commit: strings.Repeat("b", 40), Path: "modules/" + module, Manifest: digest, - None2: "the fingerprint is computed with its chain"}) - if err != nil { - t.Fatal(err) - } - if _, err := b.buckets[check.ModulesBucket].Put(b.ctx, module, value); err != nil { - t.Fatal(err) - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge.go deleted file mode 100644 index 3e3ec09f..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge.go +++ /dev/null @@ -1,604 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "path" - "slices" - "sort" - "strconv" - "strings" - "sync" - "time" - - "github.com/nats-io/nats.go/jetstream" - - "mesh-delivery-checker/internal/check" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/keys" - "git.novox.be/novox/mesh-sdk/go/process" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" -) - -// judgeDeps are the parts the judge of a check is made of. -type judgeDeps struct { - // module is the checker's own, the credential's (check.Examiner.Module). - module string - // inputs keeps the checking program's inputs (check.InputsStateName, served on check.InputVerb). - inputs check.Inputs - // beginBound is how long a run ask may wait for a build node to begin it; check.DefaultBeginBound when 0. - beginBound time.Duration - asks check.Asks - renames check.Renames - seatDefs check.SeatDefinitions - // seats are the seat list the checker's reader holds, the base the checking program lays the heads over (seatlist.go). - seats check.SeatList - // buildSeats finds the build modules from the seat list and the holders of seats (design 47 G A-82). - buildSeats *buildrun.BuildSeats - tools *buildrun.ToolchainSet - trunks *check.Trunks - kept check.KV - previews check.KV - // candidates answers the indexer's candidate of a try's group (try_candidates.go); nil leaves a whole try with no - // manifest or composition judged, said. - candidates check.TryCandidates - repos *repoModules - // published is the indexer's packages state as it is followed (packages.go). - published *publishedPackages - forge check.Forge - announce check.Announcer - builds check.BuildStates - // ends waits on the builder's builds of a candidate before the check composes (ADR 0603 §10); nil composes without waiting. - ends check.BuildEnds - // buildWait is the setting build-wait-bound; check.DefaultBuildWait when 0. - buildWait time.Duration - // compositions makes a check's composition from the engines' answers (ADR 0593 §7); nil leaves it not run. - compositions check.CompositionReader - // nodes names every node with a record; nil hands no names. - nodes *nodeNames - // predefined is the indexer's kept list of predefined keys; nil reads none. - predefined check.PredefinedList - logf func(format string, args ...any) -} - -// keptPredefined reads the indexer's key predefined.list (the seat mesh-catalog's state predefined), bound once its state appears. -type keptPredefined struct{ kv jetstream.KeyValue } - -func (k keptPredefined) PredefinedList(ctx context.Context) (json.RawMessage, error) { - e, err := k.kv.Get(ctx, meshcatalog.PredefinedByListKey()) - if errors.Is(err, jetstream.ErrKeyNotFound) { - return nil, nil - } - if err != nil { - return nil, err - } - kept, err := meshcatalog.DecodePredefinedByListValue(e.Value()) - if err != nil { - return nil, err - } - return json.Marshal(kept.List) -} - -// keptSeatDefinitions reads a pull request's entries of the indexer's seat definitions from its first view: each whose -// `unparsed` says why its head's definition does not parse (the entry's shape is the indexer's read tool's answer). -type keptSeatDefinitions struct { - keys func(ctx context.Context) ([]string, error) - get func(ctx context.Context, key string) ([]byte, error) -} - -// seatDefinitionsOf reads the state's picture (a key gone between the keys and its get is none). -func seatDefinitionsOf(kv jetstream.KeyValue) keptSeatDefinitions { - return keptSeatDefinitions{keys: func(ctx context.Context) ([]string, error) { - keys, err := kv.Keys(ctx) - if errors.Is(err, jetstream.ErrNoKeysFound) { - return nil, nil - } - return keys, err - }, get: func(ctx context.Context, key string) ([]byte, error) { - e, err := kv.Get(ctx, key) - if errors.Is(err, jetstream.ErrKeyNotFound) { - return nil, nil - } - if err != nil { - return nil, err - } - return e.Value(), nil - }} -} - -func (k keptSeatDefinitions) Unparsed(ctx context.Context, repository string, pull int) ([]check.UnparsedSeat, error) { - suffix := ".pull." + keys.EscapeName(repository) + "." + strconv.Itoa(pull) - keys, err := k.keys(ctx) - if err != nil { - return nil, err - } - sort.Strings(keys) - var out []check.UnparsedSeat - for _, key := range keys { - if !strings.HasSuffix(key, suffix) { - continue - } - raw, err := k.get(ctx, key) - if err != nil { - return nil, err - } - if raw == nil { - continue - } - var v struct { - Seat string `json:"seat"` - Module string `json:"module"` - Directory string `json:"directory"` - Unparsed string `json:"unparsed"` - } - if err := json.Unmarshal(raw, &v); err != nil { - return nil, fmt.Errorf("%s is no seat definition entry: %w", key, err) - } - if v.Unparsed != "" { - out = append(out, check.UnparsedSeat{Seat: v.Seat, Module: v.Module, Directory: v.Directory, Why: v.Unparsed}) - } - } - return out, nil -} - -// nodeNames reads every node's name from the node-engine's have, one key `.node` per node with a record (novox/hq -// ADR 0567 §12), at each ask: a node enrolled since is named in the next check. -type nodeNames struct{ kv jetstream.KeyValue } - -// openNodeNames opens the node-engine's have for the nodes' names alone: it is not watched, so no check waits on a node. -func openNodeNames(ctx context.Context, js process.BucketOpener, logf func(string, ...any)) *nodeNames { - return &nodeNames{kv: process.OptionalBucket(ctx, js, check.HaveBucket, "no check is asked until it is: the names check needs the nodes' names", logf)} -} - -func (n nodeNames) Names(ctx context.Context) ([]string, error) { - if n.kv == nil { - return nil, fmt.Errorf("the bucket %s could not be opened at the checker's start", check.HaveBucket) - } - lister, err := n.kv.ListKeysFiltered(ctx, "*."+check.HaveNodeWord) - if err != nil { - return nil, err - } - var out []string - for key := range lister.Keys() { - if node, _, isNode, err := nodeengineclient.ParseHaveKey(key); err == nil && isNode { - out = append(out, node) - } - } - sort.Strings(out) - return out, nil -} - -// runningServes says what the running builds serve (novox/hq ADR 0614 §7), read when a check asks it: every module's have -// in the node-engine's have that runs healthy, the builder's build of its fingerprint, and the verbs its manifest serves -// (graph.Served). A build whose manifest cannot be read serves nothing here, said in the log. -type runningServes struct { - have *nodeNames - builds check.BuildStates - read check.ManifestReader - logf func(format string, args ...any) -} - -func (r runningServes) Served(ctx context.Context) (func(string) bool, error) { - if r.have == nil || r.have.kv == nil || r.builds == nil || r.read == nil { - return nil, fmt.Errorf("the node-engine's have, the builder's builds or the indexer's manifests cannot be read") - } - lister, err := r.have.kv.ListKeys(ctx) - if err != nil { - return nil, err - } - haves := map[string]map[string]nodeengine.HaveByNodeModuleValue{} - for key := range lister.Keys() { - node, module, isNode, err := nodeengineclient.ParseHaveKey(key) - if err != nil || isNode { - continue - } - e, err := r.have.kv.Get(ctx, key) - if err != nil { - continue - } - if h, err := nodeengineclient.DecodeHave(e.Value()); err == nil { - if haves[node] == nil { - haves[node] = map[string]nodeengine.HaveByNodeModuleValue{} - } - haves[node][module] = h - } - } - served, unread := graph.Served(haves, func(module, fp string) ([]string, bool) { - b, found, err := r.builds.Build(ctx, module, fp) - if err != nil || !found || b.Manifest == "" { - return nil, false - } - m, err := r.read.Manifest(ctx, b.Manifest) - if err != nil { - return nil, false - } - return graph.ServesOf(m), true - }, nil) - if len(unread) > 0 && r.logf != nil { - r.logf("the manifest of the running build of %v cannot be read, so it serves nothing the check counts (ADR 0614 §7)", unread) - } - return served, nil -} - -func newJudge(d judgeDeps) check.Judge { - var nodes interface { - Names(ctx context.Context) ([]string, error) - } - if d.nodes != nil { - nodes = d.nodes - } - ex := &check.Examiner{Module: d.module, Nodes: nodes, Compositions: d.compositions, Asks: d.asks, Toolchains: d.tools, - Kept: check.Kept{Store: d.kept}, Previews: d.previews, Candidates: d.candidates, Modules: d.repos, Packages: d.repos, Published: d.published, KnownPackages: d.published, Forge: d.forge, Runs: d.repos, Builds: d.builds, BuildEnds: d.ends, BuildWait: d.buildWait, Announce: d.announce, Trunks: d.trunks, Manifests: d.repos, Read: d.repos, Dirs: d.repos, Predefined: d.predefined, Renames: d.renames, SeatDefinitions: d.seatDefs, SeatList: d.seats, Seats: d.buildSeats, Inputs: d.inputs, BeginBound: d.beginBound, Logf: d.logf} - if d.nodes != nil && d.builds != nil && d.repos != nil { - ex.Serving = runningServes{have: d.nodes, builds: d.builds, read: d.repos, logf: d.logf} - } - return ex -} - -// manifestKV reads a manifest by its digest. -type manifestKV interface { - Get(ctx context.Context, key string) (value []byte, revision uint64, found bool, err error) -} - -// repoModules knows which build modules judge a repository, from the indexer's modules and their manifests: the Go build -// module always (a repository's go.mod files are its own), the Node one when a module of the repository has a TypeScript -// artifact (ADR 0484 clause 10). Safe for use from the watch and from a check at once. -type repoModules struct { - manifests manifestKV - logf func(format string, args ...any) - // verdicts keeps the indexer's verdict on each module's manifest, for the sandbox's composer (engines.go); nil keeps none. - verdicts *manifestVerdicts - // seats finds the build modules (design 47 G A-82); set before the first check. - seats *buildrun.BuildSeats - - mu sync.Mutex - claims map[string][]string // by manifest digest: the seats its module claims - langs map[string]map[string]bool // by manifest digest: the languages of its artifacts - tsPkgs map[string][]string // by manifest digest: the names of its TypeScript package artifacts - path map[string]string // by module: its directory in its repository - named map[string]map[string][]string // by module: each artifact's named paths, as the indexer keeps them - repoOf map[string]string // by module: its repository - fp map[string]string // by module: its entry's fingerprint, whose graph entry holds the manifest - commit map[string]string // by module: the commit its record was computed at (the commit the mesh runs) - typed map[string]string // by module: its manifest digest - parsed map[string]catalogue.Manifest // by manifest digest: the manifest as read, once (a digest's manifest never changes) -} - -// Manifest is the kept manifest of a digest, read from the indexer's manifests state once and then from memory. -func (r *repoModules) Manifest(ctx context.Context, digest string) (catalogue.Manifest, error) { - r.mu.Lock() - m, known := r.parsed[digest] - r.mu.Unlock() - if known { - return m, nil - } - key, err := meshcatalogclient.ManifestsKey(digest) - if err != nil { - return catalogue.Manifest{}, err - } - raw, _, found, err := r.manifests.Get(ctx, key) - if err != nil { - return catalogue.Manifest{}, err - } - if !found { - return catalogue.Manifest{}, fmt.Errorf("the indexer keeps no manifest %s", digest) - } - kept, err := meshcatalogclient.DecodeManifest(raw) - if err != nil { - return catalogue.Manifest{}, err - } - if m, err = parseManifest(kept.Manifest); err != nil { - return catalogue.Manifest{}, err - } - r.mu.Lock() - if r.parsed == nil { - r.parsed = map[string]catalogue.Manifest{} - } - r.parsed[digest] = m - r.mu.Unlock() - return m, nil -} - -// Put takes a change of the indexer's modules bucket in: a module's repository and the languages its manifest names. -func (r *repoModules) Put(ctx context.Context, key string, value []byte, deleted bool) { - r.mu.Lock() - if r.repoOf == nil { - r.repoOf, r.typed, r.langs, r.commit = map[string]string{}, map[string]string{}, map[string]map[string]bool{}, map[string]string{} - r.fp = map[string]string{} - r.tsPkgs, r.path, r.named = map[string][]string{}, map[string]string{}, map[string]map[string][]string{} - } - if deleted { - if r.verdicts != nil { - r.verdicts.put(key, nil) - } - delete(r.repoOf, key) - delete(r.typed, key) - delete(r.fp, key) - delete(r.commit, key) - delete(r.path, key) - delete(r.named, key) - r.mu.Unlock() - return - } - r.mu.Unlock() - m, err := meshcatalogclient.DecodeModule(value) - if err != nil { - return - } - if r.verdicts != nil { - r.verdicts.put(key, meshcatalogclient.ModuleVerdict(key, m)) - } - r.mu.Lock() - r.repoOf[key] = m.Repository - r.typed[key] = m.Manifest - r.fp[key] = m.Fp2 - r.commit[key] = m.Commit - r.path[key] = m.Path - r.named[key] = m.Paths - _, known := r.langs[m.Manifest] - r.mu.Unlock() - if m.Manifest == "" || known { - return - } - set := map[string]bool{} - var pkgs, claimed []string - if mk, err := meshcatalogclient.ManifestsKey(m.Manifest); err == nil { - if raw, _, found, err := r.manifests.Get(ctx, mk); err == nil && found { - if kept, err := meshcatalogclient.DecodeManifest(raw); err == nil { - if man, err := parseManifest(kept.Manifest); err == nil { - for _, c := range man.Claims { - claimed = append(claimed, c.Name) - } - } - if man, err := parseManifest(kept.Manifest); err == nil && man.Build != nil { - for _, a := range man.Build.Artifacts { - if a.Language != "" { - set[a.Language] = true - } - if a.Kind == "package" && a.Language == "typescript" { - pkgs = append(pkgs, a.Name) - } - } - } else if err != nil && r.logf != nil { - r.logf("the manifest %s cannot be read, so its module counts as no TypeScript: %v", m.Manifest, err) - } - } - } - } - r.mu.Lock() - r.langs[m.Manifest] = set - r.tsPkgs[m.Manifest] = pkgs - if r.claims == nil { - r.claims = map[string][]string{} - } - r.claims[m.Manifest] = claimed - r.mu.Unlock() -} - -// ModuleDir is a module's directory in its repository as the indexer's modules hold it (check.Examiner.Dirs); false for a -// module the indexer holds no directory of. -func (r *repoModules) ModuleDir(module string) (string, bool) { - r.mu.Lock() - defer r.mu.Unlock() - d, ok := r.path[module] - return d, ok && d != "" -} - -// TypeScriptPackages are the TypeScript package artifacts of a repository's modules, sorted by directory: each by its -// directory in the repository and the paths, relative to the repository, it is built from: the named paths the indexer -// keeps in each module's value (meshcatalog.ModulesByModuleValue.ArtifactPaths; only the indexer reads them from a -// manifest, the lead's decision L8), under the module's directory. A package's directory is the one path it names when -// that names a directory (the contracts folders, ts/seats/, each with its own package.json), else the module's -// directory (the SDK's lib names its package.json beside its sources), as the Node build module reads it -// (mesh-build-node artifact.packageDir). None for a module whose value holds no paths. -func (r *repoModules) TypeScriptPackages(repository string) []check.TypeScriptPackage { - r.mu.Lock() - defer r.mu.Unlock() - var out []check.TypeScriptPackage - for module, repo := range r.repoOf { - if repo != repository { - continue - } - dir := strings.Trim(r.path[module], "/") - if dir == meshcatalogclient.RootPath || dir == "." { - dir = "" - } - under := func(p string) string { - p = strings.Trim(strings.TrimPrefix(p, "./"), "/") - if dir != "" { - p = dir + "/" + p - } - return p - } - for _, name := range r.tsPkgs[r.typed[module]] { - named := r.named[module][name] - if len(named) == 0 { - continue - } - pkg := check.TypeScriptPackage{Dir: dir} - if one := strings.Trim(strings.TrimPrefix(named[0], "./"), "/"); len(named) == 1 && one != "" && !strings.Contains(path.Base(one), ".") { - pkg.Dir = under(one) - } - for _, p := range named { - pkg.Paths = append(pkg.Paths, under(p)) - } - sort.Strings(pkg.Paths) - out = append(out, pkg) - } - } - sort.Slice(out, func(i, j int) bool { return out[i].Dir < out[j].Dir }) - return out -} - -// HolderOf is the module whose manifest claims the seat, as the indexer's modules hold them: none while no module of the mesh -// claims it, and the first by name where several do (design 47 G A-82, as the catalog half's holder is read by the builder). -func (r *repoModules) HolderOf(seat string) (string, bool) { - r.mu.Lock() - defer r.mu.Unlock() - found := "" - for module, digest := range r.typed { - if slices.Contains(r.claims[digest], seat) && (found == "" || module < found) { - found = module - } - } - return found, found != "" -} - -// BuildModules are the build modules that judge a repository, sorted: the build module of Go always, and that of TypeScript -// when a module of the repository builds TypeScript. A repository of which the mesh knows no module (mesh-lab, hq) -// is judged by both, each finding its own directories in the tree (go.mod files; package.json files), so a repository -// with tests in either language and no manifest is judged whole (issue 1887 A12). A language no build seat on the seat list -// builds has none. -func (r *repoModules) BuildModules(repository string) []string { - var out []string - add := func(language string) { - if m, err := r.seats.For(language, ""); err == nil { - out = append(out, m.Module) - } - } - add("go") - r.mu.Lock() - typescript := false - known := false - for module, repo := range r.repoOf { - if repo != repository { - continue - } - known = true - if r.langs[r.typed[module]]["typescript"] { - typescript = true - break - } - } - r.mu.Unlock() - if typescript || !known { - add("typescript") - } - sort.Strings(out) - return out -} - -// buildReader reads the builder's build of a module at a fingerprint (mesh-delivery-builder_builds). -type buildReader struct{ kv kvStore } - -func (r buildReader) Build(ctx context.Context, module, fp2 string) (builds.BuilderBuild, bool, error) { - key, err := builds.BuilderBuildKey(module, fp2) - if err != nil { - return builds.BuilderBuild{}, false, err - } - value, _, found, err := r.kv.Get(ctx, key) - if err != nil || !found { - return builds.BuilderBuild{}, false, err - } - b, err := builds.DecodeBuilderBuild(value) - return b, err == nil, err -} - -// buildEnds hears the builder's build keys of a candidate on the bus (mesh-delivery-builder_builds): a watch of exactly -// those keys gives each one's value now and every write the builder makes after, so the check waits on the part that owns -// the fact and polls nothing (novox/hq ADR 0603 §10). -type buildEnds struct{ kv jetstream.KeyValue } - -func (e buildEnds) Ended(ctx context.Context, asked map[string]string) (map[string]builds.BuilderBuild, error) { - return e.until(ctx, asked, func(b builds.BuilderBuild) bool { - return b.State == builds.BuildDone || b.State == builds.BuildFailed - }) -} - -func (e buildEnds) Done(ctx context.Context, asked map[string]string) bool { - done, err := e.until(ctx, asked, func(b builds.BuilderBuild) bool { return b.State == builds.BuildDone }) - return err == nil && len(done) == len(asked) -} - -// until hears the builds' keys until each holds a build that ended holds, or ctx ends, and answers those that do, by module. -func (e buildEnds) until(ctx context.Context, asked map[string]string, ended func(builds.BuilderBuild) bool) (map[string]builds.BuilderBuild, error) { - byKey := map[string]string{} - keys := make([]string, 0, len(asked)) - for module, fp2 := range asked { - key, err := builds.BuilderBuildKey(module, fp2) - if err != nil { - return nil, err - } - byKey[key] = module - keys = append(keys, key) - } - out := map[string]builds.BuilderBuild{} - if len(keys) == 0 { - return out, nil - } - w, err := e.kv.WatchFiltered(ctx, keys) - if err != nil { - return nil, err - } - defer func() { _ = w.Stop() }() - for len(out) < len(keys) { - select { - case <-ctx.Done(): - return out, nil // the bound: the builds not ended are left out - case entry, open := <-w.Updates(): - if !open { - return out, nil - } - if entry == nil || entry.Operation() != jetstream.KeyValuePut { - continue // the end of the values now, or a key deleted: it has not ended - } - module, ours := byKey[entry.Key()] - if !ours { - continue - } - b, err := builds.DecodeBuilderBuild(entry.Value()) - if err == nil && ended(b) { - out[module] = b - } else { - delete(out, module) // asked again (builder_build_again), or not a build the check can read: not ended - } - } - } - return out, nil -} - -// ManifestDigests is the manifest digest of every module the indexer holds, by module: the catalogue the indexer's judge -// judges a change's manifests in (novox/hq ADR 0578 §2).8 §2). -func (r *repoModules) ManifestDigests() map[string]string { - r.mu.Lock() - defer r.mu.Unlock() - out := map[string]string{} - for module, digest := range r.typed { - if digest != "" { - out[module] = digest - } - } - return out -} - -// ManifestFingerprints is the fingerprint of every module the indexer holds, by module, whose catalog graph entry holds its manifest -// (design 47 G A-310). -func (r *repoModules) ManifestFingerprints() map[string]string { - r.mu.Lock() - defer r.mu.Unlock() - out := map[string]string{} - for module, fp := range r.fp { - if fp != "" { - out[module] = fp - } - } - return out -} - -// CommitOf is the commit the indexer's record of the module names: the commit its fingerprint first appeared at, so the source -// of the build the mesh runs (a later merge that leaves the module alone writes no record, the operator 2026-10-25). -func (r *repoModules) CommitOf(module string) string { - r.mu.Lock() - defer r.mu.Unlock() - return r.commit[module] -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge_test.go deleted file mode 100644 index b77fec22..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judge_test.go +++ /dev/null @@ -1,258 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "maps" - "os" - "reflect" - "slices" - "strings" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-sdk/go/keys" - - "mesh-delivery-checker/internal/check" -) - -type memManifests map[string][]byte - -func (m memManifests) Get(_ context.Context, key string) ([]byte, uint64, bool, error) { - v, ok := m[key] - return v, 1, ok, nil -} - -func putModule(t *testing.T, r *repoModules, name, repository, manifest string) { - t.Helper() - data, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: repository, Commit: strings.Repeat("a", 40), Fp: "src1:" + strings.Repeat("a", 64), Manifest: meshcatalogclient.ManifestDigest([]byte(manifest))}) - if err != nil { - t.Fatal(err) - } - r.Put(context.Background(), name, data, false) -} - -func TestARepositoryWithATypeScriptModuleIsJudgedByTheNodeBuildModuleToo(t *testing.T) { // 1292/AC2 - own, err := os.ReadFile("../../module.json") // a manifest with a Go bundle: this module's own - if err != nil { - t.Fatal(err) - } - goManifest := string(own) - // A TypeScript bundle names neither a system nor a directory it is built from (the catalogue's parser says so). - var doc map[string]any - if err := json.Unmarshal(own, &doc); err != nil { - t.Fatal(err) - } - artifacts := doc["build"].(map[string]any)["artifacts"].([]any) - program := artifacts[0].(map[string]any) - program["language"] = "typescript" - delete(program, "system") - delete(program, "from") - delete(program, "binary") - tsRaw, err := json.Marshal(doc) - if err != nil { - t.Fatal(err) - } - tsManifest := string(tsRaw) - store := memManifests{} - for _, m := range []string{goManifest, tsManifest} { - data, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "demo", Manifest: m}) - if err != nil { - t.Fatal(err) - } - store[meshcatalogclient.ManifestDigest([]byte(m))] = data - } - r := &repoModules{manifests: store, seats: testBuildSeats()} - putModule(t, r, "mesh-delivery-checker", "novox/mesh-delivery", goManifest) - putModule(t, r, "mesh-ui", "novox/mesh-catalog", tsManifest) - if got := r.BuildModules("novox/mesh-delivery"); strings.Join(got, ",") != goBuildModule { - t.Errorf("mesh-delivery: %v, want the Go build module alone", got) - } - if got := r.BuildModules("novox/mesh-catalog"); strings.Join(got, ",") != goBuildModule+","+nodeBuildModule { - t.Errorf("mesh-catalog: %v, want both", got) - } - if got := r.CommitOf("mesh-delivery-checker"); got != strings.Repeat("a", 40) || r.CommitOf("gone") != "" { - t.Errorf("the commit the mesh runs = %q", got) - } - // 1887/A12: a repository with no module the mesh knows (mesh-lab: nested go.mod files and a root package.json) is - // judged by both build modules. - if got := r.BuildModules("novox/mesh-lab"); strings.Join(got, ",") != goBuildModule+","+nodeBuildModule { - t.Errorf("a repository with no module: %v, want both build modules", got) - } -} - -// sdkManifest is mesh-sdk's own manifest (its module.json at feat/r4e-sdk): one TypeScript package naming its paths. -const sdkManifest = `{"module":"mesh-sdk","version":"1","slug":"sdk","build":{"artifacts":[{"name":"lib","kind":"package","language":"typescript",` + - `"paths":["src","test","package.json","package-lock.json","tsconfig.json"]}]},"resources":[]}` - -func TestTheTypeScriptPackagesPathsComeFromTheIndexersModulesNotTheManifest(t *testing.T) { // ADR 0500 §5 with lead decision L8 - store := memManifests{} - data, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "mesh-sdk", Manifest: sdkManifest}) - if err != nil { - t.Fatal(err) - } - store[meshcatalogclient.ManifestDigest([]byte(sdkManifest))] = data - r := &repoModules{manifests: store} - put := func(path string, paths map[string][]string) { - v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Commit: strings.Repeat("a", 40), Fp: "src1:" + strings.Repeat("a", 64), - Manifest: meshcatalogclient.ManifestDigest([]byte(sdkManifest)), Path: path, Paths: paths}) - if err != nil { - t.Fatal(err) - } - r.Put(context.Background(), "mesh-sdk", v, false) - } - str := func(pkgs []check.TypeScriptPackage) string { - var out []string - for _, p := range pkgs { - out = append(out, p.Dir+":"+strings.Join(p.Paths, ",")) - } - return strings.Join(out, " ") - } - for _, row := range []struct { - name, path string - paths map[string][]string - want string - }{ - {"the indexer's word, not the manifest's five paths: the SDK's lib at the root", ".", map[string][]string{"lib": {"src", "package.json"}}, ":package.json,src"}, - {"under the module's directory", "ts", map[string][]string{"lib": {"package.json", "src"}}, "ts:ts/package.json,ts/src"}, - {"one path naming a directory is the package's own (A-285)", "modules/mesh-delivery-contracts", map[string][]string{"lib": {"ts/seats/git"}}, "modules/mesh-delivery-contracts/ts/seats/git:modules/mesh-delivery-contracts/ts/seats/git"}, - {"a value written before the indexer kept paths: nothing to serve by", ".", nil, ""}, - } { - put(row.path, row.paths) - if got := str(r.TypeScriptPackages("novox/mesh-sdk")); got != row.want { - t.Errorf("%s: packages = %q, want %q", row.name, got, row.want) - } - } - if got := r.TypeScriptPackages("novox/mesh-delivery"); len(got) != 0 { - t.Errorf("another repository: %v", got) - } -} - -// ADR 0593 §2 (D8): a Go check builds every mesh package at the version the indexer's packages state publishes, read -// there and computed nowhere here: a key's module at its commit, a deleted key gone, an unreadable value left out. -func TestThePublishedVersionsAreTheIndexersPackagesState(t *testing.T) { - var p publishedPackages - // Not read yet, the state names no package and judges none; read and empty, it is an empty list judged against. - if got := p.PackageNames(); got != nil { - t.Errorf("before the first reading the known packages = %v, want nil", got) - } - p.Answered() - if got := p.PackageNames(); got == nil || len(got) != 0 { - t.Errorf("read and empty, the known packages = %#v, want an empty map", got) - } - put := func(module, repository, dir, commit string) { - key := meshcatalog.PackagesByModuleKey(keys.EscapeName(module)) - now := time.Now().UTC() - raw, err := json.Marshal(meshcatalog.PackagesByModuleValue{V: keys.Version, Module: module, Repository: repository, Dir: dir, - Commit: commit, Requires: strings.Repeat("e", 64), - Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: module, Digest: strings.Repeat("d", 64)}}, At: &now}) - if err != nil { - t.Fatal(err) - } - p.Put(key, raw, false) - } - const sdk, build = "git.novox.be/novox/mesh-sdk/go", "git.novox.be/novox/mesh-catalog/modules/mesh-build-go" - put(sdk, "novox/mesh-sdk", "go", strings.Repeat("a", 40)) - put(build, "novox/mesh-catalog", "modules/mesh-build-go", strings.Repeat("b", 40)) - p.Put("broken", []byte("{"), false) - if got := p.LatestPackages(); !reflect.DeepEqual(got, buildstep.PackageVersions{sdk: strings.Repeat("a", 40), build: strings.Repeat("b", 40)}) { - t.Errorf("latest packages = %v", got) - } - key := meshcatalog.PackagesByModuleKey(keys.EscapeName(build)) - p.Put(key, nil, true) - if got := p.LatestPackages(); len(got) != 1 || got[sdk] == "" { - t.Errorf("after a delete: %v", got) - } - // Issue 1966: a module record names its module, with no series to say it, and none of the packages inside it. - if got := p.PackageNames(); !reflect.DeepEqual(got, map[string]string{sdk: ""}) { - t.Errorf("the known packages from a module record = %v", got) - } - // A series key names its package by its ecosystem name, the judge's known packages (DLV-I14, design 32), and is no - // module's published version. - now := time.Now().UTC() - series, err := json.Marshal(meshcatalog.PackagesByPackageSeriesValue{V: keys.Version, Name: sdk, Package: "mesh-sdk/go", Series: "0.1", At: &now}) - if err != nil { - t.Fatal(err) - } - p.Put(meshcatalog.PackagesByPackageSeriesKey(keys.EscapeName(sdk), "0.1"), series, false) - if got := p.PackageNames(); !reflect.DeepEqual(got, map[string]string{sdk: "mesh-sdk/go"}) || len(p.LatestPackages()) != 1 { - t.Errorf("the known packages = %v, the latest %v", got, p.LatestPackages()) - } - t.Run("a pull request's unparsed seat definitions are its entries of the indexer's seat-definitions", func(t *testing.T) { - state := map[string]string{ - "web-api.trunk": `{"seat":"web-api","source":"trunk","digest":"d"}`, - "web-api.pull." + keys.EscapeName("novox/web") + ".7": `{"seat":"web-api","source":"pull","module":"web-contracts","directory":"go","unparsed":"seat.json: bad"}`, - "mail-api.pull." + keys.EscapeName("novox/web") + ".7": `{"seat":"mail-api","source":"pull","digest":"e"}`, - "web-api.pull." + keys.EscapeName("novox/web") + ".17": `{"seat":"web-api","source":"pull","unparsed":"another pull request's"}`, - } - k := keptSeatDefinitions{keys: func(context.Context) ([]string, error) { return slices.Collect(maps.Keys(state)), nil }, - get: func(_ context.Context, key string) ([]byte, error) { return []byte(state[key]), nil }} - got, err := k.Unparsed(context.Background(), "novox/web", 7) - if want := []check.UnparsedSeat{{Seat: "web-api", Module: "web-contracts", Directory: "go", Why: "seat.json: bad"}}; err != nil || !reflect.DeepEqual(got, want) { - t.Errorf("unparsed of novox/web#7 = %+v, %v; want %+v", got, err, want) - } - }) -} - -// A manifest whose config value falls back to a predefined key (ADR 0348 §7) is read, not logged as unreadable for the -// catalogue's predefined.json this process never holds: the indexer and the assigner read it with -// catalogue.ParseManifestForInputs (issues 1751, 1906). xterm's module.json from mesh-catalog at 835bf22b. -func TestAManifestFallingBackToAPredefinedKeyIsRead(t *testing.T) { - raw, err := os.ReadFile("testdata/catalogue-835bf22b-xterm.module.json") - if err != nil { - t.Fatal(err) - } - manifest := string(raw) - data, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "xterm", Manifest: manifest}) - if err != nil { - t.Fatal(err) - } - store := memManifests{meshcatalogclient.ManifestDigest([]byte(manifest)): data} - var said []string - r := &repoModules{manifests: store, logf: func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) }} - putModule(t, r, "xterm", "novox/mesh-catalog", manifest) - r.BuildModules("novox/mesh-catalog") - for _, s := range said { - if strings.Contains(s, "cannot be read") { - t.Errorf("the manifest was not read: %s", s) - } - } - if _, err := parseManifest(manifest); err != nil { - t.Errorf("manifestReader: %v", err) - } - // The sandbox's composer may be an older node-engine, which knows no verdict waits: it is handed a wait as a refusal. - var held manifestVerdicts - held.put("nats", &meshcatalog.VerdictsByDigestValue{Module: "nats", State: meshcatalogclient.VerdictManifestWaits, Unknown: []string{"core-credentials"}, Judge: "j"}) - if v := held.all()["nats"]; v.State != meshcatalogclient.VerdictRefused || len(v.Problems) != 1 || len(v.Unknown) != 0 { - t.Errorf("a waiting verdict is handed to the sandbox as %+v", v) - } -} - -// The build modules are no names (design 47 G A-82): the holder of a seat is the module whose manifest, as the indexer's modules -// hold it, claims the seat. -func TestTheHolderOfASeatIsTheModuleWhoseManifestClaimsIt(t *testing.T) { - manifest := `{"module":"go-builds","version":"1","slug":"g","claims":[{"name":"node-build-go","scope":"node"}]}` - data, err := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "go-builds", Manifest: manifest}) - if err != nil { - t.Fatal(err) - } - r := &repoModules{manifests: memManifests{meshcatalogclient.ManifestDigest([]byte(manifest)): data}} - putModule(t, r, "go-builds", "novox/builds", manifest) - if got, ok := r.HolderOf("node-build-go"); !ok || got != "go-builds" { - t.Errorf("the holder of node-build-go = %q, %v, want go-builds", got, ok) - } - if got, ok := r.HolderOf("node-build-node"); ok { - t.Errorf("the holder of a seat no manifest claims = %q, want none", got) - } - var found []string - var changed buildsWatch - changed.Set(func() { found = append(found, "changed") }) - changed.Changed() - if len(found) != 1 { - t.Errorf("the build modules' change was not called through its watch: %v", found) - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judgeseats.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judgeseats.go deleted file mode 100644 index 2bc14572..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/judgeseats.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "maps" - "slices" - "sync/atomic" - - "git.novox.be/novox/mesh-sdk/go/seatdef" - "git.novox.be/novox/mesh-sdk/go/seatlist" -) - -// The checker reads the seat list through mesh-sdk's seatlist.Part, the one wiring (design 47 G §204): what the reader holds is the -// indexer's judge's Seats of a request, which the manifests of a change are judged against. - -// seatList is the reader as the check's SeatList: the held definitions raw, and an error while the seat has not answered. -type seatList struct{ reader *seatlist.Reader } - -func (s seatList) Definitions() ([]json.RawMessage, error) { - if s.reader == nil { - return nil, fmt.Errorf("the checker follows no seat list") - } - if st := s.reader.Status(); !st.Heard { - return nil, fmt.Errorf("%s", st.Health()) - } - defs := s.reader.Definitions() - var out []json.RawMessage - for _, seat := range slices.Sorted(maps.Keys(defs)) { - raw, err := json.Marshal(defs[seat]) - if err != nil { - return nil, fmt.Errorf("the definition of %s cannot be encoded: %w", seat, err) - } - out = append(out, raw) - } - return out, nil -} - -// buildsWatch is what is done when the build modules may have changed (design 47 G A-82): the seat list names the build seats -// and the indexer's modules the holders of the seats, so a change of either may name a build module not watched yet. It is set once -// the parts that watch the build modules are made, and called from then on. -type buildsWatch struct{ fn atomic.Pointer[func()] } - -// Set takes the function in. -func (b *buildsWatch) Set(f func()) { b.fn.Store(&f) } - -// Changed calls it, none before it is set. -func (b *buildsWatch) Changed() { - if f := b.fn.Load(); f != nil { - (*f)() - } -} - -// definitionsOf are the seat definitions the reader holds, none before it has answered. -func definitionsOf(reader *seatlist.Reader) map[string]seatdef.Definition { - if reader == nil { - return nil - } - return reader.Definitions() -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/kept_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/kept_test.go deleted file mode 100644 index c36810ad..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/kept_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "encoding/json" - "os" - "sort" - "testing" -) - -// The checker says on the bus which states it keeps and which others may read (novox/hq ADR 0495 clauses 2 and 3): a -// reader is granted from that announcement. owed is read by the forge module, which writes mesh/check from it (ADR 0521, -// R4e round 2 finding R2-1), and by the forge bridge; previews by the indexer; verdicts by the gate. The list names every -// state of the manifest, so no state is refused at the call for want of being announced (clause 5). -func TestTheCheckerAnnouncesEveryStateItKeepsAndOwedReadable(t *testing.T) { // R2-1, ADR 0495 §2-§3, ADR 0521 - raw, err := os.ReadFile("../../module.json") - if err != nil { - t.Fatal(err) - } - var m struct { - State []struct{ Name string } `json:"state"` - } - if err := json.Unmarshal(raw, &m); err != nil { - t.Fatal(err) - } - var manifest, announced, readable []string - for _, s := range m.State { - manifest = append(manifest, s.Name) - } - for _, s := range keptStates { - announced = append(announced, s.Name) - if s.Readable { - readable = append(readable, s.Name) - } - } - sort.Strings(manifest) - sort.Strings(announced) - if !equal(manifest, announced) { - t.Errorf("announced %v, the manifest keeps %v", announced, manifest) - } - // kept is read by the Go build module for a check ask (issue 1887 design limit 1); tries by the delivery view (build_usage). - // inputs are the checker's own: the Go build module asks the seat's verb input for one (ADR 0596 §2, issue 1921). - if want := []string{"kept", "owed", "previews", "tries", "verdicts"}; !equal(readable, want) { - t.Errorf("readable %v, want %v", readable, want) - } -} - -func equal(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i := range a { - if a[i] != b[i] { - return false - } - } - return true -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go deleted file mode 100644 index 97c0f9ab..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go +++ /dev/null @@ -1,538 +0,0 @@ -// Command mesh-delivery-checker is delivery's checker (novox/hq ADR 0453 clause 4, ADR 0447, ADR 0484, issues 1678 to 1686): for -// each candidate the indexer writes it judges every pull request's head merged onto its trunk, through the build modules' -// fetch, digest and test steps, keeps the passing packages' verdicts, writes the verdict, and owes the forge the status -// `mesh/check`, which the forge bridge sets. It runs dark: nothing reads its answers to merge or deliver (ADR 0453 clause 4). -// It serves no request subject and holds no timer: every reaction is a watch or a bus event (ADR 0437 §8). -package main - -import ( - "context" - "encoding/json" - "errors" - "fmt" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "io" - "log" - "os" - "os/signal" - "strings" - "sync/atomic" - "syscall" - "time" - - "github.com/nats-io/nats.go" - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - - "mesh-delivery-checker/internal/check" - - "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-sdk/go/announce" - "git.novox.be/novox/mesh-sdk/go/process" - "git.novox.be/novox/mesh-sdk/go/seatdef" - "git.novox.be/novox/mesh-sdk/go/seatlist" - "git.novox.be/novox/mesh-sdk/go/views" -) - -// eventSubject is the subject of an event of the checker's stream checks (the bus names the stream CHECKS): the indexer's -// watch of the previews bucket and the forge bridge's watch of the owed bucket are woken by them. -func eventSubject(module, event string) string { - return process.ModuleStreamSubject(module, event) -} - -const ( - // defaultLink is the base of the address a status points at; the verdict key follows. - defaultLink = "mesh-delivery-view/checks" -) - -func main() { - ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - defer stop() - if err := run(ctx, os.Getenv, os.Stderr); err != nil { - fmt.Fprintln(os.Stderr, "mesh-delivery-checker:", err) - os.Exit(1) - } -} - -// durationEnv reads a duration setting from the environment, def when it is not set. -func durationEnv(getenv func(string) string, name string, def time.Duration) (time.Duration, error) { - v := strings.TrimSpace(getenv(name)) - if v == "" { - return def, nil - } - d, err := time.ParseDuration(v) - if err != nil || d <= 0 { - return 0, fmt.Errorf("%s: %q is not a duration of more than 0", name, v) - } - return d, nil -} - -// The checker's own states of its first views (views.StatusState) and of its findings, where the condition keeper raises a -// first view unanswered past its bound (ADR 0615 §6); and the indexer's states it follows (check.CandidatesBucket, -// ModulesBucket, ManifestsBucket). -func firstViewsBucket(module string) string { return check.Bucket(module, views.StatusState) } - -const ( - candidatesState = "candidates" - // seatDefinitionsState is the indexer's state of the seat definitions (design 26), keyed `.trunk` and - // `.pull..`. - seatDefinitionsState = "seat-definitions" - // The owners' views families, as their manifests' `streams` name them. - indexerViews = "indexer-views" - modulesState = "modules" - manifestsState = "manifests" -) - -// run is the program: it returns when ctx ends or the bus cannot be used. -// keptStates is every state the checker keeps and which others may read (ADR 0495 §2-§3): owed by the forge module, -// which writes mesh/check from it (ADR 0521), and by the forge bridge; previews by the indexer; verdicts by the gate; tries by the delivery view. -var keptStates = []announce.State{ - // The kept verdicts are read by the Go build module, which takes them for a check ask's unchanged packages (issue 1887's - // design limit 1); the checker alone writes them (ADR 0444 clause 5). - // Whether DEAD_LETTERS is heard (issue 734): read by the checker's own status tool alone. - {Name: "hearing"}, - // The asks each running check put (check.AsksState): read by the checker's own checker_ask_again alone. - {Name: "asks"}, - // The checking program's inputs by their digest (check.InputsStateName): the checker's own, read by its tools alone, - // which serve one on the seat's verb input to the Go build module that runs the program (check.InputVerb; ADR 0596 §2, - // issue 1921). - {Name: check.InputsStateName}, - // The composition requests it sent the composer, per check and node (check.RequestsStateName): read by its tools alone. - {Name: check.RequestsStateName}, - {Name: "kept", Readable: true}, - {Name: "owed", Readable: true}, - {Name: "previews", Readable: true}, - // The tries are read by the delivery view, which tells a try's asks from a candidate's by the asks each names (build_usage). - {Name: "tries", Readable: true}, - {Name: "verdicts", Readable: true}, - // Where its first views of the indexer's and the assigner's states stand (read by checker_first_views alone), and its - // findings of one unanswered past its bound, which the condition keeper observes as it does every reader's (ADR 0615 §6). - {Name: views.StatusState}, - {Name: "findings"}, - // The checks that could not run (check.CouldNotRunState), each asked again when its part runs: read by checker_status. - {Name: check.CouldNotRunState}, -} - -func run(ctx context.Context, getenv func(string) string, logOut io.Writer) error { - logger := log.New(logOut, "mesh-delivery-checker: ", log.LstdFlags) - cred, err := process.ReadBrokerAccount(getenv) - if err != nil { - return err - } - conn, js, err := cred.Dial() - if err != nil { - return err - } - defer conn.Close() - // Its own states: a check without one of them would be unwritten, so each stops the start, naming its grant (issue 1945). - buckets := map[string]jetstream.KeyValue{} - own := func(state string) string { return check.Bucket(cred.Module, state) } // the credential's module, never a constant (A-296) - for _, state := range []string{checker.StateVerdicts, checker.StateKept, checker.StateOwed, checker.StatePreviews, check.TriesState} { - if buckets[state], err = process.EssentialBucket(ctx, js, "checker", own(state), "judge or keep a check"); err != nil { - return err - } - } - // Calls to the build modules go out as this module's own account, naming the machine (mesh-sdk process.CallOn); the - // buckets are read and written on the connection above. - caller, err := process.Connect(cred, nats.Name(cred.Node+"."+cred.Module+".calls"), nats.RetryOnFailedConnect(true)) - if err != nil { - return err - } - defer caller.Close() - // What the checker keeps, said on the bus (ADR 0495 §2-§3): a reader is granted from it. Not fatal when it cannot be said - // now: process.Conn says it again at every reconnect. - if err := caller.Keeps(keptStates...); err != nil { - logger.Printf("what the checker keeps could not be said on the bus, so readers of owed, previews and verdicts are not granted until it is: %v", err) - } - // The candidates it checks, the modules and manifests that say which build modules judge a repository, the published - // packages, the predefined keys and the assignments are their owners' states (the indexer's, the assigner's), read by the - // first view of their read tools and then their views families, never their buckets (ADR 0615 §1, ADR 0596, DLV-M2). - // An owner that is down never holds the start: the checks start once every first view is answered, and until then the - // unanswered first view is the checker's finding. - // The module has one durable consumer of EVENTS: one hub pulls it for the views reader and for the registry seats' - // published, started once both are registered. - hub := process.NewEventHub(logger.Printf) - reader := &views.ProcessReader{Module: cred.Module, Call: caller.Call, Logf: logger.Printf, Hub: hub} - var buildsChanged buildsWatch - seatPart := seatlist.NewPart("checker", nil) - seats := seatList{reader: seatPart.Follow(seatlist.ProcessBus(caller.Call, hub), buildsChanged.Changed, logger.Printf)} - // The finding writer is made once the checker is (its observe reads the checker's kept checks); until then a first view - // unanswered is said in the log alone. - var findings atomic.Pointer[checkerFindings] - reader.Findings = func() views.WireWriter { - if f := findings.Load(); f != nil { - return f.w - } - return nil - } - // Each by the owner's read tool and views family as the owner's manifest names them. - var followed error - followOwner := func(owner, state, tool, stream string) *views.Picture { - p, err := reader.Follow(owner, state, owner+"."+tool) - followed = errors.Join(followed, err) - return p - } - candidates := followOwner(check.IndexerModule, candidatesState, "indexer_read_candidates", indexerViews) - modules := followOwner(check.IndexerModule, modulesState, "indexer_read_modules", indexerViews) - manifests := followOwner(check.IndexerModule, manifestsState, "indexer_read_manifests", indexerViews) - packages := followOwner(check.IndexerModule, meshcatalog.StatePackages, "indexer_read_packages", indexerViews) - predefined := followOwner(check.IndexerModule, check.IndexerPredefinedState, "indexer_read_predefined", indexerViews) - // The assignments is followed once the seat list names the holder of the seat mesh-module-assigner (below). - var assignments atomic.Pointer[views.Picture] - // The seventh: the indexer's seat definitions, so a pull request whose head's definition does not parse fails. - seatDefs := followOwner(check.IndexerModule, seatDefinitionsState, "indexer_read_seat_definitions", indexerViews) - if followed != nil { - return followed - } - // The build modules are no names (design 47 G A-82): the holders of the build seats, the seat list's definitions and the - // holders the indexer's modules name by their manifests' claims, found at each use. - verdicts := &manifestVerdicts{} - repos := &repoModules{manifests: kvStore{manifests}, logf: logger.Printf, verdicts: verdicts} - buildSeats := buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return definitionsOf(seats.reader) }, repos.HolderOf) - repos.seats = buildSeats - - stepBound, err := durationEnv(getenv, "MESH_CHECKER_STEP_BOUND", check.DefaultStepBound) - if err != nil { - return err - } - checkBound, err := durationEnv(getenv, "MESH_CHECKER_BOUND", check.DefaultBound) - if err != nil { - return err - } - settleWindow, err := durationEnv(getenv, "MESH_CHECKER_SETTLE", check.DefaultSettle) - if err != nil { - return err - } - // The begin bound of a run ask of the checking program (check.DefaultBeginBound, issue 1921). - beginBound, err := durationEnv(getenv, "MESH_CHECKER_BEGIN_BOUND", check.DefaultBeginBound) - if err != nil { - return err - } - link := strings.TrimSpace(getenv("MESH_CHECKER_LINK")) - if link == "" { - link = defaultLink - } - tools := &buildrun.ToolchainSet{Seats: buildSeats} - presence := &buildrun.PresenceSet{} - trunks := &check.Trunks{} - // A check is one ask per pull request and build module on the build seats' check stream, pulled by a build node with a - // free slot (novox/hq ADR 0525 §1, §3): the checker chooses no node and starts no step. - asks := buildrun.JetStreamAsks{JS: js} - // The asks the build seats gave up on (issue 734): heard from DEAD_LETTERS, each ends the step its asker waits for. - // Heard in the background, and again at a reconnect or an ask while it is not; whether it is heard is kept in the - // state hearing, which checker_status says (dead_letters). - dead := &buildrun.DeadLetters{} - // The state may not be on the bus yet when a delivery started the checker (the grants part creates it, issue 1790): it - // is bound when the bus says it was created, and the latest hearing is written then. - hearingKV := process.AwaitBucket(ctx, js, conn, own(buildrun.HearingState), "checker_status cannot say whether DEAD_LETTERS is heard", logger.Printf) - hearing := buildrun.NewDeadLetterHearing(ctx, buildrun.JetStreamDeadLetters{JS: js}, []string{buildstep.AskGo, buildstep.AskNode}, dead, - logger.Printf, buildrun.SayHearing(ctx, hearingKV, logger.Printf)) - defer hearing.Stop() - // Each ask's step is heard by its own watch and, at every step end of its build module and every reconnect, read - // (buildrun.HearEnds): a watch that goes deaf loses no end (the lost check of 2026-10-28). - heard := buildrun.HearEnds(ctx, asks, asks, buildSeats.Modules(), logger.Printf) - conn.SetReconnectHandler(func(*nats.Conn) { hearing.Again(); heard.Nudge("") }) - waiter := buildrun.LostAskWaiter{Inner: heard, Dead: dead, Hearing: hearing} - asksKV := process.AwaitBucket(ctx, js, conn, own(check.AsksState), "checker_ask_again refuses every check, as it cannot tell whether its ask waits in a stream", logger.Printf) - inputsKV := process.AwaitBucket(ctx, js, conn, own(check.InputsStateName), "no checking program can be asked, so every check fails naming it", logger.Printf) - couldNotRunKV := process.AwaitBucket(ctx, js, conn, own(check.CouldNotRunState), "a check that could not run is not asked again when its part runs", logger.Printf) - requestsKV := process.AwaitBucket(ctx, js, conn, own(check.RequestsStateName), "no composition request is kept, so every composition made with the node-engine's head fails naming it", logger.Printf) - ch := &check.Checker{ - Asks: awaitedKV{asksKV}, - Verdicts: kvStore{buckets[checker.StateVerdicts]}, - Owed: kvStore{buckets[checker.StateOwed]}, - // A check that could not run waits for its part's running, and is the finding check-could-not-run after its bound. - CouldNotRun: awaitedKV{couldNotRunKV}, - Trunks: trunks, - Bound: checkBound, - Link: link, - Logf: logger.Printf, - Settle: settleWindow, - } - cf, err := newCheckerFindings(ctx, cred, conn, js, caller.State("findings"), ch.RaisedCouldNotRun, logger.Printf) - if err != nil { - return fmt.Errorf("the checker's finding writer: %w", err) - } - defer cf.w.Close() - ch.Findings = cf - findings.Store(cf) - kept := make(chan struct{}, 1) - ch.CouldNotRunKept = func() { - select { - case kept <- struct{}{}: - default: - } - } - go waitCouldNotRun(ctx, ch, kept) - // The builder's builds say how the candidates' fingerprints stand (issue 1684); where its bucket is not there yet the line - // says nothing of the builds, until the checker starts again. - var buildStates check.BuildStates - var ends check.BuildEnds - if kv := process.OptionalBucket(ctx, js, builds.BuildsBucket(builds.BuilderModule), "the line says nothing of the builds, and a check composes without waiting on them, until the checker starts again", logger.Printf); kv != nil { - buildStates, ends = buildReader{kvStore{kv}}, buildEnds{kv} - } - if ends != nil { - ch.Rebuilds = ends // a check failed on a build is asked again once that build is done again (ADR 0603 §10) - } - // The check's composition is the checker's, from what each placed node's engine answers (ADR 0593 §7, §9). - set, err := readSettings(getenv("MESH_CHECKER_SETTINGS")) - if err != nil { - return err - } - answerBound := set.answer - holdCallsFor(answerBound) - compositions := check.EngineCompositions{ - Requests: check.RequestKeeper{Store: requestsKV}, - Asker: engineAsks{call: caller.CallOn}, - Placed: placedNodes{kv: assignedNodes(&assignments)}.Placed, - Bound: answerBound, - Sandbox: seatSandbox{module: cred.Module, asker: buildrun.Asker{Seats: buildSeats, Publisher: asks, Waiter: waiter, Bound: stepBound, Dropper: buildrun.SeatDrops{Caller: caller}, Outputs: caller.CallFile}}, - Verdicts: verdicts.all, - // The node-engine's trunk head: a group with no node-engine member composes with the composer built there (ADR 0656 §5). - Composer: func() string { return trunks.Heads()[check.NodeEngineRepository] }, - } - // The tries (ADR 0501 §5) are judged by the same judge, held by the same deliveries. - tryer := &check.Tryer{Tries: kvStore{buckets[check.TriesState]}, Bound: checkBound, NotTaken: stepBound, Logf: logger.Printf, - // A whole try's start and end are said on the stream checks, for the indexer to write and delete the candidate of its group. - Say: func(ctx context.Context, event string, body checkermsg.Event) error { - data, _ := json.Marshal(body) - _, err := js.Publish(ctx, eventSubject(cred.Module, event), data, jetstream.WithRetryAttempts(10), jetstream.WithRetryWait(time.Second)) - return err - }} - announce := func(ctx context.Context, event, key string) { - body, _ := json.Marshal(map[string]string{"key": key}) - if _, err := js.Publish(ctx, eventSubject(cred.Module, event), body); err != nil { - logger.Printf("%s of %s was written and the part that reads it could not be told: %v", event, key, err) - } - } - compositions.Composer = func() string { return repos.CommitOf(check.NodeEngineModule) } - compositions.Manifests = repos - // The indexer's packages state (ADR 0593 §2), so a Go check builds every mesh package at its published version: read - // once the first views are answered, before any check starts (afterFirstViews). - published := &publishedPackages{} - compositions.Published = published - ch.Runs = repos // the node-engine a check reads beside at its running commit (ADR 0548 §6) - ch.Says = verdictSays{module: cred.Module, js: js, node: cred.Node, now: time.Now} // a pull request's verdict event, on the stream asks (design 26 *Out of step*) - ch.Judge = newJudge(judgeDeps{ - module: cred.Module, - asks: buildrun.Asker{Seats: buildSeats, Publisher: asks, Waiter: waiter, Bound: stepBound, Dropper: buildrun.SeatDrops{Caller: caller}, Outputs: caller.CallFile}, tools: tools, trunks: trunks, - kept: kvStore{buckets[checker.StateKept]}, previews: kvStore{buckets[checker.StatePreviews]}, candidates: tryCandidates{candidates}, - repos: repos, published: published, builds: buildStates, ends: ends, buildWait: set.buildWait, forge: forgeReads{call: caller.Call}, logf: logger.Printf, - announce: announce, compositions: compositions, inputs: runInputs{awaitedKV{inputsKV}}, beginBound: beginBound, - nodes: openNodeNames(ctx, js, logger.Printf), - predefined: keptPredefined{predefined}, - renames: seatRenames{call: caller.Call}, - seatDefs: seatDefinitionsOf(seatDefs), - seats: seats, - buildSeats: buildSeats, - }) - ch.Announce = announce - tryer.Judge = ch.Judge - - // The toolchains first, so a check that starts from the first candidate finds the nodes. - watch := newToolchainWatch(ctx, js, buildSeats, tools, ch.NodesChanged, logger) - // Only the toolchain reports of nodes the catalogue places the build module on count (issue 1940, ADR 0549 §3): the - // assignments is settled first, so the toolchains settle through the gate already knowing it. - gate := buildrun.NewToolchainGate(buildSeats.Modules(), tools.Put, logger.Printf) - watch.put = gate.Toolchain - // Until the assignments's first view is answered the gate passes every report on, as before the assignments is settled. - assignmentsErrs := make(chan error, 1) - // The assignments is the seat mesh-module-assigner's view, followed at the holder the seat-holders view names and as it - // moves (design 47 G §717): the holder function is the catalog half's claimant's seat-holders view (A-298), so no assigner - // module is named and nothing asks for the holder on a timer. - branches, err := meshcatalogclient.FollowBranchesProcess(reader, caller.Call) - if err != nil { - return err - } - branches.Logf = logger.Printf - pic, err := reader.FollowSeat(meshmoduleassigner.Seat, meshmoduleassigner.StateAssignments, branches.SeatHolders(ctx)) - if err != nil { - return err - } - assignments.Store(pic) - go func() { - select { - case <-ctx.Done(): - return - case <-pic.Follower().Ready(): - } - pe, err := buildrun.FollowAssignmentsIn(ctx, reader, pic.Bucket(), gate, ch.NodesChanged, logger.Printf) - if err != nil { - assignmentsErrs <- err - return - } - assignmentsErrs <- <-pe - }() - if err := watch.start(); err != nil { - return err - } - // A build seat says each time a node reported its toolchain (its event toolchain-reported, design 47 G §492): the bucket of - // the seat's holder is watched then, if it is not (Reported), and again when the seat list or the holders change (below). - for _, lang := range []string{buildstep.AskGo, buildstep.AskNode} { - seat, err := buildstep.BuildSeat(lang) - if err != nil { - return err - } - if err := hub.Handle("mesh.seat."+seat+".event.toolchain-reported.>", func(m jetstream.Msg) { watch.Reported(m) }); err != nil { - return err - } - } - // The build modules are named by the seat list and the indexer's modules: a change of either watches the steps and toolchains of - // a build module not watched yet and tells the gate which modules' reports it passes on. - buildsChanged.Set(func() { - heard.Watch(buildSeats.Modules()) - gate.UseModules(buildSeats.Modules()) - if err := watch.start(); err != nil { - logger.Printf("the toolchains of a build module cannot be watched: %v", err) - } - }) - // The node-engine seat's running.., kept last per subject (design 47): a part a check could not hear runs, - // and the check is asked again (issue 1373). Its stream and the checker's durable consumer on it are made from the - // manifest's consumes; where they are not there yet the checker says so, and a check that could not run waits for its - // bound and is said as a finding. - if cons, err := cred.EventConsumer(ctx, js, nodeengine.StreamRunning); err != nil { - logger.Printf("the consumer %s_%s on %s does not exist yet, so no check that could not run is asked again until the checker starts again: %v", cred.Node, cred.Module, nodeengine.StreamRunning, err) - } else { - cc, err := process.HearEvents(cons, func(m jetstream.Msg) { heardRunning(ctx, ch, m.Data(), logger.Printf) }, logger.Printf) - if err != nil { - return err - } - defer cc.Stop() - } - errs := make(chan error, 8) - // The watchman's presence: a node coming back online asks again a check whose forge was not heard (UnheardWords), and - // the assigner's own presence says whether a composition is being made (compositionWatch, ADR 0537 §4). A check is no - // longer held for a node: its asks wait in the build seats' streams, which redeliver a lost node's ask (ADR 0525 §6, - // issue 1912), so the node-engine's have is not watched here. - if kv := process.OptionalBucket(ctx, js, check.PresenceBucket, "no node counts as online until the checker starts again", logger.Printf); kv != nil { - if pw, err := settle(ctx, kv, func(e jetstream.KeyValueEntry) { presence.Put(e.Key(), e.Value(), !opOf(e)) }); err != nil { - process.NotWatched(logger.Printf, check.PresenceBucket, err, "no node counts as online until the checker starts again") - } else { - go func() { - errs <- follow(ctx, pw, func(e jetstream.KeyValueEntry) { - if presence.Put(e.Key(), e.Value(), !opOf(e)) { - ch.NodesChanged(ctx) // a node came online or went: a check whose forge was not heard may now be heard - } - }) - }() - } - } - // The catalog half says the trunk head of each repository, which a pull request is merged onto (design 47 G §197). Where it - // does not answer yet no trunk is known, so nothing is checked. - firstTrunks, err := followTrunks(hub, caller.Call, trunks, ch.TrunkMoved, logger.Printf) - if err != nil { - return fmt.Errorf("the checker cannot hear the catalog half's revisions: %w", err) - } - firstTrunks(ctx) - afterFirstViews := func() error { - // The modules say which repository holds a TypeScript module, so the Node build module judges it too. - pw, err := settle(ctx, packages, func(e jetstream.KeyValueEntry) { published.Put(e.Key(), e.Value(), !opOf(e)) }) - if err != nil { - return err - } - published.Answered() // read whole, an empty state too: its names are judged from here on - go func() { - errs <- follow(ctx, pw, func(e jetstream.KeyValueEntry) { published.Put(e.Key(), e.Value(), !opOf(e)) }) - }() - mw, err := settle(ctx, modules, func(e jetstream.KeyValueEntry) { repos.Put(ctx, e.Key(), e.Value(), !opOf(e)) }) - if err != nil { - return err - } - buildsChanged.Changed() // the holders of the build seats are known from here - go func() { - errs <- follow(ctx, mw, func(e jetstream.KeyValueEntry) { - before := repos.CommitOf(check.NodeEngineModule) - repos.Put(ctx, e.Key(), e.Value(), !opOf(e)) - buildsChanged.Changed() // a holder of a build seat may have moved - if after := repos.CommitOf(check.NodeEngineModule); after != before { - ch.TrunkMoved(ctx) // the node-engine the mesh runs moved: a verdict that read it beside is carried (ADR 0548 §6) - } - }) - }() - each := func(e jetstream.KeyValueEntry) { - if opOf(e) { - ch.Candidate(ctx, e.Key(), e.Value()) - } else { - ch.Forget(e.Key()) - } - } - w, err := settle(ctx, candidates, each) - if err != nil { - return err - } - // A key left running for heads no candidate holds is closed; the candidates are all known now. - if err := ch.Sweep(ctx); err != nil { - return err - } - // The tries: a queued one starts, one left running is taken over, an ended one past its keeping is removed. - tw, err := settle(ctx, buckets[check.TriesState], func(jetstream.KeyValueEntry) {}) - if err != nil { - return err - } - tryer.Reconsider(ctx) - go func() { - errs <- follow(ctx, tw, func(e jetstream.KeyValueEntry) { - if opOf(e) { - tryer.Put(ctx, e.Key(), e.Value()) - } - }) - }() - // The checker's own verdicts, updates only, in one watch: one checker_ask_again wrote asks its check again - // (Checker.VerdictWritten); a deleted key of heads a candidate holds is judged again (Checker.VerdictDeleted, issue 1733). - vw, err := buckets[checker.StateVerdicts].WatchAll(ctx, jetstream.UpdatesOnly()) - if err != nil { - return fmt.Errorf("the checker's verdicts cannot be watched, so no check can be asked again by hand and a deleted verdict would never be written again: %w", err) - } - go func() { - errs <- follow(ctx, vw, func(e jetstream.KeyValueEntry) { - if opOf(e) { - ch.VerdictWritten(ctx, e.Key(), e.Value()) - } else { - ch.VerdictDeleted(ctx, e.Key()) - } - }) - }() - go func() { errs <- follow(ctx, w, each) }() - return nil - } - reader.Start(ctx, js, cred, process.AwaitBucket(ctx, js, conn, firstViewsBucket(cred.Module), "checker_first_views reads nothing and checker_first_view_again is not heard", logger.Printf)) - // Every part has registered. Where the consumer is not there yet the hub binds it as soon as it is, and the seat list is read - // again then if it is still unread. - if err := hub.StartUntilBound(ctx, js, cred, nil, seatPart.EventsLive); err != nil { - logger.Printf("%v, so no package registry's published is heard until the consumer is there; the checker tries again", err) - } - defer hub.Stop() - // The checks, the tries and the hand asks, once every first view is answered (the lead's ruling for DLV-M2): a check - // judged without the candidates, the modules, the manifests, the published packages, the predefined keys or the - // assignments would be another check. - go func() { - select { - case <-ctx.Done(): - return - case <-reader.Ready(): - } - if err := afterFirstViews(); err != nil { - errs <- err - } - }() - logger.Printf("started on %s", cred.Node) - select { - case <-ctx.Done(): - ch.Wait() - tryer.Wait() - return nil - case err := <-errs: - return err - case err := <-assignmentsErrs: - return err - case err := <-watch.errs: - return err - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/nodes_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/nodes_test.go deleted file mode 100644 index aa903e5b..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/nodes_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "os" - "strings" - "testing" -) - -// 1912: with checks as asks on the build seats' streams, the stream redelivers a lost node's ask (ADR 0525 §6), so the -// checker program watches no node-engine have to start again a check that failed for want of a node. It reads the have's -// keys only for the nodes' names at each ask (judge.go, novox/hq ADR 0567 §12). -func TestTheCheckerWatchesNoHave(t *testing.T) { - raw, err := os.ReadFile("main.go") - if err != nil { - t.Fatal(err) - } - for _, s := range []string{"check.HaveBucket", "buildrun.HaveSet"} { - if strings.Contains(string(raw), s) { - t.Errorf("the checker program still reads %s", s) - } - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/packages.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/packages.go deleted file mode 100644 index a1925e82..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/packages.go +++ /dev/null @@ -1,108 +0,0 @@ -package main - -import ( - "strings" - "sync" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// publishedPackages is the indexer's state `packages` as the checker follows it (novox/hq ADR 0593 §2): by mesh Go -// module, the latest published commit of its repository the indexer read its packages at. The indexer alone computes a -// package's version; the checker reads it, so a Go check builds every mesh package at the version the mesh publishes -// (check.Examiner.Published) and computes none. -// -// Its series keys (meshcatalog.PackagesByPackageSeriesValue, decoded with meshcatalog.DecodePackagesByPackageSeriesValue) name each package by its name in its -// own ecosystem and the `/` it is built from (design 32): the known packages the judge takes -// (PackageNames). -type publishedPackages struct { - mu sync.Mutex - byKey map[string]meshcatalog.PackagesByModuleValue - series map[string]meshcatalog.PackagesByPackageSeriesValue - unread map[string]string - // answered is whether the state's first reading ended (Answered): until then the checker knows no package's name. - answered bool -} - -// Answered marks the state's first reading as ended, so PackageNames names what it holds, none included. -func (p *publishedPackages) Answered() { - p.mu.Lock() - defer p.mu.Unlock() - p.answered = true -} - -// Put takes one key of the state in: its value, or its deletion. A value that does not decode is kept out and remembered -// with why, never read as an older one. -func (p *publishedPackages) Put(key string, raw []byte, deleted bool) { - p.mu.Lock() - defer p.mu.Unlock() - if p.byKey == nil { - p.byKey, p.series, p.unread = map[string]meshcatalog.PackagesByModuleValue{}, map[string]meshcatalog.PackagesByPackageSeriesValue{}, map[string]string{} - } - delete(p.byKey, key) - delete(p.series, key) - delete(p.unread, key) - if deleted { - return - } - if isSeriesPackageKey(key) { - s, err := meshcatalog.DecodePackagesByPackageSeriesValue(raw) - if err != nil { - p.unread[key] = err.Error() - return - } - p.series[key] = s - return - } - v, err := meshcatalog.DecodePackagesByModuleValue(raw) - if err != nil { - p.unread[key] = err.Error() - return - } - p.byKey[key] = v -} - -// LatestPackages is the latest published version of every mesh Go module the indexer holds, by module path: the commit -// its repository was published at. A module the state does not hold is left out: a check builds it at the version -// go.mod names. -func (p *publishedPackages) LatestPackages() buildstep.PackageVersions { - p.mu.Lock() - defer p.mu.Unlock() - out := buildstep.PackageVersions{} - for _, v := range p.byKey { - if v.Module != "" && v.Commit != "" { - out[v.Module] = v.Commit - } - } - return out -} - -// PackageNames are the packages the state's series keys name, and the Go module path of each per-module record (issue -// 1966: the indexer's own knownPackages counts them the same way, with no `/` to say; never a package -// inside a module, design 32), by the name in its own ecosystem: the `/` -// each is built from (empty when the key does not say). Nil while the state is not read yet (Answered), which judges no -// name; once read never nil, an empty state included, so the judge judges every name against it. -func (p *publishedPackages) PackageNames() map[string]string { - p.mu.Lock() - defer p.mu.Unlock() - if !p.answered { - return nil - } - out := map[string]string{} - for _, s := range p.series { - if out[s.Name] == "" { - out[s.Name] = s.Package - } - } - for _, v := range p.byKey { - if _, ok := out[v.Module]; !ok && v.Module != "" { - out[v.Module] = "" - } - } - return out -} - -// isSeriesPackageKey says a key of the indexer's state packages is a package's series (`.`): a module's key -// is its path escaped, which holds no dot (keys.EscapeName). -func isSeriesPackageKey(key string) bool { return strings.Contains(key, ".") } diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/refused_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/refused_test.go deleted file mode 100644 index 9370f34f..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/refused_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -import ( - "bytes" - "context" - "errors" - "log" - "strings" - "testing" - - "git.novox.be/novox/mesh-sdk/go/process" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" -) - -// 1945 (a part exits at start for a bucket it works without): a bus that refuses every toolchains bucket leaves the -// watch unstarted and the part running, said; a refused bucket it cannot work without is an error naming the bucket and -// its grant. The gate over the seat's assignments, and its refusal, are mesh-sdk's (buildrun.ToolchainGate, -// issue 774). -func TestARefusedBucketIsSaidAndThePartGoesOn(t *testing.T) { - set := &buildrun.ToolchainSet{Seats: testBuildSeats()} - var logs bytes.Buffer - logger := log.New(&logs, "", 0) - refused := refusingBus{err: errors.New("nats: permissions violation for publish to $JS.API.CONSUMER.CREATE.KV_mesh-build-node_toolchains")} - if err := newToolchainWatch(context.Background(), refusingBus{refuseOpen: true, err: refused.err}, testBuildSeats(), set, func(context.Context) {}, logger).start(); err != nil { - t.Errorf("a refused toolchains bucket stopped the start: %v", err) - } - if !strings.Contains(logs.String(), "cannot be read") { - t.Errorf("the refusals were not said: %q", logs.String()) - } - if _, err := process.EssentialBucket(context.Background(), refusingBus{refuseOpen: true, err: refused.err}, "checker", "mesh-delivery-indexer_modules", "work"); err == nil || - !strings.Contains(err.Error(), "grant of mesh-delivery-indexer_modules") { - t.Errorf("a refused bucket the part needs: %v, want an error naming its grant", err) - } -} - -// refusingBus is a bus that refuses: every open (refuseOpen), or every watch of a bucket it opens, with err. -type refusingBus struct { - refuseOpen bool - err error -} - -func (r refusingBus) KeyValue(context.Context, string) (jetstream.KeyValue, error) { - if r.refuseOpen { - return nil, r.err - } - return refusedWatch{err: r.err}, nil -} - -type refusedWatch struct { - jetstream.KeyValue - err error -} - -func (r refusedWatch) WatchAll(context.Context, ...jetstream.WatchOpt) (jetstream.KeyWatcher, error) { - return nil, r.err -} -func (r refusedWatch) Watch(context.Context, string, ...jetstream.WatchOpt) (jetstream.KeyWatcher, error) { - return nil, r.err -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/renames.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/renames.go deleted file mode 100644 index dca90323..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/renames.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "errors" - "fmt" - - "github.com/nats-io/nats.go" - - "git.novox.be/novox/mesh-contracts/go/seats/meshconfig" - - "mesh-delivery-checker/internal/check" -) - -// seatRenames asks the seat mesh-config's verb renames as the checker's own account (its `invokes` -// seat:mesh-config.renames; design 32). A call nobody answers is a holder serving no renames (the verb is optional), said -// as check.ErrRenamesNotServed with the bus's words; any other error is an ask that could not be made. -type seatRenames struct { - call func(key string, body any) (json.RawMessage, error) -} - -func (s seatRenames) Renames(_ context.Context, module string) (meshconfig.RenamesAnswer, error) { - raw, err := s.call(check.RenamesSeat, meshconfig.RenamesInput{Module: module}) - if errors.Is(err, nats.ErrNoResponders) { - return meshconfig.RenamesAnswer{}, fmt.Errorf("%w (nothing answers it: %v)", check.ErrRenamesNotServed, err) - } - if err != nil { - return meshconfig.RenamesAnswer{}, err - } - var a meshconfig.RenamesAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return meshconfig.RenamesAnswer{}, fmt.Errorf("%s answered what is not its answer: %w", check.RenamesSeat, err) - } - return a, nil -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seatlist_wiring_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seatlist_wiring_test.go deleted file mode 100644 index f8e31bca..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seatlist_wiring_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "strings" - "testing" -) - -// The checker wires no reader of the seat list of its own (design 47 G §204, CK9): it follows the list through mesh-sdk's -// seatlist.Part, and its code holds no seatlist.Start nor a file of its own for the list. -func TestTheCheckerWiresNoSeatListReaderOfItsOwn(t *testing.T) { - if _, err := os.Stat("seatlist.go"); err == nil { - t.Error("seatlist.go is the checker's own wiring of the seat list: mesh-sdk's seatlist.Part is the one wiring") - } - files, _ := filepath.Glob("*.go") - for _, f := range files { - if strings.HasSuffix(f, "_test.go") { - continue - } - src, err := os.ReadFile(f) - if err != nil { - t.Fatal(err) - } - if strings.Contains(string(src), "seatlist.Start(") { - t.Errorf("%s starts a seat list reader of its own: use seatlist.Part.Follow", f) - } - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seats_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seats_test.go deleted file mode 100644 index 856e6f6e..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/seats_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-sdk/go/seatdef" -) - -// The holders of the build seats in the tests' seat list: names the checker's code does not know, found by the seats' acting -// rules (design 47 G A-82). -const ( - goBuildModule = "mesh-build-go" - nodeBuildModule = "mesh-build-node" -) - -// testBuildSeats is the finder over the build seats of the tests' seat list. -func testBuildSeats() *buildrun.BuildSeats { - rule := func(on string) seatdef.Definition { - return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}} - } - defs := map[string]seatdef.Definition{"node-build-go": rule("go"), "node-build-node": rule("typescript")} - holders := map[string]string{"node-build-go": goBuildModule, "node-build-node": nodeBuildModule} - return buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok }) -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go deleted file mode 100644 index c198376e..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "encoding/json" - "errors" - "fmt" - "io/fs" - "os" - "time" - - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-sdk/go/process" - - "mesh-delivery-checker/internal/check" -) - -// The checker's own settings (its config, written by the node-engine into ${dir:state}/settings.json, named to the -// process by MESH_CHECKER_SETTINGS): compose-answer-bound, the seconds a check waits for a node's engine to answer -// compose-candidate (novox/hq ADR 0593 §7, §9: 60 by default), and build-wait-bound, the seconds a check waits for the -// builder's builds of its candidate before it composes (ADR 0603 §10: 1800 by default). The checker owns both. - -// settings are the checker's settings as read. -type settings struct { - // answer is compose-answer-bound; buildWait is build-wait-bound. - answer, buildWait time.Duration -} - -// readSettings reads the settings file at path: each value's default where no file or no value is there; a value that is -// no whole number of seconds within its range is refused, naming it. -func readSettings(path string) (settings, error) { - out := settings{answer: nec.AnswerBound, buildWait: check.DefaultBuildWait} - if path == "" { - return out, nil - } - raw, err := os.ReadFile(path) - if errors.Is(err, fs.ErrNotExist) { - return out, nil - } - if err != nil { - return settings{}, err - } - var s struct { - Answer *float64 `json:"compose-answer-bound"` - BuildWait *float64 `json:"build-wait-bound"` - } - if err := json.Unmarshal(raw, &s); err != nil { - return settings{}, fmt.Errorf("%s is no settings file: %w", path, err) - } - for _, v := range []struct { - name string - value *float64 - min, max float64 - into *time.Duration - }{{"compose-answer-bound", s.Answer, 1, 600, &out.answer}, {"build-wait-bound", s.BuildWait, 60, 7200, &out.buildWait}} { - if v.value == nil { - continue - } - if *v.value < v.min || *v.value > v.max || *v.value != float64(int(*v.value)) { - return settings{}, fmt.Errorf("%s is %v: a whole number of seconds from %v to %v", v.name, *v.value, v.min, v.max) - } - *v.into = time.Duration(*v.value) * time.Second - } - return out, nil -} - -// holdCallsFor makes a bus call wait the compose-answer-bound (novox/hq ADR 0593 §7), not the SDK's CallTimeout of 30 s: -// the request of Conn.CallOn gives up at CallTimeout, so a node-engine answering at 30.4 s was lost before the bound -// applied (issue 1126). It only ever lengthens the SDK's bound, and it is set once, before the first call. -func holdCallsFor(bound time.Duration) { - if bound > process.CallTimeout { - process.CallTimeout = bound - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go deleted file mode 100644 index 73e8b431..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "testing" - "time" - - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-sdk/go/process" - - "mesh-delivery-checker/internal/check" -) - -// ADR 0593 §7: the answer bound is the checker's setting compose-answer-bound, 60 s when the file or the value is -// absent; a value that is no whole number of seconds from 1 to 600 stops the start, naming it. ADR 0603 §10: the wait for -// the candidate's builds is build-wait-bound, 30 minutes when absent, from 60 to 7200 seconds. -func TestTheAnswerBoundIsTheCheckersSetting(t *testing.T) { - dir := t.TempDir() - for _, row := range []struct { - body string - want time.Duration - err bool - buildWait time.Duration - }{{"", nec.AnswerBound, false, check.DefaultBuildWait}, {`{}`, nec.AnswerBound, false, check.DefaultBuildWait}, - {`{"compose-answer-bound": 90}`, 90 * time.Second, false, check.DefaultBuildWait}, {`{"compose-answer-bound": 0}`, 0, true, 0}, - {`{"compose-answer-bound": 1.5}`, 0, true, 0}, - {`{"compose-answer-bound": 60, "build-wait-bound": 600}`, 60 * time.Second, false, 10 * time.Minute}, - {`{"build-wait-bound": 30}`, 0, true, 0}} { - path := filepath.Join(dir, "settings.json") - os.Remove(path) - if row.body != "" { - if err := os.WriteFile(path, []byte(row.body), 0o600); err != nil { - t.Fatal(err) - } - } - set, err := readSettings(path) - got := set.answer - if (err != nil) != row.err || got != row.want || set.buildWait != row.buildWait { - t.Errorf("%q: %s, %s, %v", row.body, got, set.buildWait, err) - } - // Issue 1126: the SDK's call gives up at CallTimeout (30 s), so the checker's calls must wait the bound read - // (an answer at 31 s is heard under 60 s), and the bound never shortens the SDK's own. - if err == nil { - was := process.CallTimeout - holdCallsFor(got) - if process.CallTimeout < got || process.CallTimeout < was { - t.Errorf("%q: calls wait %v under bound %v", row.body, process.CallTimeout, got) - } - process.CallTimeout = was - } - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/testdata/catalogue-835bf22b-xterm.module.json b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/testdata/catalogue-835bf22b-xterm.module.json deleted file mode 100644 index b65be8eb..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/testdata/catalogue-835bf22b-xterm.module.json +++ /dev/null @@ -1,236 +0,0 @@ -{ - "module": "xterm", - "version": "1", - "moved": true, - "capabilities": [ - "package-manager" - ], - "requires": [ - "x11-display" - ], - "claims": [ - { - "name": "node-terminal-emulator", - "scope": "node", - "serves": [ - "open" - ] - } - ], - "tools": [ - "xterm_font", - "xterm_colours" - ], - "config": { - "face": { - "type": "string", - "description": "The font family xterm draws with, as fc-list names it: JetBrainsMono Nerd Font, because research 026/04 chose it for its glyphs the prompt uses. A family the machine does not have falls back to the nearest installed face (xterm_font says which).", - "pattern": "[A-Za-z0-9 ._-]{1,64}", - "default": "JetBrainsMono Nerd Font" - }, - "size": { - "type": "number", - "description": "The size of xterm's text, in points: 12 reads well on a screen of about 100 DPI, and a denser screen needs a larger size.", - "minimum": 6, - "maximum": 72, - "predefined": "font-size", - "default": 12 - }, - "save-lines": { - "type": "number", - "description": "How many lines of scrollback xterm keeps per terminal: 10000 holds a long build log, and each line costs memory in every open terminal.", - "minimum": 0, - "maximum": 1000000, - "default": 10000 - }, - "term-name": { - "type": "string", - "description": "The TERM value xterm sets for the programs it runs: xterm-256color, because the palette has 256 colours and every program knows the name.", - "pattern": "[A-Za-z0-9._-]{1,64}", - "default": "xterm-256color" - }, - "render-font": { - "type": "boolean", - "description": "Whether xterm draws with fontconfig faces (true) or the old X core fonts (false): true, because the face is a fontconfig family and core fonts cannot show it.", - "default": true - }, - "bold-mode": { - "type": "boolean", - "description": "Whether xterm draws bold text by overstriking the normal face (true): false, because the face has a real bold style and overstriking blurs it.", - "default": false - }, - "always-bold-mode": { - "type": "boolean", - "description": "Whether xterm overstrikes bold even where the face has a bold style (true): false, for the same reason as bold-mode.", - "default": false - }, - "allow-bold-fonts": { - "type": "boolean", - "description": "Whether xterm may use the face's bold style for bold text (true): true, so bold text is drawn with the real bold weight.", - "default": true - }, - "background": { - "type": "string", - "description": "The terminal's background colour, as #rrggbb: black, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#000000" - }, - "foreground": { - "type": "string", - "description": "The terminal's text colour, as #rrggbb: a light grey, easier on the eyes than white on black.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#a8a8a8" - }, - "color0": { - "type": "string", - "description": "Palette entry 0, the normal black, as #rrggbb: #000000, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#000000" - }, - "color1": { - "type": "string", - "description": "Palette entry 1, the normal red, as #rrggbb: #9e1828, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#9e1828" - }, - "color2": { - "type": "string", - "description": "Palette entry 2, the normal green, as #rrggbb: #008800, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#008800" - }, - "color3": { - "type": "string", - "description": "Palette entry 3, the normal yellow, as #rrggbb: #d2bb4b, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#d2bb4b" - }, - "color4": { - "type": "string", - "description": "Palette entry 4, the normal blue, as #rrggbb: #414171, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#414171" - }, - "color5": { - "type": "string", - "description": "Palette entry 5, the normal magenta, as #rrggbb: #963c59, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#963c59" - }, - "color6": { - "type": "string", - "description": "Palette entry 6, the normal cyan, as #rrggbb: #418179, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#418179" - }, - "color7": { - "type": "string", - "description": "Palette entry 7, the normal white, as #rrggbb: #bebebe, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#bebebe" - }, - "color8": { - "type": "string", - "description": "Palette entry 8, the bright black, as #rrggbb: #666666, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#666666" - }, - "color9": { - "type": "string", - "description": "Palette entry 9, the bright red, as #rrggbb: #bc5766, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#bc5766" - }, - "color10": { - "type": "string", - "description": "Palette entry 10, the bright green, as #rrggbb: #61a171, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#61a171" - }, - "color11": { - "type": "string", - "description": "Palette entry 11, the bright yellow, as #rrggbb: #e7db52, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#e7db52" - }, - "color12": { - "type": "string", - "description": "Palette entry 12, the bright blue, as #rrggbb: #5085af, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#5085af" - }, - "color13": { - "type": "string", - "description": "Palette entry 13, the bright magenta, as #rrggbb: #a97a99, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#a97a99" - }, - "color14": { - "type": "string", - "description": "Palette entry 14, the bright cyan, as #rrggbb: #6ba4a4, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#6ba4a4" - }, - "color15": { - "type": "string", - "description": "Palette entry 15, the bright white, as #rrggbb: #ffffff, as both workstations ran it.", - "pattern": "#[0-9a-fA-F]{6}", - "default": "#ffffff" - }, - "copy-binding": { - "type": "string", - "description": "The key combination that copies the selection to the clipboard, in X translation syntax: Ctrl Shift ~Alt C, so a plain Ctrl+C still interrupts the program. It holds no colon, backslash or line break, which would end the resource.", - "pattern": "[^:\\\\\\n]+", - "default": "Ctrl Shift ~Alt C" - }, - "paste-binding": { - "type": "string", - "description": "The key combination that pastes the clipboard, in X translation syntax: Ctrl Shift ~Alt V, the pair of copy-binding. It holds no colon, backslash or line break, which would end the resource.", - "pattern": "[^:\\\\\\n]+", - "default": "Ctrl Shift ~Alt V" - } - }, - "items": [ - { - "collection": "environment", - "name": "terminal", - "attributes": { - "kind": "variable", - "name": "TERMINAL" - }, - "template": "files/env-terminal" - }, - { - "collection": "shell:xresources:normal", - "name": "xresources-normal", - "template": "files/xresources-normal" - } - ], - "resources": [ - { - "id": "package", - "type": "package", - "package": "xterm" - } - ], - "build": { - "artifacts": [ - { - "name": "tools", - "kind": "bundle", - "language": "go", - "system": "arch", - "from": "cmd/xterm-tools", - "binary": "xterm-tools", - "loads": [ - "xterm-tools" - ] - }, - { - "name": "files", - "kind": "archive", - "from": "files" - } - ] - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/toolchains.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/toolchains.go deleted file mode 100644 index 65f4643c..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/toolchains.go +++ /dev/null @@ -1,108 +0,0 @@ -package main - -import ( - "context" - "errors" - "fmt" - "log" - "strings" - "sync" - - "git.novox.be/novox/mesh-sdk/go/process" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" -) - -// toolchainWatch keeps the build modules' toolchains in a buildrun.ToolchainSet and tells the builder when one changed. A -// build module's bucket is made when it is assigned, after the builder started, and the builder holds no timer (ADR 0437 -// §8): it watches the buckets that exist at start, and a build module says each time it wrote its toolchains key -// (toolchain.reported, handled by Reported); a bucket not watched yet is then watched. -type toolchainWatch struct { - ctx context.Context - js bucketOpener - seats *buildrun.BuildSeats // the build modules: the holders of the build seats (design 47 G A-82) - set *buildrun.ToolchainSet - // put takes a change of a toolchains bucket in: set.Put, or the gate of the assigned build nodes before it (issue 1940). - put func(module, key string, value []byte, deleted bool) bool - changed func(ctx context.Context) // a language's entries changed: the failed builds are tried again - logger *log.Logger - errs chan error - mu sync.Mutex - watched map[string]bool -} - -func newToolchainWatch(ctx context.Context, js bucketOpener, seats *buildrun.BuildSeats, set *buildrun.ToolchainSet, changed func(context.Context), logger *log.Logger) *toolchainWatch { - return &toolchainWatch{ctx: ctx, js: js, seats: seats, set: set, put: set.Put, changed: changed, logger: logger, errs: make(chan error, 16), watched: map[string]bool{}} -} - -// start watches the buckets that exist now; a missing one is said and waits for its build module's event. -func (w *toolchainWatch) start() error { - for _, module := range w.seats.Modules() { - if err := w.ensure(module); err != nil { - return err - } - } - return nil -} - -func (w *toolchainWatch) ensure(module string) error { - w.mu.Lock() - defer w.mu.Unlock() - if w.watched[module] { - return nil - } - name := buildrun.ToolchainsBucket(module) - kv, err := w.js.KeyValue(w.ctx, name) - switch { - case errors.Is(err, jetstream.ErrBucketNotFound): - w.logger.Printf("the bucket %s does not exist yet: it is watched when %s reports a toolchain", name, module) - return nil - case err != nil: - // Refused or not answered (its grant not on the bus yet, issue 1945): said, and opened again at the module's next report. - w.logger.Printf("the bucket %s cannot be read (%v): %s's toolchains are not heard until its next report", name, err, module) - return nil - } - watcher, err := settle(w.ctx, kv, func(e jetstream.KeyValueEntry) { w.put(module, e.Key(), e.Value(), !opOf(e)) }) - if err != nil { - process.NotWatched(w.logger.Printf, name, err, fmt.Sprintf("%s's toolchains are not heard until its next report", module)) - return nil - } - w.watched[module] = true - go func() { - w.errs <- follow(w.ctx, watcher, func(e jetstream.KeyValueEntry) { - if w.put(module, e.Key(), e.Value(), !opOf(e)) { - w.changed(w.ctx) - } - }) - }() - w.changed(w.ctx) // what the settle read is new to the builder - return nil -} - -// delivered is the part of a JetStream message the watch uses. -type delivered interface { - Subject() string - Ack() error - Term() error -} - -// Reported takes one toolchain-reported event of a build seat in: the seat is read off the subject, -// mesh.seat..event.toolchain-reported., and the bucket of its holder is watched if it is not. A subject of no build -// seat with a holder is terminated; a failure stays unacknowledged, and the server delivers it again. -func (w *toolchainWatch) Reported(m delivered) { - seat, _, _ := strings.Cut(strings.TrimPrefix(m.Subject(), "mesh.seat."), ".event.") - bm, known := w.seats.OfSeat(seat) - module := bm.Module - if !known || module == "" || bm.Toolchain == "" || !strings.HasPrefix(m.Subject(), "mesh.seat.") { - w.logger.Printf("%s: not the event of a build seat with a holder, dropped", m.Subject()) - _ = m.Term() - return - } - if err := w.ensure(module); err != nil { - w.logger.Printf("%s: left for redelivery: %v", m.Subject(), err) - return - } - _ = m.Ack() -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk.go deleted file mode 100644 index 4cbc5466..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - - "mesh-delivery-checker/internal/check" -) - -// The checker takes the trunk heads a check merges onto from the catalog half (design 47 G §197), never from the gate's state -// `source`: a first view by the seat mesh-catalog's verb `revision`, which carries the trunk head of every repository, then -// the seat's event `catalog-revision` of a trunk revision, each read again by the verb. - -// readTrunks asks the catalog half's newest trunk revision and sets the heads it carries. It says whether they changed. A -// candidate's revision, or an answer that does not read, changes nothing. -func readTrunks(ask func(string, any) (json.RawMessage, error), trunks *check.Trunks) (bool, error) { - raw, err := ask(check.TrunkVerb, meshcatalog.RevisionInput{}) - if err != nil { - return false, fmt.Errorf("the catalog half's revision cannot be read: %w", err) - } - heads, err := check.TrunkHeads(raw) - if err != nil { - return false, err - } - return trunks.Set(heads), nil -} - -// followTrunks reads the first view and then follows `catalog-revision`: a trunk revision's event reads the heads again, and a -// change of them is the trunk moving (statuses go pending, a verdict for the old trunk is judged again). A read that fails is -// said, and made again at the next event. -func followTrunks(hub interface { - Handle(string, func(jetstream.Msg)) error -}, ask func(string, any) (json.RawMessage, error), trunks *check.Trunks, moved func(context.Context), logf func(string, ...any)) (first func(context.Context), err error) { - run := func(ctx context.Context) { - changed, err := readTrunks(ask, trunks) - if err != nil { - logf("no trunk is known until the catalog half answers, so nothing is checked: %v", err) - return - } - if changed { - moved(ctx) - } - } - err = hub.Handle(meshcatalog.SubjectCatalogRevisionAll, func(m jetstream.Msg) { - var e meshcatalog.CatalogRevisionEvent - if json.Unmarshal(m.Data(), &e) == nil && e.Kind == "trunk" { - run(context.Background()) - } - _ = m.Ack() - }) - return run, err -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk_test.go deleted file mode 100644 index 611824a6..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/trunk_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - "encoding/json" - "errors" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - - "mesh-delivery-checker/internal/check" -) - -// design 47 G §197: the trunk heads come from the catalog half's trunk revision, by the seat verb revision, and never from the -// gate's source; a candidate's revision and an unanswered verb change nothing. -func TestTrunkHeadsComeFromTheCatalogHalf(t *testing.T) { - answer := func(kind string, heads ...meshcatalog.Head) func(string, any) (json.RawMessage, error) { - return func(key string, _ any) (json.RawMessage, error) { - if key != "seat:mesh-catalog.revision" { - t.Fatalf("asked %s", key) - } - return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Kind: kind, Trunk: heads}}) - } - } - trunks := &check.Trunks{} - h := meshcatalog.Head{Repository: "r", Commit: "c1"} - if changed, err := readTrunks(answer("trunk", h), trunks); err != nil || !changed || trunks.Heads()["r"] != "c1" { - t.Fatalf("first view: %v %v %v", changed, err, trunks.Heads()) - } - if changed, _ := readTrunks(answer("trunk", h), trunks); changed { - t.Fatal("the same heads moved the trunk") - } - if _, err := readTrunks(answer("candidate", meshcatalog.Head{Repository: "r", Commit: "c2"}), trunks); err == nil || trunks.Heads()["r"] != "c1" { - t.Fatalf("a candidate's revision: %v %v", err, trunks.Heads()) - } - if _, err := readTrunks(func(string, any) (json.RawMessage, error) { return nil, errors.New("down") }, trunks); err == nil || trunks.Heads()["r"] != "c1" { - t.Fatalf("an unanswered verb: %v %v", err, trunks.Heads()) - } -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/try_candidates.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/try_candidates.go deleted file mode 100644 index 02120bb6..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/try_candidates.go +++ /dev/null @@ -1,70 +0,0 @@ -package main - -import ( - "context" - "fmt" - "time" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - - "mesh-delivery-checker/internal/check" -) - -// tryCandidates answers the indexer's candidate of a try's group (novox/hq ADR 0593 §7, issue 1921): the candidate the -// engines compose and the manifest validator judges, which the indexer makes of the try's previews. It waits for it on the -// key's own watch, with no timer between reads, and gives up at the bound. -type tryCandidates struct{ kv jetstream.KeyValue } - -func (t tryCandidates) TryCandidate(ctx context.Context, group, heads string, bound time.Duration) (meshcatalog.CandidatesByGroupValue, error) { - key, err := meshcatalogclient.CandidatesKey(group) - if err != nil { - return meshcatalog.CandidatesByGroupValue{}, err - } - if bound <= 0 { - bound = time.Minute - } - waiting, cancel := context.WithTimeout(ctx, bound) - defer cancel() - w, err := t.kv.Watch(waiting, key) // the value now, then each change - if err != nil { - return meshcatalog.CandidatesByGroupValue{}, fmt.Errorf("the indexer's candidate %s cannot be watched: %w", key, err) - } - defer func() { _ = w.Stop() }() - last := "the indexer holds none" - for { - select { - case <-waiting.Done(): - return meshcatalog.CandidatesByGroupValue{}, fmt.Errorf("the indexer wrote no candidate of %s at heads %s within %s (%s)", group, heads, bound, last) - case e := <-w.Updates(): - if e == nil || e.Operation() != jetstream.KeyValuePut { - continue - } - c, err := meshcatalog.DecodeCandidatesByGroupValue(e.Value()) - switch { - case err != nil: - last = "what it holds is not a candidate: " + err.Error() - case c.Heads != heads: - last = "it holds heads " + c.Heads - case waitsOnPreview(c): - last = "it has not yet the merge previews' fingerprints" - default: - return c, nil - } - } - } -} - -// waitsOnPreview says a module of the candidate has no fingerprint yet because its preview was not read. -func waitsOnPreview(c meshcatalog.CandidatesByGroupValue) bool { - for _, p := range c.Pulls { - for _, m := range p.Fps { - if check.WaitsOnPreview(m) { - return true - } - } - } - return false -} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/verdictsay.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/verdictsay.go deleted file mode 100644 index 7a1319bd..00000000 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/verdictsay.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "context" - "crypto/sha256" - "encoding/json" - "fmt" - "strings" - "time" - - "github.com/nats-io/nats.go" - "github.com/nats-io/nats.go/jetstream" - - "mesh-delivery-checker/internal/check" -) - -// verdictSays is check.VerdictSayer on the bus: verdict published on the checker's own stream asks. -type verdictSays struct { - // module is the checker's own, the credential's: the stream of its events and their source. - module string - js jetstream.JetStream - node string - now func() time.Time -} - -// Say publishes one verdict on the checker's own stream asks with the checker's event headers; the message id makes a -// second publish of the same pull request's head, verdict and out-of-step files within the duplicate window one event. -func (t verdictSays) Say(ctx context.Context, v check.VerdictEvent) error { - body, err := json.Marshal(v) - if err != nil { - return err - } - msg := nats.NewMsg(eventSubject(t.module, check.EventVerdict)) - id := fmt.Sprintf("verdict.%s.%d.%s.%s.%x", v.Repository, v.Pull, v.Head, v.Verdict, sha256.Sum256([]byte(strings.Join(v.OutOfStep, "\n")))) - msg.Header.Set("x-event-id", id) - msg.Header.Set("x-source", t.module) - msg.Header.Set("x-node", t.node) - msg.Header.Set("x-time", t.now().UTC().Format(time.RFC3339Nano)) - msg.Header.Set("content-type", "application/json") - msg.Data = body - _, err = t.js.PublishMsg(ctx, msg, jetstream.WithMsgID(id)) - return err -} diff --git a/modules/mesh-delivery-checker/files/settings.json b/modules/mesh-delivery-checker/files/settings.json deleted file mode 100644 index c6d811e8..00000000 --- a/modules/mesh-delivery-checker/files/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compose-answer-bound": 60, - "build-wait-bound": 1800 -} diff --git a/modules/mesh-delivery-checker/go.mod b/modules/mesh-delivery-checker/go.mod deleted file mode 100644 index c86ebab1..00000000 --- a/modules/mesh-delivery-checker/go.mod +++ /dev/null @@ -1,67 +0,0 @@ -module mesh-delivery-checker - -go 1.26.0 - -require ( - git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshwatchdogs v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 - github.com/nats-io/nats-server/v2 v2.11.17 - github.com/nats-io/nats.go v1.54.0 -) - -require ( - git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-contracts/go/seats/meshconfig v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-contracts/go/seats/nodeengine v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun v0.0.0-00010101000000-000000000000 - github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op // indirect - github.com/google/go-tpm v0.9.8 // indirect - github.com/klauspost/compress v1.20.1 // indirect - github.com/minio/highwayhash v1.0.4 // indirect - github.com/nats-io/jwt/v2 v2.8.2 // indirect - github.com/nats-io/nkeys v0.4.16 // indirect - github.com/nats-io/nuid v1.0.1 // indirect - golang.org/x/crypto v0.57.0 // indirect - golang.org/x/sys v0.48.0 // indirect - golang.org/x/time v0.16.0 // indirect -) - -require ( - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/npmpackageregistry v0.0.0-00010101000000-000000000000 // indirect -) - -replace git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun => ../mesh-delivery-builder/buildrun - -require git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk v0.0.0-00010101000000-000000000000 - -require git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg v0.0.0-00010101000000-000000000000 - -replace git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg => ./checkermsg - -replace git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk => ../mesh-delivery-sdk - -require ( - git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/gopackageregistryclient v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/npmpackageregistryclient v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/ociartifactregistryclient v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry v0.0.0-00010101000000-000000000000 // indirect - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/ociartifactregistry v0.0.0-00010101000000-000000000000 // indirect -) diff --git a/modules/mesh-delivery-checker/go.sum b/modules/mesh-delivery-checker/go.sum deleted file mode 100644 index 8ca93dfd..00000000 --- a/modules/mesh-delivery-checker/go.sum +++ /dev/null @@ -1,25 +0,0 @@ -github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op h1:1BOWQJweNyvZMlpAHXGLiZQn9S+QXGcz3xh94lC0w6E= -github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI= -github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo= -github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY= -github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ= -github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= -github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4= -github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= -github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc= -github.com/nats-io/jwt/v2 v2.8.2/go.mod h1:Ag/56sq9OblL4JgdYufDd16Egb17Kr/8WwwuO/forVc= -github.com/nats-io/nats-server/v2 v2.11.17 h1:GKEghcFK6A+aFx11Yf1LjgLC3txAwvyhnYzhBIQZA8I= -github.com/nats-io/nats-server/v2 v2.11.17/go.mod h1:B1sFVz4StNosQ903ak4N1G01Fl/9f8e06mXpFIE2K24= -github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA= -github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k= -github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg= -github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs= -github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M= -golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo= -golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= -golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE= -golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s= diff --git a/modules/mesh-delivery-checker/internal/check/adr548_test.go b/modules/mesh-delivery-checker/internal/check/adr548_test.go deleted file mode 100644 index 10f18b30..00000000 --- a/modules/mesh-delivery-checker/internal/check/adr548_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package check - -import ( - "context" - "strings" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// One check per delivery (novox/hq ADR 0548): the checker's part. A merge turn holds new checks off its repository (§3); -// a trunk or sibling move never ends a running check and carries its verdict once it ended (§1, §5, §6); only a head git -// refused gets a whole check after a move (§7); the line of a carried verdict says so (§8). - -// waitFor polls a condition the checker's goroutines make true, failing after ten seconds: a bound a loaded machine does -// not reach, waited out only by a failing test. -func waitFor(t testing.TB, what string, ok func() bool) { - t.Helper() - for deadline := time.Now().Add(10 * time.Second); !ok(); time.Sleep(time.Millisecond) { - if time.Now().After(deadline) { - t.Fatalf("%s did not happen", what) - } - } -} - -// pullWithFP is a pull request touching the module m at the fingerprint `src2:` and 64 times the hex digit d. -func pullWithFP(repo string, number int, head string, d string) meshcatalog.CandidatesByGroupValuePullsItem { - p := pullOf(repo, number, head) - p.Modules = []string{"m"} - p.Fps = map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"m": {Fp2: "src2:" + strings.Repeat(d, 64)}} - return p -} - -func TestOneCheckPerDelivery(t *testing.T) { - ctx := context.Background() - for name, run := range map[string]func(t *testing.T){ - // Design 47 G §278 (test 52): a new check is claimed at once; the checker reads no state of the gate, so no merge turn holds it. - "a new check is claimed at once": func(t *testing.T) { - j := passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if j.count() != 1 || r.verdict(t, keyOf(t, "feat/x", cand)).State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("judged %d times, want once at once", j.count()) - } - }, - // §1, §5: a trunk move during a running check calls the judge once, writes its verdict, keeps the status pending (a pass - // on an old trunk is never shown), then asks one carry, on the recheck stream, and no check. - "a trunk move during a check ends nothing and asks one carry after it": func(t *testing.T) { - var r *rig - var kinds []string - var from []map[string]string - judged := make(chan struct{}) - j := &judgeFunc{f: func(ctx context.Context, c *Case, call int) (Outcome, error) { - kinds, from = append(kinds, c.Kind), append(from, c.CarriedFrom) - if call == 1 { - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) // the trunk moves while it runs - r.ch.TrunkMoved(ctx) // as the watch of the source says it - close(judged) - } else if s := owedState(t, r, repoA, 7, head1); s != "pending" { - t.Errorf("the status during the carry is %q, want pending: the pass on the old trunk is never shown", s) - } - return Outcome{Verdict: passing()}, nil - }} - r = newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - <-judged - r.ch.Wait() - v := r.verdict(t, keyOf(t, "feat/x", cand)) - if j.count() != 2 || kinds[0] != KindNew || kinds[1] != KindTrunk || from[0] != nil || from[1][repoA] != trunkA { - t.Fatalf("judged %d times as %v carried from %v; want a whole check, then one carry from %s", j.count(), kinds, from, trunkA[:12]) - } - if v.State != meshdeliverycheckerclient.VerdictPass || v.Trunk[repoA] != trunkA2 || v.CarriedFrom[repoA] != trunkA { - t.Errorf("the verdict is %s on %v carried from %v; want a pass on the new trunk carried from the old", v.State, v.Trunk, v.CarriedFrom) - } - if s := owedState(t, r, repoA, 7, head1); s != "success" { - t.Errorf("the status after the carry is %q, want success", s) - } - if r.verdicts.creates[keyOf(t, "feat/x", cand)] != 1 { - t.Error("the verdict key was made again: a carry rewrites it") - } - }, - // §5: the composition is kept when no fingerprint of a module it composed changed, and runs again otherwise. - "a carry keeps a passed composition while the fingerprints stay the same": func(t *testing.T) { - var kept []bool - j := &judgeFunc{f: func(_ context.Context, c *Case, _ int) (Outcome, error) { - kept = append(kept, c.Composition != nil) - v := passing() - v.Composition = &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionPass, Sdk: "v0.1.14-x", Fpset: c.FPSet} - return Outcome{Verdict: v}, nil - }} - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullWithFP(repoA, 7, head1, "a")) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) - r.ch.TrunkMoved(ctx) // the indexer's fingerprints of the candidate stay the same - r.ch.Wait() - r.ch.Candidate(ctx, "feat%2Fx", candidateOf(t, "feat/x", pullWithFP(repoA, 7, head1, "b"))) // a fingerprint changed with the move - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS}) - r.ch.TrunkMoved(ctx) - r.ch.Wait() - if len(kept) != 3 || kept[0] || !kept[1] || kept[2] { - t.Errorf("the composition was kept in the checks %v; want composed, kept on the carry, composed again once a fingerprint changed", kept) - } - }, - // §6: a sibling's move puts the verdict out of date, its status pending saying it is carried, and the carry's verdict - // names the sibling's old commit; the status follows the carry's verdict. Which packages run is the digest's (only - // those that name MESH_CHECK_BESIDE change with a sibling), the build module's part. - "a sibling's move is carried and the status follows the carry": func(t *testing.T) { - var r *rig - var from map[string]string - j := &judgeFunc{f: func(_ context.Context, c *Case, call int) (Outcome, error) { - if call == 2 { - from = c.CarriedFrom - if s := owedState(t, r, repoA, 7, head1); s != "pending" { - t.Errorf("the status during the sibling's carry is %q, want pending", s) - } - } - return Outcome{Verdict: passing(), Beside: map[string]string{catalogueRepository: r.trunks.Heads()[catalogueRepository]}}, nil - }} - r = newRig(t, j) - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS, catalogueRepository: trunkS}) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if b := r.verdict(t, keyOf(t, "feat/x", cand)).Beside; b[catalogueRepository] != trunkS { - t.Fatalf("the verdict names the siblings %v, want the catalogue at %s", b, trunkS[:12]) - } - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS, catalogueRepository: trunkS2}) - r.ch.TrunkMoved(ctx) - r.ch.Wait() - v := r.verdict(t, keyOf(t, "feat/x", cand)) - if j.count() != 2 || from[catalogueRepository] != trunkS || v.CarriedFrom[catalogueRepository] != trunkS || v.Beside[catalogueRepository] != trunkS2 { - t.Errorf("judged %d times, carried from %v, verdict beside %v carried from %v; want one carry over the catalogue's move", j.count(), from, v.Beside, v.CarriedFrom) - } - if s := owedState(t, r, repoA, 7, head1); s != "success" { - t.Errorf("the status after the carry is %q, want success", s) - } - }, - // §7: a carry whose merge conflicts fails naming the files and asks no check; a later move onto which the head merges - // cleanly asks a whole check, not a carry. - "a carry git refuses fails naming the files, and the next move asks a whole check": func(t *testing.T) { - var kinds []string - var from []map[string]string - j := &judgeFunc{f: func(_ context.Context, c *Case, call int) (Outcome, error) { - kinds, from = append(kinds, c.Kind), append(from, c.CarriedFrom) - if call == 2 { - return Outcome{Verdict: meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Machine: "ace", - Words: repoA + "#7 " + ConflictWords + "go.mod"}}}, nil - } - return Outcome{Verdict: passing()}, nil - }} - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) - r.ch.TrunkMoved(ctx) - r.ch.Wait() - r.ch.Reconsider(ctx) // anything else that looks again asks nothing of a conflict - r.ch.Wait() - if v := r.verdict(t, keyOf(t, "feat/x", cand)); j.count() != 2 || !IsConflictFailure(v) || !strings.Contains(v.Failed.Words, "go.mod") { - t.Fatalf("judged %d times, verdict %+v; want the carry failed naming go.mod and nothing asked after it", j.count(), v.Failed) - } - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS}) - r.ch.TrunkMoved(ctx) - r.ch.Wait() - if j.count() != 3 || kinds[1] != KindTrunk || from[1] == nil || kinds[2] != KindNew || from[2] != nil { - t.Errorf("checks %v carried from %v; want a whole check, a carry, then a whole check after the conflict", kinds, from) - } - }, - // §8, §6: the line of a carried verdict names the head on the new trunk commit first, as the gate and the merge tool - // read a line, then where it was carried from and what the carry ran and kept; while it is carried it is pending and says so. - "the line of a carry says where it was carried from": func(t *testing.T) { - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - v := passVerdict() - v.Trunk = map[string]string{repoA: trunkA} - v.Beside = map[string]string{catalogueRepository: trunkS2} - v.CarriedFrom = map[string]string{repoA: trunkA2, catalogueRepository: trunkS} - line := Line(v, cs, p, nil, nil, nil) - if !strings.HasPrefix(line, "pass 111111111111 on aaaaaaaaaaaa | carried from abababababab, mesh-catalog 555555555555 | unit 12 run") { - t.Errorf("the carried line = %q", line) - } - if head, trunk := checkWordsOf(line); head != head1[:12] || trunk != trunkA[:12] { - t.Errorf("the line names %s on %s first, want the head on the new trunk", head, trunk) - } - cs.CarriedFrom = map[string]string{repoA: trunkA2} - pending := Line(meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictRunning}, cs, p, nil, nil, nil) - if !strings.HasPrefix(pending, "being carried to 111111111111 on aaaaaaaaaaaa | from abababababab") { - t.Errorf("the pending line of a carry = %q", pending) - } - }, - // §3 (review round 1): two approved merges in one turn whose trunk moved each get their carry; neither holds the other's. - "two merges waiting in one turn each get their carry": func(t *testing.T) { - var r *rig - j := &judgeFunc{f: func(context.Context, *Case, int) (Outcome, error) { return Outcome{Verdict: passing()}, nil }} - r = newRig(t, j) - candA, candC := candidateOf(t, "feat/a", pullOf(repoA, 7, head1)), candidateOf(t, "feat/c", pullOf(repoA, 8, head2)) - r.ch.Candidate(ctx, "feat%2Fa", candA) - r.ch.Candidate(ctx, "feat%2Fc", candC) - r.ch.Wait() - a, _ := meshcatalog.DecodeCandidatesByGroupValue(candA) - c, _ := meshcatalog.DecodeCandidatesByGroupValue(candC) - _, _ = a, c - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) // a third merge moves the trunk under both - r.ch.TrunkMoved(ctx) - r.ch.Wait() - for _, cand := range [][]byte{candA, candC} { - group := map[bool]string{true: "feat/a", false: "feat/c"}[string(cand) == string(candA)] - if v := r.verdict(t, keyOf(t, group, cand)); v.Trunk[repoA] != trunkA2 || v.CarriedFrom[repoA] != trunkA { - t.Errorf("%s: verdict on %v carried from %v; want its carry claimed and done", group, v.Trunk, v.CarriedFrom) - } - } - }, - // §6 (review round 1): the node-engine read at the commit the mesh runs is named, and a new running commit is carried. - "a new running node-engine is carried": func(t *testing.T) { - runs := runsAt{nodeEngineModule: trunkS} - j := &judgeFunc{f: func(_ context.Context, c *Case, _ int) (Outcome, error) { - return Outcome{Verdict: passing(), Beside: map[string]string{nodeEngineRepo: runs[nodeEngineModule]}}, nil - }} - r := newRig(t, j) - r.ch.Runs = runs - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - r.ch.TrunkMoved(ctx) // nothing moved: nothing is carried - r.ch.Wait() - runs[nodeEngineModule] = trunkS2 - r.ch.TrunkMoved(ctx) // what the indexer's watch does when mesh-host's running commit changes - r.ch.Wait() - v := r.verdict(t, keyOf(t, "feat/x", cand)) - if j.count() != 2 || v.CarriedFrom[nodeEngineRepo] != trunkS || v.Beside[nodeEngineRepo] != trunkS2 { - t.Errorf("judged %d times, verdict beside %v carried from %v; want one carry over the node-engine's new running commit", j.count(), v.Beside, v.CarriedFrom) - } - }, - // §5: a carry that fails names the move it failed on. - "a carry that fails names the move": func(t *testing.T) { - j := &judgeFunc{f: func(_ context.Context, c *Case, call int) (Outcome, error) { - if call == 1 { - return Outcome{Verdict: passing()}, nil - } - return Outcome{Verdict: meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Test: "unit: m/a.TestX", Words: "want 4"}}}, nil - }} - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) - r.ch.TrunkMoved(ctx) - r.ch.Wait() - v := r.verdict(t, keyOf(t, "feat/x", cand)) - if v.State != meshdeliverycheckerclient.VerdictFail || v.CarriedFrom != nil || !strings.HasPrefix(v.Failed.Words, "want 4") || - !strings.Contains(v.Failed.Words, repoA+" "+trunkA[:12]+" to "+trunkA2[:12]) { - t.Errorf("the failed carry is %s carried from %v with words %q; want the test's words, then the move", v.State, v.CarriedFrom, v.Failed.Words) - } - }, - } { - t.Run(name, run) - } -} - -// checkWordsOf is the head and trunk a line names first, as the gate reads it (mesh-delivery-gate onestatus.go checkLine). -func checkWordsOf(line string) (string, string) { - for _, part := range strings.Split(line, " | ") { - f := strings.Fields(part) - for i := 0; i+2 < len(f); i++ { - if f[i+1] == "on" && len(f[i]) == 12 && len(f[i+2]) == 12 { - return f[i], f[i+2] - } - } - } - return "", "" -} diff --git a/modules/mesh-delivery-checker/internal/check/askagain.go b/modules/mesh-delivery-checker/internal/check/askagain.go deleted file mode 100644 index 9be3f0e6..00000000 --- a/modules/mesh-delivery-checker/internal/check/askagain.go +++ /dev/null @@ -1,277 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// **A check is asked again by hand** (the lost check of 2026-10-28; tools-are-how-a-module-is-spoken-to: every recovery -// has a tool). checker_ask_again ends a candidate's running verdict, whose wait judged nothing, with AskedAgainWords and -// the why; the checker hears it on its watch of its verdicts (Checker.VerdictWritten), ends the check of those heads -// running in it, and claims and asks it anew, a whole check (IsEnded). It is refused while a step of the candidate's pull -// requests can still run (checker_status's running_steps): that step's end judges it; and while an ask the check put is -// still in its build seat's stream, taken by no node (it has no step key yet): asking again then would run the check twice -// (issue 1791's kind). The checker keeps the asks each running check put in its state asks (AsksState, by verdict key). -// An ask is not put again under its own id instead: the stream de-duplicates an id within its window, so the copy waiting -// stays and the new one is dropped, and past the window both would run; nothing takes a put ask back (buildrun.Asker). - -// AsksState is the checker's state of the asks each running check put, by verdict key (CheckAsks). -const ( - AsksState = "asks" -) - -// CheckAsks are the asks a check put, in order, as the state asks keeps them while it runs; its end deletes the key. -type CheckAsks struct { - Asks []string `json:"asks"` -} - -// AsksKV is the state asks: a KV whose key a check's end deletes, so the state holds only the checks that run. -type AsksKV interface { - KV - Delete(ctx context.Context, key string) error -} - -// forgetAsks deletes the asks a check put at its end; one that cannot be deleted is said, and the next check of the same -// heads writes the key anew. -func (ch *Checker) forgetAsks(ctx context.Context, key string) { - if err := ch.Asks.Delete(ctx, key); err != nil { - ch.logf("%s: the asks it put could not be forgotten at its end: %v", key, err) - } -} - -// recordAsks keeps the asks a check put under its verdict key; nil Asks keeps nothing. A record that cannot be written -// is said: checker_ask_again then refuses the check, as it cannot tell whether its ask waits in a stream. -func (ch *Checker) recordAsks(ctx context.Context, key string, asks []string) { - if ch.Asks == nil { - return - } - data, err := json.Marshal(CheckAsks{Asks: asks}) - if err == nil { - _, err = putOnce(ctx, ch.Asks, key, data, func(cur []byte) bool { return string(cur) == string(data) }) - } - if err != nil { - ch.logf("%s: the asks it put cannot be kept (%v), so %s refuses it", key, err, AskAgainTool) - } -} - -// AskAgainTool asks a candidate's check again by hand. -const AskAgainTool = "checker_ask_again" - -// AskedAgainWords open the words of a verdict AskAgainTool wrote; the why follows. -const AskedAgainWords = EndedWords + "asked again by hand (" + AskAgainTool + "): " - -// errAskedAgain is the cause a running check is ended with when its verdict was asked again by hand. -var errAskedAgain = buildrun.Withdrawn{Why: "its verdict was asked again by hand (" + AskAgainTool + ")"} - -// IsAskedAgain says whether a verdict was written by AskAgainTool. -func IsAskedAgain(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return IsEnded(v) && strings.HasPrefix(failedOf(v).Words, AskedAgainWords) -} - -// VerdictEntry is the verdicts state as the ask-again tool writes it: a key's value and revision (nil and 0 for none), -// and a compare-and-set. -type VerdictEntry interface { - Entry(key string) (json.RawMessage, uint64, error) - Update(key string, value []byte, revision uint64) error -} - -// AskedAgain is the answer of AskAgainTool. -type AskedAgain struct { - Key string `json:"key"` - Was string `json:"was"` - Said string `json:"said"` - Note string `json:"note"` -} - -// AskAgain ends the running verdict of the group's candidate as asked again by hand, saying why. It refuses a group with -// no candidate, a verdict that is not running (a pass stands, and a failure unless every failing step ended on a transport fault, ADR 0664; both stand until a push or a trunk move), one a step of -// whose pull requests can still run, and one whose asks are not known or one of which no node took yet. -func (r Reader) AskAgain(w VerdictEntry, group, why string) (AskedAgain, error) { - why = strings.TrimSpace(why) - if group == "" || why == "" { - return AskedAgain{}, fmt.Errorf("give the group and why it is asked again") - } - if w == nil { - return AskedAgain{}, fmt.Errorf("the verdicts state cannot be written here") - } - c, ok := r.candidate(group) - if !ok { - return AskedAgain{}, fmt.Errorf("no candidate is held for the group %q", group) - } - key, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads) - if err != nil { - return AskedAgain{}, err - } - raw, rev, err := w.Entry(key) - if err != nil { - return AskedAgain{}, fmt.Errorf("%s cannot be read: %w", key, err) - } - if len(raw) == 0 { - return AskedAgain{}, fmt.Errorf("%s holds no verdict: the checker claims its check when it looks at the candidate (%s)", key, StatusReadTool) - } - v, err := meshdeliverycheckerclient.DecodeVerdict(raw) - if err != nil { - return AskedAgain{}, fmt.Errorf("%s holds what is not a verdict: %w", key, err) - } - failed := v.State == meshdeliverycheckerclient.VerdictFail - if v.State != meshdeliverycheckerclient.VerdictRunning && !failed { - return AskedAgain{}, fmt.Errorf("%s is %s, not running: a verdict stands until a push or a trunk move asks it again", key, v.State) - } - steps := r.readSteps() - if failed { - // ADR 0664 (operator answer 5, issue 1748): a failure stands, except one whose failing steps all ended on a transport - // fault (a step written passing): the network failed, not the change, so it is asked again like a lost check. - if err := steps.onlyTransportFaults(c); err != nil { - return AskedAgain{}, fmt.Errorf("%s is fail, and a failure stands until a push or a trunk move asks it again, unless every failing step of it ended on a transport fault: %w", key, err) - } - } - for _, rs := range steps.running { - if asksOf(c, rs.What) { - return AskedAgain{}, fmt.Errorf("a step of it runs: %s %s on %s since %s (%s); its end judges it", rs.Module, rs.ID, rs.Node, rs.Since, rs.What) - } - } - if failed { - return r.askedAgain(w, key, rev, v, why) - } - if r.AskState.Get == nil { - return AskedAgain{}, fmt.Errorf("the checker's asks are not readable here, so whether its ask waits in a build seat's stream cannot be told") - } - kept, err := r.AskState.Get(key) - var put CheckAsks - if err == nil && len(kept) > 0 { - err = json.Unmarshal(kept, &put) - } - if err == nil && len(put.Asks) == 0 && r.Backlog != nil { - // Issue 1373: the checker names no ask, so the build seats' check streams are read: with no check ask waiting or held - // on any of them (and no step of the candidate running, above) none of it can run, and it is asked anew. - if err := r.noCheckAskWaits(); err != nil { - return AskedAgain{}, err - } - return r.askedAgain(w, key, rev, v, why) - } - if err != nil || len(put.Asks) == 0 { - return AskedAgain{}, fmt.Errorf("the checker names no ask of %s (%v), so whether one waits in a build seat's stream cannot be told; asking again could run it twice", key, err) - } - taken := map[string]bool{} - for _, s := range steps.all { - taken[s.step.ID] = true - } - for _, id := range put.Asks { - if !taken[id] { - return AskedAgain{}, fmt.Errorf("its ask %s waits in its build seat's stream, taken by no node yet: asking again would run it twice; "+ - "the seats' backlog is in mesh-delivery-view.build_usage", id) - } - } - return r.askedAgain(w, key, rev, v, why) -} - -// onlyTransportFaults is nil when the candidate's pull requests have a failed or refused step and every one of them ended -// passing (buildstep.Step.Passing); else why not. -func (s stepsRead) onlyTransportFaults(c meshcatalog.CandidatesByGroupValue) error { - n := 0 - for _, ms := range s.all { - st := ms.step - if !asksOf(c, st.What) || (st.State != buildstep.StepFailed && st.State != buildstep.StepRefused) { - continue - } - if !st.Passing { - return fmt.Errorf("its step %s on %s ended %s and not on a transport fault: %s", st.ID, st.Node, st.State, st.Reason) - } - n++ - } - if n == 0 { - return errors.New("no failed step of it is read (the newest keys of each build module's steps are)") - } - return nil -} - -// askedAgain writes the verdict v ended as asked again by hand, why saying so. -func (r Reader) askedAgain(w VerdictEntry, key string, rev uint64, v meshdeliverychecker.VerdictsByGroupHeadsValue, why string) (AskedAgain, error) { - words := AskedAgainWords + why - ended := meshdeliverychecker.VerdictsByGroupHeadsValue{Group: v.Group, Heads: v.Heads, Trunk: v.Trunk, State: meshdeliverycheckerclient.VerdictFail, - Failed: &FailedFirst{Machine: "checker", Words: words}} - data, err := meshdeliverycheckerclient.EncodeVerdict(ended) - if err != nil { - return AskedAgain{}, err - } - if err := w.Update(key, data, rev); err != nil { - return AskedAgain{}, fmt.Errorf("%s changed while it was asked again, so it was not; read it again: %w", key, err) - } - return AskedAgain{Key: key, Was: v.State, Said: words, - Note: "the checker hears it on its watch of its verdicts, ends the wait that judged nothing and asks the check anew, whole; " + - VerdictsReadTool + " shows it running again"}, nil -} - -// VerdictWritten takes a change of the checker's verdicts in (its watch, updates only): a verdict AskAgainTool wrote ends -// the check of those heads running in this process, which then considers them again; with none running, the candidate -// that holds them is considered at once. Any other verdict is the checker's own, and left. -func (ch *Checker) VerdictWritten(ctx context.Context, key string, value []byte) { - v, err := meshdeliverycheckerclient.DecodeVerdict(value) - if err != nil || !IsAskedAgain(v) { - return - } - ch.init() - ch.mu.Lock() - if l, ok := ch.live[key]; ok { - l.end(errAskedAgain) - ch.mu.Unlock() - ch.logf("%s: %s; the check running for it is ended and asked again", key, failedOf(v).Words) - return - } - var group string - var cand meshcatalog.CandidatesByGroupValue - for k, c := range ch.known { - if vk, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads); err == nil && vk == key { - group, cand = k, c - break - } - } - ch.mu.Unlock() - if group == "" { - ch.logf("%s: %s, but no candidate holds these heads, so nothing is asked", key, failedOf(v).Words) - return - } - ch.logf("%s: %s; asked again", key, failedOf(v).Words) - ch.consider(ctx, group, cand) -} - -// BacklogRow is a row of the build seats' backlog as mesh-delivery-view's build_usage answers it (its backlog): the asks -// waiting and held on one language's stream of one kind of ask, or why it could not be read. -type BacklogRow struct { - Language string `json:"language"` - Kind string `json:"kind"` - Waiting uint64 `json:"waiting"` - Held uint64 `json:"held"` - Error string `json:"error,omitempty"` -} - -// noCheckAskWaits is nil when no check or recheck ask waits or is held on any build seat's stream and every row was read; else it -// names the stream that holds asks. It cannot tell whose ask one is, so any check ask refuses: asking again could run it twice. -func (r Reader) noCheckAskWaits() error { - rows, err := r.Backlog() - if err != nil { - return fmt.Errorf("the build seats' streams cannot be read (%v), so whether an ask of the check waits in one cannot be told; asking again could run it twice", err) - } - for _, row := range rows { - if row.Kind != "check" && row.Kind != "recheck" { // both kinds are the checker's asks (judge.go) - continue - } - if row.Error != "" { - return fmt.Errorf("the %s build seat's check stream cannot be read (%s), so whether an ask of the check waits in it cannot be told", row.Language, row.Error) - } - if row.Waiting > 0 || row.Held > 0 { - return fmt.Errorf("the %s build seat's check stream holds asks (%d waiting, %d held), one of them may be the check's: asking again could run it twice; "+ - "the seats' backlog is in mesh-delivery-view.build_usage", row.Language, row.Waiting, row.Held) - } - } - return nil -} diff --git a/modules/mesh-delivery-checker/internal/check/beside.go b/modules/mesh-delivery-checker/internal/check/beside.go deleted file mode 100644 index 097d588b..00000000 --- a/modules/mesh-delivery-checker/internal/check/beside.go +++ /dev/null @@ -1,218 +0,0 @@ -package check - -import ( - "context" - "errors" - "fmt" - "slices" - "strconv" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" -) - -// BesideRef is a sibling repository a repository's tests read, placed beside the fetched tree as a plain directory (ADR -// 0484 clause 4). Ref names the pull request's head when the commit is only there. -type BesideRef struct { - Repository string `json:"repository"` - Commit string `json:"commit"` - Ref string `json:"ref,omitempty"` - // atTrunk says the sibling was read at its trunk's head, so a move of that trunk puts the verdict out of date and is - // carried (novox/hq ADR 0548 §6). Never sent: the node-engine at the commit the mesh runs, mesh-sdk at a pin and a - // group's member at its head do not move with a trunk. - atTrunk bool - // runs says the sibling was read at the commit the mesh runs (the node-engine, the indexer's record of mesh-host): a new - // running commit puts the verdict out of date and is carried (ADR 0548 §6). Never sent. - runs bool -} - -// NodeEngineModule is the module whose running commit the node-engine sibling is read at. -const NodeEngineModule = nodeEngineModule - -const ( - catalogueRepository = "novox/mesh-catalog" - nodeEngineRepo = NodeEngineRepository - nodeEngineModule = "mesh-host" - // networkingRepository holds route-proxy, whose manifest the node-engine's proofs of a composition read. - networkingRepository = "novox/mesh-networking" - // contractsRepository and deliveryRepository hold the seat definitions mesh-sdk's bootstrapped seats are compared with: its - // tests read both beside it (beside.Dir "mesh-contracts" and "mesh-delivery"), at the group's head for a member, else at the - // trunk (a group try lays them out the same way: besideFor serves the check and the try). - contractsRepository = "novox/mesh-contracts" - deliveryRepository = DeliveryRepository -) - -// besideRules are the repositories each core repository's tests read, as the tests state it (mesh-sdk go/internal/beside -// beside.go): the catalogue, the node-engine, the SDK, and the delivery's pinned forge dependencies (mesh-catalog -// checks/deps). Which commit of each is besideCommit's rule. No repository's tests read the controller, which ended by its -// unassignment (novox/hq ADR 0590, issue 1126), and its repository is emptied and archived (ADR 0593 §11), so it has no -// siblings placed either. mesh-sdk reads mesh-contracts and mesh-delivery (its bootstrapped seats against their contracts files). The catalogue's tests read the node-engine since its composer command moved there (ADR 0593 -// §7): mesh-build-go builds it for a compose ask, and with it every repository its composer requires at the zero version -// (issue 1921: with mesh-sdk alone beside, that build looked them up on the network and failed): those are not named -// here but derived from each sibling's go.mod (zeroVersionSiblings), so no rule can lack one. The node-engine's read -// mesh-networking since route-proxy's proofs of a composition moved into them (ADR 0593). -var besideRules = map[string][]string{ - nodeEngineRepo: {catalogueRepository, SDKRepository, networkingRepository}, - SDKRepository: {catalogueRepository, nodeEngineRepo, contractsRepository, deliveryRepository}, - catalogueRepository: {SDKRepository, nodeEngineRepo}, - "novox/mesh-delivery": {SDKRepository, catalogueRepository}, -} - -// besideFor are the siblings a pull request's tests read (ADR 0484 clause 4): the node-engine at the head of the group's pull -// request for it when the group holds one, else at the commit the mesh runs (the commit of the indexer's module mesh-host, -// its trunk head when none is known); any other sibling, the catalogue -// included, at the head of the group's pull request for it when the group holds one, else at its trunk, since a group's -// check judges each member against the group's heads (ADR 0482 §2, ADR 0573 §4; issue 1126: a judge a group changed was -// judged against the catalogue's trunk). And first, the change's own repository at the trunk it is merged onto, so a test -// comparing a shrink-only list with the trunk's copy reads it at $MESH_CHECK_BESIDE/ (issue 1887 A12, ADR 0529 §2): -// that is where a catalogue change's own trunk copy is placed. -func (j *Examiner) besideFor(ctx context.Context, c *Case, p Pull) ([]BesideRef, error) { - var heads map[string]string - if j.Trunks != nil { - heads = j.Trunks.Heads() - } - var out []BesideRef - if p.Trunk != "" { - out = append(out, BesideRef{Repository: p.Repository, Commit: p.Trunk}) - } - place := func(repo string) { - switch { - case repo == nodeEngineRepo && c.member(repo) != nil: - // A group's check judges each member against the group's heads (ADR 0573 §4, ADR 0482 §2), and the group's - // node-engine is what runs after its merge: it is placed at the member's head, as any member is. Neither atTrunk - // nor runs, so no move of the trunk or of the running commit puts the verdict out of date (besideAtTrunk). - member := c.member(repo) - out = append(out, BesideRef{Repository: repo, Commit: member.Head, Ref: refOf(member.Number)}) - case repo == nodeEngineRepo: - commit := "" - if j.Runs != nil { - commit = j.Runs.CommitOf(nodeEngineModule) - } - atTrunk := false - if commit == "" { - commit, atTrunk = heads[repo], true - } - if commit != "" { - // Named in the verdict either way (ADR 0548 §6, issue 568's own example): at the commit the mesh runs, a new - // running commit puts the verdict out of date; at the trunk, a trunk move does (Checker.besideNow). - out = append(out, BesideRef{Repository: repo, Commit: commit, atTrunk: atTrunk, runs: !atTrunk}) - } - default: - if member := c.member(repo); member != nil { - out = append(out, BesideRef{Repository: repo, Commit: member.Head, Ref: refOf(member.Number)}) - } else if head := heads[repo]; head != "" { - out = append(out, BesideRef{Repository: repo, Commit: head, atTrunk: true}) - } - } - } - for _, repo := range besideRules[p.Repository] { - place(repo) - } - // A sibling a test builds needs every repository its go.mod requires at the zero version beside it too: the build - // resolves them from what lies beside, with nothing fetched (issue 1921). Its go.mod names them all, indirect ones - // included, so one level is enough. - derived, err := j.zeroVersionSiblings(ctx, p.Repository, out) - if err != nil { - return nil, err - } - for _, repo := range derived { - place(repo) - } - return out, nil -} - -// zeroVersionSiblings are the repositories the root go.mod of each sibling in refs requires at the zero version that are -// not beside already, sorted; none where the checker reads no forge. A sibling with no root go.mod requires none; one the -// forge does not answer for is an error, never a sibling left out in silence. -func (j *Examiner) zeroVersionSiblings(ctx context.Context, own string, refs []BesideRef) ([]string, error) { - if j.Forge == nil { - return nil, nil - } - have := map[string]bool{own: true} - for _, r := range refs { - have[r.Repository] = true - } - var out []string - for _, r := range refs { - if r.Repository == own { - continue - } - text, err := j.Forge.File(ctx, r.Repository, "go.mod", r.Commit) - if errors.Is(err, ErrNotFound) { - continue - } - if err != nil { - return nil, fmt.Errorf("the go.mod of %s at %.12s, beside the change, cannot be read%s: %w", r.Repository, r.Commit, unheardWords(err), err) - } - for _, path := range zeroVersionRequires(text) { - repo, _, ok := trunk.PackageRepository(path) - if !ok || have[repo] { - continue - } - have[repo] = true - out = append(out, repo) - } - } - slices.Sort(out) - return out, nil -} - -// zeroVersionRequires are the module paths a go.mod's require lines (a block or single ones) name at the zero version. -func zeroVersionRequires(gomod string) []string { - var out []string - block := false - for _, line := range strings.Split(gomod, "\n") { - line, _, _ = strings.Cut(line, "//") - f := strings.Fields(line) - switch { - case len(f) == 0: - continue - case f[0] == "require" && len(f) > 1 && f[1] == "(": - block = true - continue - case block && f[0] == ")": - block = false - continue - case f[0] == "require": - f = f[1:] - case !block: - continue - } - if len(f) >= 2 && f[1] == zeroVersion { - out = append(out, f[0]) - } - } - return out -} - -// zeroVersion is the version a go.mod requires a mesh package at (ADR 0573 §4): the builder writes the version it builds. -const zeroVersion = "v0.0.0-00010101000000-000000000000" - -func (c *Case) member(repository string) *Pull { - for i := range c.Pulls { - if c.Pulls[i].Repository == repository { - return &c.Pulls[i] - } - } - return nil -} - -func refOf(number int) string { - if number <= 0 { - return "" - } - return "refs/pull/" + strconv.Itoa(number) + "/head" -} - -// besideAtTrunk are the siblings of refs read at their trunk's head that the case does not merge, by repository: what a -// verdict names as Beside (ADR 0548 §6). -func besideAtTrunk(c *Case, refs []BesideRef, into map[string]string) { - for _, r := range refs { - if _, merged := c.Trunk[r.Repository]; (r.atTrunk || r.runs) && !merged { - into[r.Repository] = r.Commit - } - } -} - -// NodeEngineRepository is the node-engine's repository, whose trunk head a check without its member composes at. -const NodeEngineRepository = "novox/mesh-host" diff --git a/modules/mesh-delivery-checker/internal/check/binaries.go b/modules/mesh-delivery-checker/internal/check/binaries.go deleted file mode 100644 index 21abbb51..00000000 --- a/modules/mesh-delivery-checker/internal/check/binaries.go +++ /dev/null @@ -1,27 +0,0 @@ -package check - -import ( - "fmt" - - "mesh-delivery-checker/rules" -) - -// A change that adds or modifies a compiled program fails (issue 1577): it is build output, `go build` in a module's folder -// writes one beside go.mod, and `git add -A` takes it. The build module's fetch step, which holds the merged clone, reads the -// first bytes of each changed file and reports the programs (the build modules' fetch tools); the checker judges the answer. - -// checkBinariesOf records what a pull request's first fetch answer read of compiled programs, whichever build module -// gave it, as a fact the rules judge (rules.JudgePrograms). A fetch that made the merge and names no program has none: the -// answer's `programs` is an omitted empty list (B2g), and `merge` tells a preview was made. -func (st *state) checkBinariesOf(t *target) { - key := fmt.Sprintf("%s#%d", t.pull.Repository, t.pull.Number) - if t.fetched.Merge == "" { - return // no merge was made: nothing was changed to judge - } - files := t.fetched.Programs - if files == nil { - files = []ProgramFile{} // reported, and none: the rules refuse nothing (a nil list is a module that reports none) - } - st.facts = append(st.facts, rules.Step{Repository: t.pull.Repository, Number: t.pull.Number, Module: t.module, Node: t.node, - Programs: &rules.Programs{Key: key, Files: &files}}) -} diff --git a/modules/mesh-delivery-checker/internal/check/binaries_test.go b/modules/mesh-delivery-checker/internal/check/binaries_test.go deleted file mode 100644 index dd5b1675..00000000 --- a/modules/mesh-delivery-checker/internal/check/binaries_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package check - -import ( - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { // 1577 - prog := func(p ...string) []buildstep.Program { - var out []buildstep.Program // no program is the omitted empty list of the typed answer - for _, f := range p { - path, commit, _ := strings.Cut(f, "@") // `path@commit`: added by a commit of the branch and removed later - out = append(out, buildstep.Program{Path: path, Kind: "ELF", Commit: commit}) - } - return out - } - for _, c := range []struct { - name string - programs []buildstep.Program - fail []string // paths named; none passes - }{ - {"none found", prog(), nil}, - {"one program", prog("modules/m/m"), []string{"modules/m/m"}}, - {"two programs", prog("a/x", "b/y"), []string{"a/x", "b/y"}}, - {"added and removed in the branch", prog("gone/prog@0123456789abcdef0123"), []string{"gone/prog: a compiled program added in 0123456789ab and removed later: it stays in history; squash the branch (issue 1577)"}}, - } { - b := newBench(t) - b.fetch.Merge, b.fetch.Programs = "mmmm", c.programs - cs := caseOf(t, pullOf(repoA, 7, head1)) - v := b.judge(t, cs).Verdict - if len(cs.Notes()) > 0 { - t.Errorf("%s: notes = %v: a merge with no program is not a fetch that reported none", c.name, cs.Notes()) - } - if len(c.fail) == 0 { - if v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("%s: verdict = %+v", c.name, v) - } - continue - } - if v.State != meshdeliverycheckerclient.VerdictFail { - t.Errorf("%s: verdict = %+v, want a failure", c.name, v) - continue - } - for _, p := range c.fail { - want := p - if !strings.Contains(p, " added in ") { - want = p + ": a compiled program is build output: remove it and add it to .gitignore (issue 1577)" - } - if !strings.Contains(v.Failed.Words, want) { - t.Errorf("%s: words %q do not name %s", c.name, v.Failed.Words, p) - } - } - } -} diff --git a/modules/mesh-delivery-checker/internal/check/bounded.go b/modules/mesh-delivery-checker/internal/check/bounded.go deleted file mode 100644 index f444671d..00000000 --- a/modules/mesh-delivery-checker/internal/check/bounded.go +++ /dev/null @@ -1,79 +0,0 @@ -package check - -import ( - "fmt" - "sort" - "sync" - "sync/atomic" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// ReadWorkers is how many values a read tool asks the bus for at once. Each value is a round trip from the tool through the -// runtime to the bus, so reading a bucket of thousands of keys one after the other outlasts the 30 s a tool call is given -// (issue 1827, as the delivery view's issue 1945). It is a copy of the view's: a few lines are not worth a group delivery -// through mesh-sdk (rules-are-weighed). -const ReadWorkers = 16 - -// MaxReads bounds the values one call of a read tool reads; past it the answer says it was cut and how to narrow it. -const MaxReads = 1000 - -// parallel runs read(i) for i in [0, n), at most ReadWorkers at a time, and answers the first error; once one failed no -// further read starts. -func parallel(n int, read func(i int) error) error { - var ( - next atomic.Int64 - failed atomic.Bool - once sync.Once - first error - wg sync.WaitGroup - ) - for w := 0; w < min(ReadWorkers, n); w++ { - wg.Add(1) - go func() { - defer wg.Done() - for !failed.Load() { - i := int(next.Add(1) - 1) - if i >= n { - return - } - if err := read(i); err != nil { - once.Do(func() { first = err }) - failed.Store(true) - } - } - }() - } - wg.Wait() - return first -} - -// capKeys keeps the first MaxReads keys and answers a note when it cut the rest, "" otherwise. -func capKeys(keys []string, narrow string) ([]string, string) { - if len(keys) <= MaxReads { - return keys, "" - } - return keys[:MaxReads], fmt.Sprintf("read %d of %d matching keys and stopped; %s", MaxReads, len(keys), narrow) -} - -// newestFirst sorts step keys (.) by id, newest first: an id is the time in base 36, then six hex digits, so the -// longer id is the later and equal lengths compare as text. A key that is no step key goes last. -func newestFirst(keys []string) { - id := func(k string) (string, bool) { - _, _, id, err := buildstep.ParseStepKey(k) - return id, err == nil - } - sort.Slice(keys, func(i, j int) bool { - a, aok := id(keys[i]) - b, bok := id(keys[j]) - switch { - case aok != bok: - return aok - case len(a) != len(b): - return len(a) > len(b) - case a != b: - return a > b - } - return keys[i] > keys[j] - }) -} diff --git a/modules/mesh-delivery-checker/internal/check/build_change.go b/modules/mesh-delivery-checker/internal/check/build_change.go deleted file mode 100644 index 45985c49..00000000 --- a/modules/mesh-delivery-checker/internal/check/build_change.go +++ /dev/null @@ -1,144 +0,0 @@ -package check - -import ( - "context" - "fmt" - "maps" - "slices" - "strings" - - "git.novox.be/novox/mesh-sdk/go/catalogue" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" -) - -// What the check builds of a candidate before it composes (novox/hq ADR 0603 §10). The builder builds every fingerprint the -// indexer's candidate carries, as a key of its own (builds..), with the build modules that run; the -// check adds no build path of its own and waits on those keys (awaitBuilds), so the node-engines compose the candidate's -// modules with their builds. It does not wait on two kinds of changed module, and names them in its composition's warnings: -// -// - one built by a build module the change alters (the recipe of mesh-build-go or mesh-build-node enters the fingerprint -// of every module it builds, ADR 0530 §1): its candidate build is the running build module's, and the check cannot run -// the candidate's build module to build it (it runs it only for its own digest and tests, ADR 0535 §1), so it is not -// composed with a build of the changed build module; it is built again once the agreed toolchain moves (ADR 0603 §3). -// The build module's own build is waited on, as any other: the running build module builds its new source. -// - one that stands on a module the change alters (build.on): its candidate fingerprint names the base's trunk -// fingerprint, and no build module builds on another module's artifact (ADR 0487 §1), so its build stands on the -// trunk's base; the base's own build is waited on. -// -// A module the trunk holds no record of yet is not built by the builder until it is merged, so it is not waited on either. -// -// A changed build module whose manifest invokes a seat verb or module tool no running build serves is one the check cannot -// run (ADR 0614 §7): the modules it builds are composed from their manifests, as above, and the words name the verb. - -// buildsOfTheCheck are the builds the check waits on before it composes (module to fingerprint) and the words for the -// changed modules it composes without waiting on their build, one line each, sorted. A manifest that cannot be read leaves -// every build waited on and nothing said of build modules or bases (nothing is said that was not read). -func (st *state) buildsOfTheCheck(ctx context.Context) (map[string]string, []string) { - wait := map[string]string{} - changed := map[string]catalogue.Manifest{} - readable := true - for _, p := range st.c.Pulls { - for module, cm := range p.Fps { - if cm.Fp2 == "" || cm.Manifest == "" { - continue // the builder builds no fingerprint of it (candidates.go: none of the new form, or no manifest) - } - wait[module] = cm.Fp2 - if !readable || st.j.Read == nil { - readable = false - continue - } - m, err := st.j.Read.Manifest(ctx, cm.Manifest) - if err != nil { - st.j.logf("%s: the manifest of %s cannot be read, so the modules built with a changed build module or base are not named and every build is waited on: %v", st.c.Key, module, err) - readable = false - continue - } - changed[module] = m - } - } - var words []string - if st.j.Runs != nil { - var unheld []string - for _, module := range slices.Sorted(maps.Keys(wait)) { - if st.j.Runs.CommitOf(module) == "" { - unheld = append(unheld, module) - delete(wait, module) - } - } - if len(unheld) > 0 { - words = append(words, fmt.Sprintf("%s: the trunk holds no record of it yet, so the builder builds it once it is merged and the check composes it without a build (ADR 0603 §10)", - strings.Join(unheld, ", "))) - } - } - if !readable { - return wait, words - } - for _, bm := range st.j.Seats.Modules() { - if st.j.languageOf(bm) == "" { - continue - } - if _, alters := changed[bm]; !alters { - continue - } - var built []string - for module, m := range changed { - if isBuildModule := st.j.languageOf(module) != ""; !isBuildModule && buildsWith(m, st.j.languageOf(bm)) { - built = append(built, module) - delete(wait, module) - } - } - slices.Sort(built) - if len(built) > 0 { - words = append(words, fmt.Sprintf("the change alters the build module %s: %s, which it builds, are built by the running %s, not the changed one, which the check cannot run, so the check does not wait on their builds; they are built again once the agreed toolchain moves (ADR 0603 §3, §10)", - bm, strings.Join(built, ", "), bm)) - } - if unserved := st.unservedVerbs(ctx, changed[bm]); len(unserved) > 0 { - what := "nothing it builds is in the change" - if len(built) > 0 { - what = strings.Join(built, ", ") + ", which it builds, are composed from their manifests" - } - words = append(words, fmt.Sprintf("the changed build module %s invokes %s, which no running build serves, so the check cannot run it: %s (ADR 0614 §7)", - bm, strings.Join(unserved, ", "), what)) - } - } - g := graph.OfManifests(changed) - for _, base := range slices.Sorted(maps.Keys(changed)) { - if on := g.Dependents(base); len(on) > 0 { - for _, module := range on { - delete(wait, module) - } - words = append(words, fmt.Sprintf("the change alters %s, a base of %s: their builds stand on the trunk's %s, since no build module builds on a candidate's base, so the check waits on the build of %s alone (ADR 0603 §10)", - base, strings.Join(on, ", "), base, base)) - } - } - return wait, words -} - -// buildsWith says whether a manifest has a bundle in the language: the artifacts whose fingerprint names that language's -// toolchain and its build module's recipe (an archive is packed with no toolchain, ADR 0478 clause 1). -func buildsWith(m catalogue.Manifest, language string) bool { - return m.Build != nil && slices.ContainsFunc(m.Build.Artifacts, func(a catalogue.Artifact) bool { - return a.Kind == catalogue.ArtifactBundle && a.Language == language - }) -} - -// unservedVerbs are the seat verbs and module tools m invokes (graph.InvokesOf) that no running build serves, sorted; none -// when nothing reads what runs, or what runs cannot be read (said in the log: nothing is said that was not read). -func (st *state) unservedVerbs(ctx context.Context, m catalogue.Manifest) []string { - if st.j.Serving == nil { - return nil - } - served, err := st.j.Serving.Served(ctx) - if err != nil { - st.j.logf("%s: what the running builds serve cannot be read, so no build module is named for a verb it invokes: %v", st.c.Key, err) - return nil - } - var out []string - for _, v := range graph.InvokesOf(m) { - if !served(v) { - out = append(out, v) - } - } - return out -} diff --git a/modules/mesh-delivery-checker/internal/check/builds.go b/modules/mesh-delivery-checker/internal/check/builds.go deleted file mode 100644 index 2493c1da..00000000 --- a/modules/mesh-delivery-checker/internal/check/builds.go +++ /dev/null @@ -1,169 +0,0 @@ -package check - -import ( - "context" - "fmt" - "maps" - "slices" - "sort" - "strings" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// The states of a build the status line says (ADR 0484 clause 7). -const ( - BuildBuilt = "built" - BuildFailed = "failed" - BuildWaiting = "waiting" -) - -// BuildStates reads the builder's build of a module at a fingerprint of the new form (builds..): the -// value and whether the key exists. -type BuildStates interface { - Build(ctx context.Context, module, fp2 string) (builds.BuilderBuild, bool, error) -} - -// NoteOf is the state of a build as the line says it: done is built, failed is failed, and one queued, building or not -// begun is waiting. -func NoteOf(b builds.BuilderBuild, found bool) string { - switch { - case !found: - return BuildWaiting - case b.State == builds.BuildDone: - return BuildBuilt - case b.State == builds.BuildFailed: - return BuildFailed - } - return BuildWaiting -} - -// buildNotes are the state of each build the case's modules carry a fingerprint of, by module, sorted. A module two pull -// requests give is said once. -func (j *Examiner) buildNotes(ctx context.Context, c *Case) []BuildNote { - if j.Builds == nil { - return nil - } - fps := map[string]string{} - for _, p := range c.Pulls { - for module, cm := range p.Fps { - if cm.Fp2 != "" { - fps[module] = cm.Fp2 - } - } - } - modules := make([]string, 0, len(fps)) - for m := range fps { - modules = append(modules, m) - } - sort.Strings(modules) - var notes []BuildNote - for _, m := range modules { - b, found, err := j.Builds.Build(ctx, m, fps[m]) - if err != nil { - j.logf("the build of %s at %s cannot be read: %v", m, fps[m], err) - found = false - } - notes = append(notes, BuildNote{Module: m, State: NoteOf(b, found)}) - } - return notes -} - -// DefaultBuildWait is how long a check waits for the candidate's builds to end before it composes (the setting -// build-wait-bound, novox/hq ADR 0603 §10): past it the check composes without the builds not ended and names them. -const DefaultBuildWait = 30 * time.Minute - -// BuildEnds waits on the builder's build keys (builds..), hearing each key's changes on the bus as the -// builder writes them: the builder owns the fact, and nothing is polled. -type BuildEnds interface { - // Ended waits until the build of every module at its fingerprint (module to fingerprint) is done or failed, or ctx ends, - // and answers the builds that ended, by module. An error is only builds that cannot be heard at all. - Ended(ctx context.Context, builds map[string]string) (map[string]builds.BuilderBuild, error) - // Done waits until the build of every module at its fingerprint is done (a failed one built again, builder_build_again), - // and says whether they all are; false when ctx ends first or they cannot be heard. - Done(ctx context.Context, builds map[string]string) bool -} - -// BuildFailedTest is what a failure of the check names a failed build of the candidate by: the test `build: `. -// A verdict failed on builds is asked again by the checker itself once each is built again (Checker.Rebuilt). -const BuildFailedTest = "build: " - -// failedBuilds are the candidate's builds a failed verdict names as failed (BuildFailedTest), by module, at the fingerprint -// the case carries for it; none for a verdict that names no failed build. -func failedBuilds(v meshdeliverychecker.VerdictsByGroupHeadsValue, cs *Case) map[string]string { - if v.State != meshdeliverycheckerclient.VerdictFail { - return nil - } - out := map[string]string{} - for _, f := range append([]FailedFirst{failedOf(v)}, failedList(v.Failures)...) { - module, named := strings.CutPrefix(f.Test, BuildFailedTest) - if !named { - continue - } - for _, p := range cs.Pulls { - if cm, ok := p.Fps[module]; ok && cm.Fp2 != "" { - out[module] = cm.Fp2 - } - } - } - if len(out) == 0 { - return nil - } - return out -} - -func (j *Examiner) buildWait() time.Duration { - if j.BuildWait > 0 { - return j.BuildWait - } - return DefaultBuildWait -} - -// awaitBuilds waits for the candidate's builds before the check composes (ADR 0603 §10): the check builds what the builder -// builds of the candidate and composes with it. A failed build fails the check, naming the module and the builder's words; -// a build not ended within the bound is named in late, and the check does not compose: an engine composes a module only at -// a done build, so its answer would be the builder's lateness read as the change's refusal (issue 1921). It answers the -// words of the composition's warnings (what the check composes without waiting on its build, and why) and the failures of -// the builds that failed, for the rules to take in (rules.JudgeComposition); failed says the check has failed already. -func (st *state) awaitBuilds(ctx context.Context, failed bool) (words []string, failedBuilds []FailedFirst, late string) { - wait, words := st.buildsOfTheCheck(ctx) - if len(wait) == 0 { - return words, nil, "" - } - modules := slices.Sorted(maps.Keys(wait)) - if failed { - // The check has failed already: its red status is never held back by a build (the lead, 2026-11-03). - return append(words, fmt.Sprintf("the check failed before its builds were waited on, so it composes at once, without waiting on the builds of %s (ADR 0603 §10)", strings.Join(modules, ", "))), nil, "" - } - if st.j.BuildEnds == nil { - return append(words, fmt.Sprintf("the builds of %s cannot be heard, so the check composes without waiting on them (ADR 0603 §10)", strings.Join(modules, ", "))), nil, "" - } - bound := st.j.buildWait() - waits := fmt.Sprintf("waits on the builder's builds of %s before it composes, at most %s (ADR 0603 §10)", strings.Join(modules, ", "), bound) - st.c.note(waits) - st.j.logf("%s %s", st.c.Key, waits) - at, cancel := context.WithTimeout(ctx, bound) - ended, err := st.j.BuildEnds.Ended(at, wait) - cancel() - if err != nil { - st.j.logf("%s: the builds of %s cannot be heard: %v", st.c.Key, strings.Join(modules, ", "), err) - return append(words, fmt.Sprintf("the builds of %s cannot be heard (%v), so the check composes without waiting on them (ADR 0603 §10)", strings.Join(modules, ", "), err)), nil, "" - } - var notEnded []string - for _, module := range modules { - b, done := ended[module] - switch { - case !done: - notEnded = append(notEnded, module) - case b.State == builds.BuildFailed: - failedBuilds = append(failedBuilds, FailedFirst{Test: BuildFailedTest + module, Words: fmt.Sprintf("the candidate's build at %s failed (rebuild with builder_build_again; the check asks itself again when the build is done): %s", wait[module], b.Error)}) - } - } - if len(notEnded) > 0 && ctx.Err() == nil { - late = fmt.Sprintf("the builder's builds of %s did not end within the build-wait-bound of %s, so the change is not composed: an engine composes a module only at a done build (ADR 0603 §10)", strings.Join(notEnded, ", "), bound) - } - return words, failedBuilds, late -} diff --git a/modules/mesh-delivery-checker/internal/check/buildseats.go b/modules/mesh-delivery-checker/internal/check/buildseats.go deleted file mode 100644 index 25b6e944..00000000 --- a/modules/mesh-delivery-checker/internal/check/buildseats.go +++ /dev/null @@ -1,56 +0,0 @@ -package check - -import ( - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "mesh-delivery-checker/rules" -) - -// **The checker names no build module** (design 47 G A-82): a build module is the holder of a build seat found on the seat list -// (buildrun.BuildSeats), by the language of the toolchain its seat's acting rule `build` names. The checker's own logic keys on -// that language: the Go repositories and the manifests are judged by the build module of Go, a TypeScript module's by that of -// TypeScript. - -// Languages of the toolchains the checker's logic is keyed on (the `on` of the build seats' acting rules). -const ( - languageGo = rules.LanguageGo - languageTypeScript = rules.LanguageTypeScript -) - -// buildModuleOf is the module that holds the build seat building a language's artifacts; the seat's name while no module is -// known to hold it or the seat list is not read, so a failure always names where it is. -func (j *Examiner) buildModuleOf(language string) string { - if m, err := j.Seats.For(language, ""); err == nil { - return m.Module - } - for _, m := range j.Seats.All() { - if m.Toolchain == language { - return m.Seat - } - } - ask := buildstep.AskGo - if language == languageTypeScript { - ask = buildstep.AskNode - } - seat, _ := buildstep.BuildSeat(ask) - return seat -} - -// goModule is the build module the Go repositories are judged by. -func (j *Examiner) goModule() string { return j.buildModuleOf(languageGo) } - -// goModule is the build module the manifests, the module graph and the checking program are judged by. -func (st *state) goModule() string { return st.j.goModule() } - -// languageOf is the language of the toolchain a build module builds with, empty for a module no build seat names. -func (j *Examiner) languageOf(module string) string { - l, _ := j.Seats.LanguageOf(module) - return l -} - -// askLanguageOf is the language of the asks the module's build seat takes (buildstep.AskGo, buildstep.AskNode, ...). -func (j *Examiner) askLanguageOf(module string) string { - if m, ok := j.Seats.OfModule(module); ok { - return m.AskLanguage() - } - return "" -} diff --git a/modules/mesh-delivery-checker/internal/check/buildseats_test.go b/modules/mesh-delivery-checker/internal/check/buildseats_test.go deleted file mode 100644 index 7dc80331..00000000 --- a/modules/mesh-delivery-checker/internal/check/buildseats_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package check - -import ( - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-sdk/go/seatdef" -) - -// The holders of the build seats in the tests' seat list: names the checker's code does not know, found by the seats' -// acting rules (design 47 G A-82). -const ( - goBuildModule = "mesh-build-go" - nodeBuildModule = "mesh-build-node" -) - -// testSeats is the finder over the build seats of the tests' seat list. -func testSeats() *buildrun.BuildSeats { - rule := func(on string) seatdef.Definition { - return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}} - } - defs := map[string]seatdef.Definition{"node-build-go": rule("go"), "node-build-node": rule("typescript")} - holders := map[string]string{"node-build-go": goBuildModule, "node-build-node": nodeBuildModule} - return buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok }) -} - -// stepStatesOf is a Reader's StepStates over fixed states. -func stepStatesOf(m map[string]StateRead) func() map[string]StateRead { - return func() map[string]StateRead { return m } -} - -// The checker names no build module (design 47 G A-82): it finds each by the language its seat's acting rule builds, whatever the -// holder is called, and says that holder's name in what it judges. -func TestTheBuildModulesAreFoundOnTheSeatListWhateverTheyAreCalled(t *testing.T) { - rule := func(on string) seatdef.Definition { - return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}} - } - defs := map[string]seatdef.Definition{"node-build-go": rule("go"), "node-build-node": rule("typescript"), "node-build-image": rule("kind:image")} - holders := map[string]string{"node-build-go": "compilers", "node-build-node": "bundlers"} - j := &Examiner{Seats: buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok })} - if got := j.goModule(); got != "compilers" { - t.Errorf("the module that judges Go = %q, want its seat's holder", got) - } - if got, lang, ask := j.buildModuleOf(languageTypeScript), j.languageOf("bundlers"), j.askLanguageOf("bundlers"); got != "bundlers" || lang != languageTypeScript || ask != "node" { - t.Errorf("TypeScript: module %q, language %q, ask language %q", got, lang, ask) - } - if got := j.languageOf("mesh-build-go"); got != "" { - t.Errorf("a module that holds no build seat builds with %q", got) - } - if !changesBuildGo(catalogueRepository, "compilers", []string{"modules/compilers/main.go"}) || changesBuildGo(catalogueRepository, "compilers", []string{"modules/mesh-build-go/main.go"}) { - t.Error("a change under the Go build module's own directory is the one that changes it") - } - // With no seat on the list the failure still names where it is: the seat. - none := &Examiner{Seats: buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, nil)} - if got := none.goModule(); got != "node-build-go" { - t.Errorf("a build seat no module holds is named by the seat, got %q", got) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/case.go b/modules/mesh-delivery-checker/internal/check/case.go deleted file mode 100644 index 1be72fdb..00000000 --- a/modules/mesh-delivery-checker/internal/check/case.go +++ /dev/null @@ -1,292 +0,0 @@ -package check - -import ( - "encoding/json" - "fmt" - "maps" - "slices" - "sort" - "strings" - "sync" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// Pull is one pull request the checker judges: its head, the trunk head of its repository it is merged onto and the -// modules the indexer says it touches, with the fingerprints the indexer wrote for them. -type Pull struct { - Repository string - Number int - Head string - Trunk string - Modules []string - Fps map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue -} - -// Case is one check: a candidate's pull requests that are judged (those of a repository whose trunk is not known are left -// out; hq is judged as any repository since R4g, its checks Go tests: ADR 0527), the trunk head of each repository and the key of the verdict. -type Case struct { - // AskedAt is the running that asked again a check of these heads that could not run (PartRunning), "" otherwise. - AskedAt string - // Key is the verdict key, `.`. - Key string - Group string - HeadsHash string - // Heads is the heads hash the gate matches an Approve's members by (GateHeads): a verdict carries it. - Heads string - Pulls []Pull - // Trunk is the trunk head of each repository of Pulls. - Trunk map[string]string - // Left says why pull requests of the candidate are not judged (a repository with no known trunk); empty when all are. - Left []string - // Queued is when the checker took the case up, for the time of its queue. - Queued time.Time - // Seats is the seat list the checking program made, the checker's reader's list with the heads' definitions laid over - // it, which the manifest validator's and the node-engine composer's requests carry (ADR 0636 §1, §4); none until it is - // made. - Seats []json.RawMessage - // Try narrows a try's check (its level, its tests); nil for a pull request's. - Try *TryOptions - // Judged are the check's own judge's verdicts on the manifests the change brings, by module, as the seat mesh-catalog's - // verdict value (judgeManifests): the composer's request carries them in place of the running indexer's (ADR 0578 §2). - Judged map[string]json.RawMessage - - notesMu sync.Mutex - // warnings are, by pull request, what part of its check did not run (Case.warn). - warnings map[string]string - // seriesOf are, by pull request, the changes of a package series it makes (series.go), named in its status line. - seriesOf map[string][]string - // seriesChanges are, by pull request, the same changes as structures (series.go), named in the verdict and its event. - seriesChanges map[string][]meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem - notes []string - // asks are the ids of the asks the check put on the build seats' streams, in order: a try names them (Try.Asks). - asks []string - // Watch, when set, hears each ask the check puts, as it is put (step nil), and each value its step key takes while - // the check waits for it: the node that took it, the phase it says, its end. A try writes them into its record, so a - // running try names its asks and where each stands (issue 1890). Called from the check's goroutines; it must not block - // for long. - Watch func(askID string, step *buildstep.Step) - // Progress says what the check is doing, so a check that ran past its bound names the step it was stuck at. - Progress *Progress - // Wait says what a whole try waits for now ("" when nothing); the try keeps it for try-read. Nil for a pull request's check. - Wait func(why string) - // Kind is what asked the check (KindNew, KindNodes, KindTrunk): a carry after a trunk or sibling move is asked on the - // build seats' recheck stream, every other check on check (ADR 0536 §4, ADR 0548 §5). - Kind string - // CarriedFrom are, for the carry of a verdict that passed, the trunk and sibling commits it was judged on (ADR 0548 §5); - // nil for a whole check. - CarriedFrom map[string]string - // FPSet is the candidate's fingerprint set (Candidate.Fpset): a composition names the set it judged. - FPSet string - // Composition is, for a carry, the composition that passed on the same fingerprint set: it is kept and not asked again, - // since no fingerprint of a module it composed changed (ADR 0548 §5). Nil composes. - Composition *meshdeliverychecker.VerdictsByGroupHeadsValueComposition -} - -// Asked records the id of an ask the check put. -func (c *Case) Asked(id string) { - c.notesMu.Lock() - c.asks = append(c.asks, id) - c.notesMu.Unlock() -} - -// Asks are the ids of the asks the check put, in order. -func (c *Case) Asks() []string { - c.notesMu.Lock() - defer c.notesMu.Unlock() - return append([]string(nil), c.asks...) -} - -// Progress is the step a check is at, written by the check and read when its bound passes. -type Progress struct { - mu sync.Mutex - stage, node string -} - -// Set records the step now running and the node it runs on, empty for none. -func (p *Progress) Set(stage, node string) { - p.mu.Lock() - p.stage, p.node = stage, node - p.mu.Unlock() -} - -// Now is the step recorded last and its node. -func (p *Progress) Now() (stage, node string) { - p.mu.Lock() - defer p.mu.Unlock() - return p.stage, p.node -} - -// CaseOf is the check of a candidate against the trunk heads (the gate's source.main): the pull requests that are judged. -// The checker judges pull requests into main only (ADR 0484 clause 11): the pull message carries no base, a merge into -// another branch is a closed message, so every candidate is into the trunk; a repository whose trunk head is not known has -// none to merge onto. It answers nil when no pull request is left to judge. -func CaseOf(c meshcatalog.CandidatesByGroupValue, trunk map[string]string) *Case { - key, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads) - if err != nil { - return nil - } - cs := &Case{Key: key, Group: c.Group, HeadsHash: c.Heads, Heads: GateHeads(c), Trunk: map[string]string{}, Progress: &Progress{}, FPSet: c.Fpset} - for _, p := range c.Pulls { - switch head, known := trunk[p.Repository]; { - case !known || head == "": - cs.Left = append(cs.Left, fmt.Sprintf("%s#%d: %s", p.Repository, p.Number, UntrunkedWordsOf([]string{p.Repository}))) - default: - cs.Pulls = append(cs.Pulls, Pull{Repository: p.Repository, Number: int(p.Number), Head: p.Head, Trunk: head, Modules: p.Modules, Fps: p.Fps}) - cs.Trunk[p.Repository] = head - } - } - if len(cs.Pulls) == 0 { - return nil - } - sort.SliceStable(cs.Pulls, func(i, j int) bool { - if cs.Pulls[i].Repository != cs.Pulls[j].Repository { - return cs.Pulls[i].Repository < cs.Pulls[j].Repository - } - return cs.Pulls[i].Number < cs.Pulls[j].Number - }) - return cs -} - -// UntrunkedWords open the words of a verdict, and of a status, of a pull request that cannot be judged because the gate's -// source.main names no trunk head of its repository (issue 1422): never a failure of the change, and judged whole once the -// trunk head is known. It is said loudly, never left silently "new". -const UntrunkedWords = "cannot be judged: the trunk head of " - -// UntrunkedWordsOf are those words for the repositories whose trunk head is not known, in order, each named once. -func UntrunkedWordsOf(repos []string) string { - rs := slices.Clone(repos) - slices.Sort(rs) - rs = slices.Compact(rs) - return UntrunkedWords + strings.Join(rs, ", ") + " is not known: the gate's source.main names none, so there is no commit to merge it onto" -} - -// IsUntrunked says whether a verdict says its heads cannot be judged for want of a trunk head (UntrunkedWords). -func IsUntrunked(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictFail && failedOf(v).Machine == "checker" && strings.HasPrefix(failedOf(v).Words, UntrunkedWords) -} - -// **A candidate outside the mesh is not the checker's** (sweep 2026-10-30 item 7): the forge carries repositories the mesh -// does not deliver (an operator's own), whose pull requests the indexer writes as candidates like any. Their trunk the -// gate never names, so each was judged "cannot be judged" and owed the status error on mesh/check, which the forge -// module wrote 119 times per head into a repository the mesh's forge account may not write (403). A candidate every pull -// request of which is of a repository the gate's source.main names no trunk head of, and touches no module, is outside -// the mesh: judged nothing, owed nothing on the forge, said once in the log and in checker_status (outside_the_mesh). A -// new repository of the mesh is not outside: its first pull request adds a module, and is said untrunked (issue 1422). - -// OutsideWords say why a candidate is outside the mesh. -const OutsideWords = "outside the mesh: the gate's source.main names no trunk head of its repositories and it touches no module, so the checker judges nothing and owes no status on the forge" - -// Outside says every pull request of c is of a repository trunk names no head of and touches no module. Never with -// trunk unknown (nil): before the gate's source is read nothing is outside. -func Outside(c meshcatalog.CandidatesByGroupValue, trunk map[string]string) bool { - if trunk == nil || len(c.Pulls) == 0 { - return false - } - for _, p := range c.Pulls { - if trunk[p.Repository] != "" || len(p.Modules) > 0 || len(p.Fps) > 0 { - return false - } - } - return true -} - -// leftOf are the pull requests of a candidate whose repository has no trunk head known, with Trunk empty, in repository and -// number order; nil when every repository's is known. -func leftOf(c meshcatalog.CandidatesByGroupValue, trunk map[string]string) []Pull { - var out []Pull - for _, p := range c.Pulls { - if trunk[p.Repository] == "" { - out = append(out, Pull{Repository: p.Repository, Number: int(p.Number), Head: p.Head, Modules: p.Modules, Fps: p.Fps}) - } - } - sort.SliceStable(out, func(i, j int) bool { - if out[i].Repository != out[j].Repository { - return out[i].Repository < out[j].Repository - } - return out[i].Number < out[j].Number - }) - return out -} - -// GateHeads is the hash the gate matches the members an Approve covers by (mesh-catalog mesh-delivery-gate onestatus.go -// headsOf): meshdeliveryclient.Heads over every pull request of the candidate, hq's included, as -// `#=`. A lone pull request is a group of one. Empty for a candidate -// with no pull request. -func GateHeads(c meshcatalog.CandidatesByGroupValue) string { - heads := make([]meshdeliveryclient.Head, 0, len(c.Pulls)) - for _, p := range c.Pulls { - heads = append(heads, meshdeliveryclient.Head{Repository: strings.ToLower(p.Repository), Number: int(p.Number), Head: strings.ToLower(p.Head)}) - } - hash, err := meshdeliveryclient.HeadsHash(heads) - if err != nil { - return "" - } - return hash -} - -// sameTrunk says whether two verdicts' trunk heads are the same. -func sameTrunk(a, b map[string]string) bool { return maps.Equal(a, b) } - -// Trunks holds the trunk head of each repository, as the catalog half's trunk revision says (a follower of the seat mesh-catalog's -// verb revision and its event catalog-revision sets it; design 47 G §197). -type Trunks struct { - mu sync.Mutex - heads map[string]string -} - -// Set takes the trunk heads in and answers whether they changed. -func (t *Trunks) Set(heads map[string]string) bool { - t.mu.Lock() - defer t.mu.Unlock() - if maps.Equal(t.heads, heads) { - return false - } - t.heads = maps.Clone(heads) - return true -} - -// Heads are the trunk heads now (a copy). -func (t *Trunks) Heads() map[string]string { - t.mu.Lock() - defer t.mu.Unlock() - return maps.Clone(t.heads) -} - -// note puts a word of the check's way on the case, for a try's line (issue 1921). -func (c *Case) note(s string) { - c.notesMu.Lock() - defer c.notesMu.Unlock() - if !slices.Contains(c.notes, s) { - c.notes = append(c.notes, s) - } -} - -// warn says of a pull request (pullKey) that a part of its check did not run, in words for its status line (issue 1577). -func (c *Case) warn(key, words string) { - c.notesMu.Lock() - defer c.notesMu.Unlock() - if c.warnings == nil { - c.warnings = map[string]string{} - } - c.warnings[key] = words -} - -// Warning is what warn said of a pull request, or "". -func (c *Case) Warning(key string) string { - c.notesMu.Lock() - defer c.notesMu.Unlock() - return c.warnings[key] -} - -// Notes are the words noted on the case, in the order they were noted. -func (c *Case) Notes() []string { - c.notesMu.Lock() - defer c.notesMu.Unlock() - return slices.Clone(c.notes) -} diff --git a/modules/mesh-delivery-checker/internal/check/checker.go b/modules/mesh-delivery-checker/internal/check/checker.go deleted file mode 100644 index ee6bbf26..00000000 --- a/modules/mesh-delivery-checker/internal/check/checker.go +++ /dev/null @@ -1,1126 +0,0 @@ -package check - -import ( - "context" - "errors" - "fmt" - "maps" - "mesh-delivery-checker/rules" - "slices" - "sort" - "strings" - "sync" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// DefaultBound is how long a check may run before it is ended failed naming the step it was stuck at (ADR 0484, issue 1678): -// none since R4g. A check's asks wait in the build seats' streams as long as the backlog is (ADR 0525 §9), and each ask's -// step is bounded from its start on the node that took it (buildrun.Asker.Bound, DefaultStepBound); a bound set by -// MESH_CHECKER_BOUND still ends a check that ran past it. -const DefaultBound time.Duration = 0 - -// UnheardWords end the Words of a failure because a part of the mesh the check reads was not heard (the forge, issue 1624): -// like a failure of the nodes, it is not the change's, and is asked again when the part it could not hear runs. -const UnheardWords = "could not run: not heard; asked again when it runs" - -// The events the checker says on its stream checks (module.json): a preview or a status was written, so a part that reads -// the bucket, which is made when the checker is assigned and may not exist when that part starts, finds it (ADR 0437 §8: no -// timer). The body is {"key": ...}. -const ( - EventPreviewWritten = "preview.written" - EventOwedWritten = "owed.written" -) - -// Announcer says an event of the checker's stream, with the key written. -type Announcer func(ctx context.Context, event, key string) - -// Outcome is what judging a case gives: the verdict (state, failure, levels, times, composition; the checker adds the -// group, the heads and the trunk) and, for the line, what the check knows of the builds of the modules it touches. -type Outcome struct { - Verdict meshdeliverychecker.VerdictsByGroupHeadsValue - Builds []BuildNote - // Slowest names the slowest tests of a level that went over its bound ("unit pkg.Test 1.2s"). - Slowest []string - // Judged says, by pull request (pullKey), which program judged a change to a build module (ADR 0535 §5); a pull request - // that changes none is not named. - Judged map[string]string - // Beside are the siblings the check read at their trunk's head, by repository (ADR 0548 §6): the verdict names them, and - // a move of one is carried. - Beside map[string]string - // OutOfStep are, by pull request (pullKey), the generated files out of step with their seat definitions that its steps - // named (design 26): the verdict event carries them. - OutOfStep map[string][]string - // Unheard is the part of the mesh the check could not hear, when its verdict could not run (IsCouldNotRun): its running - // asks the check again (PartRunning). The zero Part is a part the judge could not name. - Unheard Part -} - -// BuildNote is the state of a candidate's module build, by module: built, failed or waiting (ADR 0484 clause 7). -type BuildNote struct { - Module string - State string -} - -// Judge runs the check of a case: the merge, the levels. It writes what it is doing to c.Progress. It answers an error -// only when it could not judge at all; a failure of the change is a Verdict. -type Judge interface { - Judge(ctx context.Context, c *Case) (Outcome, error) -} - -// Checker judges the candidates the indexer writes, dark (ADR 0453 clause 4, ADR 0484): for each candidate it claims a -// verdict key, runs the check through its Judge, writes the verdict and, for each pull request judged, the owed status -// `mesh/check` the forge bridge performs. It holds no timer; a check starts from a candidate or from a change of the -// nodes, the trunk or the controller's plan, and ends when its judge does or its bound passes. -type Checker struct { - Verdicts KV - Owed KV - Judge Judge - Trunks interface{ Heads() map[string]string } - // Runs says which commit the mesh runs of a module (the indexer's modules): the node-engine a verdict read beside at its - // running commit is out of date when that commit moves (ADR 0548 §6); nil reads every sibling at its trunk. - Runs interface{ CommitOf(module string) string } - // CouldNotRun is the checker's own state could-not-run (CouldNotRunState): the checks that could not run, each asked - // again when the part it could not hear runs (PartRunning); nil keeps none, and none is asked again. - CouldNotRun KV - // Findings writes the checker's finding of a check not asked again within CouldNotRunBound (CouldNotRunDue); nil - // writes none. - Findings FindingWriter - // CouldNotRunKept is called each time a check that could not run is kept, so the process waits for its bound anew. - CouldNotRunKept func() - // Bound is how long one check may run; none when 0 (DefaultBound). - Bound time.Duration - // Rebuilds hears the builder's build keys a failed verdict names (failedBuilds): once each is written done, the check of - // those heads is asked again by the checker itself (ADR 0603 §10), as a failure of the nodes is; nil asks none again. - Rebuilds BuildEnds - // Asks keeps the asks each running check put, by verdict key (AsksState), for checker_ask_again; nil keeps none. - Asks AsksKV - // Link is the base of the address a status points at; the verdict key follows. - Link string - // Announce says a status was written (EventOwedWritten); nil says nothing. - Announce Announcer - // Says publishes the verdict event of each pull request whose check ended (EventVerdict); nil says none. - Says VerdictSayer - Now func() time.Time - Logf func(format string, args ...any) - // Settle is how long a group's heads must stay the same after the candidate last changed them before its check starts - // (issue 1890): the members of a group are announced one after another, and a check of each partial set is thrown - // away at the next. None when 0; DefaultSettle in the module. - Settle time.Duration - - once sync.Once - wg sync.WaitGroup - mu sync.Mutex - known map[string]meshcatalog.CandidatesByGroupValue // by candidates key - inflight map[string]bool // by verdict key - again map[string]bool // by verdict key: asked again while it ran - tried map[string]bool // by verdict key: looked at since this process started - release map[string]string // by verdict key: the running that released a check that could not run - live map[string]liveCheck // by verdict key: the check running in this process, ended when its heads go - settling map[string]*window // by candidates key: the window its heads settle in - rebuilt map[string]bool // by verdict key: every failed build its verdict names is done again - awaiting map[string]bool // by verdict key: its failed builds are heard (awaitRebuilt) - // outsideSaid are the candidates outside the mesh said in the log, by group and heads. - outsideSaid map[string]bool -} - -// liveCheck is a check running in this process: the candidates key of its group and the end of its run. -type liveCheck struct { - group string - end context.CancelCauseFunc -} - -// window is a group's settle window: aborted with errUnsettled when its heads change again or the group goes, and with -// errSettled to end it at once. -type window struct{ abort context.CancelCauseFunc } - -var ( - errUnsettled = errors.New("the group's heads changed again") - errSettled = errors.New("the group's heads settled") -) - -// settleNow ends the settle window of every group at once, as if Settle had passed. -func (ch *Checker) settleNow() { - ch.mu.Lock() - defer ch.mu.Unlock() - for _, w := range ch.settling { - w.abort(errSettled) - } -} - -// DefaultSettle is the module's Settle (issue 1890). On 2026-10-26 the three members of a group were announced within 2.8 -// seconds of each other (20:31:52.3, :53.7, :55.1 UTC), a session opening or pushing them one API call after another; -// fifteen seconds holds five times that, and costs a check of 10 to 18 minutes under 2.5 % of its time. A member that comes -// later still is no waste beyond its asks already taken: the check of the heads it replaced is ended at once. -const DefaultSettle = 15 * time.Second - -// EndedWords open the words of a verdict the checker ended without judging it, its heads no candidate's any more (issue -// 1890): never a failure of the change, and judged whole if a candidate holds those heads again. -const EndedWords = "ended: " - -// IsEnded says whether a verdict was ended without being judged (EndedWords). -func IsEnded(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictFail && failedOf(v).Machine == "checker" && strings.HasPrefix(failedOf(v).Words, EndedWords) -} - -// superseded is the cause a running check is ended with: the heads that replaced its own, or none when its group went. -type superseded struct{ by string } - -func (s superseded) Error() string { - if s.by == "" { - return EndedWords + "no candidate holds these heads any more: the group was closed or merged" - } - return EndedWords + "superseded by " + s.by -} - -// Unwrap makes a check ended so a withdrawal of its asks: the asker drops what it put on the build nodes (ADR 0664 §4, §5). -func (s superseded) Unwrap() error { return buildrun.Withdrawn{Why: s.Error()} } - -func (ch *Checker) init() { - ch.once.Do(func() { - ch.known, ch.inflight, ch.again, ch.tried = map[string]meshcatalog.CandidatesByGroupValue{}, map[string]bool{}, map[string]bool{}, map[string]bool{} - ch.release = map[string]string{} - ch.live, ch.settling = map[string]liveCheck{}, map[string]*window{} - ch.rebuilt, ch.awaiting = map[string]bool{}, map[string]bool{} - ch.outsideSaid = map[string]bool{} - }) -} - -// endOthers ends every check of the group running in this process whose verdict key is not keep: no candidate holds its -// heads any more (issue 1890). Called with ch.mu held. -func (ch *Checker) endOthers(group, keep, by string) { - for k, l := range ch.live { - if l.group == group && k != keep { - l.end(superseded{by: by}) - } - } -} - -func (ch *Checker) logf(format string, args ...any) { - if ch.Logf != nil { - ch.Logf(format, args...) - } -} - -func (ch *Checker) now() time.Time { - if ch.Now != nil { - return ch.Now() - } - return time.Now() -} - -func (ch *Checker) bound() time.Duration { - if ch.Bound > 0 { - return ch.Bound - } - return DefaultBound -} - -// Wait returns when every check started so far has ended. -func (ch *Checker) Wait() { ch.wg.Wait() } - -// Candidate takes one value of the indexer's candidates bucket in (the key is the group) and checks it if it is to be -// checked. A value that is not a candidate is said and left. -func (ch *Checker) Candidate(ctx context.Context, key string, value []byte) { - if meshcatalogclient.IsTryGroup(key) { - return // a try's candidate is judged by its try (Tryer), never as a pull request's check: judged twice, the engines were asked twice - } - ch.init() - c, err := meshcatalog.DecodeCandidatesByGroupValue(value) - if err != nil { - ch.logf("candidates.%s holds what is not a candidate, left: %v", key, err) - return - } - vkey, _ := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads) - ch.mu.Lock() - prev, had := ch.known[key] - ch.known[key] = c - // A check of heads this candidate no longer holds is ended at once (issue 1890): a member's new head, a member joining - // or leaving. - ch.endOthers(key, vkey, GateHeads(c)) - moved := !had || prev.Heads != c.Heads - if had && moved { - if old, err := meshdeliverycheckerclient.VerdictKey(prev.Group, prev.Heads); err == nil && old != vkey { - defer ch.clearCouldNotRun(ctx, old) // its heads were replaced, after the lock - } - } - if ch.Settle > 0 && (moved || ch.settling[key] != nil) { - // The group's heads changed: its check waits until they have been the same for Settle, so a group whose members - // are announced one after another is checked once, whole. A later change starts the window again. The wait is a - // context's bound, no timer (ADR 0437 §8). - if w := ch.settling[key]; w != nil { - w.abort(errUnsettled) - } - base, abort := context.WithCancelCause(ctx) - w := &window{abort: abort} - ch.settling[key] = w - ch.wg.Add(1) - go func() { - defer ch.wg.Done() - wait, done := context.WithTimeout(base, ch.Settle) - defer done() - <-wait.Done() - settled := errors.Is(wait.Err(), context.DeadlineExceeded) || errors.Is(context.Cause(wait), errSettled) - ch.mu.Lock() - if !settled || ch.settling[key] != w { - ch.mu.Unlock() - return // changed again, forgotten, or the checker stops - } - delete(ch.settling, key) - now, ok := ch.known[key] - ch.mu.Unlock() - abort(nil) - if ok { - ch.consider(ctx, key, now) - } - }() - ch.mu.Unlock() - return - } - ch.mu.Unlock() - ch.consider(ctx, key, c) -} - -// VerdictDeleted takes the delete of a verdict key in (the checker's watch of its verdicts, issue 1733): the gate asks the -// operator's Approve only on a verdict, so heads a candidate holds are never left without one. A check of them running in -// this process writes its verdict anew at its end; otherwise the candidate is considered at once and judged again (or said -// again to be unjudgeable). A key no candidate holds is said and left. -func (ch *Checker) VerdictDeleted(ctx context.Context, key string) { - ch.init() - ch.mu.Lock() - if ch.inflight[key] { - ch.mu.Unlock() - ch.logf("%s: deleted while its check runs; its end writes it anew", key) - return - } - var group string - var cand meshcatalog.CandidatesByGroupValue - for k, c := range ch.known { - if vk, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads); err == nil && vk == key { - group, cand = k, c - break - } - } - ch.mu.Unlock() - if group == "" { - ch.logf("%s: deleted, and no candidate holds these heads, so nothing is judged", key) - return - } - ch.logf("%s: deleted; its heads are judged again", key) - ch.consider(ctx, group, cand) -} - -// Forget takes a candidate out (its key was deleted): a check of its heads still running is ended, as no candidate holds -// them any more. -func (ch *Checker) Forget(key string) { - ch.init() - ch.mu.Lock() - gone, had := ch.known[key] - delete(ch.known, key) - if had { - if vkey, err := meshdeliverycheckerclient.VerdictKey(gone.Group, gone.Heads); err == nil { - defer ch.clearCouldNotRun(context.Background(), vkey) // its pull request closed, after the lock - } - } - if w := ch.settling[key]; w != nil { - w.abort(errUnsettled) - delete(ch.settling, key) - } - ch.endOthers(key, "", "") - ch.mu.Unlock() -} - -// NodesChanged is Reconsider after a change of the nodes: one came online or went, a build module became healthy or -// stopped being, or a toolchain moved. A check that could not run is not asked again by it, only by the running of the -// part it could not hear (PartRunning). -func (ch *Checker) NodesChanged(ctx context.Context) { - ch.init() - ch.Reconsider(ctx) -} - -// Reconsider looks at every candidate again: the trunk moved, the nodes changed or a delivery ended. A candidate whose -// verdict stands for the trunk it was judged against is left. -func (ch *Checker) Reconsider(ctx context.Context) { - ch.init() - ch.mu.Lock() - known := make(map[string]meshcatalog.CandidatesByGroupValue, len(ch.known)) - for k, c := range ch.known { - known[k] = c - } - ch.mu.Unlock() - for k, c := range known { - ch.consider(ctx, k, c) - } -} - -func (ch *Checker) heads() map[string]string { - if ch.Trunks == nil { - return nil - } - return ch.Trunks.Heads() -} - -func (ch *Checker) consider(ctx context.Context, key string, c meshcatalog.CandidatesByGroupValue) { - heads := ch.heads() - if Outside(c, heads) { - ch.outside(ctx, c) - return - } - if left := leftOf(c, heads); len(left) > 0 { - // A pull request the checker cannot claim (its repository's trunk head is not known) leaves its whole group - // unjudged, said in a failure verdict (issue 1422, issue 1733): the gate asks the Approve only on a verdict, and a - // pass of the other members would let the group merge with that one never checked. - ch.untrunked(ctx, c, left) - return - } - cs := CaseOf(c, heads) - if cs == nil { - return // no pull request at all: nothing to judge - } - cs.Queued = ch.now() - ch.mu.Lock() - if ch.settling[key] != nil { - ch.mu.Unlock() - return // its heads are settling: the window's end considers it (Settle) - } - if ch.inflight[cs.Key] { - ch.again[cs.Key] = true // looked at once more when the check ends, so a change of the trunk is never lost - ch.mu.Unlock() - return - } - ch.inflight[cs.Key] = true - run, end := context.WithCancelCause(ctx) - ch.live[cs.Key] = liveCheck{group: key, end: end} - ch.mu.Unlock() - ch.wg.Add(1) - go func() { - defer ch.wg.Done() - vkey := cs.Key - defer func() { - ch.mu.Lock() - delete(ch.inflight, vkey) - delete(ch.again, vkey) - delete(ch.live, vkey) - ch.mu.Unlock() - again := errors.Is(context.Cause(run), errAskedAgain) - end(nil) - if again && ctx.Err() == nil { - ch.consider(ctx, key, ch.candidate(key, c)) // asked again by hand (AskAgainTool): claimed anew - } - }() - for { - // Every check is asked at once: the build seats' streams hold the backlog, a new head's check and a check after a - // failure of the nodes on check, a re-judge after a trunk move on recheck, pulled after them (ADR 0525 §4, §9; - // ADR 0536 §4). The checker holds no place and no capacity of its own. - ch.prepare(ctx, key, cs) - ch.try(ctx, run, key, cs) - ch.hearFailedBuilds(ctx, key, cs) // a check it failed on a build is asked again once that build is done again - ch.mu.Lock() - more := ch.again[vkey] - delete(ch.again, vkey) - ch.mu.Unlock() - if !more || run.Err() != nil { - return - } - // Looked at again for the same heads only: a candidate that moved to other heads has its own check (issue 1890). - if next := CaseOf(ch.candidate(key, c), ch.heads()); next != nil { - if next.Key != vkey { - return - } - cs = next - } - cs.Queued = ch.now() - } - }() -} - -// untrunked says, loudly, that pull requests of a candidate cannot be judged because the gate's source.main names no trunk -// head of their repository (issue 1422): its verdict key holds a failure that says so, whatever it held before (a running -// verdict left by a check that can no longer run, or a verdict judged on a trunk that is no longer named: issue 1733), which -// checker_verdicts and checker_status show; and every pull request of the candidate gets the status error with -// UntrunkedWords, the members whose trunk is known too, as their group is not judged. It is logged once per head: when a -// status or the verdict is written, never at a look that finds them already said. Once the trunk head is known the verdict -// is stale (it names no trunk) and the heads are judged whole (prepare, claim). -func (ch *Checker) untrunked(ctx context.Context, c meshcatalog.CandidatesByGroupValue, left []Pull) { - key, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads) - if err != nil { - ch.logf("candidates of %s: no verdict key for heads %q, so it cannot be said that they cannot be judged: %v", c.Group, c.Heads, err) - return - } - repos := make([]string, 0, len(left)) - for _, p := range left { - repos = append(repos, p.Repository) - } - words := UntrunkedWordsOf(repos) - v := meshdeliverychecker.VerdictsByGroupHeadsValue{Group: c.Group, Heads: GateHeads(c), Trunk: map[string]string{}, State: meshdeliverycheckerclient.VerdictFail, - Failed: &FailedFirst{Machine: "checker", Words: words}} - data, err := meshdeliverycheckerclient.EncodeVerdict(v) - if err != nil { - ch.logf("%s: %s, and the verdict cannot say so: %v", key, words, err) - return - } - said, err := putOnce(ctx, ch.Verdicts, key, data, func(cur []byte) bool { - held, err := meshdeliverycheckerclient.DecodeVerdict(cur) - return err == nil && IsUntrunked(held) && failedOf(held).Words == words // the same words stand; anything else is replaced - }) - if err != nil { - ch.logf("%s: %s, and the verdict cannot say so: %v", key, words, err) - } - for _, cp := range c.Pulls { - okey, err := CheckerOwedKey(cp.Repository, int(cp.Number), cp.Head) - if err != nil { - ch.logf("%s: %v", key, err) - continue - } - o := meshdeliverychecker.OwedByRepositoryNumberHeadActValue{Act: meshdeliveryclient.OwedStatus, Context: meshdeliveryclient.StatusContextCheck, State: "error", - Target: strings.TrimSuffix(ch.Link, "/") + "/" + key, Text: rules.ClipLine(words, MaxLine)} - data, err := EncodeCheckerOwed(o) - if err != nil { - ch.logf("%s: the status of %s cannot be written: %v", key, okey, err) - continue - } - wrote, err := putOnce(ctx, ch.Owed, okey, data, func(cur []byte) bool { - held, err := DecodeCheckerOwed(cur) - o.V = keys.Version - return err == nil && held == o - }) - if err != nil { - ch.logf("%s: the status of %s cannot be written: %v", key, okey, err) - continue - } - if wrote { - said = true - if ch.Announce != nil { - ch.Announce(ctx, EventOwedWritten, okey) - } - } - } - if said { - names := make([]string, 0, len(left)) - for _, p := range left { - names = append(names, fmt.Sprintf("%s#%d@%s", p.Repository, p.Number, short12(p.Head))) - } - ch.logf("%s: %s %s; the verdict and every status of its group say so (error), and it is judged once the trunk head is known", key, strings.Join(names, ", "), words) - } -} - -// outside takes a candidate outside the mesh (case.go Outside): no verdict, and every status owed for its pull requests -// taken away, so the forge module stops writing one into a repository the mesh's forge account may not write. Said once -// per heads in the log. -func (ch *Checker) outside(ctx context.Context, c meshcatalog.CandidatesByGroupValue) { - var names []string - for _, p := range c.Pulls { - names = append(names, fmt.Sprintf("%s#%d@%s", p.Repository, p.Number, short12(p.Head))) - key, err := CheckerOwedKey(p.Repository, int(p.Number), p.Head) - if err != nil { - continue - } - _, _, found, err := ch.Owed.Get(ctx, key) - if err != nil || !found { - continue - } - d, ok := ch.Owed.(Deleter) - if !ok { - continue - } - if err := d.Delete(ctx, key); err != nil { - ch.logf("%s: the status owed of a pull request outside the mesh could not be taken away: %v", key, err) - } - } - said := c.Group + "@" + c.Heads - ch.mu.Lock() - first := !ch.outsideSaid[said] - ch.outsideSaid[said] = true - ch.mu.Unlock() - if first { - ch.logf("candidates of %s: %s %s", c.Group, strings.Join(names, ", "), OutsideWords) - } -} - -// The kinds of a check (ADR 0536 §4): a head never judged and a head asked again after a failure of the nodes are asked on -// the build seats' check stream; a carry, a verdict moved to a newer trunk or sibling commit by its package digests (ADR 0548 -// §5), on the recheck stream, pulled after. -const ( - KindNew = "new" - KindNodes = "nodes" - KindTrunk = "trunk" -) - -// prepare reads the case's verdict key and says what its check is (ADR 0548 §1, §5, §7): none (or one left running) is a -// head never judged, a whole check; a failure of the nodes is asked again after the nodes changed; a verdict judged on trunk -// or sibling commits that moved since is carried, its packages run only where the move changed their digest, and a pass's -// commits are named as the carry's CarriedFrom. A verdict that stands is ranked with the carries: its claim finds nothing -// to do. -func (ch *Checker) prepare(ctx context.Context, group string, cs *Case) { - cs.Kind, cs.CarriedFrom, cs.Composition = KindNew, nil, nil - value, _, found, err := ch.Verdicts.Get(ctx, cs.Key) - if err != nil || !found { - return - } - v, err := meshdeliverycheckerclient.DecodeVerdict(value) - switch { - case err != nil || v.State == meshdeliverycheckerclient.VerdictRunning: - return - case IsCouldNotRun(v): - cs.Kind = KindNodes - return - case failedBuilds(v, cs) != nil: - cs.Kind = KindNodes // asked again on check once its builds are done again (awaitRebuilt), never by a recheck - ch.awaitRebuilt(ctx, group, cs.Key, failedBuilds(v, cs)) - return - case IsConflictFailure(v): - return // a head git refused: its next check is whole (ADR 0548 §7) - case IsEnded(v), IsUntrunked(v): - return // ended unjudged when its heads went (issue 1890), or never judged for want of a trunk head (issue 1422): checked whole - } - cs.Kind = KindTrunk - if v.State == meshdeliverycheckerclient.VerdictPass && ch.stale(v, cs) { - cs.CarriedFrom = judgedOn(v) - if c := v.Composition; c != nil && c.State == meshdeliverycheckerclient.CompositionPass && c.Fpset != "" && c.Fpset == cs.FPSet { - kept := *c - cs.Composition = &kept - } - } -} - -// stale says whether a verdict was judged on commits that are no longer the case's: a trunk it merged moved, or a sibling it -// read at its trunk's head (ADR 0548 §6). -func (ch *Checker) stale(v meshdeliverychecker.VerdictsByGroupHeadsValue, cs *Case) bool { - return !sameTrunk(v.Trunk, cs.Trunk) || besideMoved(v.Beside, ch.besideNow()) -} - -// besideNow are the commits a sibling is read at now, by repository: its trunk head, and for the node-engine the commit the -// mesh runs when the indexer names one, as besideFor places them. -func (ch *Checker) besideNow() map[string]string { - return besideAt(ch.heads(), ch.Runs) -} - -// besideAt places the commits a sibling is read at: the trunk heads, with the node-engine at the commit the mesh runs when -// runs names one (ADR 0548 §6). The checker's decision and the status read the same commits through it. -func besideAt(now map[string]string, runs interface{ CommitOf(module string) string }) map[string]string { - if runs != nil { - if c := runs.CommitOf(nodeEngineModule); c != "" { - out := make(map[string]string, len(now)+1) - for r, h := range now { - out[r] = h - } - out[nodeEngineRepo] = c - return out - } - } - return now -} - -// besideMoved says whether a sibling read at these commits moved: the commit it is read at now is known and another. -func besideMoved(beside, now map[string]string) bool { - for r, c := range beside { - if h := now[r]; h != "" && h != c { - return true - } - } - return false -} - -// judgedOn are the trunk and sibling commits a verdict was judged on, by repository. -func judgedOn(v meshdeliverychecker.VerdictsByGroupHeadsValue) map[string]string { - out := make(map[string]string, len(v.Trunk)+len(v.Beside)) - for r, c := range v.Beside { - out[r] = c - } - for r, c := range v.Trunk { - out[r] = c - } - return out -} - -// carried is what a carry's verdict names as carried from (ADR 0548 §5): the commits it was judged on before, of the -// repositories the new verdict still judges or reads; nil when none of them moved. -func carried(from map[string]string, v meshdeliverychecker.VerdictsByGroupHeadsValue) map[string]string { - out, moved := map[string]string{}, false - for r, c := range from { - now, ok := v.Trunk[r] - if !ok { - now, ok = v.Beside[r] - } - if ok && now != "" && c != "" { - out[r] = c - moved = moved || now != c - } - } - if !moved { - return nil - } - return out -} - -// moveWords say a carry's moves, for the words of a failure: "carried from to of ", each moved -// repository, sorted. -func moveWords(from map[string]string, v meshdeliverychecker.VerdictsByGroupHeadsValue) string { - var moves []string - for r, c := range from { - now, ok := v.Trunk[r] - if !ok { - now = v.Beside[r] - } - if now != "" && now != c { - moves = append(moves, fmt.Sprintf("%s %s to %s", r, short12(c), short12(now))) - } - } - sort.Strings(moves) - return strings.Join(moves, ", ") -} - -func (ch *Checker) candidate(key string, fallback meshcatalog.CandidatesByGroupValue) meshcatalog.CandidatesByGroupValue { - ch.mu.Lock() - defer ch.mu.Unlock() - if c, ok := ch.known[key]; ok { - return c - } - return fallback -} - -// claimed is a verdict key the checker holds: the revision the next write is made at. -type claimed struct{ rev uint64 } - -// claim takes the check of the case, or answers nil when it is not this checker's to run now: -// - no key: it is created running; a create that finds the key made meanwhile gets nothing; -// - a key left running is taken over as it stands when this process looks at it for the first time (it was left by the -// checker that stopped; there is one instance, as there is one builder per node, ADR 0478 clause 6), and left otherwise; -// - a pass or a failure for the trunk heads the case has stands; one for other trunk heads (the trunk moved) is taken -// again by compare-and-set on the same key, and so is a failure of the nodes after the nodes changed. -func (ch *Checker) claim(ctx context.Context, cs *Case, first bool) (*claimed, error) { - running := meshdeliverychecker.VerdictsByGroupHeadsValue{Group: cs.Group, Heads: cs.Heads, Trunk: cs.Trunk, State: meshdeliverycheckerclient.VerdictRunning} - data, err := meshdeliverycheckerclient.EncodeVerdict(running) - if err != nil { - return nil, err - } - value, rev, found, err := ch.Verdicts.Get(ctx, cs.Key) - if err != nil { - return nil, fmt.Errorf("%s: %w", cs.Key, err) - } - if !found { - rev, err := ch.Verdicts.Create(ctx, cs.Key, data) - if errors.Is(err, ErrConflict) { - return nil, nil // another checker made it first - } - if err != nil { - return nil, fmt.Errorf("%s: %w", cs.Key, err) - } - return &claimed{rev}, nil - } - cur, err := meshdeliverycheckerclient.DecodeVerdict(value) - if err != nil { - return nil, fmt.Errorf("%s holds what is not a verdict: %w", cs.Key, err) - } - retake := false - switch { - case cur.State == meshdeliverycheckerclient.VerdictRunning: - if first { - return &claimed{rev}, nil - } - return nil, nil - case IsEnded(cur), ch.stale(cur, cs): - retake = true // heads held again after their check was ended unjudged (issue 1890), or a trunk that moved - case cur.State == meshdeliverycheckerclient.VerdictFail && ch.takeRebuilt(cs.Key): - retake = true // every failed build it names is done again (ADR 0603 §10) - case IsCouldNotRun(cur): - // Its claim was released when it could not run: only the running of the part it could not hear asks it again. - cs.AskedAt, retake = ch.takeRelease(cs.Key) - } - if !retake { - return nil, nil - } - rev, err = ch.Verdicts.Update(ctx, cs.Key, data, rev) - if errors.Is(err, ErrConflict) { - return nil, nil - } - if err != nil { - return nil, fmt.Errorf("%s: %w", cs.Key, err) - } - return &claimed{rev}, nil -} - -// ConflictWords are what the words of a head that git would not merge onto its trunk say before the files in conflict. -const ConflictWords = "does not merge into the trunk: files in conflict: " - -// IsConflictFailure says whether a verdict failed because its head did not merge onto its trunk (ADR 0548 §7): it has no -// pass to carry, so its next check, at a push or at a later trunk move, is a whole check of its head. -func IsConflictFailure(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictFail && strings.Contains(failedOf(v).Words, ConflictWords) -} - -// try claims the check, judges it within its bound under run and writes the verdict and the owed statuses. A check that ends -// because ctx did is left running: the checker takes it again when it starts. A check whose run was ended because no -// candidate holds its heads any more (issue 1890) is ended: its verdict says so, and no status is written. -func (ch *Checker) try(ctx, run context.Context, key string, cs *Case) { - if run.Err() != nil { - return // ended before it was claimed: nothing to write - } - ch.mu.Lock() - first := !ch.tried[cs.Key] - ch.tried[cs.Key] = true - ch.mu.Unlock() - cl, err := ch.claim(ctx, cs, first) - if err != nil { - ch.logf("%s: %v", cs.Key, err) - return - } - if cl == nil { - return - } - ch.clearCouldNotRun(ctx, cs.Key) // checked again: a record that it could not run, and its finding, go - began := ch.now() - if cs.Watch == nil && ch.Asks != nil { - cs.Watch = func(_ string, step *buildstep.Step) { - if step == nil { // put: kept before its wait starts - ch.recordAsks(ctx, cs.Key, cs.Asks()) - } - } - defer ch.forgetAsks(ctx, cs.Key) - } - ch.writeOwed(ctx, cs, meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictRunning}, Outcome{}) - out := ch.judge(run, cs) - // An ask the build seat gave up on, or whose step the build module's next process ended because it was replaced under - // it, judged nothing (issue 734, IsLostAsk): the check is asked again under the same claim, its status pending, and after - // LostAskTries it fails as not heard, asked again when the part it could not hear runs. A step that ended while its watch was deaf is - // read at the next nudge (HeardEnds) and judged. - for try := 1; IsLostAsk(out.Verdict) && run.Err() == nil; try++ { - if try >= LostAskTries { - out.Verdict.Failed.Words = strings.TrimSpace(failedOf(out.Verdict).Words + "\nasked " + fmt.Sprint(LostAskTries) + - " times and given up each time: " + UnheardWords) - break - } - ch.logf("%s: %s; asked again (%d of %d)", cs.Key, failedOf(out.Verdict).Words, try+1, LostAskTries) - out = ch.judge(run, cs) - } - if ctx.Err() != nil || errors.Is(context.Cause(run), errAskedAgain) { - return // the checker stops, or the verdict was asked again by hand, which wrote it: its next check claims it anew - } - var why superseded - if errors.As(context.Cause(run), &why) { - ch.end(ctx, cs, cl, why) - return - } - v := out.Verdict - v.Group, v.Heads, v.Trunk, v.Beside = cs.Group, cs.Heads, cs.Trunk, nil - for r, c := range out.Beside { - if _, merged := cs.Trunk[r]; !merged && c != "" { - if v.Beside == nil { - v.Beside = map[string]string{} - } - v.Beside[r] = c - } - } - if cs.CarriedFrom != nil { - // A carry (ADR 0548 §5): a pass names the commits it was carried from; a failure names the move it failed on. - switch v.State { - case meshdeliverycheckerclient.VerdictPass: - v.CarriedFrom = carried(cs.CarriedFrom, v) - case meshdeliverycheckerclient.VerdictFail: - if moves := moveWords(cs.CarriedFrom, v); moves != "" { - v.Failed.Words = strings.TrimSpace(failedOf(v).Words + "\nfailed on the carry over the move of " + moves + ": the move changed what these tests read") - } - } - } - if tookOf(v).Queue == 0 && !cs.Queued.IsZero() && began.After(cs.Queued) { - if v.Took == nil { - v.Took = &meshdeliverychecker.VerdictsByGroupHeadsValueTook{} - } - v.Took.Queue = began.Sub(cs.Queued).Milliseconds() - } - data, err := meshdeliverycheckerclient.EncodeVerdict(v) - if err != nil { - ch.logf("%s: the verdict cannot be written: %v", cs.Key, err) - v = meshdeliverychecker.VerdictsByGroupHeadsValue{Group: cs.Group, Heads: cs.Heads, Trunk: cs.Trunk, State: meshdeliverycheckerclient.VerdictFail, - Failed: &FailedFirst{Machine: "checker", Words: "the verdict could not be written: " + err.Error()}} - if data, err = meshdeliverycheckerclient.EncodeVerdict(v); err != nil { - return - } - } - if _, err := ch.Verdicts.Update(ctx, cs.Key, data, cl.rev); err != nil { - if _, _, found, gerr := ch.Verdicts.Get(ctx, cs.Key); gerr == nil && !found { - _, err = ch.Verdicts.Create(ctx, cs.Key, data) // its key was deleted while it ran (issue 1733): written anew - } - if err != nil { - ch.logf("%s: the verdict could not be written: %v", cs.Key, err) - return - } - } - if IsCouldNotRun(v) { - ch.keepCouldNotRun(ctx, cs, v, out.Unheard, cs.AskedAt) - } - if ch.movedSince(cs) || besideMoved(v.Beside, ch.besideNow()) { - // Judged on a trunk that moved while it ran: the verdict is kept as judged, and the status stays pending until the - // check of the new trunk, which Reconsider starts, ends. - ch.owePending(ctx, cs, v) - ch.logf("%s: %s on a trunk that moved while it ran; the status stays pending until it is carried", cs.Key, v.State) - return - } - ch.writeOwed(ctx, cs, v, out) - ch.sayVerdict(ctx, cs, v, out) - ch.logf("%s: %s", cs.Key, v.State) -} - -// end writes the verdict of a check whose heads no candidate holds any more (issue 1890), by compare-and-set on its claim, -// and says it once in the log with the asks it had put: they stay in the build seats' streams, since an ask once put cannot -// be taken back (buildrun.Asker has no withdraw), and are no longer waited for. No status is written: the heads that -// replaced these have their own check, whose pending status stands. -func (ch *Checker) end(ctx context.Context, cs *Case, cl *claimed, why superseded) { - v := meshdeliverychecker.VerdictsByGroupHeadsValue{Group: cs.Group, Heads: cs.Heads, Trunk: cs.Trunk, State: meshdeliverycheckerclient.VerdictFail, - Failed: &FailedFirst{Machine: "checker", Words: why.Error()}} - data, err := meshdeliverycheckerclient.EncodeVerdict(v) - if err == nil { - _, err = ch.Verdicts.Update(ctx, cs.Key, data, cl.rev) - } - if err != nil { - ch.logf("%s: %s, but the verdict could not say so: %v", cs.Key, why.Error(), err) - return - } - stage, _ := cs.Progress.Now() - asks := cs.Asks() - ch.logf("%s: %s; it was at %q with %d asks put %v, which are no longer waited for", cs.Key, why.Error(), stage, len(asks), asks) -} - -// judge runs the case within the bound. A judge that fails to judge, and a check that ran past its bound, are verdicts of -// failure naming the machine and the step. -func (ch *Checker) judge(ctx context.Context, cs *Case) Outcome { - out, _ := judgeWithin(ctx, ch.Judge, cs, ch.bound()) - return out -} - -var errBound = errors.New("the check ran past its bound") - -func failure(machine, words string) meshdeliverychecker.VerdictsByGroupHeadsValue { - return meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Machine: machine, Words: words}} -} - -// writeOwed writes, for each pull request judged, the status the forge bridge performs: pending while the check runs, success -// or failure at its end (ADR 0484 clause 2). A key already holding the same value is not written again, so the bridge -// performs one act for each change; an older head's key is never touched. -func (ch *Checker) writeOwed(ctx context.Context, cs *Case, v meshdeliverychecker.VerdictsByGroupHeadsValue, out Outcome) { - for _, p := range cs.Pulls { - key, err := CheckerOwedKey(p.Repository, int(p.Number), p.Head) - if err != nil { - ch.logf("%s: %v", cs.Key, err) - continue - } - state := map[string]string{meshdeliverycheckerclient.VerdictRunning: "pending", meshdeliverycheckerclient.VerdictPass: "success", meshdeliverycheckerclient.VerdictFail: "failure"}[v.State] - o := meshdeliverychecker.OwedByRepositoryNumberHeadActValue{Act: meshdeliveryclient.OwedStatus, Context: meshdeliveryclient.StatusContextCheck, State: state, - Target: strings.TrimSuffix(ch.Link, "/") + "/" + cs.Key, Text: Line(v, cs, p, out.Builds, out.Slowest, out.Judged)} - data, err := EncodeCheckerOwed(o) - if err != nil { - ch.logf("%s: the status of %s cannot be written: %v", cs.Key, key, err) - continue - } - wrote, err := putOnce(ctx, ch.Owed, key, data, func(cur []byte) bool { - held, err := DecodeCheckerOwed(cur) - o.V = keys.Version - return err == nil && held == o - }) - if err != nil { - ch.logf("%s: the status of %s cannot be written: %v", cs.Key, key, err) - } else if wrote && ch.Announce != nil { - ch.Announce(ctx, EventOwedWritten, key) - } - } -} - -// putOnce writes data under key by create, or by compare-and-set when the key exists, and writes nothing when same says the -// key holds the value already. -func putOnce(ctx context.Context, kv KV, key string, data []byte, same func(cur []byte) bool) (bool, error) { - for try := 0; try < 4; try++ { - cur, rev, found, err := kv.Get(ctx, key) - if err != nil { - return false, err - } - if found && same(cur) { - return false, nil - } - if !found { - _, err = kv.Create(ctx, key, data) - } else { - _, err = kv.Update(ctx, key, data, rev) - } - if errors.Is(err, ErrConflict) { - continue - } - return err == nil, err - } - return false, fmt.Errorf("%s changed under every one of 4 tries", key) -} - -// Sweep closes, at start, every verdict left running for a candidate that no longer holds those heads: nothing will check -// them again, and the key would stay running for ever (the builder's Sweep, issue 1660). Call it once the candidates have been -// read. A key of heads a candidate holds now is not touched: the check takes it over. -func (ch *Checker) Sweep(ctx context.Context) error { - ch.init() - keys, err := ch.Verdicts.Keys(ctx) - if err != nil { - return err - } - ch.mu.Lock() - current := map[string]bool{} - for _, c := range ch.known { - if k, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads); err == nil { - current[k] = true - } - } - ch.mu.Unlock() - for _, key := range keys { - if current[key] { - continue - } - value, rev, found, err := ch.Verdicts.Get(ctx, key) - if err != nil || !found { - continue - } - cur, err := meshdeliverycheckerclient.DecodeVerdict(value) - if err != nil || cur.State != meshdeliverycheckerclient.VerdictRunning { - continue - } - cur.State = meshdeliverycheckerclient.VerdictFail - cur.Failed = &FailedFirst{Machine: "checker", Words: EndedWords + "closed at start: left running, and no candidate holds these heads any more, so nothing will check them"} - data, err := meshdeliverycheckerclient.EncodeVerdict(cur) - if err != nil { - return err - } - if _, err := ch.Verdicts.Update(ctx, key, data, rev); err != nil && !errors.Is(err, ErrConflict) { - return fmt.Errorf("%s: %w", key, err) - } - ch.logf("%s: closed, left running for heads no candidate holds", key) - } - return nil -} - -// TrunkMoved is Reconsider after a move of a trunk, which first owes mesh/check pending on every open pull request of a -// candidate whose verdict was judged on other trunk heads, every member's for a group (the lead's decision L4, the checker's -// part of issue 1302): the forge's success of the old trunk never stands while the check waits for a place or for a delivery -// that holds it, so the gate never reads it as the head's. -func (ch *Checker) TrunkMoved(ctx context.Context) { - ch.init() - ch.mu.Lock() - known := make(map[string]meshcatalog.CandidatesByGroupValue, len(ch.known)) - for k, c := range ch.known { - known[k] = c - } - ch.mu.Unlock() - heads := ch.heads() - for _, c := range known { - cs := CaseOf(c, heads) - if cs == nil { - continue - } - value, _, found, err := ch.Verdicts.Get(ctx, cs.Key) - if err != nil || !found { - continue // never judged: no status to put out of date - } - v, err := meshdeliverycheckerclient.DecodeVerdict(value) - if err == nil && !ch.stale(v, cs) { - continue - } - if err == nil && v.State == meshdeliverycheckerclient.VerdictPass { - cs.CarriedFrom = judgedOn(v) // the status says it is being carried to the new commit (ADR 0548 §6) - } - ch.writeOwed(ctx, cs, meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictRunning}, Outcome{}) - } - ch.Reconsider(ctx) -} - -// owePending owes mesh/check pending on the heads of a verdict judged on commits that moved while it ran: a pass says it is -// being carried to the trunk's head now (ADR 0548 §6), anything else that it is checked again. -func (ch *Checker) owePending(ctx context.Context, judged *Case, v meshdeliverychecker.VerdictsByGroupHeadsValue) { - next := judged - ckey, err := meshcatalogclient.CandidatesKey(v.Group) - ch.mu.Lock() - c, ok := ch.known[ckey] - ch.mu.Unlock() - if err == nil && ok { - if now := CaseOf(c, ch.heads()); now != nil && now.Key == judged.Key { - next = now - } - } - if v.State == meshdeliverycheckerclient.VerdictPass { - next.CarriedFrom = judgedOn(v) - } - ch.writeOwed(ctx, next, meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictRunning}, Outcome{}) -} - -// movedSince says whether a trunk the case was judged on is no longer the trunk's head. -func (ch *Checker) movedSince(cs *Case) bool { - now := ch.heads() - for repo, head := range cs.Trunk { - if now[repo] != head { - return true - } - } - return false -} - -// awaitRebuilt hears, once per verdict key, the builder's keys of the builds a failed verdict names: when each is written -// done again (builder_build_again), the check of those heads is asked again (claim retakes it), as a failure of the nodes -// is after the nodes changed, so no recheck by hand is needed (ADR 0603 §10). Heard on the builder's own writes, never -// polled; it ends with the checker. -func (ch *Checker) awaitRebuilt(ctx context.Context, group, vkey string, builds map[string]string) { - if ch.Rebuilds == nil { - return - } - ch.mu.Lock() - if ch.awaiting[vkey] { - ch.mu.Unlock() - return - } - ch.awaiting[vkey] = true - ch.mu.Unlock() - ch.wg.Add(1) - go func() { - defer ch.wg.Done() - done := ch.Rebuilds.Done(ctx, builds) - ch.mu.Lock() - delete(ch.awaiting, vkey) - if done { - ch.rebuilt[vkey] = true - } - c, known := ch.known[group] - ch.mu.Unlock() - if done && known && ctx.Err() == nil { - ch.logf("%s: the builds of %s it failed on are done again, so it is checked again (ADR 0603 §10)", vkey, strings.Join(slices.Sorted(maps.Keys(builds)), ", ")) - ch.consider(ctx, group, c) - } - }() -} - -// hearFailedBuilds starts awaitRebuilt for the case's verdict when it names failed builds (failedBuilds). -func (ch *Checker) hearFailedBuilds(ctx context.Context, group string, cs *Case) { - if ch.Rebuilds == nil || ctx.Err() != nil { - return - } - value, _, found, err := ch.Verdicts.Get(ctx, cs.Key) - if err != nil || !found { - return - } - if v, err := meshdeliverycheckerclient.DecodeVerdict(value); err == nil { - if builds := failedBuilds(v, cs); builds != nil { - ch.awaitRebuilt(ctx, group, cs.Key, builds) - } - } -} - -// takeRebuilt says whether every failed build the verdict of vkey names is done again, and forgets it: one retake each. -func (ch *Checker) takeRebuilt(vkey string) bool { - ch.mu.Lock() - defer ch.mu.Unlock() - was := ch.rebuilt[vkey] - delete(ch.rebuilt, vkey) - return was -} - -// containsWords says whether words hold the given words. -func containsWords(words, part string) bool { return strings.Contains(words, part) } diff --git a/modules/mesh-delivery-checker/internal/check/checker_test.go b/modules/mesh-delivery-checker/internal/check/checker_test.go deleted file mode 100644 index 0d48110d..00000000 --- a/modules/mesh-delivery-checker/internal/check/checker_test.go +++ /dev/null @@ -1,761 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "strings" - "sync" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -const hqRepo = "novox/hq" - -const ( - repoA = "novox/mesh-delivery" - repoSDK = "novox/mesh-sdk" - head1 = "1111111111111111111111111111111111111111" - head2 = "2222222222222222222222222222222222222222" - trunkA = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - trunkA2 = "abababababababababababababababababababab" - trunkS = "5555555555555555555555555555555555555555" - trunkS2 = "5656565656565656565656565656565656565656" -) - -// candidateOf is a candidate of a group with the given pull requests, as the indexer writes one. -func candidateOf(t testing.TB, group string, pulls ...meshcatalog.CandidatesByGroupValuePullsItem) []byte { - t.Helper() - heads := make([]meshdeliveryclient.Head, len(pulls)) - for i, p := range pulls { - heads[i] = meshdeliveryclient.Head{Repository: p.Repository, Number: int(p.Number), Head: p.Head} - } - hash, err := meshdeliveryclient.HeadsHash(heads) - if err != nil { - t.Fatal(err) - } - c := meshcatalog.CandidatesByGroupValue{V: keys.Version, Group: group, Heads: hash, Pulls: pulls, Fpset: meshcatalogclient.FingerprintSet(pulls)} - data, err := json.Marshal(c) - if err != nil { - t.Fatal(err) - } - return data -} - -func pullOf(repo string, number int, head string) meshcatalog.CandidatesByGroupValuePullsItem { - return meshcatalog.CandidatesByGroupValuePullsItem{Repository: repo, Number: int64(number), Head: head, Modules: []string{}} -} - -// newRepoPullOf is a pull request of a new repository of the mesh: its trunk not named yet, its first module added. -func newRepoPullOf(repo string, number int, head string) meshcatalog.CandidatesByGroupValuePullsItem { - p := pullOf(repo, number, head) - p.Modules = []string{"mod-u"} - return p -} - -// judgeFunc is a Judge written as a function; it counts its calls. -type judgeFunc struct { - mu sync.Mutex - calls int - f func(ctx context.Context, c *Case, call int) (Outcome, error) -} - -func (j *judgeFunc) Judge(ctx context.Context, c *Case) (Outcome, error) { - j.mu.Lock() - j.calls++ - n := j.calls - j.mu.Unlock() - return j.f(ctx, c, n) -} - -func (j *judgeFunc) count() int { j.mu.Lock(); defer j.mu.Unlock(); return j.calls } - -func passing() meshdeliverychecker.VerdictsByGroupHeadsValue { - return meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictPass, Levels: map[string]meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue{ - buildstep.LevelUnit: {Run: 2, Kept: 3}, buildstep.LevelIntegration: {Run: 1}}} -} - -func passJudge() *judgeFunc { - return &judgeFunc{f: func(context.Context, *Case, int) (Outcome, error) { return Outcome{Verdict: passing()}, nil }} -} - -type rig struct { - ch *Checker - verdicts *memKV - owed *memKV - trunks *Trunks -} - -func newRig(t testing.TB, j Judge) *rig { - t.Helper() - r := &rig{verdicts: newMemKV(), owed: newMemKV(), trunks: &Trunks{}} - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS}) - r.ch = &Checker{Verdicts: r.verdicts, Owed: r.owed, Judge: j, Trunks: r.trunks, Link: "https://view.invalid/checks", Now: time.Now} - return r -} - -func (r *rig) setTrunks(t testing.TB, heads map[string]string) bool { - t.Helper() - return r.trunks.Set(heads) -} - -func (r *rig) verdict(t testing.TB, key string) meshdeliverychecker.VerdictsByGroupHeadsValue { - t.Helper() - raw, _, found, _ := r.verdicts.Get(context.Background(), key) - if !found { - t.Fatalf("no verdict %s; the bucket holds %v", key, r.verdicts.vals) - } - v, err := meshdeliverycheckerclient.DecodeVerdict(raw) - if err != nil { - t.Fatal(err) - } - return v -} - -func keyOf(t testing.TB, group string, value []byte) string { - t.Helper() - c, err := meshcatalog.DecodeCandidatesByGroupValue(value) - if err != nil { - t.Fatal(err) - } - k, err := meshdeliverycheckerclient.VerdictKey(group, c.Heads) - if err != nil { - t.Fatal(err) - } - return k -} - -func TestACandidateNotYetCheckedGetsItsVerdictKeyCreatedOnceAndIsJudged(t *testing.T) { // N6/AC1, 1678 - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - key := keyOf(t, "feat/x", cand) - if v := r.verdict(t, key); v.State != meshdeliverycheckerclient.VerdictPass || v.Group != "feat/x" || v.Trunk[repoA] != trunkA { - t.Fatalf("verdict = %+v", v) - } - if r.verdicts.creates[key] != 1 || j.count() != 1 { - t.Errorf("creates = %d, judged = %d, want one each", r.verdicts.creates[key], j.count()) - } - // The same candidate heard again, with nothing changed, is not judged again. - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if j.count() != 1 { - t.Errorf("judged %d times after the same candidate again, want once", j.count()) - } - // The candidate of a whole try's group is the try's: the try judges it, never the checker as a pull request's check. - r.ch.Candidate(ctx, "try-1793913602402800439", candidateOf(t, "try-1793913602402800439", pullOf(repoA, 7, head1))) - r.ch.Wait() - if j.count() != 1 { - t.Errorf("a try's candidate was judged as a check: %d judgments, want one", j.count()) - } -} - -// racyKV lets another instance create the key just before this one's create. -type racyKV struct { - *memKV - other []byte -} - -func (r racyKV) Create(ctx context.Context, key string, value []byte) (uint64, error) { - if r.other != nil { - _, _ = r.memKV.Create(ctx, key, r.other) - } - return r.memKV.Create(ctx, key, value) -} - -func TestASecondInstancesCreateIsRefusedAndItDoesNothing(t *testing.T) { // N6/AC1 - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - key := keyOf(t, "feat/x", cand) - other, _ := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: "feat/x", Heads: strings.SplitN(key, ".", 2)[1], State: meshdeliverycheckerclient.VerdictRunning}) - r.ch.Verdicts = racyKV{r.verdicts, other} - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if j.count() != 0 { - t.Errorf("the instance that lost the create judged %d times, want none", j.count()) - } - if v := r.verdict(t, key); v.State != meshdeliverycheckerclient.VerdictRunning { - t.Errorf("the other instance's key was changed: %+v", v) - } -} - -func TestARestartWithARunningKeyJudgesItAgain(t *testing.T) { // N6/AC2 - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - key := keyOf(t, "feat/x", cand) - left, _ := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: "feat/x", Heads: strings.SplitN(key, ".", 2)[1], Trunk: map[string]string{repoA: trunkA}, State: meshdeliverycheckerclient.VerdictRunning}) - if _, err := r.verdicts.Create(ctx, key, left); err != nil { - t.Fatal(err) - } - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if j.count() != 1 || r.verdict(t, key).State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("judged %d times, verdict %+v, want the left check judged once and passed", j.count(), r.verdict(t, key)) - } -} - -func TestACheckPastItsBoundFailsNamingTheStuckStep(t *testing.T) { // N6/AC3 - ctx := context.Background() - j := &judgeFunc{f: func(ctx context.Context, c *Case, _ int) (Outcome, error) { - c.Progress.Set("test the unit level of mesh-delivery", "shanks") - <-ctx.Done() - return Outcome{}, ctx.Err() - }} - r := newRig(t, j) - r.ch.Bound = 30 * time.Millisecond - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - v := r.verdict(t, keyOf(t, "feat/x", cand)) - if v.State != meshdeliverycheckerclient.VerdictFail || v.Failed.Machine != "shanks" || !strings.Contains(v.Failed.Words, "stuck at: test the unit level of mesh-delivery") { - t.Fatalf("verdict = %+v, want a failure naming shanks and the stuck step", v) - } -} - -// findingsKept is a FindingWriter that keeps what is written, by ID. -type findingsKept map[string]Finding - -func (f findingsKept) Put(x Finding) error { f[x.ID] = x; return nil } -func (f findingsKept) Delete(x Finding) error { delete(f, x.ID); return nil } - -// A check that could not hear a part of the mesh says `could not run`, naming the part, and releases its claim; only the -// running of that part asks it again, once per heads and part at one fingerprint; not asked again within an hour it is the -// finding check-could-not-run, which clears when the heads are checked again, replaced, or their pull request closes -// (design 47 test 58, issue 1373; issue 1912: no check fails for want of a build node). -func TestACheckThatCouldNotRunIsAskedAgainWhenItsPartRuns(t *testing.T) { // N6/AC4, 47/58 - ctx := context.Background() - unheard := Part{Node: "g14", Module: "forge"} - newCase := func(t *testing.T, fails int) (*rig, *judgeFunc, findingsKept, *time.Time) { - j := &judgeFunc{f: func(_ context.Context, _ *Case, n int) (Outcome, error) { - if n <= fails { - return Outcome{Verdict: failure("the forge", "novox/mesh-delivery#7: go.mod cannot be read: no responders (the forge was "+UnheardWords+")"), Unheard: unheard}, nil - } - return Outcome{Verdict: passing()}, nil - }} - r := newRig(t, j) - found, now := findingsKept{}, time.Date(2026, 11, 9, 20, 0, 0, 0, time.UTC) - r.ch.CouldNotRun, r.ch.Findings, r.ch.Now = newMemKV(), found, func() time.Time { return now } - return r, j, found, &now - } - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - key := keyOf(t, "feat/x", cand) - for name, run := range map[string]func(t *testing.T){ - "it says could not run, naming the part, and only its running asks it again, once per fingerprint": func(t *testing.T) { - r, j, _, _ := newCase(t, 2) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if v := r.verdict(t, key); !IsCouldNotRun(v) || !strings.Contains(v.Failed.Words, "could not run") { - t.Fatalf("verdict = %+v, want could not run", v) - } - if rec, _, ok := r.ch.couldNotRunOf(ctx, key); !ok || rec.Part != unheard || rec.AskedAt != "" { - t.Fatalf("could-not-run.%s = %+v (%v), want the part %v", key, rec, ok, unheard) - } - r.ch.Reconsider(ctx) // nothing ran: not asked again - r.ch.NodesChanged(ctx) - r.ch.PartRunning(ctx, "g14", "mail", "src2:1") // another part ran - r.ch.Wait() - if j.count() != 1 { - t.Fatalf("judged %d times before its part ran, want once", j.count()) - } - r.ch.PartRunning(ctx, "g14", "forge", "src2:1") - r.ch.Wait() - r.ch.PartRunning(ctx, "g14", "forge", "src2:1") // the same part at the same fingerprint asks nothing more - r.ch.Wait() - if j.count() != 2 { - t.Fatalf("judged %d times after its part ran twice at one fingerprint, want twice", j.count()) - } - if rec, _, _ := r.ch.couldNotRunOf(ctx, key); rec.AskedAt != runningAt("g14", "forge", "src2:1") { - t.Fatalf("asked-at = %q after it could not run again", rec.AskedAt) - } - r.ch.PartRunning(ctx, "g14", "forge", "src2:2") // a new build of the part asks once more - r.ch.Wait() - if j.count() != 3 || r.verdict(t, key).State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("judged %d times, verdict %+v, want a pass on the third", j.count(), r.verdict(t, key)) - } - if _, _, ok := r.ch.couldNotRunOf(ctx, key); ok { - t.Error("checked again, the record that it could not run is kept") - } - }, - "not asked again within the hour it is a finding, cleared when it is checked again": func(t *testing.T) { - r, _, found, now := newCase(t, 1) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - if due := r.ch.CouldNotRunDue(ctx, now.Add(59*time.Minute)); !due.Equal(now.Add(CouldNotRunBound)) || len(found) != 0 { - t.Fatalf("before its bound: due %v, findings %v", due, found) - } - if due := r.ch.CouldNotRunDue(ctx, now.Add(CouldNotRunBound)); !due.IsZero() || found[key].Kind != CouldNotRunKind || !strings.Contains(found[key].Summary, "forge on g14") { - t.Fatalf("at its bound: due %v, findings %+v, want %s naming the part", due, found, CouldNotRunKind) - } - if observed, err := r.ch.RaisedCouldNotRun(ctx); err != nil || len(observed) != 1 || observed[0].Kind != CouldNotRunKind || observed[0].ID != key { - t.Fatalf("observed at its bound = %+v, %v, want its one finding, for the finding writer's statement", observed, err) - } - r.ch.PartRunning(ctx, "g14", "forge", "src2:1") - r.ch.Wait() - if observed, _ := r.ch.RaisedCouldNotRun(ctx); len(found) != 0 || len(observed) != 0 { - t.Errorf("checked again, the finding stays: %v, observed %v", found, observed) - } - }, - "its heads replaced, or its pull request closed, the record and the finding go": func(t *testing.T) { - r, _, found, now := newCase(t, 1) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - r.ch.CouldNotRunDue(ctx, now.Add(CouldNotRunBound)) - r.ch.Candidate(ctx, "feat%2Fx", candidateOf(t, "feat/x", pullOf(repoA, 7, head2))) - r.ch.Wait() - if _, _, ok := r.ch.couldNotRunOf(ctx, key); ok || len(found) != 0 { - t.Fatalf("heads replaced: record kept %v, findings %v", ok, found) - } - r2, _, found2, now2 := newCase(t, 1) - r2.ch.Candidate(ctx, "feat%2Fx", cand) - r2.ch.Wait() - r2.ch.CouldNotRunDue(ctx, now2.Add(CouldNotRunBound)) - r2.ch.Forget("feat%2Fx") - if _, _, ok := r2.ch.couldNotRunOf(ctx, key); ok || len(found2) != 0 { - t.Fatalf("pull request closed: record kept %v, findings %v", ok, found2) - } - }, - } { - t.Run(name, run) - } -} - -// Issue 1422: a pull request of a repository the gate's source.main names no trunk head of (one never merged through the -// gate) is never dropped silently. It is not judged, its verdict says it cannot be judged and why, its status is error with -// those words, checker_status names it, and the log says it once per head. Once its trunk head is known it is judged whole; -// in a group, the members whose trunk is known are judged and the others' status says why they are not. -func TestARepositoryWithNoTrunkCannotBeJudgedLoudlyUntilItsTrunkIsKnown(t *testing.T) { // N6/AC6, ADR 0484 clause 11, 1422 - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - var logged []string - r.ch.Logf = func(f string, a ...any) { logged = append(logged, fmt.Sprintf(f, a...)) } - const unknown = "novox/unknown" - cand := candidateOf(t, "feat/y", newRepoPullOf(unknown, 4, head1)) - key := keyOf(t, "feat/y", cand) - r.ch.Candidate(ctx, "feat/y", cand) - r.ch.Wait() - r.ch.Reconsider(ctx) // looked at again: nothing is written or said twice - r.ch.NodesChanged(ctx) - r.ch.Wait() - v := r.verdict(t, key) - if j.count() != 0 || !IsUntrunked(v) || !strings.Contains(v.Failed.Words, "the trunk head of "+unknown+" is not known") { - t.Fatalf("judged %d times, verdict %+v, want none judged and a verdict that says it cannot be judged", j.count(), v) - } - if s := owedState(t, r, unknown, 4, head1); s != "error" { - t.Errorf("%s#4 owes %q, want error", unknown, s) - } - if n := countWith(logged, "cannot be judged"); n != 1 { - t.Errorf("said %d times in the log, want once for the head: %q", n, logged) - } - reader := func() Reader { - ckey, _ := meshcatalogclient.CandidatesKey("feat/y") - return Reader{CandidateState: fakeState{ckey: cand}.read(), VerdictState: fakeState(r.verdicts.vals).read(), - Trunks: func() (map[string]string, error) { return r.trunks.Heads(), nil }} - } - st, err := reader().Status() - if err != nil { - t.Fatal(err) - } - if why := st.CannotBeJudged["feat/y"]; !strings.Contains(why, unknown) || len(st.Waiting[KindNew]) != 0 || len(st.Unjudged) != 0 { - t.Errorf("cannot_be_judged %v, waiting %v, unjudged %v: want feat/y named as cannot be judged, not as new", st.CannotBeJudged, st.Waiting, st.Unjudged) - } - if rows, _, err := reader().Verdicts("feat/y"); err != nil || len(rows) != 1 || !strings.Contains(rows[0].Reports[unknown+"#4"], "cannot be judged") { - t.Errorf("checker_verdicts %+v (%v), want the report of %s#4 to say it cannot be judged", rows, err, unknown) - } - - // Its trunk head becomes known: the heads are judged whole, the same key rewritten, the status success. - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS, unknown: trunkA2}) - r.ch.TrunkMoved(ctx) - r.ch.Wait() - if v := r.verdict(t, key); j.count() != 1 || v.State != meshdeliverycheckerclient.VerdictPass || v.Trunk[unknown] != trunkA2 { - t.Errorf("judged %d times, verdict %+v, want one pass on %s", j.count(), v, trunkA2) - } - if s := owedState(t, r, unknown, 4, head1); s != "success" { - t.Errorf("%s#4 owes %q once its trunk is known, want success", unknown, s) - } - - // Issue 1733: the gate asks the Approve only on a verdict, so no candidate is left without one. A group with a member - // whose trunk is not known is not judged in part: its verdict fails naming that repository, and every status says so; a - // running verdict left for heads that cannot be judged is replaced; a verdict key deleted is judged again on its delete. - for _, row := range []struct { - name string - pulls []meshcatalog.CandidatesByGroupValuePullsItem - running bool // a running verdict is left under the key first - deleted bool // the key is deleted after its verdict - judged int - want string // the verdict's state, and for a failure the repository it names - }{ - {name: "a member the checker cannot claim", pulls: []meshcatalog.CandidatesByGroupValuePullsItem{pullOf(repoA, 9, head2), pullOf("novox/other", 2, head2)}, want: "novox/other"}, - {name: "a running verdict left for heads that cannot be judged", pulls: []meshcatalog.CandidatesByGroupValuePullsItem{newRepoPullOf(unknown, 5, head2)}, running: true, want: unknown}, - {name: "a verdict key deleted", pulls: []meshcatalog.CandidatesByGroupValuePullsItem{pullOf(repoA, 5, head2)}, deleted: true, judged: 2, want: meshdeliverycheckerclient.VerdictPass}, - } { - t.Run(row.name, func(t *testing.T) { - j := passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/z", row.pulls...) - key := keyOf(t, "feat/z", cand) - if row.running { - group, heads, _ := meshdeliverycheckerclient.ParseVerdictKey(key) - raw, _ := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: group, Heads: heads, State: meshdeliverycheckerclient.VerdictRunning}) - _, _ = r.verdicts.Create(ctx, key, raw) - } - r.ch.Candidate(ctx, "feat%2Fz", cand) - r.ch.Wait() - if row.deleted { - _ = r.verdicts.Delete(ctx, key) - r.ch.VerdictDeleted(ctx, key) // the watch of the verdicts hands the delete over - r.ch.Wait() - } - v := r.verdict(t, key) - if row.want == meshdeliverycheckerclient.VerdictPass { - if v.State != meshdeliverycheckerclient.VerdictPass || j.count() != row.judged { - t.Errorf("verdict %s after %d judgings, want a pass after %d", v.State, j.count(), row.judged) - } - return - } - if !IsUntrunked(v) || !strings.Contains(v.Failed.Words, row.want) || j.count() != 0 { - t.Errorf("verdict %+v after %d judgings, want a failure naming %s and none judged", v, j.count(), row.want) - } - for _, p := range row.pulls { - if s := owedState(t, r, p.Repository, int(p.Number), p.Head); s != "error" { - t.Errorf("%s#%d owes %q, want error", p.Repository, p.Number, s) - } - } - }) - } - - // ADR 0664 §5 (issue 1748): a candidate taken out (its pull request merged or closed) ends the check running for it with a - // cause its asks' wait names, never a plain cancel, so its asker drops the asks it put on the build nodes. - t.Run("a candidate taken out ends its check with a named cause", func(t *testing.T) { - ch := &Checker{} - ch.init() - run, end := context.WithCancelCause(context.Background()) - ch.live["g.heads"] = liveCheck{group: "g", end: end} - // The check's asker is waiting on an ask of its run when the candidate goes (review 1, finding 7). - drops := &checkDrops{} - fake := &buildrun.FakeAsks{} - done := make(chan struct{}) - go func() { - defer close(done) - (buildrun.Asker{Seats: testSeats(), Publisher: fake, Waiter: fake, Bound: time.Hour, Dropper: drops}).Wait(run, buildstep.StepAsk{ID: "mvl0frv18d2000", Language: buildstep.AskGo, Kind: buildstep.AskCheck}) - }() - ch.Forget("g") - <-done - var s superseded - if cause := context.Cause(run); !errors.As(cause, &s) || s.by != "" || errors.Is(cause, context.Canceled) { - t.Errorf("the check was ended with %v, want superseded with no heads, not a plain cancel", cause) - } - if len(drops.got) != 1 || !strings.Contains(drops.got[0], "mvl0frv18d2000") || !strings.Contains(drops.got[0], "no candidate holds these heads") { - t.Errorf("the asker dropped %q, want its ask withdrawn with the check's cause", drops.got) - } - }) -} - -// checkDrops keeps the asks an asker dropped: " ". -type checkDrops struct{ got []string } - -func (d *checkDrops) DropAsk(_ context.Context, a buildstep.StepAsk, why string) error { - d.got = append(d.got, a.ID+" "+why) - return nil -} - -func countWith(lines []string, words string) int { - n := 0 - for _, l := range lines { - if strings.Contains(l, words) { - n++ - } - } - return n -} - -// 1887/A10, ADR 0527 §2: hq is judged as any repository, its checks Go tests, and its pull request gets a verdict and a -// mesh/check; in a group, hq's member is judged with the others. -func TestAnHqPullRequestGetsAVerdictAndAStatus(t *testing.T) { - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS, hqRepo: trunkA2}) - r.ch.Candidate(ctx, "feat/hq", candidateOf(t, "feat/hq", pullOf(hqRepo, 3, head1))) - r.ch.Wait() - if j.count() != 1 || len(r.verdicts.vals) != 1 { - t.Fatalf("judged %d times, %d verdicts, want one", j.count(), len(r.verdicts.vals)) - } - if s := owedState(t, r, hqRepo, 3, head1); s != "success" { - t.Errorf("hq#3 owes %q, want success", s) - } - r.ch.Candidate(ctx, "feat/x", candidateOf(t, "feat/x", pullOf(hqRepo, 4, head2), pullOf(repoA, 7, head2))) - r.ch.Wait() - if s := owedState(t, r, hqRepo, 4, head2); s != "success" { - t.Errorf("hq#4 in a group owes %q, want success", s) - } -} - -func TestATrunkMoveRewritesTheSameVerdictKeyAndTheHeadsStatus(t *testing.T) { // 1300/AC7 - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - key := keyOf(t, "feat/x", cand) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - _, rev1, _, _ := r.verdicts.Get(ctx, key) - owedKey, _ := CheckerOwedKey(repoA, 7, head1) - _, orev1, _, _ := r.owed.Get(ctx, owedKey) - if !r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) { - t.Fatal("the trunks did not change") - } - r.ch.Reconsider(ctx) - r.ch.Wait() - _, rev2, _, _ := r.verdicts.Get(ctx, key) - if j.count() != 2 || rev2 <= rev1 || r.verdict(t, key).Trunk[repoA] != trunkA2 { - t.Fatalf("judged %d times, revisions %d then %d, trunk %v", j.count(), rev1, rev2, r.verdict(t, key).Trunk) - } - if r.verdicts.creates[key] != 1 { - t.Errorf("the key was created %d times, want the same key rewritten", r.verdicts.creates[key]) - } - if _, orev2, _, _ := r.owed.Get(ctx, owedKey); orev2 <= orev1 { - // the line is the same when nothing differs; the status is rewritten when the words change, here the trunk is in them - t.Logf("the status keeps revision %d (its words did not change)", orev2) - } - // A new head is another key, and the older head's status is not touched. - older, _, _, _ := r.owed.Get(ctx, owedKey) - cand2 := candidateOf(t, "feat/x", pullOf(repoA, 7, head2)) - r.ch.Candidate(ctx, "feat%2Fx", cand2) - r.ch.Wait() - if again, _, _, _ := r.owed.Get(ctx, owedKey); string(again) != string(older) { - t.Errorf("the older head's status was rewritten") - } - if n := len(r.owed.vals); n != 2 { - t.Errorf("%d statuses, want one for each head", n) - } -} - -func TestTheStatusIsPendingWhileTheCheckRunsAndEndsSuccessOrFailure(t *testing.T) { // 1300/AC5 (unit part) - ctx := context.Background() - var seen []string - var r *rig - j := &judgeFunc{f: func(ctx context.Context, c *Case, _ int) (Outcome, error) { - key, _ := CheckerOwedKey(repoA, 7, head1) - raw, _, _, _ := r.owed.Get(ctx, key) - o, _ := DecodeCheckerOwed(raw) - seen = append(seen, o.State) - c.series(repoA+"#7", []string{"web/pkg series 0.1 → 0.2"}, []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem{{Module: "web", Artifact: "pkg", From: "0.1", To: "0.2"}}) - return Outcome{Verdict: meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Test: "m/a.TestX"}}, - OutOfStep: map[string][]string{repoA + "#7": {"go/seats/x/contract.go"}}}, nil - }} - r = newRig(t, j) - says := &verdictsSaid{} - r.ch.Says = says - r.ch.Candidate(ctx, "feat/x", candidateOf(t, "feat/x", pullOf(repoA, 7, head1))) - r.ch.Wait() - key, _ := CheckerOwedKey(repoA, 7, head1) - raw, _, _, _ := r.owed.Get(ctx, key) - o, err := DecodeCheckerOwed(raw) - if err != nil { - t.Fatal(err) - } - if len(seen) != 1 || seen[0] != "pending" || o.State != "failure" || o.Context != meshdeliveryclient.StatusContextCheck || !strings.HasPrefix(o.Target, "https://view.invalid/checks/") { - t.Errorf("while running %v, at the end %+v", seen, o) - } - // DLV-C2 (design 26 *Out of step*): the check's end says one verdict event for the pull request, naming its out-of-step - // files; the running status says none. - if len(says.said) != 1 || says.said[0].Repository != repoA || says.said[0].Pull != 7 || says.said[0].Head != head1 || - says.said[0].Verdict != meshdeliverycheckerclient.VerdictFail || strings.Join(says.said[0].OutOfStep, ",") != "go/seats/x/contract.go" || - // The join (A2j finding 2): and its series changes, as the seat's event names them. - len(says.said[0].Series) != 1 || says.said[0].Series[0] != (meshdeliverychecker.VerdictHolderEventSeriesItem{Module: "web", Artifact: "pkg", From: "0.1", To: "0.2"}) { - t.Errorf("verdict events %+v", says.said) - } -} - -// verdictsSaid is a VerdictSayer that keeps what it was told. -type verdictsSaid struct { - mu sync.Mutex - said []VerdictEvent -} - -func (s *verdictsSaid) Say(_ context.Context, v VerdictEvent) error { - s.mu.Lock() - defer s.mu.Unlock() - s.said = append(s.said, v) - return nil -} - -// No check of heads no candidate holds is left running (issue 1890): at start the sweep ends a key left running; while the -// checker runs, a check whose group moved to other heads is ended at once, unjudged, and writes no status; heads held again -// are checked whole; and a group's check starts only once its heads settled, so a partial set of members is never checked. -func TestHeadsNoCandidateHoldsAreNeverLeftRunning(t *testing.T) { - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - live := keyOf(t, "feat/x", cand) - dead, _ := meshdeliverycheckerclient.VerdictKey("feat/gone", "0123456789ab") - for _, k := range []string{live, dead} { - group, heads, _ := meshdeliverycheckerclient.ParseVerdictKey(k) - raw, _ := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: group, Heads: heads, State: meshdeliverycheckerclient.VerdictRunning}) - _, _ = r.verdicts.Create(ctx, k, raw) - } - r.ch.init() - var c meshcatalog.CandidatesByGroupValue - _ = json.Unmarshal(cand, &c) - r.ch.known["feat%2Fx"] = c - if err := r.ch.Sweep(ctx); err != nil { - t.Fatal(err) - } - if v := r.verdict(t, dead); !IsEnded(v) || !strings.Contains(v.Failed.Words, "closed at start") { - t.Errorf("the dead key = %+v", v) - } - if v := r.verdict(t, live); v.State != meshdeliverycheckerclient.VerdictRunning { - t.Errorf("the live key = %+v, want it left for the check to take over", v) - } - - // A member joins while the check of the lone member's heads runs: that check is ended, its judge's run cancelled. - started, ended := make(chan struct{}), make(chan error, 1) - j = &judgeFunc{f: func(run context.Context, _ *Case, call int) (Outcome, error) { - if call == 1 { - close(started) - <-run.Done() - ended <- context.Cause(run) - return Outcome{}, run.Err() - } - return Outcome{Verdict: passing()}, nil - }} - r = newRig(t, j) - var logged []string - var logMu sync.Mutex - r.ch.Logf = func(f string, a ...any) { logMu.Lock(); logged = append(logged, fmt.Sprintf(f, a...)); logMu.Unlock() } - alone, both := cand, candidateOf(t, "feat/x", pullOf(repoA, 7, head1), pullOf(repoSDK, 3, head2)) - r.ch.Candidate(ctx, "feat%2Fx", alone) - <-started - r.ch.Candidate(ctx, "feat%2Fx", both) - var bothC meshcatalog.CandidatesByGroupValue - _ = json.Unmarshal(both, &bothC) - select { - case err := <-ended: - if err == nil || !strings.Contains(err.Error(), "superseded by "+GateHeads(bothC)) { - t.Errorf("the old check's run ended with %v", err) - } - case <-time.After(5 * time.Second): - t.Fatal("the check of the heads the candidate left still runs") - } - r.ch.Wait() - if v := r.verdict(t, live); !IsEnded(v) || v.Failed.Words != EndedWords+"superseded by "+GateHeads(bothC) { - t.Errorf("the superseded verdict = %+v", v.Failed) - } - if v := r.verdict(t, keyOf(t, "feat/x", both)); v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("the group's verdict = %s", v.State) - } - okey, _ := CheckerOwedKey(repoA, 7, head1) - if raw, _, _, _ := r.owed.Get(ctx, okey); !strings.Contains(string(raw), `"success"`) { - t.Errorf("the head's status = %s, want the group's success, never the ended check's", raw) - } - logMu.Lock() - said := 0 - for _, l := range logged { - if strings.Contains(l, "ended: superseded") { - said++ - } - } - logMu.Unlock() - if said != 1 { - t.Errorf("the end was said %d times: %v", said, logged) - } - // The member leaves again: the ended heads are held again and checked whole. - r.ch.Candidate(ctx, "feat%2Fx", alone) - r.ch.Wait() - if v := r.verdict(t, live); v.State != meshdeliverycheckerclient.VerdictPass || j.count() != 3 { - t.Errorf("the heads held again = %s after %d judgings, want a pass of a third", v.State, j.count()) - } - - // Members announced one after another: only the settled, whole set is checked. - j = passJudge() - r = newRig(t, j) - r.ch.Settle = time.Hour - sdk := candidateOf(t, "feat/y", pullOf(repoSDK, 4, head2)) - whole := candidateOf(t, "feat/y", pullOf(repoSDK, 4, head2), pullOf(repoA, 8, head1)) - r.ch.Candidate(ctx, "feat%2Fy", sdk) - r.ch.Candidate(ctx, "feat%2Fy", whole) - r.ch.Reconsider(ctx) // a trunk move or a turn while the heads settle starts nothing - if j.count() != 0 { - t.Fatalf("judged %d times before the heads settled", j.count()) - } - r.ch.settleNow() - r.ch.Wait() - if _, _, found, _ := r.verdicts.Get(ctx, keyOf(t, "feat/y", sdk)); found || j.count() != 1 { - t.Errorf("the partial set has a verdict (%v) or the judge ran %d times, want the whole set alone", found, j.count()) - } - if v := r.verdict(t, keyOf(t, "feat/y", whole)); v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("the whole set = %s", v.State) - } -} - -func TestTheForgeBridgeIsToldOnceForEachChangeOfAStatus(t *testing.T) { // 1683 (the checker's half of AC5) - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - var told []string - r.ch.Announce = func(_ context.Context, event, key string) { told = append(told, event+" "+key) } - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - key, _ := CheckerOwedKey(repoA, 7, head1) - want := []string{EventOwedWritten + " " + key, EventOwedWritten + " " + key} // pending, then success - if len(told) != 2 || told[0] != want[0] || told[1] != want[1] { - t.Fatalf("told %v, want the status said when pending and when success", told) - } - r.ch.Candidate(ctx, "feat%2Fx", cand) // nothing changed: nothing written, nothing said - r.ch.Wait() - if len(told) != 2 { - t.Errorf("told %v after a check that changed nothing", told) - } -} - -// Sweep 2026-10-30 item 7: a pull request of a repository the mesh does not deliver (an operator's own, on the same -// forge) touches no module and its trunk the gate never names. It is outside the mesh: no verdict, no status owed (one -// owed before is taken away, so the forge module stops writing it into a repository the mesh may not write), said once. -func TestACandidateOutsideTheMeshIsJudgedNothingAndOwesNothing(t *testing.T) { - ctx, j := context.Background(), passJudge() - r := newRig(t, j) - var logged []string - r.ch.Logf = func(f string, a ...any) { logged = append(logged, fmt.Sprintf(f, a...)) } - const theirs = "someone/own-app" - okey, _ := CheckerOwedKey(theirs, 55, head1) - before, _ := EncodeCheckerOwed(meshdeliverychecker.OwedByRepositoryNumberHeadActValue{Act: meshdeliveryclient.OwedStatus, Context: meshdeliveryclient.StatusContextCheck, State: "error", Text: "cannot be judged"}) - if _, err := r.owed.Create(ctx, okey, before); err != nil { - t.Fatal(err) - } - cand := candidateOf(t, "feat/theirs", pullOf(theirs, 55, head1)) - key := keyOf(t, "feat/theirs", cand) - r.ch.Candidate(ctx, "feat/theirs", cand) - r.ch.Wait() - r.ch.Reconsider(ctx) - r.ch.Wait() - if _, _, found, _ := r.verdicts.Get(ctx, key); found || j.count() != 0 { - t.Errorf("a candidate outside the mesh was judged (%d) or given a verdict (%v)", j.count(), found) - } - if s := owedState(t, r, theirs, 55, head1); s != "" { - t.Errorf("%s#55 still owes %q on the forge", theirs, s) - } - if n := countWith(logged, "outside the mesh"); n != 1 { - t.Errorf("said %d times in the log, want once: %q", n, logged) - } - ckey, _ := meshcatalogclient.CandidatesKey("feat/theirs") - st, err := Reader{CandidateState: fakeState{ckey: cand}.read(), VerdictState: fakeState(r.verdicts.vals).read(), - Trunks: func() (map[string]string, error) { return r.trunks.Heads(), nil }}.Status() - if err != nil { - t.Fatal(err) - } - if st.Outside["feat/theirs"] == "" || len(st.CannotBeJudged) != 0 || len(st.Unjudged) != 0 { - t.Errorf("status: outside %v, cannot be judged %v, unjudged %v", st.Outside, st.CannotBeJudged, st.Unjudged) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/composition_test.go b/modules/mesh-delivery-checker/internal/check/composition_test.go deleted file mode 100644 index 56f4f5ad..00000000 --- a/modules/mesh-delivery-checker/internal/check/composition_test.go +++ /dev/null @@ -1,344 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "maps" - "mesh-delivery-checker/rules" - "slices" - "strings" - "testing" - - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - - buildsrec "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-sdk/go/catalogue" -) - -// fakeCompositions answers a check's composition from memory, recording the keys asked. -type fakeCompositions struct { - v rules.Composed - err error - asked []string - // seats are the seat lists the cases asked carried (Case.Seats), one per ask. - seats [][]json.RawMessage - // waits answers only when its context ends. - waits bool -} - -func (f *fakeCompositions) Compose(ctx context.Context, c *Case) (rules.Composed, error) { - f.asked = append(f.asked, c.Key) - f.seats = append(f.seats, c.Seats) - if f.waits { - <-ctx.Done() - return rules.Composed{}, ctx.Err() - } - return f.v, f.err -} - -// composedOn is the engines' answers of a composition by composer on the nodes, each composing it, taking took ms. -func composedOn(composer string, took int64, nodes ...string) rules.Composed { - c := rules.Composed{Group: "feat/x", Heads: "0123456789ab", Composer: composer, Nodes: nodes, Took: took, Answers: map[string]ne.ComposeCandidateAnswer{}} - for _, n := range nodes { - c.Answers[n] = ne.ComposeCandidateAnswer{Node: n, Verdict: nec.Composed} - } - return c -} - -// refusedOn is the engines' answers of a composition the node refuses with the words. -func refusedOn(composer, node, words string) rules.Composed { - return rules.Composed{Group: "feat/x", Heads: "0123456789ab", Composer: composer, Nodes: []string{node}, - Answers: map[string]ne.ComposeCandidateAnswer{node: {Node: node, Verdict: nec.Refused, Refused: words}}} -} - -// 1297/AC3 (its unit half): a check whose tests pass takes the assigner's composition of it, by the check's own key, -// into its verdict: a pass says it passed with the mesh-sdk and machines it composed, and is no longer "not run". -func TestAPassingCheckTakesTheAssignersComposition(t *testing.T) { - t.Run("a change to a build module or base names the modules built on it", aChangeToABuildModuleOrBaseNamesTheModulesBuiltOnIt) - b := newBench(t) - f := &fakeCompositions{v: composedOn("v0.1.14-x", 40, "g14")} - b.ex.Compositions = f - cs := caseOf(t, pullOf(repoA, 7, head1)) - cs.FPSet = "fps-of-the-candidate" - v := b.judge(t, cs).Verdict - if v.State != meshdeliverycheckerclient.VerdictPass || v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionPass || v.Composition.Sdk != "v0.1.14-x" || v.Took.Composition != 40 { - t.Fatalf("verdict = %+v, composition %+v", v, v.Composition) - } - if len(f.asked) != 1 || f.asked[0] != cs.Key { - t.Errorf("asked %v, want the check's key %s", f.asked, cs.Key) - } - if !compositionMentions(v, "passed") { - t.Errorf("the line says %q", compositionWords(v.Composition, v.Took.Composition)) - } - if v.Composition.Fpset == "" || v.Composition.Fpset != cs.FPSet { - t.Errorf("the composition names the fingerprint set %q, want the candidate's %q (ADR 0548 §5)", v.Composition.Fpset, cs.FPSet) - } - // Issue 1966 (the group try of 2026-11-06 10:07): the composition is handed the check's seat list, the judge's, once the - // checker's reader read it; a list not read hands none (the composer then judges no machine, ADR 0636 §1). - if len(f.seats) != 1 || f.seats[0] != nil { - t.Errorf("with no seat list reader the composition was handed %v, want none", f.seats) - } - for _, read := range []bool{true, false} { - b.ex.SeatList = fakeSeatList{read: read} - asked := len(f.seats) - rv := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if read { - if got := f.seats[len(f.seats)-1]; len(got) != 2 || string(got[0]) != `{"seat":"a"}` { - t.Errorf("with the list read the composition was handed %s, want the reader's two definitions", got) - } - } else if len(f.seats) != asked || rv.Failed == nil || !strings.Contains(rv.Failed.Words, "the seat list is not read") { - // A reader that has not read the list acts on nothing new (ADR 0636 §1): the check ends before any judge. - t.Errorf("with the list not read the composition was asked %d more, verdict %+v; want none and a fail naming the list", len(f.seats)-asked, rv.Failed) - } - } - // ADR 0635 §3: at a node-engine member's head a list not read fails the check, naming why, and asks no composer - // (a composer handed none would judge no machine and the composition would pass); read, it composes. - for _, read := range []bool{false, true} { - b.ex.SeatList = fakeSeatList{read: read} - asked := len(f.asked) - hv := b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf(nodeEngineRepo, 3, head2))).Verdict - switch { - case !read && (hv.State != meshdeliverycheckerclient.VerdictFail || hv.Failed == nil || !strings.Contains(hv.Failed.Words, "seat list") || len(f.asked) != asked): - t.Errorf("at a node-engine head with the list not read: verdict %+v, composition %+v, asked %d more; want a failed composition naming the seat list, no ask", hv, hv.Composition, len(f.asked)-asked) - case read && (hv.Composition == nil || hv.Composition.State != meshdeliverycheckerclient.CompositionPass || len(f.asked) != asked+1): - t.Errorf("at a node-engine head with the list read: composition %+v, want the composer's pass", hv.Composition) - } - } - b.ex.SeatList = nil - f.asked, f.seats = f.asked[:1], f.seats[:1] - // ADR 0548 §5: a carry whose fingerprints did not change keeps the composition it passed and asks the assigner nothing. - carry := caseOf(t, pullOf(repoA, 7, head1)) - carry.CarriedFrom, carry.Composition = map[string]string{repoA: trunkA2}, v.Composition - if kept := b.judge(t, carry).Verdict; kept.Composition == nil || kept.Composition.Sdk != "v0.1.14-x" || len(f.asked) != 1 { - t.Errorf("the carry's composition is %+v and the assigner was asked %d times; want the kept one and no second ask", kept.Composition, len(f.asked)) - } -} - -func compositionMentions(v meshdeliverychecker.VerdictsByGroupHeadsValue, word string) bool { - return strings.Contains(compositionWords(v.Composition, v.Took.Composition), word) -} - -// 1297/AC2 at the checker: a failed composition fails the check, naming the machine it failed at and its words. -func TestAFailedCompositionFailsTheCheck(t *testing.T) { - b := newBench(t) - b.ex.Compositions = &fakeCompositions{v: refusedOn("x", "g14", "g14 runs web, which the change removes from its source")} - v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if v.State != meshdeliverycheckerclient.VerdictFail || v.Failed.Machine != "g14" || v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionFail { - t.Fatalf("verdict = %+v", v) - } - v.Group, v.Heads = "feat/x", "0123456789ab" // the checker names them when it writes the verdict - if _, err := meshdeliverycheckerclient.EncodeVerdict(v); err != nil { - t.Errorf("the verdict cannot be written: %v", err) - } -} - -// 1297/B3d: a composition that cannot be read leaves it not run; a try is not composed. -func TestACompositionNotHadIsNotRun(t *testing.T) { - b := newBench(t) - f := &fakeCompositions{err: errors.New("the check's bound passed")} - b.ex.Compositions = f - v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if v.State != meshdeliverycheckerclient.VerdictPass || v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionNotRun { - t.Fatalf("verdict = %+v", v) - } - b2 := newBench(t) - f2 := &fakeCompositions{v: refusedOn("x", "g14", "w")} - b2.ex.Compositions = f2 - cs := caseOf(t, pullOf(repoA, 7, head1)) - cs.Try = &TryOptions{} - b2.judge(t, cs) - if len(f2.asked) != 0 { - t.Errorf("a try asked for a composition: %v", f2.asked) - } -} - -// fixedTrunks are trunk heads that never move. -type fixedTrunks struct{ heads map[string]string } - -func (f fixedTrunks) Heads() map[string]string { return f.heads } - -// fakeEnds answers the builder's builds of a candidate as fakeBuilds holds them, recording the builds waited on; the -// composition must not have been asked yet when it is (ADR 0603 §10: the check composes with the builds). -type fakeEnds struct { - builds fakeBuilds - asked map[string]string - composed *fakeCompositions - early bool -} - -func (f *fakeEnds) Ended(_ context.Context, asked map[string]string) (map[string]buildsrec.BuilderBuild, error) { - f.asked = asked - f.early = f.composed != nil && len(f.composed.asked) > 0 - out := map[string]buildsrec.BuilderBuild{} - for module, fp := range asked { - if b, ok := f.builds[module+" "+fp]; ok && (b.State == buildsrec.BuildDone || b.State == buildsrec.BuildFailed) { - out[module] = b - } - } - return out, nil -} - -func (f *fakeEnds) Done(context.Context, map[string]string) bool { return false } - -// fixedServing are the verbs the running builds serve. -type fixedServing []string - -func (f fixedServing) Served(context.Context) (func(string) bool, error) { - return func(v string) bool { return slices.Contains(f, v) }, nil -} - -// knownRuns are the modules the trunk holds a record of (the indexer's modules): any commit. -type knownRuns []string - -func (k knownRuns) CommitOf(module string) string { - if slices.Contains(k, module) { - return trunkA - } - return "" -} - -// ADR 0603 §10: before it composes, the check waits on the builder's builds of the candidate's changed modules and composes -// with them; a failed build fails the check naming it, and one not ended within the bound is named. It does not wait on a -// module built by a build module the change alters, nor on one standing on a base the change alters, nor on one the trunk -// holds no record of, and names each in the composition's warnings (and so the check's line); a change that alters none of -// these says nothing. -func aChangeToABuildModuleOrBaseNamesTheModulesBuiltOnIt(t *testing.T) { - dig := func(c string) string { return strings.Repeat(c, 64) } - fp := "src2:" + dig("f") - goBuild := &catalogue.Build{Artifacts: []catalogue.Artifact{{Name: "bin", Kind: catalogue.ArtifactBundle, Language: "go"}}} - tsBuild := &catalogue.Build{Artifacts: []catalogue.Artifact{{Name: "app", Kind: catalogue.ArtifactBundle, Language: "typescript"}}} - done := buildsrec.BuilderBuild{State: buildsrec.BuildDone} - for _, row := range []struct { - name string - manifest map[string]catalogue.Manifest - builds map[string]buildsrec.BuilderBuild // by module, at fp; nil leaves the check without the builds' ends - runs knownRuns // nil: the trunk holds every module - want []string - waited string // the modules waited on, sorted - failed string // the failure's test, when the check fails on a build - tests bool // the tests fail: the check fails before it would wait - served []string // what the running builds serve (ADR 0614 §7); nil reads nothing of what runs - preview bool // the check began on the candidate the indexer wrote before its merge preview (issue 1921) - late bool // a build did not end within the bound: the change is not composed (issue 1921) - }{ - {name: "the Go build module invokes a verb no running build serves", - manifest: map[string]catalogue.Manifest{"mesh-build-go": {Module: "mesh-build-go", Build: goBuild, - Invokes: []string{"seat:package-registry.publish", "seat:artifact-store.put"}}, "web": {Module: "web", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"mesh-build-go": done}, served: []string{"seat:artifact-store.put"}, - want: []string{"the changed build module mesh-build-go invokes seat:package-registry.publish, which no running build serves, " + - "so the check cannot run it: web, which it builds, are composed from their manifests (ADR 0614 §7)"}, waited: "mesh-build-go"}, - {name: "the Go build module changes", - manifest: map[string]catalogue.Manifest{"mesh-build-go": {Module: "mesh-build-go", Build: goBuild}, "web": {Module: "web", Build: goBuild}, - "mail": {Module: "mail", Build: goBuild}, "docs": {Module: "docs"}}, - builds: map[string]buildsrec.BuilderBuild{"mesh-build-go": done, "docs": done}, - want: []string{"the build module mesh-build-go: mail, web, which it builds"}, waited: "docs, mesh-build-go"}, - {name: "the Node build module changes", - manifest: map[string]catalogue.Manifest{"mesh-build-node": {Module: "mesh-build-node", Build: goBuild}, "panel": {Module: "panel", Build: tsBuild}, - "web": {Module: "web", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"mesh-build-node": done, "web": done}, - want: []string{"the build module mesh-build-node: panel, which it builds"}, waited: "mesh-build-node, web"}, - {name: "a base changes", - manifest: map[string]catalogue.Manifest{"image": {Module: "image"}, - "web": {Module: "web", Build: &catalogue.Build{On: []catalogue.BuildsOn{{Arg: "BASE", Module: "image", Artifact: "img"}}}}}, - builds: map[string]buildsrec.BuilderBuild{"image": done}, - want: []string{"alters image, a base of web", "waits on the build of image alone"}, waited: "image"}, - {name: "neither changes", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"web": done}, waited: "web"}, - {name: "a build fails", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}, "mail": {Module: "mail", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"web": {State: buildsrec.BuildFailed, Error: "go build: undefined: x"}, "mail": done}, - waited: "mail, web", failed: "build: web"}, - {name: "the tests fail", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"web": {State: buildsrec.BuildBuilding}}, tests: true, - want: []string{"composes at once, without waiting on the builds of web"}}, - {name: "a build does not end within the bound", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"web": {State: buildsrec.BuildBuilding}}, late: true, - want: []string{"the builder's builds of web did not end within the build-wait-bound", "the change is not composed"}, waited: "web"}, - {name: "the check began before the merge preview", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"web": done}, preview: true, waited: "web"}, - {name: "a module the trunk does not hold", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}, "new": {Module: "new", Build: goBuild}}, - builds: map[string]buildsrec.BuilderBuild{"web": done}, runs: knownRuns{"web"}, - want: []string{"new: the trunk holds no record of it yet"}, waited: "web"}, - {name: "the builds cannot be heard", manifest: map[string]catalogue.Manifest{"web": {Module: "web", Build: goBuild}}, - want: []string{"the builds of web cannot be heard"}}, - } { - b := candidateBench(t, true) - if row.tests { - b.test = func(c stepCall) (any, error) { - r := captured[Tested](t, "go-test-failing") - r.Level, _ = c.args["level"].(string) - return r, nil - } - } - comps := &fakeCompositions{v: composedOn("x", 0, "g14")} - b.ex.Compositions = comps - var ends *fakeEnds - if row.builds != nil { - ends = &fakeEnds{builds: fakeBuilds{}, composed: comps} - for module, build := range row.builds { - ends.builds[module+" "+fp] = build - } - b.ex.BuildEnds = ends - } - if row.runs != nil { - b.ex.Runs = row.runs - } - if row.served != nil { - b.ex.Serving = fixedServing(row.served) - } - read, fps := fixedManifests{}, map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{} - for module, m := range row.manifest { - d := dig(string(rune('a' + len(read)))) - read[d], fps[module] = m, meshcatalog.CandidatesByGroupValuePullsItemFpsValue{Fp2: fp, Manifest: d} - } - b.ex.Read = read - p := pullOf(catalogueRepository, 9, head1) - p.Fps, p.Modules = fps, slices.Sorted(maps.Keys(fps)) - if row.preview { - previewed := p - b.ex.Candidates = &fakeTryCandidates{cand: meshcatalog.CandidatesByGroupValue{Fpset: "fps", Pulls: []meshcatalog.CandidatesByGroupValuePullsItem{previewed}}} - p.Fps = map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{} - for module, m := range fps { - p.Fps[module] = meshcatalog.CandidatesByGroupValuePullsItemFpsValue{Manifest: m.Manifest, None2: meshcatalogclient.NoneNoPreview} - } - } - v := b.judge(t, caseOf(t, p)).Verdict - asks := 1 - if row.late { - asks = 0 // never asked: an engine would read the builder's lateness as the change's refusal - } - if v.Composition == nil || len(comps.asked) != asks || row.late && v.Composition.State != meshdeliverycheckerclient.CompositionNotRun { - t.Fatalf("%s: composed %d times: %+v", row.name, len(comps.asked), v) - } - if ends != nil { - if got := strings.Join(slices.Sorted(maps.Keys(ends.asked)), ", "); got != row.waited || ends.early { - t.Errorf("%s: waited on %q (after the composition: %v), want %q before it composes", row.name, got, ends.early, row.waited) - } - } - switch { - case row.failed != "" && (v.State != meshdeliverycheckerclient.VerdictFail || v.Failed.Test != row.failed || !strings.Contains(v.Failed.Words, "undefined: x") || - !strings.Contains(v.Failed.Words, "the check asks itself again when the build is done")): - t.Errorf("%s: the verdict is %s failing %+v, want it failed naming %s, the builder's words and how it is asked again", row.name, v.State, v.Failed, row.failed) - case row.tests && v.State != meshdeliverycheckerclient.VerdictFail: - t.Errorf("%s: %+v, want the tests' failure", row.name, v) - case row.failed == "" && !row.tests && v.State != meshdeliverycheckerclient.VerdictPass: - t.Errorf("%s: %+v", row.name, v) - } - words := compositionWords(v.Composition, v.Took.Composition) - for _, w := range row.want { - if !strings.Contains(words, w) { - t.Errorf("%s: the line says %q, want it to name %q", row.name, words, w) - } - } - if row.want == nil && v.Composition.Words != "" { - t.Errorf("%s: warned %q though the check waited on every build of the change", row.name, v.Composition.Words) - } - } -} - -func ptr[T any](v T) *T { return &v } diff --git a/modules/mesh-delivery-checker/internal/check/couldnotrun.go b/modules/mesh-delivery-checker/internal/check/couldnotrun.go deleted file mode 100644 index 067c42c5..00000000 --- a/modules/mesh-delivery-checker/internal/check/couldnotrun.go +++ /dev/null @@ -1,275 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "sort" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// A check that failed because a part of the mesh was not heard says `could not run`, naming the part, and releases its -// claim on the verdict key (design 47, *A check runs to its end*; issue 1373). It is asked again once per set of heads and -// per part returning, on the one event that can change its outcome: the node-engine seat's `running..` -// naming that part (PartRunning), never on a timer; a `running` of the same part at the same fingerprint after that asks -// nothing. One not asked again within CouldNotRunBound becomes the checker's finding CouldNotRunKind, which clears when the -// heads are checked again, replaced, or their pull request closes. -// -// What the checker knows of each such check is its own state could-not-run (CouldNotRunState), one key per verdict key, -// read by checker_status (could_not_run): kept on the bus, so a checker started again asks each one again on the next -// `running` and raises its finding at the same time. - -// CouldNotRunState is the checker's own state of its checks that could not run, by verdict key. -const CouldNotRunState = "could-not-run" - -// CouldNotRunKind is the checker's finding of a check that could not run and was not asked again within CouldNotRunBound. -const CouldNotRunKind = "check-could-not-run" - -// CouldNotRunBound is how long a check that could not run waits to be asked again before it is a finding: the check's own -// bound of an hour. -const CouldNotRunBound = time.Hour - -// Part is a part of the mesh a check could not hear: the node it runs on and its module, as the node-engine seat's -// `running..` names it. An empty field is not known: an empty Module is any part on Node, and an empty Node is -// Module wherever it runs; a Part with neither is a part the check could not name, asked again on the first `running`. -type Part struct { - Node string `json:"node,omitempty"` - Module string `json:"module,omitempty"` -} - -// String names the part as a verdict says it. -func (p Part) String() string { - switch { - case p.Node != "" && p.Module != "": - return p.Module + " on " + p.Node - case p.Module != "": - return p.Module - case p.Node != "": - return "the node " + p.Node - } - return "a part of the mesh" -} - -// matches says whether a `running` of module on node is the part's return. -func (p Part) matches(node, module string) bool { - return (p.Node == "" || p.Node == node) && (p.Module == "" || p.Module == module) -} - -// CouldNotRun is one check that could not run, as the state could-not-run keeps it. -type CouldNotRun struct { - V int `json:"v"` - Group string `json:"group"` - Heads string `json:"heads"` - Part Part `json:"part"` - Words string `json:"words"` - // Since is when its verdict was written; CouldNotRunBound after it, not asked again, it is a finding. - Since time.Time `json:"since"` - // AskedAt is the `running` that asked the check of these heads again, `.@`: a `running` of - // the same part at the same fingerprint asks nothing more. - AskedAt string `json:"asked-at,omitempty"` - // Raised says its finding is written. - Raised bool `json:"raised,omitempty"` -} - -// IsCouldNotRun says whether a verdict failed because a part of the mesh the check reads was not heard (UnheardWords): its -// claim is released, and it is asked again when that part runs (PartRunning). -func IsCouldNotRun(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictFail && containsWords(failedOf(v).Words, UnheardWords) -} - -// running is how a `running` event is kept in AskedAt and in the release of a check. -func runningAt(node, module, fingerprint string) string { - return node + "." + module + "@" + fingerprint -} - -// PartRunning is the node-engine seat's `running..` at fingerprint: every check that could not run for want -// of that part, and was not asked again by the same part at the same fingerprint, is released and asked again once. -func (ch *Checker) PartRunning(ctx context.Context, node, module, fingerprint string) { - ch.init() - if ch.CouldNotRun == nil { - return - } - keys, err := ch.CouldNotRun.Keys(ctx) - if err != nil { - ch.logf("the checks that could not run cannot be listed, so the running of %s on %s asks none again: %v", module, node, err) - return - } - at := runningAt(node, module, fingerprint) - released := 0 - for _, key := range keys { - r, _, ok := ch.couldNotRunOf(ctx, key) - if !ok || !r.Part.matches(node, module) || r.AskedAt == at { - continue - } - ch.mu.Lock() - ch.release[key] = at - ch.mu.Unlock() - released++ - ch.logf("%s: %s runs (%s), which the check could not hear: asked again", key, module, at) - } - if released > 0 { - ch.Reconsider(ctx) - } -} - -// couldNotRunOf reads one key of the state could-not-run. -func (ch *Checker) couldNotRunOf(ctx context.Context, key string) (CouldNotRun, uint64, bool) { - raw, rev, found, err := ch.CouldNotRun.Get(ctx, key) - if err != nil || !found || len(raw) == 0 { - return CouldNotRun{}, 0, false - } - var r CouldNotRun - if json.Unmarshal(raw, &r) != nil { - return CouldNotRun{}, 0, false - } - return r, rev, true -} - -// takeRelease answers the `running` that released the check of key, once, and forgets it. -func (ch *Checker) takeRelease(key string) (string, bool) { - ch.mu.Lock() - defer ch.mu.Unlock() - at, ok := ch.release[key] - delete(ch.release, key) - return at, ok -} - -// keepCouldNotRun writes the check's record after a verdict that could not run, asked again by askedAt ("" for none). -func (ch *Checker) keepCouldNotRun(ctx context.Context, cs *Case, v meshdeliverychecker.VerdictsByGroupHeadsValue, part Part, askedAt string) { - if ch.CouldNotRun == nil { - return - } - r := CouldNotRun{V: 1, Group: cs.Group, Heads: cs.Heads, Part: part, Words: failedOf(v).Words, Since: ch.now().UTC(), AskedAt: askedAt} - data, err := json.Marshal(r) - if err != nil { - return - } - _, rev, found, err := ch.CouldNotRun.Get(ctx, cs.Key) - if err == nil && found { - _, err = ch.CouldNotRun.Update(ctx, cs.Key, data, rev) - } else if err == nil { - _, err = ch.CouldNotRun.Create(ctx, cs.Key, data) - } - if err != nil { - ch.logf("%s: could not run, and that cannot be kept, so no running of %s asks it again until it is checked again: %v", cs.Key, part, err) - return - } - if ch.CouldNotRunKept != nil { - ch.CouldNotRunKept() - } -} - -// clearCouldNotRun forgets the check of key that could not run, and clears its finding: its heads are checked again, -// replaced, or their pull request closed. -func (ch *Checker) clearCouldNotRun(ctx context.Context, key string) { - if ch.CouldNotRun == nil { - return - } - r, _, ok := ch.couldNotRunOf(ctx, key) - if !ok { - return - } - if d, can := ch.CouldNotRun.(Deleter); can { - if err := d.Delete(ctx, key); err != nil { - ch.logf("%s: the record that it could not run cannot be deleted: %v", key, err) - return - } - } - if r.Raised && ch.Findings != nil { - if err := ch.Findings.Delete(couldNotRunFinding(key, r, ch.now())); err != nil { - ch.logf("%s: its finding %s cannot be cleared: %v", key, CouldNotRunKind, err) - } - } -} - -// CouldNotRunDue raises the finding of every check that could not run and was not asked again within CouldNotRunBound by -// now, and answers when the next one is due (the zero time when none waits). The checker's process waits for that time; -// a test gives now. -func (ch *Checker) CouldNotRunDue(ctx context.Context, now time.Time) time.Time { - if ch.CouldNotRun == nil { - return time.Time{} - } - keys, err := ch.CouldNotRun.Keys(ctx) - if err != nil { - ch.logf("the checks that could not run cannot be listed, so none is raised as %s now: %v", CouldNotRunKind, err) - return time.Time{} - } - sort.Strings(keys) - var next time.Time - for _, key := range keys { - r, rev, ok := ch.couldNotRunOf(ctx, key) - if !ok || r.Raised { - continue - } - due := r.Since.Add(CouldNotRunBound) - if now.Before(due) { - if next.IsZero() || due.Before(next) { - next = due - } - continue - } - if ch.Findings == nil { - continue - } - if err := ch.Findings.Put(couldNotRunFinding(key, r, now)); err != nil { - ch.logf("%s: its finding %s cannot be written: %v", key, CouldNotRunKind, err) - continue - } - r.Raised = true - if data, err := json.Marshal(r); err == nil { - if _, err := ch.CouldNotRun.Update(ctx, key, data, rev); err != nil && !errors.Is(err, ErrConflict) { - ch.logf("%s: its finding is written, and that cannot be kept: %v", key, err) - } - } - } - return next -} - -// Finding is the checker's finding of a check that could not run, in plain fields: the checker's writer lays it out as the seat -// mesh-conditions' finding (design 47 G §689). -type Finding struct { - Kind, ID, Summary, Headline, Explanation string - At time.Time -} - -// FindingWriter writes and clears the checker's findings. -type FindingWriter interface { - Put(f Finding) error - Delete(f Finding) error -} - -// RaisedCouldNotRun is every finding the checker observes now (design 47 G §384, §461): the check that could not run -// and whose finding is written. The finding writer states them at its start and when the keeper asks. -func (ch *Checker) RaisedCouldNotRun(ctx context.Context) ([]Finding, error) { - if ch.CouldNotRun == nil { - return nil, nil - } - keys, err := ch.CouldNotRun.Keys(ctx) - if err != nil { - return nil, fmt.Errorf("the checks that could not run cannot be listed: %w", err) - } - sort.Strings(keys) - var out []Finding - for _, key := range keys { - if r, _, ok := ch.couldNotRunOf(ctx, key); ok && r.Raised { - out = append(out, couldNotRunFinding(key, r, r.Since)) - } - } - return out, nil -} - -// couldNotRunFinding is the finding of the check of key that could not run. -func couldNotRunFinding(key string, r CouldNotRun, at time.Time) Finding { - return Finding{Kind: CouldNotRunKind, ID: key, - Summary: fmt.Sprintf("the check of %s (heads %s) could not run since %s: %s was not heard, and has not run since", - r.Group, r.Heads, r.Since.UTC().Format(time.RFC3339), r.Part), - Headline: fmt.Sprintf("The check of %s could not run", r.Group), - Explanation: "A check that cannot hear a part of the mesh it reads says so and is asked again when that part runs. " + - "It has not run for an hour: look at " + r.Part.String() + ". The finding clears when the heads are checked again, " + - "replaced, or their pull request closes.", - At: at.UTC()} -} diff --git a/modules/mesh-delivery-checker/internal/check/declared.go b/modules/mesh-delivery-checker/internal/check/declared.go deleted file mode 100644 index 95bf4c55..00000000 --- a/modules/mesh-delivery-checker/internal/check/declared.go +++ /dev/null @@ -1,115 +0,0 @@ -package check - -import ( - "context" - "errors" - "fmt" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-sdk/go/catalogue" -) - -// declaredPackage is one package a group member declares: the module, its directory in the repository (RootPath for its -// root, empty when not known), and the artifact's name, paths and language. -type declaredPackage struct { - pull Pull - module, dir string - name string - paths []string - language string -} - -// manifestAtHead is a touched module's manifest read from the forge at its member's head (the lead's ruling 4 on A2c's -// finding 4): with no preview of the merge, a package new in the group is declared only there, never at the trunk. The -// module's directory is the indexer's when it knows the module, else modules/ or the repository's root, the one -// whose manifest names the module. Found is false when no such file names it. -func (st *state) manifestAtHead(ctx context.Context, p Pull, module string) (m catalogue.Manifest, dir string, found bool, err error) { - var dirs []string - if st.j.Dirs != nil { - if d, ok := st.j.Dirs.ModuleDir(module); ok { - dirs = []string{d} - } - } - if dirs == nil { - dirs = []string{"modules/" + module, meshcatalogclient.RootPath} - } - for _, d := range dirs { - file := "module.json" - if t := strings.Trim(d, "/"); t != "" && t != meshcatalogclient.RootPath { - file = t + "/module.json" - } - text, err := st.j.Forge.File(ctx, p.Repository, file, p.Head) - if errors.Is(err, ErrNotFound) { - continue - } - if err != nil { - return catalogue.Manifest{}, "", false, fmt.Errorf("the manifest of %s at the head of %s cannot be read%s: %w", module, pullKey(p), unheardWords(err), err) - } - m, err := catalogue.Decode([]byte(text)) - if err != nil { - return catalogue.Manifest{}, "", false, fmt.Errorf("the manifest %s of %s at the head of %s is no manifest: %w", file, module, pullKey(p), err) - } - if m.Module == module { - return m, d, true, nil - } - } - return catalogue.Manifest{}, "", false, nil -} - -// declaredPackages are the packages the case's members declare, read from each touched module's manifest at the merge -// preview (the candidate's); with no preview, at the member's head on the forge, so a package new in the group is asked -// for on the first check too (trunk's manifest when no forge is read): a member that declares none is not asked for. -func (st *state) declaredPackages(ctx context.Context) ([]declaredPackage, error) { - if st.j.Read == nil && st.j.Forge == nil { - return nil, nil - } - var trunk map[string]string - if st.j.Manifests != nil { - trunk = st.j.Manifests.ManifestDigests() - } - var out []declaredPackage - for _, p := range st.c.Pulls { - for _, module := range p.Modules { - var m catalogue.Manifest - var dir string - digest := p.Fps[module].Manifest - switch { - case digest != "" && st.j.Read != nil: - var err error - if m, err = st.j.Read.Manifest(ctx, digest); err != nil { - return nil, fmt.Errorf("the manifest of %s (%s) cannot be read, so the packages it declares are not known: %w", module, pullKey(p), err) - } - case st.j.Forge != nil: - var found bool - var err error - if m, dir, found, err = st.manifestAtHead(ctx, p, module); err != nil { - return nil, fmt.Errorf("%v, so the packages it declares are not known", err) - } - if !found { - continue - } - case trunk[module] != "" && st.j.Read != nil: - var err error - if m, err = st.j.Read.Manifest(ctx, trunk[module]); err != nil { - return nil, fmt.Errorf("the manifest of %s (%s) cannot be read, so the packages it declares are not known: %w", module, pullKey(p), err) - } - default: - continue - } - if dir == "" && st.j.Dirs != nil { - dir, _ = st.j.Dirs.ModuleDir(module) - } - if m.Build == nil { - continue - } - for _, a := range m.Build.Artifacts { - if a.Kind != catalogue.ArtifactPackage { - continue - } - out = append(out, declaredPackage{pull: p, module: module, dir: dir, name: a.Name, paths: a.Paths, language: a.Language}) - } - } - } - return out, nil -} diff --git a/modules/mesh-delivery-checker/internal/check/digestform_test.go b/modules/mesh-delivery-checker/internal/check/digestform_test.go deleted file mode 100644 index 1648c337..00000000 --- a/modules/mesh-delivery-checker/internal/check/digestform_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package check - -import ( - "encoding/json" - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// 1930/AC3: given a check ask whose stored end keeps the digest's packages as a list of {package, digest} (issue 1930), -// or one stored before it with the packages a map keyed by package path, when the same heads are checked a second time, -// then the kept verdicts the first check wrote are read from it: every package it passed is kept, none run again. -func TestKeptVerdictsAreReadFromTheDigestsListForm(t *testing.T) { - for _, tc := range []struct { - name string - old bool - }{{"the list form", false}, {"a map stored before issue 1930", true}} { - t.Run(tc.name, func(t *testing.T) { - b := newBench(t) - var stored []string - b.asks.Answer = func(a buildstep.StepAsk) buildstep.Step { - s := b.answer(a) - if tc.old && s.State == buildstep.StepPassed { - s.Result = oldDigestForm(t, s.Result) - } - stored = append(stored, string(s.Result)) - return s - } - first := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - u := first.Levels[buildstep.LevelUnit] - if first.State != meshdeliverycheckerclient.VerdictPass || u.Run == 0 || u.Kept != 0 { - t.Fatalf("the first check = %+v", first) - } - if len(stored) == 0 { - t.Fatal("no ask's end was stored") - } - list := strings.Contains(stored[0], `"packages":[{"package":"fixture/slow"`) - if list == tc.old || strings.Contains(stored[0], `"fixture/slow":"`) != tc.old { - t.Fatalf("the stored end is not in the form under test: %s", stored[0]) - } - b.steps.calls = nil - second := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if s := second.Levels[buildstep.LevelUnit]; second.State != meshdeliverycheckerclient.VerdictPass || s.Kept != u.Run || s.Run != 0 { - t.Fatalf("the second check's unit level = %+v, want %d kept and none run", s, u.Run) - } - if n := len(b.steps.tool("test")); n != 0 { - t.Errorf("%d test steps ran on the second check", n) - } - }) - } -} - -// oldDigestForm rewrites a check answer's level digests to the form stored before issue 1930: packages as a map keyed by -// package path. -func oldDigestForm(t *testing.T, result json.RawMessage) json.RawMessage { - t.Helper() - var a struct { - Fetch json.RawMessage `json:"fetch"` - Levels []map[string]any `json:"levels"` - } - if err := json.Unmarshal(result, &a); err != nil { - t.Fatal(err) - } - for _, l := range a.Levels { - d, ok := l["digest"].(map[string]any) - if !ok { - continue - } - m := map[string]any{} - list, _ := d["packages"].([]any) - for _, p := range list { - pd := p.(map[string]any) - m[pd["package"].(string)] = pd["digest"] - } - d["packages"] = m - } - raw, err := json.Marshal(a) - if err != nil { - t.Fatal(err) - } - return raw -} diff --git a/modules/mesh-delivery-checker/internal/check/doc.go b/modules/mesh-delivery-checker/internal/check/doc.go deleted file mode 100644 index 781347eb..00000000 --- a/modules/mesh-delivery-checker/internal/check/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// Package check is the checker's logic (novox/hq ADR 0484, ADR 0453 clause 4, ADR 0447, ADR 0444), apart from the bus: the -// claim of a verdict key, the judging of a pull request's head merged onto its trunk through the build modules' fetch, -// digest and test steps, the kept verdicts, the line of the status and the act the forge bridge performs. The bus is -// reached through the small interfaces here, so each part is tested with fakes. The checker runs dark: nothing reads its -// answers to merge or deliver (ADR 0453 clause 4). -package check diff --git a/modules/mesh-delivery-checker/internal/check/engines.go b/modules/mesh-delivery-checker/internal/check/engines.go deleted file mode 100644 index bf2fc352..00000000 --- a/modules/mesh-delivery-checker/internal/check/engines.go +++ /dev/null @@ -1,261 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "fmt" - "mesh-delivery-checker/rules" - "sort" - "strings" - "sync" - "time" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" -) - -// **A check's composition is the checker's, made from what each node's engine answers** (novox/hq ADR 0593 §7, §9). -// Only a node knows whether a change composes there: the checker asks every placed node's engine -// `node-engine.compose-candidate` in parallel, with the check's candidate, and waits at most its answer bound -// (compose-answer-bound, 60 s by default). A node that refuses fails the check, naming the node and each module with the -// engine's words; a node that does not answer within the bound, answers unready or cannot be asked is named, "not composed -// on that node: no answer", and the check passes with that warning: its own composition judges again when it applies, -// and the canary rule holds. The checker decides by the answer's verdict, never by its words. -// -// **A group that changes the node-engine's composition code** (a member of the node-engine's repository) is not judged by -// the running engines, which cannot judge their own next code: each node's engine answers the composition input it -// composed from (ne.ComposeCandidateInput.Input), and the composer program built from that member's head composes it in a -// build module's sandbox (Sandbox), with every manifest of the catalogue as the case leaves it and the indexer's verdicts. - -// EngineAsker asks one node's engine to compose a check's candidate (the verb node-engine.compose-candidate on that node). -type EngineAsker interface { - ComposeCandidate(ctx context.Context, node string, ask ne.ComposeCandidateInput) (ne.ComposeCandidateAnswer, error) -} - -// Sandbox runs a compose job on the Go build seat and answers the composer's verdict. -type Sandbox interface { - Compose(ctx context.Context, job buildstep.ComposeJob) (composer.Verdict, error) -} - -// EngineCompositions is the checker's composition of a check (Examiner.Compositions). -type EngineCompositions struct { - Asker EngineAsker - // Placed names every node in assignments now (the seat mesh-module-assigner's state), or why it cannot be read: then no node - // can be asked, and the composition is not made (an error), never passed with nobody asked. - Placed func() ([]string, error) - // Bound is the answer bound (the setting compose-answer-bound); zero is nec.AnswerBound. - Bound time.Duration - // Composer is the node-engine's trunk head: a check whose group has no node-engine member is composed by the composer - // built there, so every check composes with an acting part built from the change's heads or their trunk, never with - // the running engines' own code (ADR 0656 §5; the lead's ruling Q3 on milestone 47/G). Nil, or an empty head, leaves - // such a check composed by the running engines, said. - Composer func() string - // Sandbox runs the composer of a node-engine member's head; nil leaves such a group judged by the running engines, - // said in a warning. - Sandbox Sandbox - // Manifests are the indexer's trunk manifest digests by module, and Verdicts its refusals of them: the catalogue the - // sandbox composes with, before the case's own manifests are laid over. - Manifests TrunkManifests - // Published names the latest published version of every mesh package (Examiner.Published): the composer is built - // against them and the group's heads, as a check is (issue 1921); nil names the group's heads alone. - Published interface { - LatestPackages() buildstep.PackageVersions - } - Verdicts func() map[string]meshcatalog.VerdictsByDigestValue - // Requests keeps each request sent to the composer, per check and node (issue 1921); nil keeps none. A request that - // cannot be kept fails the node's composition, naming why: never dropped. - Requests interface { - Keep(ctx context.Context, key, node string, body []byte) error - } -} - -// composerHead is the node-engine member's head of a case, or empty. -// atWord names where a composer was built: the member's head or the node-engine's trunk. -func atWord(member bool) string { - if member { - return "head" - } - return "trunk" -} - -func composerHead(c *Case) string { - if m := c.member(nodeEngineRepo); m != nil { - return m.Head - } - return "" -} - -// Compose asks every placed node and answers their answers, for the rules to judge (rules.JudgeEngines). An error is only a -// case it cannot ask at all. -func (e EngineCompositions) Compose(ctx context.Context, c *Case) (rules.Composed, error) { - began := time.Now() - key, err := nodeengineclient.CompositionKey(c.Group, c.Heads) - if err != nil { - return rules.Composed{}, err - } - var nodes []string - if e.Placed != nil { - if nodes, err = e.Placed(); err != nil { - return rules.Composed{}, fmt.Errorf("the assignments cannot be read, so no node can be asked: %w", err) - } - } - bound := e.Bound - if bound <= 0 { - bound = nec.AnswerBound - } - // One composition path (ADR 0656 §5): the composer built at the node-engine member's head, else at its trunk. - head, member := composerHead(c), true - if head == "" && e.Composer != nil { - head, member = e.Composer(), false - } - sandboxed := head != "" && e.Sandbox != nil - answers := map[string]ne.ComposeCandidateAnswer{} - silent := map[string]string{} - var mu sync.Mutex - var wg sync.WaitGroup - for _, node := range nodes { - wg.Add(1) - go func() { - defer wg.Done() - at, cancel := context.WithTimeout(ctx, bound) - defer cancel() - a, err := e.Asker.ComposeCandidate(at, node, ne.ComposeCandidateInput{Candidate: key, Input: sandboxed}) - if err == nil && sandboxed && a.Verdict != nec.Unready { - // The composer's build and run are the check's to bound, not the engine's answer bound. A composer that - // cannot run is no silent node (ADR 0593 §9 lets only that pass): the node's composition fails, naming - // the head. - if composed, serr := e.inSandbox(ctx, c, head, node, a); serr != nil { - a = ne.ComposeCandidateAnswer{V: a.V, Node: node, Candidate: a.Candidate, Verdict: nec.Refused, - Refused: "the composer at the node-engine's " + atWord(member) + " " + head + " could not compose it: " + serr.Error()} - } else { - a = composed - } - } - mu.Lock() - defer mu.Unlock() - switch { - case err != nil: - silent[node] = err.Error() - case a.Verdict == nec.Unready: - silent[node] = "unready" - default: - answers[node] = a - } - }() - } - wg.Wait() - // What composed, named by the node-engine's commit: the member's head in the sandbox, else the one the mesh runs. - composerName := "node-engine" - if sandboxed { - composerName = head - } - v := rules.Composed{Group: c.Group, Heads: c.HeadsHash, Composer: composerName, Nodes: nodes, Answers: answers, Silent: silent} - switch { - case member && head != "" && e.Sandbox == nil: - v.Warnings = append(v.Warnings, "the group changes the node-engine's composition code and was composed by the running engines") - case !sandboxed && e.Sandbox != nil && len(nodes) > 0: - v.Warnings = append(v.Warnings, "composed by the running engines: no composer at the node-engine's trunk is known to build") - } - v.Took = time.Since(began).Milliseconds() - return v, nil -} - -// inSandbox composes a node's answer again with the composer built from the node-engine member's head, over the input the -// node's engine composed from: the node's answer becomes the sandbox's, refused with the composer's words where the -// composer refuses the node. -func (e EngineCompositions) inSandbox(ctx context.Context, c *Case, head, node string, a ne.ComposeCandidateAnswer) (ne.ComposeCandidateAnswer, error) { - if len(a.Input) == 0 { - return a, fmt.Errorf("the engine of %s answered no composition input, so the node-engine's head cannot compose it", node) - } - manifests := map[string]composer.Manifest{} - if e.Manifests != nil { - fps := e.Manifests.ManifestFingerprints() - for name, digest := range e.Manifests.ManifestDigests() { - manifests[name] = composer.Manifest{Digest: digest, Fingerprint: fps[name]} - } - } - for _, p := range c.Pulls { - for name, m := range p.Fps { - if m.Manifest != "" { - manifests[name] = composer.Manifest{Digest: m.Manifest, Fingerprint: m.Fp2} - } - } - } - verdicts := map[string]json.RawMessage{} - if e.Verdicts != nil { - for name, v := range e.Verdicts() { - raw, err := json.Marshal(v) - if err != nil { - return a, fmt.Errorf("the verdict of the manifest of %s cannot be encoded: %w", name, err) - } - verdicts[name] = raw - } - } - // A manifest the change brings is the check's own judge's (ADR 0578 §2, §3): its verdict there when the judge gave one, - // else none, which the composer reads as accepted; never the running indexer's (F5 of milestone 47/G). - for _, p := range c.Pulls { - for name := range p.Fps { - delete(verdicts, name) - if raw, ok := c.Judged[name]; ok { - verdicts[name] = raw - } - } - } - // The answer carries its input as the object the seat's contract names, decoded with its numbers as written - // (json.Number), so encoding it again gives the composer the same values the engine sent. - input, err := json.Marshal(a.Input) - if err != nil { - return a, fmt.Errorf("the engine of %s answered a composition input that cannot be encoded again: %w", node, err) - } - req := composer.Request{V: composer.Version, Input: input, Depth: composer.DepthCompose, Machines: []string{node}, - Cases: []composer.Case{{Name: "change", Manifests: manifests, Verdicts: verdicts}}, Seats: c.Seats} - raw, err := json.Marshal(req) - if err != nil { - return a, err - } - if e.Requests != nil { - key, err := nodeengineclient.CompositionKey(c.Group, c.Heads) - if err == nil { - err = e.Requests.Keep(ctx, key, node, raw) - } - if err != nil { - return a, err - } - } - job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Dir: meshcatalogclient.RootPath, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath, - Package: composer.Package, Request: raw, Reader: "the node-engine head of " + c.Group} - // The ask travels on the bus, whose message limit a whole request passes (1.2 MB for a large node): it goes packed. - if err := job.PackRequest(raw); err != nil { - return a, err - } - verdict, err := e.Sandbox.Compose(ctx, job) - if err != nil { - return a, fmt.Errorf("the composer at the node-engine's head %s did not answer for %s: %w", head, node, err) - } - out := ne.ComposeCandidateAnswer{V: a.V, Node: node, Candidate: a.Candidate, Verdict: nec.Composed} - notJudged := "" - for _, cv := range verdict.Cases { - if m, ok := cv.Machines[node]; ok && m.NotJudged != "" { - notJudged = m.NotJudged // the composer did not judge the node: neither composed nor refused (ADR 0593 §9) - } else if ok && !m.Composes { - out.Verdict = nec.Refused - out.Refused = strings.Join(append(append([]string{m.Reason}, m.Problems...), m.Refusals...), "; ") - } - for name, read := range cv.Manifests { - if !read.Accepted { - out.Verdict = nec.Refused - out.Modules = append(out.Modules, ne.Module{Module: name, State: nec.ModuleRefused, Words: read.Refused}) - } - } - } - sort.Slice(out.Modules, func(i, j int) bool { return out.Modules[i].Module < out.Modules[j].Module }) - if notJudged != "" && out.Verdict == nec.Composed { - out.Verdict, out.Refused = nec.NotJudged, notJudged - } - return out, nil -} diff --git a/modules/mesh-delivery-checker/internal/check/engines_test.go b/modules/mesh-delivery-checker/internal/check/engines_test.go deleted file mode 100644 index 66483abb..00000000 --- a/modules/mesh-delivery-checker/internal/check/engines_test.go +++ /dev/null @@ -1,392 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "mesh-delivery-checker/rules" - "strings" - "sync" - "testing" - "time" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" -) - -// fakeEngines answers compose-candidate by node from memory; a node it holds no answer for never answers. -type fakeEngines struct { - mu sync.Mutex - answers map[string]ne.ComposeCandidateAnswer - errs map[string]error - asked map[string]ne.ComposeCandidateInput -} - -func (f *fakeEngines) ComposeCandidate(ctx context.Context, node string, ask ne.ComposeCandidateInput) (ne.ComposeCandidateAnswer, error) { - f.mu.Lock() - if f.asked == nil { - f.asked = map[string]ne.ComposeCandidateInput{} - } - f.asked[node] = ask - a, ok := f.answers[node] - err := f.errs[node] - f.mu.Unlock() - if err != nil { - return ne.ComposeCandidateAnswer{}, err - } - if !ok { - <-ctx.Done() - return ne.ComposeCandidateAnswer{}, ctx.Err() - } - return a, nil -} - -// fakeSandbox answers a compose job with a verdict, recording the job. -type fakeSandbox struct { - mu sync.Mutex - jobs []buildstep.ComposeJob - v func(node string) composer.Verdict - err error -} - -func (f *fakeSandbox) Compose(_ context.Context, job buildstep.ComposeJob) (composer.Verdict, error) { - var req composer.Request - body, err := job.RequestBytes() - if err != nil { - return composer.Verdict{}, err - } - if err := json.Unmarshal(body, &req); err != nil { - return composer.Verdict{}, err - } - f.mu.Lock() - f.jobs = append(f.jobs, job) - f.mu.Unlock() - if f.err != nil { - return composer.Verdict{}, f.err - } - return f.v(req.Machines[0]), nil -} - -// keptRequests is the state of composition requests in memory; a put fails with err when it is set. -type keptRequests struct { - mu sync.Mutex - vals map[string][]byte - err error -} - -func (k *keptRequests) Put(_ context.Context, key string, value []byte) (uint64, error) { - k.mu.Lock() - defer k.mu.Unlock() - if k.err != nil { - return 0, k.err - } - if k.vals == nil { - k.vals = map[string][]byte{} - } - k.vals[key] = value - return 1, nil -} - -func (k *keptRequests) read() StateRead { - return StateRead{Keys: func() ([]string, error) { - var out []string - for n := range k.vals { - out = append(out, n) - } - return out, nil - }, Get: func(key string) (json.RawMessage, error) { return k.vals[key], nil }} -} - -type digests map[string]string - -func (d digests) ManifestDigests() map[string]string { return d } - -// ManifestFingerprints: the trunk entry of each module is src2: in a test. -func (d digests) ManifestFingerprints() map[string]string { - out := map[string]string{} - for m := range d { - out[m] = "src2:" + m - } - return out -} - -// ADR 0593 §7, §9 (D12, G1, G2): the checker asks every placed node's engine in parallel and makes the composition from -// their answers: a refusal fails it naming the node and each module; a node that does not answer within the bound, -// answers unready or cannot be asked is named "not composed on that node: no answer" and the check passes with that -// warning, decided by the verdict and never by its words; a group with a node-engine member is composed by the composer -// built at that member's head, over the input each node's engine composed from. -func TestTheCompositionIsMadeFromTheEnginesAnswers(t *testing.T) { - composed := func(node string) ne.ComposeCandidateAnswer { - return ne.ComposeCandidateAnswer{Node: node, Verdict: nec.Composed, - Modules: []ne.Module{{Module: "web", State: nec.ModuleComposed, Digest: "sha256:" + strings.Repeat("a", 64)}}, - Own: ne.Module{Module: nec.Own, State: nec.ModuleComposed, Digest: "sha256:" + strings.Repeat("b", 64)}} - } - cs := caseOf(t, pullOf(repoA, 7, head1)) - key, _ := nodeengineclient.CompositionKey(cs.Group, cs.HeadsHash) - var last rules.Composed // the engines' answers of the last compose, for the check's verdict to take in - compose := func(e *fakeEngines, nodes ...string) meshwants.CompositionsByGroupHeadsValue { - t.Helper() - ec := EngineCompositions{Asker: e, Placed: func() ([]string, error) { return nodes, nil }, Bound: 50 * time.Millisecond, - Composer: func() string { return strings.Repeat("7", 40) }} - raw, err := ec.Compose(context.Background(), cs) - if err != nil { - t.Fatal(err) - } - last = raw - return rules.JudgeEngines(raw) - } - - t.Run("one node refusing fails the composition, naming the node and the module", func(t *testing.T) { - refusing := composed("laptop") - refusing.Verdict = nec.Refused - refusing.Modules = []ne.Module{{Module: "web", State: nec.ModuleRefused, Words: "a required value is unset"}, - {Module: "mail", State: nec.ModuleHeld, Words: "held as today"}} - e := &fakeEngines{answers: map[string]ne.ComposeCandidateAnswer{"anchor": composed("anchor"), "laptop": refusing}} - v := compose(e, "anchor", "laptop") - if v.State != meshdeliverycheckerclient.CompositionFail || v.Machine != "laptop" || !strings.Contains(v.Words, "not composed on laptop: web: a required value is unset") || - strings.Contains(v.Words, "mail") || len(v.Machines) != 2 { - t.Errorf("verdict = %+v", v) - } - if e.asked["anchor"].Candidate != key || e.asked["laptop"].Input { - t.Errorf("asked %+v, want the check's candidate %s and no input", e.asked, key) - } - var ver meshdeliverychecker.VerdictsByGroupHeadsValue - rules.JudgeComposition(&ver, rules.Composition{Composed: &last}) - if ver.State != meshdeliverycheckerclient.VerdictFail || ver.Failed.Machine != "laptop" { - t.Errorf("the check's verdict = %+v", ver) - } - }) - - t.Run("a silent, unready or unreachable node is no answer, and the check passes naming it", func(t *testing.T) { - unready := ne.ComposeCandidateAnswer{Node: "g14", Verdict: nec.Unready, Refused: "a module refused it"} - e := &fakeEngines{answers: map[string]ne.ComposeCandidateAnswer{"anchor": composed("anchor"), "g14": unready}, - errs: map[string]error{"ace": errors.New("no responders")}} - began := time.Now() - v := compose(e, "anchor", "laptop", "g14", "ace") - if took := time.Since(began); took > 2*time.Second { - t.Errorf("the nodes were not asked in parallel within the bound: %s", took) - } - // No sandbox: the running engines composed, named so, though the node-engine's trunk head is known. - if v.State != meshdeliverycheckerclient.CompositionPass || v.Sdk != "node-engine" || len(v.Machines) != 1 { - t.Fatalf("verdict = %+v", v) - } - for _, node := range []string{"ace", "g14", "laptop"} { - if !strings.Contains(strings.Join(v.Warnings, "; "), node+": "+nec.NoAnswer) { - t.Errorf("%s is not named: %v", node, v.Warnings) - } - } - var ver meshdeliverychecker.VerdictsByGroupHeadsValue - ver.State = meshdeliverycheckerclient.VerdictPass - rules.JudgeComposition(&ver, rules.Composition{Composed: &last}) - if ver.State != meshdeliverycheckerclient.VerdictPass || !strings.Contains(composition(ver.Composition, 0, false), "laptop: "+nec.NoAnswer) { - t.Errorf("the line = %q", composition(ver.Composition, 0, false)) - } - }) - - t.Run("a node-engine member is composed by the composer at its head over each node's input", func(t *testing.T) { - c, err := meshcatalog.DecodeCandidatesByGroupValue(candidateOf(t, "feat/x", pullOf(nodeEngineRepo, 3, head2), pullOf(repoA, 7, head1))) - if err != nil { - t.Fatal(err) - } - host := CaseOf(c, map[string]string{repoA: trunkA, nodeEngineRepo: trunkA}) - host.Seats = []json.RawMessage{json.RawMessage(`{"seat":"node-x","scope":"node"}`)} // the heads' list (ADR 0636 §4) - withInput := composed("anchor") - withInput.Input = map[string]any{"nodes": []any{map[string]any{"name": "anchor"}}} - // Issue 1966 (the group try of 2026-11-06 10:07): the composer at the head composes against the check's seat list. - host.Seats = []json.RawMessage{json.RawMessage(`{"format":1,"seat":"node-uplink"}`)} - e := &fakeEngines{answers: map[string]ne.ComposeCandidateAnswer{"anchor": withInput}} - sb := &fakeSandbox{v: func(node string) composer.Verdict { - return composer.Verdict{V: composer.Version, Cases: []composer.CaseVerdict{{Name: "change", - Machines: map[string]composer.Machine{node: {Composes: false, Reason: "the new composer refuses it"}}}}} - }} - ec := EngineCompositions{Asker: e, Placed: func() ([]string, error) { return []string{"anchor"}, nil }, Bound: time.Second, - Sandbox: sb, Manifests: digests{"web": "sha256:" + strings.Repeat("c", 64)}, Published: published{}} - raw, err := ec.Compose(context.Background(), host) - v := rules.JudgeEngines(raw) - if err != nil { - t.Fatal(err) - } - if !e.asked["anchor"].Input || len(sb.jobs) != 1 { - t.Fatalf("asked %+v, jobs %+v: want the input asked and one job", e.asked, sb.jobs) - } - job := sb.jobs[0] - if job.Fetch.Dir == "" || job.Fetch.Dir != job.Dir { // a build is for one module: its fetch names the directory (A-447b) - t.Errorf("the compose job's fetch names the directory %q, want its module's %q", job.Fetch.Dir, job.Dir) - } - var req composer.Request - if len(job.Request) == 0 || job.Request[0] != '"' { - t.Errorf("the request went whole, not packed (issue 1966): %.60s", job.Request) - } - body, _ := job.RequestBytes() - _ = json.Unmarshal(body, &req) - if job.Fetch.Repository != nodeEngineRepo || job.Fetch.Commit != head2 || job.Package != composer.Package || - string(req.Input) != `{"nodes":[{"name":"anchor"}]}` || req.Cases[0].Manifests["web"].Digest == "" || - len(req.Seats) != 1 || string(req.Seats[0]) != string(host.Seats[0]) { - t.Errorf("job = %+v, request %+v", job, req) - } - // Issue 1921 (notes 66-67): the request sent to the composer is kept per check and node, exactly as sent (read back - // whole through the tool's reader); a request that cannot be kept fails the node's composition, naming why. - store := &keptRequests{} - ec.Requests = RequestKeeper{Store: store} - if _, err := ec.Compose(context.Background(), host); err != nil { - t.Fatal(err) - } - keyOfHost, _ := nodeengineclient.CompositionKey(host.Group, host.Heads) - lastBody, _ := sb.jobs[len(sb.jobs)-1].RequestBytes() - got, err := ReadRequests(store.read(), keyOfHost, "anchor") - if b, _ := json.Marshal(got); err != nil || !strings.Contains(string(b), `"request":`+string(lastBody)) { - t.Errorf("kept %s, %v: want the request of the last job under %s/anchor", b, err, keyOfHost) - } - store.err = errors.New("the state is full") - raw, _ = ec.Compose(context.Background(), host) - if v := rules.JudgeEngines(raw); v.State != meshdeliverycheckerclient.CompositionFail || !strings.Contains(v.Words, "could not be kept") || !strings.Contains(v.Words, "the state is full") || !strings.Contains(v.Words, RequestsDropTool) { - t.Errorf("a request that cannot be kept gave %+v, which must name %s", v, RequestsDropTool) - } - // The drop tool: records the hand act first (a drop whose act is not recorded is not made), then drops that check's - // requests and the pieces no other kept request names; another check's stay. - store.err = nil - other := RequestKeeper{Store: store} - if err := other.Keep(context.Background(), "g.other", "anchor", []byte("another check's request")); err != nil { - t.Fatal(err) - } - drop := StateDrop{StateRead: store.read(), Delete: func(k string) error { store.mu.Lock(); delete(store.vals, k); store.mu.Unlock(); return nil }} - before := len(store.vals) - if _, err := DropRequests(drop, keyOfHost, "the state is full", func(string) error { return errors.New("no holder") }); err == nil || len(store.vals) != before { - t.Errorf("a drop whose hand act was not recorded was made: %v, %d of %d kept", err, len(store.vals), before) - } - var acts []string - answer, err := DropRequests(drop, keyOfHost, "the state is full", func(what string) error { acts = append(acts, what); return nil }) - if b, _ := json.Marshal(answer); err != nil || len(acts) != 1 || !strings.Contains(string(b), `"dropped_requests":["anchor"]`) { - t.Errorf("the drop answered %s, %v, acts %v", b, err, acts) - } - if _, still := store.vals[RequestKey(keyOfHost, "anchor")]; still { - t.Errorf("the dropped check's request is kept still") - } - if got, err := ReadRequests(store.read(), "g.other", "anchor"); err != nil || !strings.Contains(fmt.Sprint(got), "another check's request") { - t.Errorf("another check's request after the drop: %v, %v", got, err) - } - if _, err := DropRequests(drop, keyOfHost, "again", func(string) error { return nil }); err == nil { - t.Errorf("a check with no kept request was dropped") - } - ec.Requests = nil - // Issue 1921: the composer is built at the group's heads, also a member that publishes no package yet. - if pkgs := job.Fetch.Packages; len(pkgs) != 1 || pkgs[trunk.ForgeModulePrefix+"mesh-delivery"] != head1 { - t.Errorf("the composer is fetched with the packages %v, want the group's mesh-delivery member at its head %s alone", pkgs, head1) - } - if v.State != meshdeliverycheckerclient.CompositionFail || v.Sdk != head2 || !strings.Contains(v.Words, "the new composer refuses it") { - t.Errorf("verdict = %+v", v) - } - // ADR 0593 §9 (ADR 0601 §4's kind): a node the composer did not judge is named as no answer with its words, by the - // contract's field, and the check passes; words in Reason alone are no such mark. - sb.err = nil - for _, row := range []struct { - m composer.Machine - pass bool - }{ - {composer.Machine{NotJudged: "its node-engine sends no running state for web"}, true}, - {composer.Machine{Reason: "not judged: its node-engine sends no running state for web"}, false}, - } { - sb.v = func(node string) composer.Verdict { - return composer.Verdict{V: composer.Version, Cases: []composer.CaseVerdict{{Name: "change", Machines: map[string]composer.Machine{node: row.m}}}} - } - raw, err = ec.Compose(context.Background(), host) - v = rules.JudgeEngines(raw) - named := len(v.Warnings) == 1 && strings.Contains(v.Warnings[0], "anchor: "+nec.NoAnswer+" (its node-engine sends no running state for web)") - if err != nil || (v.State == meshdeliverycheckerclient.CompositionPass) != row.pass || named != row.pass { - t.Errorf("%+v: verdict %+v, %v", row.m, v, err) - } - } - // Review finding 3 (ADR 0593 §9 lets only a node that does not answer pass): a composer at the head that cannot - // run fails the composition, naming the head, never passing as a silent node. - sb.err = errors.New("the build of mesh-compose failed") - raw, err = ec.Compose(context.Background(), host) - v = rules.JudgeEngines(raw) - if err != nil || v.State != meshdeliverycheckerclient.CompositionFail || !strings.Contains(v.Words, head2) || - !strings.Contains(v.Words, "the build of mesh-compose failed") || len(v.Warnings) != 0 { - t.Errorf("a composer that cannot run: %+v, %v", v, err) - } - }) - - // ADR 0578 §2, §3, ADR 0656 §5 (milestone 47/G D12, D13): with no node-engine member, every node is composed by the - // composer built at the node-engine's trunk over the input its engine answers, and a manifest the change brings carries - // the check's own judge's verdict, not the running indexer's: one the running indexer refused and the judge accepted - // composes, and the verdict names the trunk's composer. - t.Run("a change's manifest the check's judge accepted is composed by the composer at the node-engine's trunk", func(t *testing.T) { - p := pullOf(repoA, 7, head1) - p.Modules = []string{"mesh-build-go"} - p.Fps = map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"mesh-build-go": {Fp2: "src2:" + strings.Repeat("f", 64), Manifest: strings.Repeat("d", 64)}} - brings := caseOf(t, p) - brings.Judged = map[string]json.RawMessage{"mesh-build-go": json.RawMessage(`{"module":"mesh-build-go","state":"accepted"}`)} - trunkHead := strings.Repeat("7", 40) - withInput := composed("anchor") - withInput.Input = map[string]any{"nodes": []any{map[string]any{"name": "anchor"}}} - e := &fakeEngines{answers: map[string]ne.ComposeCandidateAnswer{"anchor": withInput}} - sb := &fakeSandbox{v: func(node string) composer.Verdict { - return composer.Verdict{V: composer.Version, Cases: []composer.CaseVerdict{{Name: "change", - Machines: map[string]composer.Machine{node: {Composes: true}}}}} - }} - indexer := map[string]meshcatalog.VerdictsByDigestValue{"mesh-build-go": {Module: "mesh-build-go", State: "refused", Problems: []string{"serves no verb input"}}, "mail": {Module: "mail", State: "accepted"}} - ec := EngineCompositions{Asker: e, Placed: func() ([]string, error) { return []string{"anchor"}, nil }, Bound: time.Second, - Sandbox: sb, Composer: func() string { return trunkHead }, Published: published{}, - Verdicts: func() map[string]meshcatalog.VerdictsByDigestValue { return indexer }} - raw, err := ec.Compose(context.Background(), brings) - if err != nil { - t.Fatal(err) - } - if v := rules.JudgeEngines(raw); v.State != meshdeliverycheckerclient.CompositionPass || v.Sdk != trunkHead { - t.Fatalf("verdict = %+v, want a pass composed at the node-engine's trunk %s", v, trunkHead) - } - if len(sb.jobs) != 1 || sb.jobs[0].Fetch.Commit != trunkHead || sb.jobs[0].Fetch.Repository != nodeEngineRepo { - t.Fatalf("jobs %+v: want one job at the node-engine's trunk", sb.jobs) - } - var req composer.Request - b0, _ := sb.jobs[0].RequestBytes() - _ = json.Unmarshal(b0, &req) - if got := string(req.Cases[0].Verdicts["mesh-build-go"]); got != string(brings.Judged["mesh-build-go"]) || len(req.Cases[0].Verdicts) != 2 { - t.Errorf("the request's verdicts %s: want the check's judge's for mesh-build-go and the indexer's for mail", req.Cases[0].Verdicts) - } - // A manifest the judge gave no verdict on carries none, which the composer reads as accepted (ADR 0578 §3). - brings.Judged = nil - if _, err := ec.Compose(context.Background(), brings); err != nil { - t.Fatal(err) - } - var none composer.Request - bn, _ := sb.jobs[len(sb.jobs)-1].RequestBytes() - _ = json.Unmarshal(bn, &none) - if _, kept := none.Cases[0].Verdicts["mesh-build-go"]; kept { - t.Errorf("the running indexer's verdict on the change's manifest was kept: %s", none.Cases[0].Verdicts) - } - // A refusal the trunk's composer makes stays the node-engine's own. - sb.v = func(node string) composer.Verdict { - return composer.Verdict{V: composer.Version, Cases: []composer.CaseVerdict{{Name: "change", - Machines: map[string]composer.Machine{node: {Composes: false, Reason: "a required value is unset"}}}}} - } - raw, _ = ec.Compose(context.Background(), brings) - if v := rules.JudgeEngines(raw); v.State != meshdeliverycheckerclient.CompositionFail || !strings.Contains(v.Words, "a required value is unset") { - t.Errorf("a refusal the trunk's composer makes: %+v", v) - } - }) - - // Review finding 4: assignments that cannot be read is no mesh with no node: the composition is not made, said. - t.Run("an unreadable assignments makes no composition", func(t *testing.T) { - ec := EngineCompositions{Asker: &fakeEngines{}, Placed: func() ([]string, error) { return nil, errors.New("no such bucket") }} - if _, err := ec.Compose(context.Background(), cs); err == nil || !strings.Contains(err.Error(), "no such bucket") { - t.Errorf("an unreadable assignments: %v", err) - } - b := newBench(t) - b.ex.Compositions = ec - v := b.judge(t, cs).Verdict - if v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionNotRun || !strings.Contains(v.Composition.Words, "no such bucket") { - t.Errorf("the verdict's composition = %+v", v.Composition) - } - }) -} diff --git a/modules/mesh-delivery-checker/internal/check/every_failure_test.go b/modules/mesh-delivery-checker/internal/check/every_failure_test.go deleted file mode 100644 index 6016ff00..00000000 --- a/modules/mesh-delivery-checker/internal/check/every_failure_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package check - -import ( - "encoding/json" - "fmt" - "mesh-delivery-checker/rules" - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// failingResult is a level's test result in which the named tests failed, each in its own package. -func failingResult(t *testing.T, tests int, failed ...Failure) json.RawMessage { - t.Helper() - raw, err := json.Marshal(Tested{Level: buildstep.LevelIntegration, Tests: tests, Elapsed: 2, Failed: failed, Passed: len(failed) == 0}) - if err != nil { - t.Fatal(err) - } - return raw -} - -func judgeLevel(t *testing.T, tests ...json.RawMessage) (*meshdeliverychecker.VerdictsByGroupHeadsValue, *state) { - t.Helper() - st := &state{j: &Examiner{}, c: &Case{}, levels: rules.NewTally()} - st.level(t.Context(), &target{pull: Pull{Repository: "novox/x"}}, buildstep.LevelAnswer{Level: buildstep.LevelIntegration, Tests: tests}) - // 1921 (B0, D1a): the running checker only gathers the level as a fact; the rules judge it, and count what it kept. - judged := rules.Judge(rules.Facts{V: rules.FactsVersion, Steps: st.facts}) - if judged.Levels[buildstep.LevelIntegration] != (meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue{Run: int64(st.levels[buildstep.LevelIntegration].Run)}) { - t.Errorf("the rules count %+v, the running checker %+v", judged.Levels, *st.levels[buildstep.LevelIntegration]) - } - if judged.State == meshdeliverycheckerclient.VerdictPass { - return nil, st - } - return &judged, st -} - -// Issue 1921: two failing tests in two packages are two entries of the verdict's Failures and two lines of a try's -// failed list, each with its own first line (its cause, issue 1901), whether the build module answered them in one test -// result (one go test run over both packages) or in two (the changed packages first, then the rest); every result is -// counted, the ones after a failure too; and Failed keeps the first one's words whole. -func TestTwoFailingTestsInTwoPackagesAreTwoEntries(t *testing.T) { - a := Failure{Package: "x/a", Test: "TestA", Cause: "a_test.go:9: want 1, got 2", Output: " a_test.go:3: logged\n a_test.go:9: want 1, got 2\n--- FAIL: TestA (0.00s)"} - b := Failure{Package: "x/b", Test: "TestB", Cause: "b_test.go:4: boom", Output: " b_test.go:4: boom\n--- FAIL: TestB (0.00s)"} - for name, tests := range map[string][]json.RawMessage{ - "one result": {failingResult(t, 10, a, b)}, - "two results": {failingResult(t, 4, a), failingResult(t, 3), failingResult(t, 3, b)}, - } { - v, st := judgeLevel(t, tests...) - if v == nil { - t.Fatalf("%s: the level passed", name) - } - want := []string{"integration: x/a.TestA: a_test.go:9: want 1, got 2", "integration: x/b.TestB: b_test.go:4: boom"} - if got := failedLines(*v); strings.Join(got, "\n") != strings.Join(want, "\n") { - t.Errorf("%s: failed lines\n%s\nwant\n%s", name, strings.Join(got, "\n"), strings.Join(want, "\n")) - } - if len(v.Failures) != 2 || v.Failed.Test != "integration: x/a.TestA" || !strings.Contains(v.Failed.Words, "a_test.go:3: logged") { - t.Errorf("%s: verdict %+v", name, v) - } - if run := st.levels[buildstep.LevelIntegration].Run; run != 10 { - t.Errorf("%s: %d tests counted, want all 10", name, run) - } - if _, err := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: "g", Heads: "0123456789ab", State: v.State, Failed: v.Failed, Failures: v.Failures}); err != nil { - t.Errorf("%s: the verdict is not written: %v", name, err) - } - } - // Design 26 *Out of step* (DLV-C2): the out-of-step files the compare step names, in each result, are the outcome's for - // the pull request, each once and sorted; a level naming none leaves the outcome with none. - step := func(files ...string) json.RawMessage { - raw, _ := json.Marshal(Tested{Level: buildstep.LevelUnit, Tests: 1, Passed: false, Why: "out of step", OutOfStep: files}) - return raw - } - _, st := judgeLevel(t, step("go/seats/b/contract.go", "go/seats/a/contract.go"), step("go/seats/a/contract.go")) - if got := st.outcome(meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail}).OutOfStep["novox/x#0"]; strings.Join(got, ",") != "go/seats/a/contract.go,go/seats/b/contract.go" { - t.Errorf("out of step %v", got) - } - if _, st := judgeLevel(t, failingResult(t, 2, a)); st.outcome(meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail}).OutOfStep != nil { - t.Errorf("a level naming no out-of-step file has %v", st.outOfStep) - } -} - -// Issue 1921: past meshdeliverycheckerclient.MaxFailures the list names the first fifty and how many more, the status line says how many -// failed and names the first, cut so "and N more" stays whole, and each entry's line is cut to rules.MaxFailureLine. -func TestFailuresAreCappedWithHowManyMore(t *testing.T) { - var fs []Failure - for i := range 60 { - fs = append(fs, Failure{Package: fmt.Sprintf("x/p%d", i), Test: "TestT", Cause: strings.Repeat("y", 500)}) - } - v, _ := judgeLevel(t, failingResult(t, 60, fs...)) - if len(v.Failures) != meshdeliverycheckerclient.MaxFailures+1 || v.Failures[meshdeliverycheckerclient.MaxFailures].Test != "and 10 more" { - t.Fatalf("%d entries, last %+v", len(v.Failures), v.Failures[len(v.Failures)-1]) - } - if len(v.Failures[0].Words) > rules.MaxFailureLine { - t.Errorf("an entry's line is %d bytes", len(v.Failures[0].Words)) - } - if n := rules.FailedCount(*v); n != 60 { - t.Errorf("failedCount = %d, want 60", n) - } - cs := &Case{Pulls: []Pull{{Repository: "novox/x", Head: "0123456789abcdef", Trunk: "fedcba9876543210"}}} - if line := Line(*v, cs, cs.Pulls[0], nil, nil, nil); !strings.HasPrefix(line, "failed (60): integration: x/p0.TestT: yyy") || - !strings.Contains(line, "…; and 59 more | 0123456789ab on fedcba987654") { - t.Errorf("line %q", line) - } - // A composition failing after them is counted in the last entry (the operator, 2026-11-02). - refused := refusedOn("x", "g14", "route-proxy is defined twice") - rules.JudgeComposition(v, rules.Composition{Composed: &refused}) - if n := rules.FailedCount(*v); n != 61 || v.Failed.Test != "integration: x/p0.TestT" { - t.Errorf("after the composition failedCount = %d, failed %+v", n, v.Failed) - } - - // A verdict that names no list (a conflict, a refused step, a verdict written before issue 1921) is one failed line, as - // before. - one := meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Machine: "g14", Words: "files in conflict: go.mod\nmore"}} - if got := failedLines(one); len(got) != 1 || got[0] != "g14: files in conflict: go.mod" { - t.Fatalf("%q", got) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/examiner_test.go b/modules/mesh-delivery-checker/internal/check/examiner_test.go deleted file mode 100644 index e09bbee2..00000000 --- a/modules/mesh-delivery-checker/internal/check/examiner_test.go +++ /dev/null @@ -1,1671 +0,0 @@ -package check - -import ( - "cmp" - "context" - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "io/fs" - "mesh-delivery-checker/rules" - "os" - "path/filepath" - "reflect" - "slices" - "sort" - "strings" - "sync" - "testing" - "testing/fstest" - "time" - "unicode/utf8" - - "git.novox.be/novox/mesh-contracts/go/seats/meshconfig" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" - gobuild "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" - "git.novox.be/novox/mesh-sdk/go/catalogue" -) - -// captured reads a result the build module's own code marshalled (testdata/captured/README). -func captured[T any](t testing.TB, name string) T { - t.Helper() - raw, err := os.ReadFile(filepath.Join("testdata", "captured", name+".json")) - if err != nil { - t.Fatal(err) - } - var v T - if err := json.Unmarshal(raw, &v); err != nil { - t.Fatal(err) - } - return v -} - -type stepCall struct { - module, node, tool string - args map[string]any -} - -// fakeSteps stands for the build modules: a handler for each tool answers what the module's code answers. -type fakeSteps struct { - mu sync.Mutex - calls []stepCall - handlers map[string]func(c stepCall) (any, error) -} - -func (f *fakeSteps) Run(_ context.Context, module, node, tool string, args map[string]any) (json.RawMessage, error) { - c := stepCall{module, node, tool, args} - f.mu.Lock() - f.calls = append(f.calls, c) - h := f.handlers[tool] - f.mu.Unlock() - if h == nil { - return nil, fmt.Errorf("the fake build module has no tool %s", tool) - } - v, err := h(c) - if err != nil { - return nil, err - } - return json.Marshal(v) -} - -func (f *fakeSteps) tool(name string) []stepCall { - f.mu.Lock() - defer f.mu.Unlock() - var out []stepCall - for _, c := range f.calls { - if strings.HasSuffix(c.tool, "_"+name) { - out = append(out, c) - } - } - return out -} - -type entries []buildstep.NodeToolchain - -func (e entries) Entries(language string) []buildstep.NodeToolchain { - var out []buildstep.NodeToolchain - for _, x := range e { - if x.Language == language { - out = append(out, x) - } - } - return out -} - -type langs map[string][]string - -func (l langs) BuildModules(repository string) []string { - if m, ok := l[repository]; ok { - return m - } - return []string{goBuildModule} -} - -func goEntries(nodes ...string) entries { - var e entries - for _, n := range nodes { - e = append(e, buildstep.NodeToolchain{Node: n, Toolchain: buildstep.Toolchain{Language: "go", Version: "go1.27.1", Recipe: "7"}}) - e = append(e, buildstep.NodeToolchain{Node: n, Toolchain: buildstep.Toolchain{Language: "typescript", Version: "node24", Recipe: "3"}}) - } - return e -} - -const digC = "cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33cc33" -const digD = "dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44dd44" - -type bench struct { - ex *Examiner - asks *buildrun.FakeAsks - steps *fakeSteps - kept *memKV - prev *memKV - fetch Fetched - digest map[string]Digested // by level - test func(c stepCall) (any, error) - // declines is how many asks naming needs a node lacking them declines before shanks, which has every need, takes - // one (issue 890); an ask naming none runs on shanks, which then has none. - declines int - // inputs are the checking program's kept inputs; heads the heads laid for it (none when nil); run, when set, answers - // a run ask in its place (a program that does not build or answer). - inputs *memKV - heads fs.FS - run func(a buildstep.StepAsk) (buildstep.Step, bool) - mu sync.Mutex - runs []buildstep.StepAsk // the run asks put -} - -// benchAsks puts the bench's asks: a run ask is answered at once by the checking program's work (answerRun), written by -// write and kept apart (bench.runs); every other ask goes to inner (the fake bus by default), answered as it answers. -type benchAsks struct { - b *bench - inner buildrun.AskPublisher - write func(buildstep.Step) -} - -func (b *bench) asker(inner buildrun.AskPublisher, write func(buildstep.Step)) benchAsks { - return benchAsks{b: b, inner: inner, write: write} -} - -func (p benchAsks) PublishAsk(ctx context.Context, subject, id string, data []byte) error { - inner, write := p.inner, p.write - if inner == nil { - inner, write = p.b.asks, p.b.asks.Write - } - a, err := buildstep.DecodeStepAsk(data) - if err != nil || a.Run == nil { - return inner.PublishAsk(ctx, subject, id, data) - } - p.b.mu.Lock() - p.b.runs = append(p.b.runs, a) - p.b.mu.Unlock() - if step := p.b.answerRun(a); step.ID != "" { - write(step) - } - return nil -} - -// trunkD is mesh-delivery's trunk the bench's checking program is built at. -var trunkD = strings.Repeat("d", 40) - -// answerRun answers a run ask as the build module would: the checking program's work (rules.Program) over the input the -// ask names, read from the kept inputs and checked against its digest. -func (b *bench) answerRun(a buildstep.StepAsk) buildstep.Step { - began := time.Date(2026, 10, 21, 19, 0, 0, 0, time.UTC) - step := buildstep.Step{ID: a.ID, Tool: a.Kind + " ask", Node: "shanks", State: buildstep.StepPassed, Started: began, Ended: began.Add(time.Second)} - if b.run != nil { - if s, ok := b.run(a); ok { - return s - } - } - answer := buildstep.RunAnswer{Built: true, Key: "program-0123456789abcdef"} - out, err := rules.Program(a.Run.Args, func() ([]byte, error) { - body, _, _, _ := b.inputs.Get(context.Background(), a.Run.Input.Digest) - return body, a.Run.Input.Verify(body) - }, b.heads) - if err != nil { - answer.Exit, answer.Said = 2, err.Error() - } - answer.Output = out - step.Result, _ = json.Marshal(answer) - return step -} - -// refsOf reads the siblings of a fetch's arguments, as they arrive in an ask (JSON) or as the checker gave them. -func refsOf(v any) []BesideRef { - raw, _ := json.Marshal(v) - var refs []BesideRef - _ = json.Unmarshal(raw, &refs) - return refs -} - -// toolPrefix is the start of each build module's tool names, as the fake build modules answer them. -var toolPrefix = map[string]string{goBuildModule: "build_go_", nodeBuildModule: "build_node_"} - -// answer runs a check ask as the build module that pulls it does (gobuild.RunAsk), with the fake tools on shanks and the -// bench's kept verdicts, and answers the step it writes. -func (b *bench) answer(a buildstep.StepAsk) buildstep.Step { - bm, _ := testSeats().OfAskLanguage(a.Language) - module := bm.Module - const node = "shanks" - tool := func(name string) gobuild.StepFunc { - return func(ctx context.Context, args map[string]any) (any, error) { - raw, err := b.steps.Run(ctx, module, node, toolPrefix[module]+name, args) - if err != nil { - return nil, err - } - return raw, nil - } - } - steps := gobuild.AskSteps{Fetch: tool("fetch"), Test: tool("test"), - Kept: func(ctx context.Context, level, digest string) (int, bool, error) { - k, found, err := (Kept{Store: b.kept}).Lookup(ctx, level, digest) - return int(k.Tests), found, err - }} - if module == goBuildModule { - steps.Digest = tool("digest") - } - began := time.Date(2026, 10, 21, 19, 0, 0, 0, time.UTC) - if len(a.Needs) > 0 { - if b.declines > 0 { - b.declines-- - result, _ := json.Marshal(buildstep.StepDeclined{Declined: true, Needs: a.Needs, Lacks: a.Needs}) - return buildstep.Step{ID: a.ID, Tool: a.Kind + " ask", Node: "ace", State: buildstep.StepRefused, Started: began, Ended: began, - Reason: "declined", Result: result} - } - steps.Has = func(string) bool { return true } - } - out, err := gobuild.RunAsk(context.Background(), steps, a) - step := buildstep.Step{ID: a.ID, Tool: a.Kind + " ask", Node: node, State: buildstep.StepPassed, Started: began, Ended: began.Add(2 * time.Second)} - if out != nil { - step.Result, _ = json.Marshal(out) // a failed step keeps what it answered beside its error, as the step runner does - } - if err != nil { - step.State, step.Reason = buildstep.StepFailed, err.Error() - } - return step -} - -// newBench is an examiner over fake build modules that merge cleanly, digest the captured fixture's packages and pass -// the captured slow fixture's result at both levels, on shanks. -func newBench(t testing.TB) *bench { - b := &bench{steps: &fakeSteps{}, kept: newMemKV(), prev: newMemKV(), inputs: newMemKV(), heads: fstest.MapFS{}} - b.fetch = captured[Fetched](t, "go-fetch-clean") - b.fetch.Modules, b.fetch.Changed, b.fetch.Trees = []string{"."}, []string{"README.md"}, nil - one := captured[Digested](t, "go-digest") - b.digest = map[string]Digested{ - buildstep.LevelUnit: {Level: "unit", Packages: map[string]string{"fixture/slow": digA}}, - buildstep.LevelIntegration: {Level: "integration", Packages: map[string]string{"fixture/slow": digB}}, - } - _ = one - slow := captured[Tested](t, "go-test-slow") - b.test = func(c stepCall) (any, error) { - r := slow - r.Level, _ = c.args["level"].(string) - return r, nil - } - b.steps.handlers = map[string]func(stepCall) (any, error){ - "build_go_fetch": func(stepCall) (any, error) { return b.fetch, nil }, - "build_node_fetch": func(stepCall) (any, error) { return b.fetch, nil }, - "build_go_digest": func(c stepCall) (any, error) { return echoBeside(b, b.digest[c.args["level"].(string)]), nil }, - "build_go_test": func(c stepCall) (any, error) { return b.test(c) }, - "build_node_test": func(c stepCall) (any, error) { return b.test(c) }, - } - now := time.Date(2026, 10, 21, 19, 0, 0, 0, time.UTC) - b.asks = &buildrun.FakeAsks{Answer: b.answer} - b.ex = &Examiner{Module: "acme-checker", Asks: buildrun.Asker{Seats: testSeats(), Publisher: b.asker(nil, nil), Waiter: b.asks, Bound: 5 * time.Second}, Toolchains: goEntries("shanks"), Kept: Kept{Store: b.kept}, Previews: b.prev, - Modules: langs{}, Seats: testSeats(), Trunks: &Trunks{heads: map[string]string{DeliveryRepository: trunkD}}, Inputs: memInputs{b.inputs}, Now: func() time.Time { now = now.Add(50 * time.Millisecond); return now }} - return b -} - -func caseOf(t testing.TB, pulls ...meshcatalog.CandidatesByGroupValuePullsItem) *Case { - t.Helper() - raw := candidateOf(t, "feat/x", pulls...) - c, err := meshcatalog.DecodeCandidatesByGroupValue(raw) - if err != nil { - t.Fatal(err) - } - cs := CaseOf(c, map[string]string{repoA: trunkA, repoSDK: trunkS, "novox/mesh-controller": trunkA, "novox/mesh-catalog": trunkA, - "novox/mesh-host": trunkA, "novox/mesh-networking": trunkA}) - if cs == nil { - t.Fatal("no case") - } - return cs -} - -func (b *bench) judge(t testing.TB, cs *Case) Outcome { - t.Helper() - out, err := b.ex.Judge(context.Background(), cs) - if err != nil { - t.Fatal(err) - } - return out -} - -func testedWith(t testing.TB, name string, edit func(*Tested)) Tested { - r := captured[Tested](t, name) - if edit != nil { - edit(&r) - } - return r -} - -func packagesOf(c stepCall) []string { - var out []string - if l, ok := c.args["packages"].([]string); ok { - out = l - } - return out -} - -// overlapAsks counts the asks put and not yet ended, and the most at once: a wait holds until a second ask is put, or a -// second passed, so asks put one after another never overlap. -type overlapAsks struct { - Asks - mu sync.Mutex - open, top int - more chan struct{} -} - -func (o *overlapAsks) Put(ctx context.Context, a buildstep.StepAsk) error { - o.mu.Lock() - o.open++ - if o.open > o.top { - o.top = o.open - } - if o.open >= 2 { - select { - case <-o.more: - default: - close(o.more) - } - } - o.mu.Unlock() - return o.Asks.Put(ctx, a) -} - -func (o *overlapAsks) Wait(ctx context.Context, a buildstep.StepAsk) (buildstep.Step, error) { - select { - case <-o.more: - case <-time.After(time.Second): - } - defer func() { o.mu.Lock(); o.open--; o.mu.Unlock() }() - return o.Asks.Wait(ctx, a) -} - -// Design 47 G A-304 (ADR 0525 §4): a phase puts every ask of its own at once and then waits for them all, and the -// verdict is judged in the order of the members as before. -func TestAPhasesAsksAreAllOutstandingAtOnce(t *testing.T) { - b := newBench(t) - o := &overlapAsks{Asks: b.ex.Asks, more: make(chan struct{})} - b.ex.Asks = o - v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2))).Verdict - if o.top < 2 { - t.Errorf("at most %d asks were outstanding at once, want both members' asks of the phase", o.top) - } - if v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("verdict = %+v", v) - } - if fetch := b.steps.tool("fetch"); len(fetch) != 2 { - t.Errorf("fetch calls = %+v, want one per member", fetch) - } -} - -func TestACleanMergeIsFetchedAtItsTrunkAndBothLevelsPass(t *testing.T) { // 1679/AC1 - b := newBench(t) - cs := caseOf(t, pullOf(repoA, 7, head1)) - out := b.judge(t, cs) - v := out.Verdict - if v.State != meshdeliverycheckerclient.VerdictPass || v.Levels[buildstep.LevelUnit].Run != 2 || v.Levels[buildstep.LevelIntegration].Run != 2 { - t.Fatalf("verdict = %+v", v) - } - if v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionNotRun { - t.Errorf("composition = %+v, want not run", v.Composition) - } - if len(v.Machines) != 1 || v.Machines[0] != "shanks" { - t.Errorf("machines = %v", v.Machines) - } - fetch := b.steps.tool("fetch") - if len(fetch) != 1 || fetch[0].args["repository"] != repoA || fetch[0].args["commit"] != head1 || fetch[0].args["base"] != trunkA || fetch[0].args["ref"] != "refs/pull/7/head" { - t.Fatalf("fetch calls = %+v", fetch) - } - if v.Took.Clone <= 0 || v.Took.Unit <= 0 { - t.Errorf("took = %+v, want the clone and the unit level timed", v.Took) - } - // What passed is kept under each level's digest. - for _, k := range []string{"unit." + digA, "integration." + digB} { - if _, _, found, _ := b.kept.Get(context.Background(), k); !found { - t.Errorf("%s was not kept", k) - } - } - - // ADR 0567 §12: every check ask carries every node's name for the names check; a check whose names cannot be read, or - // that reads none, is not asked and fails saying so. - for _, c := range []struct { - names []string - err error - fails string - }{{[]string{"anchor", "laptop"}, nil, ""}, {nil, nil, "no node record"}, {nil, errors.New("no bucket"), "no bucket"}} { - b := newBench(t) - b.ex.Nodes = namesOf{c.names, c.err} - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - asks := b.asks.Asks() - if c.fails != "" { - if out.Verdict.State != meshdeliverycheckerclient.VerdictFail || len(asks) != 0 || !strings.Contains(out.Verdict.Failed.Words, c.fails) { - t.Errorf("names %v, %v: verdict %+v, %d asks", c.names, c.err, out.Verdict, len(asks)) - } - } else if len(asks) == 0 || strings.Join(asks[0].Check.NodeNames, ",") != "anchor,laptop" { - t.Errorf("the check ask carries the names %v", asks) - } - } - - // Issue 1921 (B0, D4 to D6): the check's verdict is the checking program's, built at the group's mesh-delivery head, - // else at mesh-delivery's trunk, over the facts kept as its input; a program that is never begun, does not build or - // does not answer fails the check naming it, and a rule the change's program alters judges the check. - verdictOf := func(state, words string) json.RawMessage { - out, _ := json.Marshal(rules.Answer{V: rules.AnswerVersion, Verdict: meshdeliverychecker.VerdictsByGroupHeadsValue{State: state, Failed: &FailedFirst{Words: words}}}) - return out - } - for _, row := range []struct { - name string - repo string // the member's repository: mesh-delivery unless named - run func(a buildstep.StepAsk, s buildstep.Step) (buildstep.Step, bool) - at string // the commit the program is built at; empty when it fails - fails string - runs int // the run asks put when it fails: each put twice when never begun, and none after the seat list's - }{ - {name: "at the group's mesh-delivery head", at: head1}, - {name: "at mesh-delivery's trunk", repo: "novox/mesh-catalog", at: trunkD}, - {name: "never begun", run: func(buildstep.StepAsk, buildstep.Step) (buildstep.Step, bool) { return buildstep.Step{}, true }, - fails: "no build node began the job run of the asks", runs: 2}, - {name: "does not build", run: func(_ buildstep.StepAsk, s buildstep.Step) (buildstep.Step, bool) { - s.State, s.Reason = buildstep.StepFailed, "the program does not build: undefined: rules.Nothing" - return s, true - }, fails: "by the checking program: its run ask", runs: 1}, - // Design 47 G A-290: a run whose program exited other than 0 ends its key failed, its answer kept; the checker reads it. - {name: "a program that exits other than 0", run: func(_ buildstep.StepAsk, s buildstep.Step) (buildstep.Step, bool) { - s.State, s.Reason = buildstep.StepFailed, "the program exited 2: bad flag" - s.Result, _ = json.Marshal(buildstep.RunAnswer{Key: "program-0123456789abcdef", Built: true, Exit: 2, Said: "bad flag"}) - return s, true - }, fails: "it exited 2 on shanks: bad flag", runs: 1}, - {name: "a rule the change alters", at: head1, run: func(a buildstep.StepAsk, s buildstep.Step) (buildstep.Step, bool) { - if a.Run.Args[0] != "-verdict" { - return s, false - } - s.Result, _ = json.Marshal(buildstep.RunAnswer{Key: "program-0123456789abcdef", Output: verdictOf(meshdeliverycheckerclient.VerdictFail, "the change's own rule refuses it")}) - return s, true - }, fails: "the change's own rule refuses it"}, - } { - b := newBench(t) - b.ex.BeginBound = 20 * time.Millisecond - if row.run != nil { - b.run = func(a buildstep.StepAsk) (buildstep.Step, bool) { - return row.run(a, buildstep.Step{ID: a.ID, Tool: "check ask", Node: "shanks", State: buildstep.StepPassed}) - } - } - repo := cmp.Or(row.repo, repoA) - v := b.judge(t, caseOf(t, pullOf(repo, 7, head1))).Verdict - if row.fails != "" { - if v.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(v.Failed.Words, row.fails) { - t.Errorf("%s: verdict %+v, want a fail saying %q", row.name, v, row.fails) - } - if row.at == "" && (len(b.runs) != row.runs || v.JudgedBy != nil || slices.ContainsFunc(b.runs, func(a buildstep.StepAsk) bool { return a.Run.Args[0] == "-verdict" })) { - t.Errorf("%s: %d run asks, judged by %+v: want %d and none judging", row.name, len(b.runs), v.JudgedBy, row.runs) - } - } else if v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("%s: verdict %+v", row.name, v) - } - if row.at == "" { - continue - } - if by := v.JudgedBy; by == nil || by.Program.Commit != row.at || by.Program.Package != CheckingProgramPackage || by.Key == "" || - len(by.Heads) != 1 || by.Heads[0].Repository != repo || by.Heads[0].Commit != head1 { - t.Errorf("%s: judged by %+v, want the program at %s over the member's head", row.name, v.JudgedBy, row.at) - } - if len(b.runs) != 2 || b.runs[0].Run.Args[0] != "-seats" || b.runs[1].Run.Args[0] != "-verdict" { - t.Fatalf("%s: run asks %+v, want the seat list and then the verdict", row.name, b.runs) - } - in := b.runs[1].Run.Input // the facts kept as their exact bytes under their digest - body, _, found, _ := b.inputs.Get(context.Background(), in.Digest) - if !found || in.Verify(body) != nil || in.Verb != InputVerb || - !strings.Contains(string(body), `"group":"feat/x"`) { - t.Errorf("%s: the verdict's input %+v is not kept whole: %s", row.name, in, body) - } - // Review round 1 of milestone 47/B0: a level is carried as the rules read it, without its digest, its packages or - // its kept packages' names, so a group's facts stay within the input's bound. - for _, unread := range []string{`"digest":{`, `"packages":[`, `"unmet"`, `"package":"m/`} { - if strings.Contains(string(body), unread) { - t.Errorf("%s: the facts carry %s, which no rule reads: %s", row.name, unread, body) - } - } - } -} - -// namesOf is the nodes' names as a test gives them. -type namesOf struct { - names []string - err error -} - -func (n namesOf) Names(context.Context) ([]string, error) { return n.names, n.err } - -func TestOnlyThePackageWithoutAKeptVerdictRuns(t *testing.T) { // 1288/AC1 - b := newBench(t) - b.digest[buildstep.LevelUnit] = Digested{Level: "unit", Packages: map[string]string{"fixture/slow": digA, "fixture/other": digC}} - if _, err := (Kept{Store: b.kept}).Keep(context.Background(), "unit", digC, keptValue("fixture/other", 40)); err != nil { - t.Fatal(err) - } - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - tests := b.steps.tool("test") - if len(tests) != 2 || strings.Join(packagesOf(tests[0]), ",") != "fixture/slow" || tests[0].args["level"] != "unit" { - t.Fatalf("test calls = %+v, want the unit level of fixture/slow alone, then the integration level", tests) - } - if u := out.Verdict.Levels[buildstep.LevelUnit]; u.Run != 2 || u.Kept != 40 { - t.Errorf("unit = %+v, want 2 run and 40 kept", u) - } - - // Issue 890/AC5: a package needing node-build-node is left unmet where the node lacks it; the check keeps the passes - // and asks the integration level again for a node with it, puts it again when a node declines it, and that node tests - // the package alone, its kept passes not counted twice. - // fixture/outside has no kept verdict after its pass (it reads outside itself: its digest moves every call), so a - // placed ask that ran more than its unmet packages would run and count it again. - b = newBench(t) - b.declines = 1 - outside := 0 - b.steps.handlers["build_go_digest"] = func(c stepCall) (any, error) { - d := echoBeside(b, b.digest[c.args["level"].(string)]) - if d.Level == "integration" { - outside++ - d.Packages = map[string]string{"fixture/slow": digB, "fixture/node": digC, "fixture/outside": fmt.Sprintf("%064x", outside)} - } - return d, nil - } - b.digest[buildstep.LevelIntegration] = Digested{Level: "integration", - Needs: []buildstep.PackageNeeds{{Package: "fixture/node", Needs: []string{buildstep.NeedNodeBuildNode}}}} - out = b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - asks := b.asks.Asks() - if out.Verdict.State != meshdeliverycheckerclient.VerdictPass || len(asks) != 3 || len(asks[0].Needs) != 0 { - t.Fatalf("verdict %+v, asks %+v: want a pass of three asks, the first naming no need", out.Verdict, asks) - } - for _, a := range asks { // ADR 0584: every check ask names the agreed toolchain, so a node off it declines - if a.Check.Toolchain == nil || a.Check.Toolchain.Version != "go1.27" || a.Check.Toolchain.Recipe != "7" { - t.Errorf("a check ask names toolchain %+v, want go1.27 recipe 7", a.Check.Toolchain) - } - } - for _, a := range asks[1:] { - if strings.Join(a.Needs, ",") != buildstep.NeedNodeBuildNode || strings.Join(a.Check.Levels, ",") != buildstep.LevelIntegration || strings.Join(a.Check.Packages, ",") != "fixture/node" { - t.Errorf("a placed ask %+v, want the integration level needing node-build-node", a) - } - } - tests = b.steps.tool("test") - if last := tests[len(tests)-1]; len(tests) != 3 || strings.Join(packagesOf(last), ",") != "fixture/node" || last.args["level"] != "integration" { - t.Errorf("test calls = %+v, want the unit level, the integration level of fixture/slow and fixture/outside, then fixture/node alone", tests) - } - slow := captured[Tested](t, "go-test-slow") - if i := out.Verdict.Levels[buildstep.LevelIntegration]; int(i.Run) != 2*slow.Tests || i.Kept != 0 { - t.Errorf("integration = %+v, want %d run and nothing counted kept", i, 2*slow.Tests) - } - // And where no node has the need, the check fails once the declines outlast the bound, naming the need. - b.kept, b.declines = newMemKV(), 1000 - b.ex.Kept, b.ex.DeclineBound = Kept{Store: b.kept}, 200*time.Millisecond - if v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict; v.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(failedOf(v).Words, "needs a node with node-build-node") { - t.Errorf("with no node having the need: %+v", v) - } -} - -func TestAReAskRunsOnlyWhatFailedAndWhatChanged(t *testing.T) { // 1288/AC2, AC3 - b := newBench(t) - failing := captured[Tested](t, "go-test-failing") - b.digest[buildstep.LevelUnit] = Digested{Level: "unit", Packages: map[string]string{"fixture/failing/bad": digA, "fixture/failing/good": digB}} - b.test = func(c stepCall) (any, error) { - if c.args["level"] == "unit" { - return failing, nil - } - return captured[Tested](t, "go-test-slow"), nil - } - cs := caseOf(t, pullOf(repoA, 7, head1)) - first := b.judge(t, cs).Verdict - if first.State != meshdeliverycheckerclient.VerdictFail || first.Failed.Test != "unit: fixture/failing/bad.TestThreeIsFour" { - t.Fatalf("first = %+v", first) - } - if _, _, found, _ := b.kept.Get(context.Background(), "unit."+digB); !found { - t.Fatal("the package that passed in the failing run was not kept") - } - if _, _, found, _ := b.kept.Get(context.Background(), "unit."+digA); found { - t.Fatal("the package that failed was kept") - } - // Asked again with nothing changed: only the failed package runs; the good one is taken. - b.steps.calls = nil - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - tests := b.steps.tool("test") - if len(tests) == 0 || strings.Join(packagesOf(tests[0]), ",") != "fixture/failing/bad" { - t.Fatalf("the re-ask ran %+v, want only fixture/failing/bad", tests) - } - // The trunk moved and one digest changed: that package runs, the unchanged one is taken. - b.digest[buildstep.LevelUnit] = Digested{Level: "unit", Packages: map[string]string{"fixture/failing/bad": digA, "fixture/failing/good": digD}} - b.steps.calls = nil - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - tests = b.steps.tool("test") - if got := strings.Join(packagesOf(tests[0]), ","); got != "fixture/failing/bad,fixture/failing/good" && got != "fixture/failing/good,fixture/failing/bad" { - t.Errorf("after a digest changed the run was %q, want the failed package and the changed one", got) - } -} - -func TestANodePackageIsNeverKeptAndRunsEveryCheck(t *testing.T) { // 1288/AC4, 1292/AC1 - b := newBench(t) - b.ex.Modules = langs{repoA: {nodeBuildModule}} - b.fetch = captured[Fetched](t, "node-fetch-clean") - b.test = func(c stepCall) (any, error) { - return Tested{Level: c.args["level"].(string), Module: "modules/m", Passed: true, Elapsed: 0.4, Bound: 5}, nil - } - cs := caseOf(t, pullOf(repoA, 7, head1)) - for i := 0; i < 2; i++ { - v := b.judge(t, cs).Verdict - if v.State != meshdeliverycheckerclient.VerdictPass || v.Levels[buildstep.LevelUnit].Kept != 0 || v.Levels[buildstep.LevelUnit].Run != 1 { - t.Fatalf("round %d: verdict = %+v", i, v) - } - } - if n := len(b.steps.tool("test")); n != 4 { - t.Errorf("%d node test calls in two checks, want 4 (both levels each time)", n) - } - if n := len(b.steps.tool("digest")); n != 0 { - t.Errorf("the node build module was asked for a digest %d times", n) - } - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 0 { - t.Errorf("kept %v for a node package", keys) - } -} - -// The operator, 2026-11-02 ("A failed check shows only its first fault"): a check runs every member, every level and the -// composition to its end and its verdict names every failure in the order judged, Failed keeping the first whole; the -// change's own tests still run first (issue 1289), and the rest of the level after them. A member that only failed its -// tests still gets its preview, so the composition is read and its failure named after the tests'. A member whose head -// does not merge has no preview of a merge, so the assigner's composition would only wait: the check does not wait for it -// and says why it was not run (review of 650a1d0). A member whose step failed after its fetch merged is previewed from the -// fetch the failed step answered, and the composition is read (design 47 G A-286). -func TestEveryFailureOfEveryMemberLevelAndTheCompositionIsNamed(t *testing.T) { - for _, kind := range []string{"tests", "conflicts", "errors"} { - conflicts, errs := kind == "conflicts", kind == "errors" - b := newBench(t) - comps := &fakeCompositions{v: refusedOn("x", "g14", "route-proxy is defined twice"), waits: conflicts} - b.ex.Compositions = comps - b.fetch.Changed = []string{"modules/m/internal/b/b_test.go"} - b.digest[buildstep.LevelUnit] = Digested{Level: "unit", Packages: map[string]string{"m/internal/a": digA, "m/internal/b": digB}} - conflict := captured[Fetched](t, "go-fetch-conflict") - b.steps.handlers["build_go_fetch"] = func(c stepCall) (any, error) { - if conflicts && c.args["repository"] == repoSDK { - return conflict, nil - } - return b.fetch, nil - } - failing := captured[Tested](t, "go-test-failing") - b.test = func(c stepCall) (any, error) { - if errs && c.args["level"] == "unit" { - return nil, errors.New("the seat definitions in . do not generate") - } - if got := packagesOf(c); c.args["level"] == "integration" || (len(got) == 1 && got[0] == "m/internal/b") { - r := failing - r.Level = c.args["level"].(string) - return r, nil - } - return captured[Tested](t, "go-test-slow"), nil - } - cs := caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2)) - done := make(chan meshdeliverychecker.VerdictsByGroupHeadsValue, 1) - go func() { done <- b.judge(t, cs).Verdict }() - var v meshdeliverychecker.VerdictsByGroupHeadsValue - select { - case v = <-done: - case <-time.After(5 * time.Second): - t.Fatalf("conflicts %v: the check waits on a composition that only waits", conflicts) - } - if errs { - keys, _ := b.prev.Keys(context.Background()) - if len(keys) != 2 || len(comps.asked) == 0 || v.Composition == nil || v.Composition.State == meshdeliverycheckerclient.CompositionNotRun { - t.Errorf("a step failed after its fetch merged: previews %v, asked %v, composition %+v, want both previews and the composition read", - keys, comps.asked, v.Composition) - } - continue - } - var got []string - for _, f := range v.Failures { - got = append(got, firstFailed(meshdeliverychecker.VerdictsByGroupHeadsValue{Failed: &FailedFirst{Test: f.Test, Machine: f.Machine, Words: f.Words}})) - } - tests := []string{"unit: fixture/failing/bad.TestThreeIsFour", "integration: fixture/failing/bad.TestThreeIsFour"} - want := append(append(slices.Clone(tests), tests...), "g14: not composed on g14: route-proxy is defined twice") // both members fail their tests - if conflicts { - want = append([]string{"shanks: novox/mesh-sdk#12 does not merge into the trunk: files in conflict: a.go"}, tests...) - } - if v.State != meshdeliverycheckerclient.VerdictFail || len(got) != len(want) { - t.Fatalf("conflicts %v: verdict %+v: failures\n%s\nwant\n%s", conflicts, v, strings.Join(got, "\n"), strings.Join(want, "\n")) - } - for i := range want { - if !strings.HasPrefix(got[i], want[i]) { - t.Errorf("conflicts %v: failure %d is %q, want %q", conflicts, i, got[i], want[i]) - } - } - keys, _ := b.prev.Keys(context.Background()) - switch { - case !conflicts && (len(keys) != 2 || v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionFail): - t.Errorf("tests alone failed: previews %v, composition %+v, want both previews and the composition read", keys, v.Composition) - case conflicts && (len(comps.asked) != 0 || v.Composition == nil || v.Composition.State != meshdeliverycheckerclient.CompositionNotRun || - !strings.Contains(v.Composition.Words, "novox/mesh-sdk#12 (its head does not merge)")): - t.Errorf("a member did not merge: asked %v, composition %+v, want not run naming novox/mesh-sdk#12", comps.asked, v.Composition) - } - var unit []string - for _, c := range b.steps.tool("test") { - if c.args["level"] == "unit" && c.args["workspace"] != nil { - unit = append(unit, strings.Join(packagesOf(c), ",")) - } - } - if conflicts && (strings.Join(unit, " | ") != "m/internal/b | m/internal/a" || len(b.steps.tool("digest")) != 2) { - t.Errorf("the unit level ran %v and %d digests, want the changed test's package, then the rest, at both levels", unit, len(b.steps.tool("digest"))) - } - v.Group, v.Heads = "feat/x", "0123456789ab" - if _, err := meshdeliverycheckerclient.EncodeVerdict(v); err != nil { - t.Errorf("conflicts %v: the verdict cannot be written: %v", conflicts, err) - } - if line := Line(v, cs, cs.Pulls[0], nil, nil, nil); !strings.HasPrefix(line, fmt.Sprintf("failed (%d): %s", len(want), want[0][:20])) || - !strings.Contains(line, fmt.Sprintf("; and %d more | ", len(want)-1)) || utf8.RuneCountInString(line) > MaxLine { - t.Errorf("conflicts %v: line %q", conflicts, line) - } - } -} - -func TestTheChangesOwnPassingTestRunsFirstAndTheRestFollow(t *testing.T) { // 1289/AC3 - b := newBench(t) - b.fetch.Changed = []string{"modules/m/internal/b/b_test.go", "modules/m/internal/a/a.go"} - b.digest[buildstep.LevelUnit] = Digested{Level: "unit", Packages: map[string]string{"m/internal/a": digA, "m/internal/b": digB}} - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if out.Verdict.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", out.Verdict) - } - var unit []string - for _, c := range b.steps.tool("test") { - if c.args["level"] == "unit" { - unit = append(unit, strings.Join(packagesOf(c), ",")) - } - } - if strings.Join(unit, " | ") != "m/internal/b | m/internal/a" { - t.Errorf("the unit level ran %v, want the changed test's package first, then the rest", unit) - } -} - -func TestAHeadThatDoesNotMergeEndsFailedNamingTheFilesAndRunsNoTest(t *testing.T) { // 1289/AC4 - b := newBench(t) - b.fetch = captured[Fetched](t, "go-fetch-conflict") - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - f := out.Verdict.Failed - if out.Verdict.State != meshdeliverycheckerclient.VerdictFail || f.Machine != "shanks" || !strings.Contains(f.Words, "files in conflict: a.go, sub/b.go") { - t.Fatalf("verdict = %+v", out.Verdict) - } - if n := len(b.steps.tool("digest")) + len(b.steps.tool("test")); n != 0 { - t.Errorf("%d digest and test steps ran after a conflict", n) - } - // 1921/D1c: the node that ran the step is a fact, so the verdict judged from the facts names its machine. - if m := out.Verdict.Machines; len(m) != 1 || m[0] != "shanks" { - t.Errorf("machines = %v, want the node that ran the step", m) - } -} - -func TestALevelWhoseDigestIsNotNamedRunsWholeAndKeepsNothing(t *testing.T) { // 1287/AC4 - b := newBench(t) - b.steps.handlers["build_go_digest"] = func(stepCall) (any, error) { return nil, fmt.Errorf("go list failed") } - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if out.Verdict.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", out.Verdict) - } - tests := b.steps.tool("test") - if len(tests) != 2 || tests[0].args["packages"] != nil { - t.Errorf("test calls = %+v, want each level once, whole", tests) - } - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 0 { - t.Errorf("kept %v with no digest", keys) - } -} - -func TestALevelOverItsBoundIsNamedWithItsSlowestTestsAndKeepsItsVerdict(t *testing.T) { // 1300/AC3 - b := newBench(t) - b.test = func(c stepCall) (any, error) { - return testedWith(t, "go-test-slow", func(r *Tested) { - r.Level = c.args["level"].(string) - r.OverBound = true - r.OverWhich = "run" - r.Elapsed = 7 - }), nil - } - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - v := out.Verdict - if v.State != meshdeliverycheckerclient.VerdictPass || strings.Join(v.OverBound, ",") != "unit,integration" { - t.Fatalf("verdict = %+v", v) - } - if len(out.Slowest) == 0 || !strings.Contains(out.Slowest[0], "TestTakesAWhile") { - t.Errorf("slowest = %v", out.Slowest) - } -} - -func TestSkippedTestsAreCountedPerLevel(t *testing.T) { // 1300/AC6, 1251 - b := newBench(t) - b.test = func(c stepCall) (any, error) { - return testedWith(t, "go-test-slow", func(r *Tested) { r.Level = c.args["level"].(string); r.Skipped = 3 }), nil - } - v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if v.Levels[buildstep.LevelUnit].Skipped != 3 || v.Levels[buildstep.LevelIntegration].Skipped != 3 { - t.Errorf("levels = %+v", v.Levels) - } -} - -func TestAGroupIsOneVerdictAndEachMembersTestsReadTheOthersAtTheirHeads(t *testing.T) { // 1624/AC1 - b := newBench(t) - cs := caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2)) - v := b.judge(t, cs).Verdict - if v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", v) - } - fetch := b.steps.tool("fetch") - if len(fetch) != 2 { - t.Fatalf("%d fetches, want one for each member", len(fetch)) - } - var forA []BesideRef - for _, f := range fetch { - if f.args["repository"] == repoA { - forA, _ = refsOf(f.args["beside"]), true - } - } - found := false - for _, r := range forA { - if r.Repository == repoSDK && r.Commit == head2 { - found = true - } - } - if !found { - t.Errorf("mesh-delivery's tests were not given the SDK member at its head: %+v", forA) - } -} - -func TestAnExaminerIsAJudgeOfTheChecker(t *testing.T) { - var _ Judge = (*Examiner)(nil) -} - -const ( - manA = "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a" -) - -func TestACleanMergeWritesItsPreviewWithTheTreesManifestsAndLocks(t *testing.T) { // 1445/AC1 - b := newBench(t) - b.fetch.Trees = map[string]buildstep.ModuleTree{ - "modules/avahi": {Tree: "7777777777777777777777777777777777777777", Manifest: manA, Locks: map[string]string{"go.sum": "ff00"}}, - "modules/bare": {Tree: "8888888888888888888888888888888888888888"}, // no manifest digest: left out - } - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - key, _ := meshdeliverycheckerclient.PreviewKey(repoA, head1, trunkA) - raw, _, found, _ := b.prev.Get(context.Background(), key) - if !found { - t.Fatalf("no preview %s; the bucket holds %v", key, b.prev.vals) - } - pv, err := meshdeliverycheckerclient.DecodePreview(raw) - if err != nil { - t.Fatal(err) - } - m := pv.Modules["modules/avahi"] - if pv.Merge != b.fetch.Merge || pv.Trunk != trunkA || pv.Head != head1 || len(pv.Modules) != 1 || m.Tree != "7777777777777777777777777777777777777777" || m.Manifest != manA || m.Locks["go.sum"] != "ff00" { - t.Errorf("preview = %+v", pv) - } -} - -func TestAHeadThatDoesNotMergeWritesAPreviewOfItsConflictsAlone(t *testing.T) { // 1445/AC5 - b := newBench(t) - b.fetch = captured[Fetched](t, "go-fetch-conflict") - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - key, _ := meshdeliverycheckerclient.PreviewKey(repoA, head1, trunkA) - raw, _, found, _ := b.prev.Get(context.Background(), key) - if !found { - t.Fatalf("no preview for a head that does not merge; the bucket holds %v", b.prev.vals) - } - pv, err := meshdeliverycheckerclient.DecodePreview(raw) - if err != nil || strings.Join(pv.Conflicts, ",") != "a.go,sub/b.go" || pv.Merge != "" || len(pv.Modules) != 0 { - t.Errorf("preview = %+v, %v, want the files in conflict and no merge", pv, err) - } -} - -func TestAPreviewIsWrittenOnceAndAnExistingKeyStands(t *testing.T) { - b := newBench(t) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - b.fetch.Merge = "5656565656565656565656565656565656565656" - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - key, _ := meshdeliverycheckerclient.PreviewKey(repoA, head1, trunkA) - if b.prev.creates[key] != 1 { - t.Errorf("the preview was created %d times, want once", b.prev.creates[key]) - } - raw, _, _, _ := b.prev.Get(context.Background(), key) - if pv, _ := meshdeliverycheckerclient.DecodePreview(raw); pv.Merge == b.fetch.Merge { - t.Error("the second merge commit replaced the first") - } -} - -func TestTheIndexerIsToldOfAPreviewOnceWhenItIsCreated(t *testing.T) { // 1445/AC4 (the checker's half) - b := newBench(t) - var told []string - b.ex.Announce = func(_ context.Context, event, key string) { told = append(told, event+" "+key) } - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - key, _ := meshdeliverycheckerclient.PreviewKey(repoA, head1, trunkA) - if len(told) != 1 || told[0] != EventPreviewWritten+" "+key { - t.Errorf("told %v, want once of %s", told, key) - } -} - -type fakeBuilds map[string]builds.BuilderBuild - -func (f fakeBuilds) Build(_ context.Context, module, fp2 string) (builds.BuilderBuild, bool, error) { - b, ok := f[module+" "+fp2] - return b, ok, nil -} - -func TestTheOutcomeSaysIfEachCandidatesModuleIsBuiltFailedOrWaiting(t *testing.T) { // N7/AC1 (the checker reads the builder's keys) - b := newBench(t) - fpA := "src2:" + strings.Repeat("a", 64) - fpB := "src2:" + strings.Repeat("b", 64) - fpC := "src2:" + strings.Repeat("c", 64) - b.ex.Builds = fakeBuilds{ - "avahi " + fpA: {State: builds.BuildDone}, - "mesh-tools " + fpB: {State: builds.BuildFailed, Error: "boom"}, - // netcheck has no key yet - } - p := pullOf(repoA, 7, head1) - p.Modules = []string{"avahi", "mesh-tools", "netcheck", "nofp"} - p.Fps = map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"avahi": {Fp2: fpA}, "mesh-tools": {Fp2: fpB}, "netcheck": {Fp2: fpC}, "nofp": {None2: "toolchain not yet reported"}} - out := b.judge(t, caseOf(t, p)) - var got []string - for _, n := range out.Builds { - got = append(got, n.Module+" "+n.State) - } - if strings.Join(got, ", ") != "avahi built, mesh-tools failed, netcheck waiting" { - t.Errorf("builds = %v, want one note for each module that has a fingerprint, sorted", got) - } -} - -// trunksOf are trunk heads of every repository, as the catalog half's trunk revision names them. -func trunksOf(t *testing.T, heads map[string]string) *Trunks { - t.Helper() - tr := &Trunks{} - tr.Set(heads) - return tr -} - -func TestNothingIsKeptForAWorkspaceGivenSiblingsWhenTheDigestDoesNotSayItCoversThem(t *testing.T) { // review D1, ADR 0444, issue 1287 - b := newBench(t) - // A build module whose digest does not echo the siblings (before DigestVersion 3). - b.steps.handlers["build_go_digest"] = func(c stepCall) (any, error) { return b.digest[c.args["level"].(string)], nil } - b.ex.Trunks = trunksOf(t, map[string]string{repoSDK: trunkS, "novox/mesh-catalog": trunkA}) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if got := len(b.steps.tool("fetch")); got != 1 || b.steps.tool("fetch")[0].args["beside"] == nil { - t.Fatalf("the fetch was not given siblings: %+v", b.steps.tool("fetch")) - } - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 0 { - t.Errorf("kept %v for a package whose digest does not say it covers the siblings", keys) - } - // And a kept verdict of the same digest from elsewhere is not taken for it: everything runs. - if _, err := (Kept{Store: b.kept}).Keep(context.Background(), "unit", digA, keptValue("fixture/slow", 2)); err != nil { - t.Fatal(err) - } - b.steps.calls = nil - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if n := len(b.steps.tool("test")); n != 2 { - t.Errorf("%d test steps, want both levels run whole", n) - } -} - -// besideDigest stands for the Go build module's digest over a workspace with siblings (DigestVersion 3, lead decision L5): -// each package's digest folds the siblings' commits in, and the answer echoes the lines it folded. -// echoBeside is d with the siblings the fetches placed, as the Go build module's digest echoes them (its DigestResult's -// Beside): every check now places the change's own repository at its trunk (issue 1887 A12). -func echoBeside(b *bench, d Digested) Digested { - var lines []string - if fetches := b.steps.tool("fetch"); len(fetches) > 0 { // the workspace digested is the last fetch's (issue 890: a placed ask fetches again) - for _, r := range refsOf(fetches[len(fetches)-1].args["beside"]) { - lines = append(lines, r.Repository+" "+r.Commit) - } - } - sort.Strings(lines) - d.Beside = lines - return d -} - -func besideDigest(b *bench) func(c stepCall) (any, error) { - return func(c stepCall) (any, error) { - level := c.args["level"].(string) - var lines []string - for _, f := range b.steps.tool("fetch") { - refs, _ := refsOf(f.args["beside"]), true - for _, r := range refs { - lines = append(lines, r.Repository+" "+r.Commit) - } - } - sort.Strings(lines) - sum := sha256.Sum256([]byte(level + "\n" + strings.Join(lines, "\n"))) - return Digested{Level: level, Packages: map[string]string{"fixture/slow": hex.EncodeToString(sum[:])}, Beside: lines}, nil - } -} - -func TestACoreRepositorysPassingPackageIsKeptUnderADigestCoveringItsSiblings(t *testing.T) { // 1287 AC1-AC3, AC7 with L5 - b := newBench(t) - b.steps.handlers["build_go_digest"] = besideDigest(b) - b.ex.Trunks = trunksOf(t, map[string]string{repoSDK: trunkS, "novox/mesh-catalog": trunkA}) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - keys, _ := b.kept.Keys(context.Background()) - if len(keys) != 2 { - t.Fatalf("kept %v, want the passing package at both levels", keys) - } - // The same siblings again: everything is taken, nothing runs. - b.steps.calls = nil - v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if n := len(b.steps.tool("test")); n != 0 || v.Levels[buildstep.LevelUnit].Run != 0 || v.Levels[buildstep.LevelUnit].Kept == 0 { - t.Fatalf("%d test steps, unit %+v, want none run and the kept verdict taken", n, v.Levels[buildstep.LevelUnit]) - } - // A sibling's commit moves: a new digest, so the package runs again and is kept under it. - b.ex.Trunks = trunksOf(t, map[string]string{repoSDK: trunkS2, "novox/mesh-catalog": trunkA}) - b.steps.calls = nil - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if n := len(b.steps.tool("test")); n != 2 { - t.Errorf("%d test steps after a sibling moved, want both levels run", n) - } - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 4 { - t.Errorf("kept %v, want a second key per level under the new digest", keys) - } -} - -func TestADigestThatEchoesOtherSiblingsKeepsNothing(t *testing.T) { // 1287 with L5: an echo that differs is not trusted - b := newBench(t) - inner := besideDigest(b) - b.steps.handlers["build_go_digest"] = func(c stepCall) (any, error) { - v, err := inner(c) - d := v.(Digested) - d.Beside = d.Beside[:len(d.Beside)-1] - return d, err - } - b.ex.Trunks = trunksOf(t, map[string]string{repoSDK: trunkS, "novox/mesh-catalog": trunkA}) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 0 { - t.Errorf("kept %v under a digest that does not cover every sibling", keys) - } -} - -type pkgPaths map[string][]TypeScriptPackage - -func (p pkgPaths) TypeScriptPackages(repository string) []TypeScriptPackage { return p[repository] } - -// contractsGit is a contracts package of mesh-delivery: one directory with its own package.json. -const contractsGit = "modules/mesh-delivery-contracts/ts/seats/git" - -// groupPackageBench is a group of a TypeScript member (mesh-delivery, with a contracts package) and the mesh-sdk member, -// whose merges change changed of each repository. -func groupPackageBench(t *testing.T, changed map[string][]string) *bench { - b := newBench(t) - b.ex.Modules = langs{repoA: {goBuildModule, nodeBuildModule}, repoSDK: {goBuildModule, nodeBuildModule}} - b.ex.Packages = pkgPaths{ - repoSDK: {{Dir: "", Paths: []string{"package-lock.json", "package.json", "src", "tsconfig.json"}}}, - repoA: {{Dir: contractsGit, Paths: []string{contractsGit}}}, - } - fetch := func(c stepCall) (any, error) { - f := b.fetch - f.Changed = changed[c.args["repository"].(string)] - return f, nil - } - b.steps.handlers["build_go_fetch"], b.steps.handlers["build_node_fetch"] = fetch, fetch - return b -} - -func nodeFetchOf(b *bench, repo string) stepCall { - for _, c := range b.steps.tool("fetch") { - if c.module == nodeBuildModule && c.args["repository"] == repo { - return c - } - } - return stepCall{} -} - -// design 47 G A-284, A-285 (ADR 0500 §5): every TypeScript fetch of a group's check is given every package any member's -// merge changes, each at its member's head with its directory there; the registry's only for a package none changes. -func TestATypeScriptMemberTakesEveryPackageTheGroupChanges(t *testing.T) { - sdk := map[string]any{"repository": repoSDK, "commit": head2, "ref": "refs/pull/12/head"} - git := map[string]any{"repository": repoA, "commit": head1, "ref": "refs/pull/7/head", "path": contractsGit} - for _, row := range []struct { - name string - changed map[string][]string - want []any - }{ - {"the SDK's sources", map[string][]string{repoSDK: {"go/delivery/x.go", "src/state.ts"}}, []any{sdk}}, - {"another member's contracts package", map[string][]string{repoA: {contractsGit + "/index.ts"}}, []any{git}}, - {"both", map[string][]string{repoSDK: {"package.json"}, repoA: {contractsGit + "/package.json", "go.mod"}}, []any{sdk, git}}, - {"Go alone", map[string][]string{repoSDK: {"go/delivery/x.go"}, repoA: {"modules/mesh-delivery-contracts/go/seats/git/contract.go"}}, nil}, - {"the manifest alone", map[string][]string{repoSDK: {"module.json"}}, nil}, - {"beside the named paths", map[string][]string{repoSDK: {"srcx/a.ts"}, repoA: {contractsGit + "x/a.ts"}}, nil}, - } { - b := groupPackageBench(t, row.changed) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2))) - for _, repo := range []string{repoA, repoSDK} { - got, _ := nodeFetchOf(b, repo).args["group-packages"].([]any) - if !reflect.DeepEqual(got, row.want) { - t.Errorf("%s: the Node fetch of %s was given %v, want %v", row.name, repo, got, row.want) - } - if pkg, ok := nodeFetchOf(b, repo).args["package"]; ok { - t.Errorf("%s: the Node fetch of %s was given the retired package %v", row.name, repo, pkg) - } - } - } - // A lone pull request: no group package. - b := groupPackageBench(t, map[string][]string{repoA: {contractsGit + "/index.ts"}}) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if got, ok := nodeFetchOf(b, repoA).args["group-packages"]; ok { - t.Errorf("a lone pull request's Node fetch was given %v", got) - } -} - -// design 47 G A-284: the mesh-sdk member is judged first, and its TypeScript fetch still learns the package another -// member's merge changes: every member's other fetches come before any TypeScript one. -func TestEveryMembersMergeIsKnownBeforeATypeScriptFetch(t *testing.T) { - b := groupPackageBench(t, map[string][]string{repoA: {contractsGit + "/index.ts"}}) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2))) - var order []string - for _, c := range b.steps.tool("fetch") { - order = append(order, c.module+" "+c.args["repository"].(string)) - } - want := []string{goBuildModule + " " + repoSDK, goBuildModule + " " + repoA, nodeBuildModule + " " + repoSDK, nodeBuildModule + " " + repoA} - if !reflect.DeepEqual(order, want) { - t.Errorf("fetches in the order %v, want %v", order, want) - } -} - -func TestNoStepOfACheckCarriesPublish(t *testing.T) { // ADR 0500 §4, 1309 (the checker's half): only the builder's trunk build publishes - b := groupPackageBench(t, map[string][]string{repoSDK: {"src/state.ts"}}) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2))) - if len(b.steps.calls) == 0 { - t.Fatal("no step ran") - } - for _, c := range b.steps.calls { - if _, ok := c.args["publish"]; ok { - t.Errorf("%s was given publish: %v", c.tool, c.args) - } - if strings.HasSuffix(c.tool, "_build") || strings.HasSuffix(c.tool, "_pack") { - t.Errorf("the checker asked %s: a check builds no artifact of its own", c.tool) - } - } -} - -// 1890/AC1, 1887/A5a: an ask whose step never ends (the build node stopped with it running, and nothing redelivered it in -// time) ends the check loudly at the asker's bound; the checker holds no place to free. -func TestAnAskWhoseStepNeverEndsEndsTheCheckLoudly(t *testing.T) { - b := newBench(t) - // A node took the ask and its step stays running: the bound runs from its start (review round 2 item 1). - b.asks.Answer = func(a buildstep.StepAsk) buildstep.Step { - return buildstep.Step{ID: a.ID, Tool: "check ask", Node: "shanks", State: buildstep.StepRunning, Started: time.Now()} - } - b.ex.Asks = buildrun.Asker{Seats: testSeats(), Publisher: b.asker(nil, nil), Waiter: b.asks, Bound: 20 * time.Millisecond} - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if f := out.Verdict.Failed; out.Verdict.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(f.Words, "on shanks did not end within") { - t.Fatalf("verdict = %+v", out.Verdict) - } - if n := len(b.asks.Asks()); n != 1 || b.asks.Asks()[0].Kind != buildstep.AskCheck || b.asks.Asks()[0].Check == nil { - t.Fatalf("asks = %+v, want one check ask", b.asks.Asks()) - } -} - -// 1887/A5a, ADR 0536 §4: a check is one ask per pull request and build module on the check stream, a re-judge after a -// trunk move one on the recheck stream, each carrying both levels with the kept verdicts taken by the build module. -func TestACheckIsOneAskAndAReJudgeGoesOnTheRecheckStream(t *testing.T) { - b := newBench(t) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - asks := b.asks.Asks() - if len(asks) != 1 || asks[0].Kind != buildstep.AskCheck || asks[0].Language != buildstep.AskGo || asks[0].Asker != "acme-checker" { - t.Fatalf("asks = %+v, want one Go check ask", asks) - } - if j := asks[0].Check; j == nil || !j.Kept || strings.Join(j.Levels, ",") != "unit,integration" || j.Fetch.Repository != repoA { - t.Fatalf("the job = %+v", asks[0].Check) - } - // B2g: the job carries the toolchain the checker agreed (ADR 0584), with its language, so a node on another declines it. - if tc := asks[0].Check.Toolchain; tc == nil || *tc != (buildstep.ToolchainUsed{Language: "go", Version: "go1.27", Recipe: "7"}) { - t.Errorf("the job's toolchain = %+v, want the agreed go toolchain", tc) - } - cs := caseOf(t, pullOf(repoA, 7, head1)) - cs.Kind = KindTrunk - b.judge(t, cs) - if asks := b.asks.Asks(); len(asks) != 2 || asks[1].Kind != buildstep.AskRecheck { - t.Fatalf("asks = %+v, want the re-judge on recheck", asks) - } -} - -// Review round 2 item 1: a check ask that waits in its stream longer than the step bound (no node has a free slot during a -// large rebuild) is not failed: the check goes on when a node takes it, and no second ask is put. -func TestACheckAskWaitingInItsStreamIsNotBounded(t *testing.T) { - b := newBench(t) - answer := b.asks.Answer - b.asks.Answer = nil - b.ex.Asks = buildrun.Asker{Seats: testSeats(), Publisher: b.asker(nil, nil), Waiter: b.asks, Bound: 20 * time.Millisecond} - done := make(chan Outcome, 1) - go func() { done <- b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) }() - for deadline := time.Now().Add(10 * time.Second); len(b.asks.Asks()) == 0; time.Sleep(time.Millisecond) { - if time.Now().After(deadline) { - t.Fatal("no ask was put") - } - } - time.Sleep(100 * time.Millisecond) // five bounds in the stream - select { - case out := <-done: - t.Fatalf("the check ended while its ask waited: %+v", out.Verdict) - default: - } - b.asks.End(answer(b.asks.Asks()[0])) // a node took it and ran it - if out := <-done; out.Verdict.State != meshdeliverycheckerclient.VerdictPass || len(b.asks.Asks()) != 1 { - t.Fatalf("verdict %+v after %d asks, want a pass from the one ask", out.Verdict, len(b.asks.Asks())) - } -} - -// 1917: the digest is taken inside the check ask, as the build module's own digest step answers it (no step key is asked -// of it), so a second check of the same heads keeps every package the first one passed: "N kept", nothing run again. -func TestASecondCheckOfTheSameHeadsKeepsWhatTheFirstPassed(t *testing.T) { - b := newBench(t) - first := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - u := first.Levels[buildstep.LevelUnit] - if first.State != meshdeliverycheckerclient.VerdictPass || u.Run == 0 || u.Kept != 0 { - t.Fatalf("the first check = %+v", first) - } - b.steps.calls = nil - second := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))).Verdict - if s := second.Levels[buildstep.LevelUnit]; second.State != meshdeliverycheckerclient.VerdictPass || s.Kept != u.Run || s.Run != 0 { - t.Fatalf("the second check's unit level = %+v, want %d kept and none run", s, u.Run) - } - if n := len(b.steps.tool("test")); n != 0 { - t.Errorf("%d test steps ran on the second check", n) - } -} - -// keptList is the indexer's kept predefined list as a test gives it. -type keptList string - -func (k keptList) PredefinedList(context.Context) (json.RawMessage, error) { - return json.RawMessage(k), nil -} - -// fixedManifests are the indexer's kept manifests by digest as a test gives them. -type fixedManifests map[string]catalogue.Manifest - -func (f fixedManifests) Manifest(_ context.Context, digest string) (catalogue.Manifest, error) { - m, ok := f[digest] - if !ok { - return catalogue.Manifest{}, errors.New("no manifest " + digest) - } - return m, nil -} - -// fixedDigests are the indexer's manifest digests as a test gives them. -type fixedDigests map[string]string - -func (f fixedDigests) ManifestDigests() map[string]string { return f } - -func (f fixedDigests) ManifestFingerprints() map[string]string { - out := map[string]string{} - for m := range f { - out[m] = "src2:" + m - } - return out -} - -// ADR 0578 §2: a change's manifests are judged by the indexer's judge, built at mesh-delivery's trunk and run as the -// composer is (a compose ask of its command); a refusal fails the check naming the manifest and each problem; a group -// whose mesh-delivery member changes the judge is judged by that member's head. -func TestTheIndexersJudgeJudgesTheChangesManifests(t *testing.T) { - web, trunk := strings.Repeat("e", 64), strings.Repeat("d", 40) - for _, row := range []struct { - name string - refused string - fails string - // untouched is the judge's refusal of mail, which the change leaves as it is, and trunkMail its refusal on the trunk: - // a problem the trunk had is a warning, one the change causes fails (ADR 0579 §2) - untouched, trunkMail string - // cycle reads the manifests, so the change's module graph is worked out (ADR 0603 §2): with "provisions" the change's - // web awaits mail's site while mail awaits web's database, and trunkCycle has the trunk's web await it too; with "bases" - // each is built on the other; with "verbs" each invokes the other's tool, and with "a verb and a provision" web invokes - // mail's tool while mail awaits web's database: both left out, so neither is refused (ADR 0614 §3, §6). - cycle string - trunkCycle bool - // series is the series of web's package the change raises it to, and the words its status line names (DLV-C4). - series, seriesWords string - // renames is what the change does to web's renamed-from ("bring", "drop") and what the seat mesh-config's verb - // renames answers ("served", "open" on g14, "not served", "unasked" with no seat to ask, "error"); DLV-C5. - renames, seat string - // unparsed is the indexer's words of why the pull request's head's seat definition of web-api does not parse. - unparsed string - // known are the judge's known packages the request hands it (DLV-I14, design 32): the packages state's names and, - // of web's package new in the group, the name its go.mod says at the member's head. - known []string - // emptyState is a packages state answered and empty, no member declaring a package: the judge is handed an empty - // list, never nil, so every name a manifest's packages names is refused (review round 1, DLV-I14). - emptyState bool - // indexer makes web the holder of the seat mesh-catalog, and the trunk's manifest validator answers for it: "held" with no verdict, - // "aside" with a field it does not know; ownJudge has the group change the judge, so the manifest is also judged by the - // trunk's, in a second ask (ADR 0633 clause 6, 1585/T22, T23) - indexer string - ownJudge bool - // seats is the seat list the checker holds: "read" gives the judge its two definitions as the request's Seats, "unread" - // is a reader the seat has not answered, and the manifests are then judged by nothing (ADR 0636 §1). - seats string - // try judges the same change as a whole group try, whose manifests come from the indexer's candidate of the try's - // group (issue 1921): the same judge, the same verdicts. - try bool - // heads has the change touch a contracts module too, whose head defines the Delivery seat mesh-catalog with a verb of - // a part it includes: "domain" is the domain's contracts module, so the judges get that definition over the list's - // (ADR 0636 §4, ADR 0633 §6); "outside" is mesh-contracts, whose definition of another domain's seat is not taken - // (ADR 0636 §5); "misnamed" is the domain's module whose seats/mesh-catalog/seat.json names another seat. - heads string - // headSeats lays heads that add a seat: the checking program's seat list is carried by every judge ask's request (ADR - // 0636 §4, issue 1921 D4). - headSeats bool - }{ - {name: "the seat list read is the request's Seats", seats: "read"}, - {name: "the members' heads' definitions over the list's, for the trunk's manifest validator too", seats: "read", indexer: "ok", heads: "domain"}, - {name: "a head's definition of a seat outside its module's domain is not taken", seats: "read", indexer: "ok", heads: "outside"}, - {name: "a head's definition naming another seat than its directory's fails the judging", seats: "read", heads: "misnamed", - fails: `names the seat "other", not "mesh-catalog"`}, - {name: "the seat list not read judges nothing", seats: "unread", - fails: "the change's manifests cannot be judged: the seat list is not read (the seat list is held from the bootstrap"}, - {name: "a seat definition that does not parse", unparsed: "seats/web-api/seat.json: unexpected end of JSON input", - fails: "novox/mesh-delivery#7: the seat definition of web-api (module web-contracts, go) does not parse: seats/web-api/seat.json: unexpected end of JSON input"}, - {name: "a rename brought, the verb not served", renames: "bring", seat: "not served", - fails: "web (novox/mesh-delivery#7) renames new-key from old-key: refused, the holder of the seat mesh-config does not serve its verb renames"}, - {name: "a rename brought, the verb served", renames: "bring", seat: "served"}, - {name: "a renamed-from dropped while its window is open", renames: "drop", seat: "open", - fails: "web (novox/mesh-delivery#7) drops renamed-from old-key of new-key while its rename window is open on g14"}, - {name: "a renamed-from dropped once its window closed", renames: "drop", seat: "served"}, - {name: "a rename the check cannot ask of", renames: "bring", seat: "error", fails: "the check cannot ask seat:mesh-config.renames: the bus said no"}, - {name: "a rename with no seat to ask", renames: "drop", seat: "unasked", fails: "this checker cannot ask seat:mesh-config.renames"}, - {name: "accepted"}, - {name: "a package series raised", series: "0.2", seriesWords: "web/pkg series 0.1 → 0.2"}, - {name: "a package series kept", series: "0.1"}, - {name: "a package new in the group", series: "0.1", known: []string{"git.novox.be/novox/mesh-sdk/go", "git.novox.be/novox/web/go"}}, - {name: "an answered packages state holding no name", emptyState: true, known: []string{}}, - {name: "the heads' seat list is carried by the head's judge and the trunk's", headSeats: true, indexer: "ok", ownJudge: true}, - {name: "accepted in a group try", try: true}, - {name: "refused in a group try", try: true, refused: "web has no id", fails: "the indexer's judge at mesh-delivery's trunk " + strings.Repeat("d", 40) + ` refuses the manifest of web: web has no id`}, - {name: "a cycle the group try makes", try: true, cycle: "provisions", fails: "the change's module graph has the cycle mail -> web -> mail"}, - {name: "the indexer accepted by the trunk's manifest validator", indexer: "ok"}, - {name: "the indexer held by the trunk's manifest validator", indexer: "held", fails: "the indexer web, the holder of the seat mesh-catalog, would never run: the trunk's manifest validator at mesh-delivery's trunk " + strings.Repeat("d", 40) + " does not accept its manifest: the manifest validator holds it, with no verdict yet"}, - {name: "the indexer with a field the trunk's manifest validator does not know", indexer: "aside", fails: "the manifest validator does not know its fields new_field, so it waits"}, - {name: "the indexer refused by the trunk's manifest validator", indexer: "refused", refused: "web has no id", fails: "does not accept its manifest: web has no id"}, - {name: "the indexer under a changed judge is judged by the trunk's as well", indexer: "aside", ownJudge: true, fails: "the manifest validator does not know its fields new_field, so it waits"}, - {name: "a touched manifest the judge holds", indexer: "heldplain", fails: "holds the manifest of web: it gave no verdict"}, - {name: "an untouched manifest's problem the trunk had", untouched: "mail says no credential form", trunkMail: "mail says no credential form"}, - {name: "a problem the change causes in an untouched manifest", untouched: "mail reads a state web no longer keeps", - fails: "refuses the manifest of mail: mail reads a state web no longer keeps"}, - {name: "a cycle the change makes", cycle: "provisions", fails: "the change's module graph has the cycle mail -> web -> mail"}, - {name: "a cycle the trunk has", cycle: "provisions", trunkCycle: true}, - {name: "a cycle of bases", cycle: "bases", fails: "the change's module graph has the cycle mail -> web -> mail"}, - {name: "a cycle of verbs", cycle: "verbs"}, - {name: "a cycle of a verb and a provision", cycle: "a verb and a provision"}, - {name: "refused", refused: "web requires \"amqp\"\nweb has no id", fails: "the indexer's judge at mesh-delivery's trunk " + strings.Repeat("d", 40) + ` refuses the manifest of web: web requires "amqp"; web has no id`}, - } { - b := newBench(t) - if row.headSeats { - b.heads = fstest.MapFS{ - repoA + "/modules/x-contracts/module.json": {Data: []byte(`{"module": "x-contracts", "build": {"artifacts": [{"name": "go", "kind": "package", "language": "go", "generated-from": "."}]}}`)}, - repoA + "/modules/x-contracts/seats/node-x/seat.json": {Data: []byte(`{"format":1,"seat":"node-x","scope":"node","grain":"whole","domain":"Delivery","decision":"ADR 1"}`)}, - } - } - b.ex.Manifests = fixedDigests{"mail": strings.Repeat("a", 64), "web": strings.Repeat("b", 64)} - b.ex.Trunks = fixedTrunks{heads: map[string]string{DeliveryRepository: trunk}} - b.ex.Predefined = keptList(`{"font-size": {"type": "number", "description": "the size"}}`) - if row.cycle != "" { - offer := func(name string) []catalogue.Offer { - return []catalogue.Offer{{Name: name, Scope: catalogue.ScopeMesh, AnsweredBy: catalogue.AnsweredByHelper}} - } - on := func(module string) *catalogue.Build { - return &catalogue.Build{On: []catalogue.BuildsOn{{Arg: "BASE", Module: module, Artifact: "img"}}} - } - trunkWeb := catalogue.Manifest{Module: "web", Provides: offer("database")} - if row.trunkCycle { - trunkWeb.Requires = []string{"site"} - } - mail := catalogue.Manifest{Module: "mail", Provides: offer("site"), Requires: []string{"database"}} - changed := catalogue.Manifest{Module: "web", Provides: offer("database"), Requires: []string{"site"}} - switch row.cycle { - case "bases": - mail = catalogue.Manifest{Module: "mail", Build: on("web")} - changed = catalogue.Manifest{Module: "web", Build: on("mail")} - case "verbs": - mail = catalogue.Manifest{Module: "mail", Tools: []string{"mail_send"}, Invokes: []string{"web.web_page"}} - changed = catalogue.Manifest{Module: "web", Tools: []string{"web_page"}, Invokes: []string{"mail.mail_send"}} - case "a verb and a provision": - mail = catalogue.Manifest{Module: "mail", Tools: []string{"mail_send"}, Requires: []string{"database"}} - changed = catalogue.Manifest{Module: "web", Provides: offer("database"), Invokes: []string{"mail.mail_send"}} - } - b.ex.Read = fixedManifests{strings.Repeat("a", 64): mail, strings.Repeat("b", 64): trunkWeb, web: changed} - } - if row.series != "" { - pkg := func(series string) *catalogue.Build { - return &catalogue.Build{Artifacts: []catalogue.Artifact{{Name: "pkg", Kind: catalogue.ArtifactPackage, Language: "go", Series: series}}} - } - b.ex.Read = fixedManifests{strings.Repeat("a", 64): {Module: "mail"}, strings.Repeat("b", 64): {Module: "web", Build: pkg("")}, - web: {Module: "web", Build: pkg(row.series)}} - } - if row.known != nil { - b.ex.KnownPackages = knownNames{"git.novox.be/novox/mesh-sdk/go": "mesh-sdk/go"} - b.ex.Read = fixedManifests{strings.Repeat("a", 64): {Module: "mail"}, strings.Repeat("b", 64): {Module: "web"}, web: {Module: "web", - Build: &catalogue.Build{Artifacts: []catalogue.Artifact{{Name: "pkg", Kind: catalogue.ArtifactPackage, Language: "go", Paths: []string{"go"}}}}}} - b.ex.Forge = headFiles{repoA + " modules/web/go/go.mod " + head1: "module git.novox.be/novox/web/go\n\ngo 1.26\n"} - } - if row.emptyState { - b.ex.KnownPackages = knownNames{} - b.ex.Read = fixedManifests{strings.Repeat("a", 64): {Module: "mail"}, strings.Repeat("b", 64): {Module: "web"}, web: {Module: "web"}} - } - if row.renames != "" { - renamed := map[string]catalogue.SettingDeclaration{"new-key": {Type: catalogue.ConfigString, RenamedFrom: "old-key"}} - plain := map[string]catalogue.SettingDeclaration{"new-key": {Type: catalogue.ConfigString}} - trunkWeb, headWeb := catalogue.Manifest{Module: "web", Settings: plain}, catalogue.Manifest{Module: "web", Settings: renamed} - if row.renames == "drop" { - trunkWeb, headWeb = headWeb, trunkWeb - } - b.ex.Read = fixedManifests{strings.Repeat("a", 64): {Module: "mail"}, strings.Repeat("b", 64): trunkWeb, web: headWeb} - // The verb faked from its definition: the answer of the seat's fixture (mesh-contracts seats/mesh-config). - fake := fakeRenames{} - switch row.seat { - case "not served": - fake.err = fmt.Errorf("%w (nothing answers it)", ErrRenamesNotServed) - case "error": - fake.err = errors.New("the bus said no") - case "open": - fake.answer = meshconfig.RenamesAnswer{Renames: []meshconfig.RenamesAnswerRenamesItem{{Module: "web", From: "old-key", To: "new-key", At: "2026-11-04T12:00:00Z", Open: []string{"g14"}}}} - } - if row.seat != "unasked" { - b.ex.Renames = fake - } - } - if row.unparsed != "" { - b.ex.SeatDefinitions = fakeSeatDefinitions{"novox/mesh-delivery#7": {{Seat: "web-api", Module: "web-contracts", Directory: "go", Why: row.unparsed}}} - } - if row.indexer != "" && row.indexer != "heldplain" { - b.ex.Read = fixedManifests{strings.Repeat("a", 64): {Module: "mail"}, strings.Repeat("b", 64): {Module: "web"}, - web: {Module: "web", Claims: []catalogue.Claim{{Name: CatalogSeat}}}} - } - if row.seats != "" { - b.ex.SeatList = fakeSeatList{read: row.seats == "read"} - } - var judged []buildstep.ComposeJob - answer := b.asks.Answer - b.asks.Answer = func(a buildstep.StepAsk) buildstep.Step { - if a.Compose == nil { - return answer(a) - } - judged = append(judged, *a.Compose) - read := composer.ManifestRead{Accepted: row.refused == "", Refused: row.refused} - switch row.indexer { - case "held", "heldplain": - read = composer.ManifestRead{} - case "aside": - read.SetAside = "new_field" - } - verdict, _ := json.Marshal(composer.Verdict{V: composer.Version, SDK: "exe:1", Cases: []composer.CaseVerdict{{Name: JudgeCase, - Manifests: map[string]composer.ManifestRead{"web": read, "mail": {Accepted: row.untouched == "", Refused: row.untouched}}}, - {Name: JudgeTrunk, Manifests: map[string]composer.ManifestRead{"web": {Accepted: true}, "mail": {Accepted: row.trunkMail == "", Refused: row.trunkMail}}}}}) - result, _ := json.Marshal(buildstep.ComposeAnswer{Key: "k", Verdict: verdict}) - return buildstep.Step{ID: a.ID, State: buildstep.StepPassed, Result: result} - } - p := pullOf(repoA, 7, head1) - if row.ownJudge { - p = pullOf(DeliveryRepository, 7, head1) - b.fetch.Changed = []string{JudgeDir + "/judge/judge.go"} - } - p.Modules = []string{"web"} - if row.heads != "" { - contracts, seat := "mesh-delivery-contracts", "mesh-catalog" - switch row.heads { - case "outside": - contracts = "mesh-contracts" - case "misnamed": - seat = "other" - } - dir := "modules/" + contracts - p.Modules = append(p.Modules, contracts) - // The checking program reads the heads the build node lays for its run (D6): the running checker reads none. - b.heads = fstest.MapFS{ - repoA + "/" + dir + "/module.json": {Data: []byte(`{"module": "` + contracts + `", "build": {"artifacts": [{"name": "go", "kind": "package", "language": "go", "generated-from": "."}]}}`)}, - repoA + "/" + dir + "/seats/mesh-catalog/seat.json": {Data: []byte(`{"format":1,"seat":"` + seat + `","scope":"mesh","grain":"whole","domain":"Delivery","decision":"ADR 1","includes":["lists"],` + - `"verbs":[{"name":"modules","input":{"type":"object"},"answer":{"type":"object"}}]}`)}, - repoA + "/" + dir + "/seats/mesh-catalog/fixtures/a.json": {Data: []byte(`{}`)}, - repoA + "/" + dir + "/parts/lists.json": {Data: []byte(`{"format":1,"part":"lists","verbs":[{"name":"seat-definitions","input":{"type":"object"},"answer":{"type":"object"}}]}`)}, - } - } - p.Fps = map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"web": {Fp2: "src2:" + strings.Repeat("f", 64), Manifest: web}} - // Issue 1921: the judge is built at the group's heads too, also a member that publishes no package yet. - cs := caseOf(t, p, pullOf("novox/mesh-networking", 9, head2)) - if row.try { - cs = TryCase("try-1", Try{Members: []TryMember{{Repository: repoA, Head: head1, Trunk: trunkA}}}, nil) - b.ex.Candidates = &fakeTryCandidates{cand: meshcatalog.CandidatesByGroupValue{Fpset: "fps", Pulls: []meshcatalog.CandidatesByGroupValuePullsItem{p}}} - } - v := b.judge(t, cs).Verdict - if line := Line(v, cs, cs.Pulls[0], nil, nil, nil); row.seriesWords != "" && !strings.Contains(line, row.seriesWords) || row.seriesWords == "" && strings.Contains(line, "series") { - t.Errorf("%s: the line %q, want it to name %q", row.name, line, row.seriesWords) - } - // The join (A2j finding 2): the verdict names each series change as {module, artifact, from, to}. - if want := []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem(nil); row.series == "0.2" { - if want = []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem{{Module: "web", Artifact: "pkg", From: "0.1", To: "0.2"}}; !reflect.DeepEqual(v.Series, want) { - t.Errorf("%s: the verdict's series %+v, want %+v", row.name, v.Series, want) - } - } else if len(v.Series) != 0 { - t.Errorf("%s: the verdict's series %+v, want none", row.name, v.Series) - } - if row.indexer == "ok" && !slices.ContainsFunc(cs.notes, func(n string) bool { - return strings.Contains(n, "the new indexer's manifest of web is accepted by the trunk's manifest validator") - }) { - t.Errorf("%s: the case says %v, want the new indexer's manifest said accepted by the trunk's manifest validator", row.name, cs.notes) - } - if row.seats == "unread" || row.heads == "misnamed" { - if v.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(v.Failed.Words, row.fails) || len(judged) != 0 { - t.Errorf("%s: %+v, judged %d, want a fail saying %q before any judge", row.name, v.Failed, len(judged), row.fails) - } - continue - } - // Issue 1921: the judge of the change is built at the group's heads (also a member that publishes no package yet), but - // the trunk's manifest validator that rules on a new indexer is built at the latest published versions alone, never - // at a group's head (ADR 0633 clause 6): a group with a member of its own then judges the indexer a second time. - trunkRuns := 0 - if row.indexer != "" && row.indexer != "heldplain" && (row.ownJudge || !row.try) { - trunkRuns = 1 - } - if want := 1 + trunkRuns; len(judged) != want { - t.Fatalf("%s: %d judge asks %+v, want %d", row.name, len(judged), judged, want) - } - for i, j := range judged { - pkgs := j.Fetch.Packages - atGroup := pkgs["git.novox.be/novox/mesh-networking"] == head2 - switch trunkRun := trunkRuns == 1 && i == len(judged)-1; { - case row.try: - case trunkRun && atGroup: - t.Errorf("%s: the trunk's manifest validator is built with the group's head: %v", row.name, pkgs) - case !trunkRun && !atGroup: - t.Errorf("%s: the judge at %v is fetched with the packages %v, want the group's mesh-networking member at its head %s", row.name, j.Fetch.Commit, pkgs, head2) - } - } - if row.ownJudge && (len(judged) != 2 || judged[0].Fetch.Commit != head1 || judged[1].Fetch.Commit != trunk) { - t.Fatalf("%s: judged %+v, want the head's judge and then the trunk's", row.name, judged) - } - if row.ownJudge { - judged = judged[1:] - } else if trunkRuns == 1 { - judged = judged[1:] // the group's run; the trunk's is the one read below - } - if len(judged) != 1 || judged[0].Fetch.Repository != DeliveryRepository || judged[0].Fetch.Commit != trunk || - judged[0].Package != JudgePackage || judged[0].Dir != JudgeDir { - t.Fatalf("%s: judged %+v (verdict %+v)", row.name, judged, v) - } - for _, j := range judged { - var seated composer.Request - if err := json.Unmarshal(j.Request, &seated); err != nil || (len(seated.Seats) == 1) != row.headSeats || - (row.headSeats && !strings.Contains(string(seated.Seats[0]), `"node-x"`)) { - t.Errorf("%s: the judge at %v is handed the seats %s, want the heads' list: %v", row.name, j.Fetch.Commit, seated.Seats, err) - } - } - var req composer.Request - if err := json.Unmarshal(judged[0].Request, &req); err != nil || req.Cases[0].Manifests["web"].Digest != web || - req.Cases[1].Name != JudgeTrunk || req.Cases[1].Manifests["web"].Digest != strings.Repeat("b", 64) || - req.Predefined["font-size"].Type != "number" || - req.Cases[0].Manifests["mail"].Digest != strings.Repeat("a", 64) { - t.Fatalf("%s: the request %+v: %v", row.name, req, err) - } - if row.heads != "" { - // Review round 2 of G (programs.go's digest side): the checking program's -seats input carries the digest of - // every definition the reader holds, never the list, and its answer is laid over the list (below). - var digests map[string]string - b.inputs.mu.Lock() - for _, body := range b.inputs.vals { - var f rules.Facts - if json.Unmarshal(body, &f) == nil && f.SeatDigests != nil { - digests = f.SeatDigests - } - } - b.inputs.mu.Unlock() - if want := map[string]string{"a": rules.SeatDigest(json.RawMessage(`{"seat":"a"}`)), "b": rules.SeatDigest(json.RawMessage(`{"seat": "b"}`))}; !reflect.DeepEqual(digests, want) { - t.Errorf("%s: the -seats input carries the digests %v, want the reader's list's %v", row.name, digests, want) - } - var got []string - for _, raw := range req.Seats { - var d struct { - Seat string `json:"seat"` - Verbs []struct { - Name string `json:"name"` - } `json:"verbs"` - } - _ = json.Unmarshal(raw, &d) - for _, v := range d.Verbs { - d.Seat += "." + v.Name - } - got = append(got, d.Seat) - } - want := []string{"a", "b", "mesh-catalog.seat-definitions.modules"} - if row.heads == "outside" { - want = want[:2] - } - if !slices.Equal(got, want) { - t.Errorf("%s: the trunk's manifest validator's seats %v, want %v: the list's with the head's definition, its part resolved", row.name, got, want) - } - } else if row.seats == "read" && (len(req.Seats) != 2 || string(req.Seats[0]) != `{"seat":"a"}` || string(req.Seats[1]) != `{"seat":"b"}`) { - t.Errorf("%s: the request's seats %s, want the two definitions the reader holds", row.name, req.Seats) - } - if row.seats == "" && !row.headSeats && len(req.Seats) != 0 { - t.Errorf("%s: the request's seats %s, want none from a checker that follows no list", row.name, req.Seats) - } - if !reflect.DeepEqual(req.Packages, row.known) || len(req.Input) != 0 && string(req.Input) != "null" { - t.Errorf("%s: the judge's known packages %v and input %s, want the known packages %v and no input", row.name, - req.Packages, req.Input, row.known) - } - switch { - case row.fails == "" && v.State != meshdeliverycheckerclient.VerdictPass: - t.Errorf("%s: %+v", row.name, v) - case row.fails != "" && (v.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(v.Failed.Words, row.fails)): - t.Errorf("%s: %+v, want a fail saying %q", row.name, v.Failed, row.fails) - } - } - if !changesJudge(DeliveryRepository, []Fetched{{Changed: []string{JudgeDir + "/judge/judge.go"}}}) || - changesJudge(DeliveryRepository, []Fetched{{Changed: []string{JudgeDir + "/internal/index/x.go"}}}) || - changesJudge("novox/mesh-catalog", []Fetched{{Changed: []string{JudgeDir + "/judge/judge.go"}}}) { - t.Error("which merge changes the judge") - } -} - -// fakeSeatList is the seat list reader as a test gives it: two definitions once read, else the reader's words. -type fakeSeatList struct{ read bool } - -func (f fakeSeatList) Definitions() ([]json.RawMessage, error) { - if !f.read { - return nil, errors.New("the seat list is held from the bootstrap (2 seats) and nothing new is acted on") - } - return []json.RawMessage{json.RawMessage(`{"seat":"a"}`), json.RawMessage(`{"seat":"b"}`)}, nil -} - -// knownNames are the packages state's names as a test gives them, each with the / it is built from. -type knownNames map[string]string - -func (k knownNames) PackageNames() map[string]string { return k } - -// fakeRenames is the seat mesh-config's verb renames as its definition answers it. -type fakeRenames struct { - answer meshconfig.RenamesAnswer - err error -} - -func (f fakeRenames) Renames(context.Context, string) (meshconfig.RenamesAnswer, error) { - return f.answer, f.err -} - -// fakeSeatDefinitions are the indexer's unparsed seat definitions by pull request (pullKey). -type fakeSeatDefinitions map[string][]UnparsedSeat - -func (f fakeSeatDefinitions) Unparsed(_ context.Context, repository string, pull int) ([]UnparsedSeat, error) { - return f[fmt.Sprintf("%s#%d", repository, pull)], nil -} diff --git a/modules/mesh-delivery-checker/internal/check/failure_words_test.go b/modules/mesh-delivery-checker/internal/check/failure_words_test.go deleted file mode 100644 index 37e2b87c..00000000 --- a/modules/mesh-delivery-checker/internal/check/failure_words_test.go +++ /dev/null @@ -1,108 +0,0 @@ -package check - -import ( - "encoding/json" - "mesh-delivery-checker/rules" - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" -) - -// The failure the build module reported for group r4g on 2026-10-23: the test logged a line, then failed with a multi-line -// t.Fatalf. Its output is what the build module now sends (its last lines, with the error line as Cause). -func fatalAfterLog() Failure { - return Failure{ - Package: "github.com/novox/mesh-controller/internal/broker", Test: "TestTheCataloguesDerivedSubjectsMeet", - Cause: "3 subscription(s) derive to a subject no emitter owns:", - Output: " agreement_catalogue_test.go:130: judged against /var/lib/mesh-build-go-work/id/beside/mesh-catalog as cloned\n" + - " agreement_catalogue_test.go:186: 3 subscription(s) derive to a subject no emitter owns:\n" + - " a.b.c\n d.e.f\n g.h.i\n--- FAIL: TestTheCataloguesDerivedSubjectsMeet (0.00s)", - } -} - -// A failed test's words are its whole failure message, kept within their bound by their last lines (issue 1901). -func TestAFailuresWordsAreItsWholeMessageWithinTheirBound(t *testing.T) { - for _, row := range []struct { - name string - test func(t *testing.T) - }{ - {"a failed tests verdict keeps its whole failure message", func(t *testing.T) { // 1901/AC1 - v := rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{fatalAfterLog()}}) - for _, want := range []string{"3 subscription(s) derive to a subject no emitter owns:", "a.b.c", "d.e.f", "g.h.i"} { - if !strings.Contains(v.Failed.Words, want) { - t.Errorf("words lack %q: %q", want, v.Failed.Words) - } - } - if len(v.Failed.Words) > rules.MaxWords+200 { - t.Errorf("words are %d bytes, bound %d", len(v.Failed.Words), rules.MaxWords) - } - }}, - {"the status line names the failure not the first logged line", func(t *testing.T) { // 1901/AC2 - v := rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{fatalAfterLog()}}) - got := firstFailed(*v) - if !strings.Contains(got, "3 subscription(s) derive to a subject no emitter owns:") || strings.Contains(got, "judged against") || strings.Contains(got, "\n") { - t.Errorf("firstFailed = %q", got) - } - // With no cause told apart (an older build module), the words still start at the first line, as before. - f := fatalAfterLog() - f.Cause = "" - v = rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{f}}) - if !strings.HasPrefix(afterHid(v.Failed.Words), "agreement_catalogue_test.go:130") { - t.Errorf("words = %q", v.Failed.Words) - } - }}, - {"words longer than the bound keep their last lines", func(t *testing.T) { // 1901/AC1 - f := Failure{Output: strings.Repeat("log line of some length\n", 500) + "the cause is here"} - v := rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{f}}) - if !strings.HasSuffix(v.Failed.Words, "the cause is here") || len(v.Failed.Words) > rules.MaxWords+200 { - t.Errorf("%d bytes, ends %q", len(v.Failed.Words), v.Failed.Words[len(v.Failed.Words)-30:]) - } - _ = meshdeliverycheckerclient.VerdictFail - }}, - // An older build module sends no "cause": its answer is still accepted and the verdict's words are its output, as before - // (1901/AC3). A failure that hides its cause (none, or a passing line) is said loudly first in the words and in the status - // line, naming the build module and the version it says it is, and the level still fails; a failure that keeps the - // contract is worded as before (1901/AC8). - {"an older build modules failure is accepted with its whole output", func(t *testing.T) { // 1901/AC3, AC8 - old := `{"package":"p","test":"TestX","output":"x_test.go:1: logged\nx_test.go:2: the old kept lines"}` - var f Failure - if err := json.Unmarshal([]byte(old), &f); err != nil || f.Cause != "" { - t.Fatalf("1901/AC3: err = %v, cause = %q", err, f.Cause) - } - v := rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{f}}) - if afterHid(v.Failed.Words) != "x_test.go:1: logged\nx_test.go:2: the old kept lines" { - t.Errorf("1901/AC3: words = %q", v.Failed.Words) - } - if got := firstFailed(*v); !strings.Contains(got, "the build module hid the failure") || strings.Contains(got, "\n") { - t.Errorf("1901/AC3, AC8: status = %q", got) - } - - by := "mesh-build-node with mesh-sdk v0.1.14-0.20261026184535-e40dd0f56a78" - for _, c := range []struct { - name, module, by, cause, output, loud string - }{ - {"no cause", "mesh-build-node", by, "", "test/b.test.ts: something", "the build module hid the failure (mesh-build-node at mesh-sdk v0.1.14-0.20261026184535-e40dd0f56a78): it sent no cause"}, - {"a passing line as its cause", "mesh-build-node", by, "\u2714 the same merge has the same id (8.006913ms)", "", "the build module hid the failure (mesh-build-node at mesh-sdk v0.1.14-0.20261026184535-e40dd0f56a78): its cause is a passing line"}, - {"from before the contract", "mesh-build-node", "", "", "\u2714 the same merge has the same id (8.006913ms)", "the build module hid the failure (mesh-build-node at a version before the failure contract): it sent no cause"}, - {"a real cause", "mesh-build-node", by, "one plus one is not three", "not ok 3 - fails", ""}, - } { - t.Run(c.name, func(t *testing.T) { - v := rules.LevelFailure("", c.module, "", "unit", Tested{By: c.by, Failed: []Failure{{Package: "modules/gitea", Test: "fails", Cause: c.cause, Output: c.output}}}) - if v.State != meshdeliverycheckerclient.VerdictFail { - t.Errorf("1901/AC8: the verdict is %q, want it failed", v.State) - } - line := firstFailed(*v) - switch { - case c.loud == "" && strings.Contains(v.Failed.Words, "hid the failure"): - t.Errorf("1901/AC8: a failure that keeps the contract is said hidden: %q", v.Failed.Words) - case c.loud != "" && (!strings.HasPrefix(v.Failed.Words, c.loud) || !strings.Contains(line, c.loud) || !strings.Contains(v.Failures[0].Words, "hid the failure")): - t.Errorf("1901/AC8: words %q, status %q, want both to start with %q", v.Failed.Words, line, c.loud) - } - }) - } - }}, - } { - t.Run(row.name, row.test) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/fakes_test.go b/modules/mesh-delivery-checker/internal/check/fakes_test.go deleted file mode 100644 index bade10ab..00000000 --- a/modules/mesh-delivery-checker/internal/check/fakes_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package check - -import ( - "context" - "sort" - "sync" -) - -// memKV is a bucket in memory with the revisions a real one gives. -type memKV struct { - mu sync.Mutex - vals map[string][]byte - revs map[string]uint64 - next uint64 - // creates counts the creates that succeeded, by key. - creates map[string]int -} - -func newMemKV() *memKV { - return &memKV{vals: map[string][]byte{}, revs: map[string]uint64{}, creates: map[string]int{}} -} - -func (m *memKV) Get(_ context.Context, key string) ([]byte, uint64, bool, error) { - m.mu.Lock() - defer m.mu.Unlock() - v, ok := m.vals[key] - return v, m.revs[key], ok, nil -} - -func (m *memKV) Create(_ context.Context, key string, value []byte) (uint64, error) { - m.mu.Lock() - defer m.mu.Unlock() - if _, ok := m.vals[key]; ok { - return 0, ErrConflict - } - m.next++ - m.vals[key], m.revs[key] = append([]byte(nil), value...), m.next - m.creates[key]++ - return m.next, nil -} - -func (m *memKV) Update(_ context.Context, key string, value []byte, revision uint64) (uint64, error) { - m.mu.Lock() - defer m.mu.Unlock() - if _, ok := m.vals[key]; !ok || m.revs[key] != revision { - return 0, ErrConflict - } - m.next++ - m.vals[key], m.revs[key] = append([]byte(nil), value...), m.next - return m.next, nil -} - -func (m *memKV) Keys(context.Context) ([]string, error) { - m.mu.Lock() - defer m.mu.Unlock() - keys := make([]string, 0, len(m.vals)) - for k := range m.vals { - keys = append(keys, k) - } - sort.Strings(keys) - return keys, nil -} - -func (m *memKV) Delete(_ context.Context, key string) error { - m.mu.Lock() - defer m.mu.Unlock() - delete(m.vals, key) - delete(m.revs, key) - return nil -} - -// memInputs keeps run inputs in a memKV, under their digest. -type memInputs struct{ kv *memKV } - -func (m memInputs) Keep(ctx context.Context, digest string, body []byte) error { - if _, _, found, _ := m.kv.Get(ctx, digest); found { - return nil - } - _, err := m.kv.Create(ctx, digest, body) - return err -} diff --git a/modules/mesh-delivery-checker/internal/check/gate_test.go b/modules/mesh-delivery-checker/internal/check/gate_test.go deleted file mode 100644 index 63680278..00000000 --- a/modules/mesh-delivery-checker/internal/check/gate_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package check - -import ( - "context" - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" -) - -// What the gate reads of the checker (R4e, lead's interface with dev-r4e-gate): the verdict's heads are the gate's hash over -// `#=`, a lone pull request is a group of one, and a move of a trunk marks -// mesh/check pending on every open pull request into it, every member's for a group, before any check starts. - -func owedState(t testing.TB, r *rig, repo string, number int, head string) string { - t.Helper() - key, err := CheckerOwedKey(repo, number, head) - if err != nil { - t.Fatal(err) - } - raw, _, found, _ := r.owed.Get(context.Background(), key) - if !found { - return "" - } - o, err := DecodeCheckerOwed(raw) - if err != nil { - t.Fatal(err) - } - return o.State -} - -func TestTheVerdictsHeadsAreTheGatesHashOverLowercaseHeads(t *testing.T) { // gate (b), (c) - ctx := context.Background() - r := newRig(t, passJudge()) - upper := strings.ToUpper(head1[:20]) + head1[20:] - r.setTrunks(t, map[string]string{"Novox/Mesh-Delivery": trunkA, repoA: trunkA, repoSDK: trunkS}) - cand := candidateOf(t, "feat/x", pullOf("Novox/Mesh-Delivery", 7, upper)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - want, _ := meshdeliveryclient.HeadsHash([]meshdeliveryclient.Head{{Repository: repoA, Number: 7, Head: head1}}) - if v := r.verdict(t, keyOf(t, "feat/x", cand)); v.Heads != want { - t.Errorf("heads = %q, want the gate's hash of the lone pull request, a group of one, %q", v.Heads, want) - } -} - -func TestAGroupsVerdictHeadsCoverEveryMember(t *testing.T) { // gate (b): hq's member too, as the gate's ask covers it - ctx := context.Background() - r := newRig(t, passJudge()) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2), pullOf(hqRepo, 3, head2)) - r.ch.Candidate(ctx, "feat%2Fx", cand) - r.ch.Wait() - want, _ := meshdeliveryclient.HeadsHash([]meshdeliveryclient.Head{{Repository: repoA, Number: 7, Head: head1}, {Repository: repoSDK, Number: 12, Head: head2}, - {Repository: hqRepo, Number: 3, Head: head2}}) - if v := r.verdict(t, keyOf(t, "feat/x", cand)); v.Heads != want { - t.Errorf("heads = %q, want %q", v.Heads, want) - } -} - -func TestATrunkMoveMarksEveryOpenPullRequestIntoItPendingAtOnce(t *testing.T) { // gate (a), lead decision L4 (1302's checker part) - ctx := context.Background() - r := newRig(t, passJudge()) - r.ch.Candidate(ctx, "feat%2Fg", candidateOf(t, "feat/g", pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2))) - r.ch.Candidate(ctx, "feat%2Fs", candidateOf(t, "feat/s", pullOf(repoSDK, 13, head1))) - r.ch.Wait() - for _, p := range []struct { - repo string - n int - head string - }{{repoA, 7, head1}, {repoSDK, 12, head2}, {repoSDK, 13, head1}} { - if s := owedState(t, r, p.repo, p.n, p.head); s != "success" { - t.Fatalf("%s#%d is %q before the move", p.repo, p.n, s) - } - } - // mesh-delivery's trunk moves; the re-judges it asks are held in their judge (in the stream, since R4g) meanwhile. - release := make(chan struct{}) - r.ch.Judge = &judgeFunc{f: func(context.Context, *Case, int) (Outcome, error) { <-release; return Outcome{Verdict: passing()}, nil }} - defer func() { close(release); r.ch.Wait() }() - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) - r.ch.TrunkMoved(ctx) - if s := owedState(t, r, repoA, 7, head1); s != "pending" { - t.Errorf("mesh-delivery#7, into the moved trunk, is %q, want pending", s) - } - if s := owedState(t, r, repoSDK, 12, head2); s != "pending" { - t.Errorf("mesh-sdk#12, a member of the same group, is %q, want pending", s) - } - if s := owedState(t, r, repoSDK, 13, head1); s != "success" { - t.Errorf("mesh-sdk#13, alone into a trunk that did not move, is %q, want its success to stand", s) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/graph_edges.go b/modules/mesh-delivery-checker/internal/check/graph_edges.go deleted file mode 100644 index e7c7afef..00000000 --- a/modules/mesh-delivery-checker/internal/check/graph_edges.go +++ /dev/null @@ -1,116 +0,0 @@ -package check - -import ( - "cmp" - "context" - "fmt" - "maps" - "slices" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" - "git.novox.be/novox/mesh-sdk/go/catalogue" - - "mesh-delivery-checker/rules" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" -) - -// The module graph of a change (novox/hq ADR 0603 §2, ADR 0614 §6): the running checker gathers its ordering edges, the -// checking program judges whether it has a cycle (rules.JudgeGraph, ADR 0656 §5). The graph is worked out from the -// catalogue as the change leaves it (every trunk manifest, each one a pull request touches replaced by its candidate's) -// and as the trunk has it, with the contract's ManifestGraph, the way the indexer works out its graph's edges; the facts -// carry only each edge's two modules and its kind. - -// ManifestReader reads a kept manifest by its digest (the indexer's manifests state). -type ManifestReader interface { - Manifest(ctx context.Context, digest string) (catalogue.Manifest, error) -} - -// gatherGraph records the change's and the trunk's module graph edges as a fact; none when the case touches no manifest -// or nothing reads manifests. A change's manifest that cannot be read fails the check, said, never passes it; a trunk's -// that cannot be read leaves the trunk's graph unread, so no cycle is the trunk's. -func (st *state) gatherGraph(ctx context.Context) { - if st.j.Manifests == nil || st.j.Read == nil || st.narrowTry() { - return - } - req, touched := judgeRequest(st.j.Manifests.ManifestDigests(), st.j.Manifests.ManifestFingerprints(), st.c.Pulls) - if len(touched) == 0 { - return - } - read := func(digests map[string]composer.Manifest) (map[string]catalogue.Manifest, error) { - out := map[string]catalogue.Manifest{} - for _, module := range slices.Sorted(maps.Keys(digests)) { - m, err := st.j.Read.Manifest(ctx, digests[module].Digest) - if err != nil { - return nil, fmt.Errorf("the manifest %s of %s: %w", digests[module].Digest, module, err) - } - out[module] = m - } - return out, nil - } - change, err := read(req.Cases[0].Manifests) - if err != nil { - st.fail(st.goModule(), "the change's module graph cannot be worked out, so no cycle can be ruled out: "+err.Error()) - return - } - g := rules.Graph{} - changed := orderingEdges(graph.OfManifests(change)) - trunk := map[[2]string]string{} - if before, err := read(req.Cases[1].Manifests); err == nil { - g.Trunk = true - trunk = orderingEdges(graph.OfManifests(before)) - } - for _, pair := range slices.SortedFunc(maps.Keys(changed), cmpPair) { - e := rules.Edge{From: pair[0], To: pair[1], Kind: changed[pair]} - if _, both := trunk[pair]; !both && g.Trunk { - e.Only = rules.EdgeChange - } - g.Edges = append(g.Edges, e) - } - for _, pair := range slices.SortedFunc(maps.Keys(trunk), cmpPair) { - if _, both := changed[pair]; !both { - g.Edges = append(g.Edges, rules.Edge{From: pair[0], To: pair[1], Kind: trunk[pair], Only: rules.EdgeTrunk}) - } - } - st.facts = append(st.facts, rules.Step{Module: st.goModule(), Graph: &g}) -} - -func cmpPair(a, b [2]string) int { - return cmp.Or(strings.Compare(a[0], b[0]), strings.Compare(a[1], b[1])) -} - -// orderingEdges are the graph's ordering edges (graph.Graph.Before) between its modules, each pair once with the kind it -// is first met by: a base, a provision or bus state awaited of another provider, or a verb the graph keeps served by -// another module (a base on itself is a cycle). A verb edge the graph leaves out (ADR 0614 §3), a toolchain and a package edge are none (§6). -func orderingEdges(g graph.Graph) map[[2]string]string { - out := map[[2]string]string{} - add := func(from, to, kind string) { - if _, ours := g[to]; !ours || (from == to && kind != rules.EdgeBase) { - return - } - if _, met := out[[2]string{from, to}]; !met { - out[[2]string{from, to}] = kind - } - } - for _, name := range slices.Sorted(maps.Keys(g)) { - n := g[name] - for _, b := range n.Bases { - add(name, b, rules.EdgeBase) - } - for _, a := range n.Awaits { - for _, p := range g.Providers(a) { - add(name, p, rules.EdgeAwaits) - } - } - for _, v := range n.Invokes { - if slices.Contains(n.LeftOut, v) { - continue - } - for _, s := range g.Servers(v) { - add(name, s, rules.EdgeInvokes) - } - } - } - return out -} diff --git a/modules/mesh-delivery-checker/internal/check/heard.go b/modules/mesh-delivery-checker/internal/check/heard.go deleted file mode 100644 index b10bd09f..00000000 --- a/modules/mesh-delivery-checker/internal/check/heard.go +++ /dev/null @@ -1,21 +0,0 @@ -package check - -import ( - "errors" - - "github.com/nats-io/nats.go" -) - -// Unheard is the error of a call that reached nobody: the bus had no responder for it, or none answered within the call's -// bound. The program wraps the errors of its forge calls in it where the bus gives a timeout; a no-responders error is -// known as it is. A build step is no call since R4g: an ask whose node stops is delivered again by its stream (ADR 0525 §6). -type Unheard struct{ Err error } - -func (u *Unheard) Error() string { return u.Err.Error() } -func (u *Unheard) Unwrap() error { return u.Err } - -// isUnheard says whether err is a call that reached nobody. A step that began and failed, or ended failed, is not. -func isUnheard(err error) bool { - var u *Unheard - return errors.As(err, &u) || errors.Is(err, nats.ErrNoResponders) -} diff --git a/modules/mesh-delivery-checker/internal/check/judge.go b/modules/mesh-delivery-checker/internal/check/judge.go deleted file mode 100644 index ac25c7e3..00000000 --- a/modules/mesh-delivery-checker/internal/check/judge.go +++ /dev/null @@ -1,992 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "fmt" - "mesh-delivery-checker/rules" - "slices" - "sort" - "strings" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// RunnerWorkspace is the runner the Go build module's digest and test steps are asked with when the merge changes the build -// module itself: the installed module compiles the candidate's program from the merged tree and runs the step as it, shut -// off (ADR 0535 §1). -const RunnerWorkspace = "workspace" - -// buildGoDir is the Go build module's directory in the catalogue: a merge changing a path under it is judged by its -// candidate (ADR 0535 §1). The other build modules' own directories are judged by the installed module until its part of issue 1898. -func buildGoDir(goModule string) string { return "modules/" + goModule + "/" } - -// changesBuildGo says whether a merge of the repository with these changed paths changes the Go build module. -func changesBuildGo(repository, goModule string, changed []string) bool { - if repository != catalogueRepository || goModule == "" { - return false - } - for _, p := range changed { - if strings.HasPrefix(p, buildGoDir(goModule)) { - return true - } - } - return false -} - -// The words of the line on the program that judged a change to the Go build module (ADR 0535 §2, §5). -func judgedByOldInstalled(module string) string { - return "judged by the installed " + module + ": it does not run a candidate yet" -} -func judgedByInstalled(module string) string { return "judged by the installed " + module } -func judgedByCandidate(module string) string { return "judged by the candidate's " + module + " at " } - -// Asks puts a check's ask on its build seat's stream and waits for its step (buildrun.Asker; ADR 0525 §1, §6): the -// checker chooses no node, starts no step and holds none; whichever build node pulls the ask runs the check. -type Asks interface { - Put(ctx context.Context, a buildstep.StepAsk) error - Wait(ctx context.Context, a buildstep.StepAsk) (buildstep.Step, error) -} - -// ToolchainEntries are the nodes' toolchain entries of a language (buildrun.ToolchainSet). -type ToolchainEntries interface { - Entries(language string) []buildstep.NodeToolchain -} - -// BuildModules says which build modules judge a repository: the Go one always, the Node one when the repository holds a -// TypeScript module. -type BuildModules interface { - BuildModules(repository string) []string -} - -// Examiner judges a case through the build seats (ADR 0484 clauses 3, 4, 10, 13; ADR 0525 §1, §3): for each pull request -// and build module it puts one check ask whose job fetches the head merged onto its trunk head, then runs the unit level -// and the integration level, taking the kept verdicts of unchanged packages and running the change's own tests first; -// every level and member runs to its end also after a failure, so the verdict names every failure (the operator, -// 2026-11-02). It judges the step's answer as it judged the tools' answers. -type Examiner struct { - // Module is the checker's own module, the credential's: the asker of its asks and the owner of its buckets (design 47 G A-296). - Module string - Asks Asks - // DeclineBound is how long a placed ask may go on being declined, from its first decline, before the check fails - // saying no node with its need took it (issue 890, ADR 0552); DefaultDeclineBound when zero. - DeclineBound time.Duration - // Toolchains are the nodes' toolchains: a kept verdict names the toolchain the nodes agree on. - Toolchains ToolchainEntries - Kept Kept - // Previews is the previews bucket; nil writes none. - Previews KV - Modules BuildModules - // Seats finds the build modules from the seat list and the holders of seats (design 47 G A-82). - Seats *buildrun.BuildSeats - // Runs says which commit the mesh runs of a module (the indexer's modules); nil knows none. - Runs interface{ CommitOf(module string) string } - // Forge reads the forge's files for the siblings a repository's tests read; nil reads none. - Forge Forge - // Published names the latest published version of every mesh package a module of the mesh uses, by package, from the - // indexer's modules (novox/hq ADR 0573 §2): a check builds against those, or against a member's head for a package - // its group publishes (§4), whatever go.mod names. Nil names none, and go.mod's versions are built. - Published interface { - LatestPackages() buildstep.PackageVersions - } - // KnownPackages names the packages the indexer's packages state knows (its series keys, meshcatalog.PackagesByPackageSeriesValue), by the - // name in its own ecosystem, each with the `/` it is built from: the names a manifest's `packages` is - // judged against (manifests_judge.go, design 32). Nil, or PackageNames answering nil while the state is not read yet, - // hands the judge no names, and it judges none; an empty map is a state read and empty, against which every name fails. - KnownPackages interface { - PackageNames() map[string]string - } - // Builds says how the build of a fingerprint the candidate carries stands (the builder's builds bucket); nil says nothing - // of the builds. - Builds BuildStates - // BuildEnds waits on the builder's builds of the candidate before the check composes (ADR 0603 §10); nil composes - // without waiting, said in the composition's warnings. - BuildEnds BuildEnds - // BuildWait is how long the check waits for those builds (the setting build-wait-bound); DefaultBuildWait when 0. - BuildWait time.Duration - // Announce says a preview was written under the key (EventPreviewWritten); nil says nothing. - Announce Announcer - // Dirs names a module's directory in its repository, from the indexer's modules, so a manifest is read at a member's - // head (tagwanted.go); nil, or a module it does not know, tries modules/ and the repository's root. - Dirs interface { - ModuleDir(module string) (string, bool) - } - // Packages names, of a repository, its TypeScript package artifacts, each by its directory and the paths - // (repository-relative) it is built from, from the indexer's modules (meshcatalog.ModulesByModuleValue.ArtifactPaths, - // lead decision L8); nil serves no group package. - Packages interface { - TypeScriptPackages(repository string) []TypeScriptPackage - } - // Trunks are the trunk heads of every repository, for the siblings a repository's tests read. - Trunks interface{ Heads() map[string]string } - // Manifests are the indexer's manifest digests by module: the catalogue a change's manifests are judged in by the - // indexer's judge (manifests_judge.go, novox/hq ADR 0578 §2); nil judges no manifest. - Manifests TrunkManifests - // SeatDefinitions reads the indexer's seat definitions of a pull request (seatdefs.go, design 26); nil reads none. - SeatDefinitions SeatDefinitions - // SeatList gives the seat list the checker's reader holds from the seat mesh-catalog (verb seat-definitions): the base the - // checking program lays the heads' definitions over (programs.go, novox/hq ADR 0636 §1, §4); nil gives it none. - SeatList SeatList - // Renames asks the seat mesh-config's verb renames for a change that brings or drops a `renamed-from` (renames.go, - // design 32); nil fails such a change, saying it cannot ask. - Renames Renames - // Read reads a kept manifest by its digest: the change's module graph is worked out from them (graph_edges.go, novox/hq - // ADR 0603 §2); nil works out no graph. - Read ManifestReader - // Serving says, from what runs, whether a running healthy build serves a seat verb or module tool (novox/hq ADR 0614 - // §7): the node-engines' haves, the builder's build of each, its manifest (graph.Served). Nil reads nothing, and no - // changed build module is named for a verb it invokes. - Serving interface { - Served(ctx context.Context) (func(invoke string) bool, error) - } - // Predefined reads the catalogue's predefined keys the indexer keeps (manifests_judge.go); nil reads none. - Predefined PredefinedList - // Compositions makes a check's composition (ADR 0593 §7): the engines' answers (EngineCompositions); nil leaves the - // composition not run. - Compositions CompositionReader - // Nodes names every node with a record, read from each `.node` of the node-engine's have (novox/hq ADR 0567 - // §12): every check ask carries them (CheckJob.NodeNames) for the names check, so no repository lists them. A check - // whose names cannot be read, or that reads none, is not asked and fails saying so; nil hands no names. - Nodes interface { - Names(ctx context.Context) ([]string, error) - } - // Candidates answers the indexer's candidate of a try's group once it wrote it from the try's previews, the manifests - // and fingerprints a group try's manifest validator and composition judge (issue 1921), and of a pull request's check - // that began before the indexer read its merge preview; nil leaves such a case with no manifest or composition judged, - // said. - Candidates TryCandidates - // Inputs keeps the checking program's inputs (the state InputsStateName, served on InputVerb); BeginBound is how long a run ask may wait for a - // build node to begin it (DefaultBeginBound when zero). - Inputs Inputs - BeginBound time.Duration - Now func() time.Time - Logf func(format string, args ...any) -} - -// TryCandidates answers the candidate the indexer holds for a try's group at its heads hash, waiting for it within the -// bound; an error says it did not come (and why). -type TryCandidates interface { - TryCandidate(ctx context.Context, group, heads string, bound time.Duration) (meshcatalog.CandidatesByGroupValue, error) -} - -// CompositionReader composes a check: the engines' answers, which the rules judge (rules.JudgeEngines); an error is only -// a case that cannot be composed at all. -type CompositionReader interface { - Compose(ctx context.Context, c *Case) (rules.Composed, error) -} - -func (j *Examiner) now() time.Time { - if j.Now != nil { - return j.Now() - } - return time.Now() -} - -func (j *Examiner) logf(format string, args ...any) { - if j.Logf != nil { - j.Logf(format, args...) - } -} - -// fetchBeside are the siblings as the fetch is asked to place them. -func fetchBeside(refs []BesideRef) []buildstep.FetchBeside { - out := make([]buildstep.FetchBeside, 0, len(refs)) - for _, r := range refs { - out = append(out, buildstep.FetchBeside{Repository: r.Repository, Commit: r.Commit}) - } - return out -} - -// besideLines are the siblings as the digest step echoes them: ` `, sorted. -func besideLines(refs []BesideRef) []string { - out := make([]string, 0, len(refs)) - for _, r := range refs { - out = append(out, r.Repository+" "+r.Commit) - } - sort.Strings(out) - return out -} - -// TypeScriptPackage is one TypeScript package artifact of a repository's module: Dir, its directory in the repository -// ("" for the repository's root), and Paths, the repository-relative paths it is built from. -type TypeScriptPackage struct { - Dir string - Paths []string -} - -// target is a pull request on one build module: the node that pulled its ask, the workspace its fetch made and what it -// said. -type target struct { - pull Pull - module string - // language is the language of the toolchain the build module builds with (the `on` of its seat's acting rule). - language string - node string - toolchain string - // agreed is the toolchain the ask names, so a node off it declines the check (ADR 0584); nil when none is agreed. - agreed *buildstep.ToolchainUsed - fetched Fetched - // fetchArgs are the arguments of the fetch its check ask runs. - fetchArgs buildstep.Fetch - // priority are the Go packages (import paths) or the Node module directories whose test files the merge changes. - changed []string - // beside are the lines ` ` of the siblings the workspace was given, sorted: its tests may read them, - // so a verdict is kept or taken only under a digest that says it folded exactly these in (lead decision L5). - beside []string - // runner is RunnerWorkspace when the target's ask runs the candidate's own build module (ADR 0535 §1), empty otherwise. - runner string - // judged is what the line says of the program that judged a change to the build module; empty for any other change. - judged string -} - -// judgedBy takes what a step under runner workspace answered of the program that ran it (judged_by): the candidate, or the -// installed module (a module that does not take the runner says nothing, and is asked without it from now on: ADR 0535 §2). -// It says whether the candidate ran. -func (t *target) judgedBy(answer string) bool { - switch { - case strings.HasPrefix(answer, "candidate "): - t.judged = judgedByCandidate(t.module) + short12(strings.TrimPrefix(answer, "candidate ")) - return true - case answer == "": - t.judged, t.runner = judgedByOldInstalled(t.module), "" - default: - t.judged, t.runner = judgedByInstalled(t.module), "" - } - return false -} - -// stepArgs are a step's arguments with the target's runner. -func (t *target) stepArgs(args map[string]any) map[string]any { - if t.runner != "" { - args["runner"] = t.runner - } - return args -} - -// state is one judging. -type state struct { - j *Examiner - c *Case - targets []*target - levels rules.Tally - // facts are the facts of the check met so far, in order: what the checking program judges (milestone 47/B0). - facts []rules.Step - // composition is how the check composed, recorded after every step (compose). - composition *rules.Composition - clone time.Duration - slow []string - // beside are the siblings read at their trunk's head, by repository (ADR 0548 §6). - beside map[string]string - // judgeHead is the group's mesh-delivery member head when its merge changes the judge (ADR 0578 §2); empty judges - // with mesh-delivery's trunk. - judgeHead string - // predefinedHead is the catalogue member's head when its merge changes predefined.json: the list is read there. - predefinedHead string - // unpreviewed are the members (pullKey) with no preview of a merge, each with which of the two it is: a head that does not - // merge, or a fetch that did not answer (design 47 G A-286). The indexer holds no manifest of them, so the assigner's - // composition would only wait: it is not awaited. A member whose fetch merged is previewed whatever its later steps ended with. - unpreviewed []string - // conflicted are the members (pullKey) whose head does not merge into its trunk. - conflicted map[string]bool - // outOfStep are, by pull request (pullKey), the generated files a level's compare step found out of step (design 26). - outOfStep map[string][]string - // noCandidate says why the case has no previewed candidate of its heads from the indexer within the bound: for a whole - // try its manifests were not judged and it was not composed; for a pull request's check that began on the indexer's - // first write, its manifests were judged from that write and it was not composed. Empty when it has one, and for a pull - // request's check whose case already holds its fingerprints. - noCandidate string -} - -// narrowTry says the case is a try narrowed to a level or to some tests: it judges no manifest, graph or composition. -func (st *state) narrowTry() bool { return st.c.Try != nil && !st.c.Try.Whole() } - -// WaitsOnPreview says a candidate's module has no fingerprint yet because the indexer wrote it from a pull message alone, -// before it read the head's merge preview (meshcatalogclient.NoneNoPreview): its fingerprint comes with the preview, on the -// same heads, so a candidate that holds one is not yet the candidate of its heads previewed. -func WaitsOnPreview(m meshcatalog.CandidatesByGroupValuePullsItemFpsValue) bool { - return m.None2 == meshcatalogclient.NoneNoPreview -} - -// previewPending says a module of the case's pulls waits on its merge preview (WaitsOnPreview). -func (st *state) previewPending() bool { - for _, p := range st.c.Pulls { - for _, m := range p.Fps { - if WaitsOnPreview(m) { - return true - } - } - } - return false -} - -// takeTryCandidate gives a whole try's pulls the fingerprints and manifests the indexer's candidate of its group holds, -// once the indexer wrote it from the try's previews. A pull request's check has them from its candidate (CaseOf), but the -// indexer writes a pull request's candidate first from its pull message alone and its fingerprints only with the merge -// preview, on the same heads: a check that began on that first write takes the previewed candidate too, before it judges -// the manifests, waits on the builds and composes (ADR 0603 §10; issue 1921: a check otherwise waited on no build and -// the engines, reading the previewed candidate, refused its modules as not yet built). A case with no such candidate is -// said so, in a note and in its composition, and is no pass (Tryer.run). -func (st *state) takeTryCandidate(ctx context.Context) { - if st.c.Try != nil && !st.c.Try.Whole() || st.c.Try == nil && !st.previewPending() { - return - } - no := func(why string) { - what := "the group's manifests and composition were not judged: " - if st.c.Try == nil { - what = "the composition was not judged (the manifests were judged from the indexer's first write): " - } - st.noCandidate = what + why - st.c.note(st.noCandidate) - } - if st.j.Candidates == nil { - no("the checker reads no candidate of the indexer's") - return - } - if len(st.unpreviewed) > 0 { - no("no preview of a merge of " + strings.Join(st.unpreviewed, ", ")) - return - } - if st.c.Wait != nil { - st.c.Wait("the indexer's candidate of the group at its heads (up to " + st.j.buildWait().String() + ")") - defer st.c.Wait("") - } - cand, err := st.j.Candidates.TryCandidate(ctx, st.c.Group, st.c.HeadsHash, st.j.buildWait()) - if err != nil { - no(err.Error()) - return - } - for i, p := range st.c.Pulls { - for _, cp := range cand.Pulls { - if cp.Repository == p.Repository && cp.Head == p.Head { - st.c.Pulls[i].Modules, st.c.Pulls[i].Fps = cp.Modules, cp.Fps - } - } - } - st.c.FPSet = cand.Fpset -} - -// Judge runs the case (it is the Judge of a Checker). A failure of the change, of a merge or of a step is a verdict; an error is only a case that cannot -// be judged at all. -func (j *Examiner) Judge(ctx context.Context, c *Case) (Outcome, error) { - st := &state{j: j, c: c, levels: rules.NewTally(), - beside: map[string]string{}} - // Every member and level runs to its end, and every manifest the change touches is judged by the indexer's judge (ADR - // 0578 §2), also after a failure: the verdict names every failure, not only the first (the operator, 2026-11-02). - // Each failure is a fact recorded where it is met; the verdict is the judging rules' of the facts. - st.judgeAll(ctx) - st.takeTryCandidate(ctx) - st.seriesChanges(ctx) // DLV-C4: a fact of the check, named in the verdict whatever it is - // The heads' seat list, from the checking program, before the validator and the composer are asked (ADR 0636 §4). - // A list it cannot make ends the check there, failed naming the checking program, worded from the facts so far. - var answer rules.Answer - var by *meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy - if st.seatList(ctx) { - st.judgeManifests(ctx) - st.gatherGraph(ctx) - st.judgeRenames(ctx) - st.refuseUnparsed(ctx) - st.compose(ctx) - // The verdict is the checking program's of the facts (ADR 0644 §1, ADR 0656 §5). - answer, by = st.judged(ctx) - } else { - answer = rules.Answer{V: rules.AnswerVersion, Verdict: rules.Judge(st.factsOf())} - } - for _, n := range answer.Notes { - st.c.note(n) - } - answer.Verdict.JudgedBy = by - out := st.outcome(answer.Verdict) - out.Builds = st.j.buildNotes(ctx, st.c) - return out, nil -} - -// compose records how the check composed as the facts' composition, after every step (ADR 0593 §7, §9): kept by a carry, -// not run (said why), or the engines' answers with the candidate's builds awaited first (ADR 0603 §10). A narrowed try -// and an examiner that composes nothing record none. -func (st *state) compose(ctx context.Context) { - if st.c.Composition != nil && st.c.Try == nil { - // A carry whose candidate's fingerprints did not change keeps the composition it passed (ADR 0548 §5). - kept := *st.c.Composition - st.composition = &rules.Composition{Kept: &kept} - st.c.note("the composition is kept: no fingerprint of a module it composed changed") - return - } - if st.narrowTry() { - return - } - if st.noCandidate != "" { - st.composition = &rules.Composition{NotRun: st.noCandidate} - return - } - if st.j.Compositions == nil { - return - } - if len(st.unpreviewed) > 0 { - // An engine would only say it cannot read a manifest the indexer will not have: the check does not ask it. - st.composition = &rules.Composition{NotRun: "no preview of a merge of " + strings.Join(st.unpreviewed, ", ") + - ", so the change cannot be composed"} - return - } - // ADR 0603 §10: the check composes with the candidate's builds; whether it failed already is the running rules' word - // on the facts so far, an asking choice only (the verdict is the rules' of every fact). - failed := rules.Judge(st.factsOf()).State == meshdeliverycheckerclient.VerdictFail - words, builds, late := st.awaitBuilds(ctx, failed) - c := &rules.Composition{Waits: words, BuildsFailed: builds, FPSet: st.c.FPSet} - st.composition = c - if late != "" { - c.NotRun = late // the builder's lateness, said by name, never the change's refusal (issue 1921) - return - } - comp, err := st.j.Compositions.Compose(ctx, st.c) - if err != nil { - // Said in the verdict, never left as a composition not yet run (review finding 4). - st.j.logf("%s: the composition could not be made, so it is said as not run: %v", st.c.Key, err) - c.NotRun = "not made: " + err.Error() - return - } - c.Composed = &comp -} - -// outcome is the verdict judged from the facts with the slowest tests, the siblings read and what judged a build module. -func (st *state) outcome(v meshdeliverychecker.VerdictsByGroupHeadsValue) Outcome { - slow := rules.Slowest(st.levels) - out := Outcome{Verdict: v, Slowest: slow, OutOfStep: st.outOfStep} - if len(st.beside) > 0 { - out.Beside = st.beside - } - for _, t := range st.targets { - if t.judged != "" { - if out.Judged == nil { - out.Judged = map[string]string{} - } - out.Judged[pullKey(Pull{Repository: t.pull.Repository, Number: t.pull.Number})] = t.judged - } - } - return out -} - -// stepOutOfStep keeps the out-of-step files a step of the pull request named, each once, sorted. -func (st *state) stepOutOfStep(p Pull, files []string) { - if len(files) == 0 { - return - } - if st.outOfStep == nil { - st.outOfStep = map[string][]string{} - } - k := pullKey(Pull{Repository: p.Repository, Number: p.Number}) - all := append(st.outOfStep[k], files...) - slices.Sort(all) - st.outOfStep[k] = slices.Compact(all) -} - -// fail records a failure the asking met as a fact of the check, where it is met, and answers it as a verdict of failure -// at a machine: the verdict is the judging rules' of the facts (rules.Judge), so a failure only returned is no failure -// (milestone 47/B0). -func (st *state) fail(machine, words string) { - st.facts = append(st.facts, rules.Step{Failed: &FailedFirst{Machine: machine, Words: words}}) -} - -// fail is a verdict of failure at a machine, for a step that answers one before any member is asked (tagged); it is -// recorded as facts (failedAll), never returned as the check's verdict. -func fail(machine, words string) *meshdeliverychecker.VerdictsByGroupHeadsValue { - v := failure(machine, words) - return &v -} - -// failedAll records every failure a verdict of the asking names (its list, else its first) as facts of the check. -func (st *state) failedAll(v meshdeliverychecker.VerdictsByGroupHeadsValue) { - all := failedList(v.Failures) - if len(all) == 0 { - all = []FailedFirst{failedOf(v)} - } - for _, f := range all { - st.facts = append(st.facts, rules.Step{Failed: &f}) - } -} - -// factsOf are the check's facts as met: what the checking program judges. -func (st *state) factsOf() rules.Facts { - f := st.factsHead() - f.Steps, f.CloneMS, f.Composition, f.Notes = st.facts, st.clone.Milliseconds(), st.composition, st.c.Notes() - f.Series = st.c.allSeries() - return f -} - -// levels are the levels a case's asks run: both, or the one a try names. -func (st *state) levelsOf() []string { - if st.c.Try != nil && st.c.Try.Level != "" { - return []string{st.c.Try.Level} // a try of one level runs that level alone - } - return []string{buildstep.LevelUnit, buildstep.LevelIntegration} -} - -// judgeAll puts one check ask per pull request and build module the repository needs, the mesh-sdk member first, and -// judges each answer. A head that does not merge, a pin that is not allowed or a level that fails is a failure of that -// member; every other member is still judged, and the verdict names every failure (the operator, 2026-11-02), unjoined -// to its first lines (settled does that). Only a check whose context ended stops. -// -// Every member's asks of the other languages come first and its TypeScript asks after them all: the merges those -// fetches answer say which TypeScript packages the group changes, and each TypeScript fetch is given them all -// (groupPackages; design 47 G A-284, A-285). -func (st *state) judgeAll(ctx context.Context) { - pulls := slices.Clone(st.c.Pulls) - slices.SortStableFunc(pulls, func(a, b Pull) int { - if (a.Repository == SDKRepository) != (b.Repository == SDKRepository) { - if a.Repository == SDKRepository { - return -1 - } - return 1 - } - return 0 - }) - met := len(st.facts) - stopped := func() bool { - if ctx.Err() == nil { - return false - } - if !st.failedSince(met) { // an ask that ended with the context said it already - st.fail(st.j.Module, ctx.Err().Error()) - } - return true - } - merged := make([][]Fetched, len(pulls)) - modules := make([][]string, len(pulls)) - for i, p := range pulls { - modules[i] = st.j.Modules.BuildModules(p.Repository) - } - // Each phase puts every ask of its own at once and then waits for them all (design 47 G A-304, ADR 0525 §4): its - // asks are judged in the order they were put, whatever order they end in. - phase := func(typeScript bool, group []buildstep.FetchPackage) bool { - var asked []*asking - for i, p := range pulls { - for _, bm := range modules[i] { - if (st.j.languageOf(bm) == languageTypeScript) != typeScript { - continue - } - if stopped() { - return false - } - if t := st.memberTarget(ctx, p, bm, group); t != nil { - if q := st.prepareAsk(ctx, t, &merged[i], st.levelsOf(), nil, nil); q != nil && st.putAsk(ctx, q) { - asked = append(asked, q) - } - } - } - } - for _, q := range asked { - go q.wait(ctx, st) - } - for n, q := range asked { - if n > 0 && stopped() { - return false - } - <-q.done - st.judgeAsk(ctx, q) - } - return true - } - if !phase(false, nil) { - return - } - var group []buildstep.FetchPackage - if len(st.c.Pulls) > 1 { - group = st.groupPackages(pulls, merged) - } - if !phase(true, group) { - return - } - for i, p := range pulls { - // Every build module's fetch merged (each is in merged once): the preview is written, also when the member's tests - // or a later step failed, so the indexer holds its manifests and the assigner can compose the change (review of - // 650a1d0; design 47 G A-286). - switch { - case st.narrowTry(): // a try of a level or some tests owes the indexer no preview: it judges no manifest - case len(merged[i]) == len(modules[i]): - st.j.writePreview(ctx, p, merged[i]) - case st.conflicted[pullKey(p)]: - st.unpreviewed = append(st.unpreviewed, pullKey(p)+" (its head does not merge)") - default: - st.unpreviewed = append(st.unpreviewed, pullKey(p)+" (its fetch did not answer)") - } - st.judgedByMember(p, merged[i]) - } -} - -// memberTarget is the target of the check ask of one build module of a member, nil when it cannot be asked (said as a -// failure); a TypeScript fetch is given the group's packages. -func (st *state) memberTarget(ctx context.Context, p Pull, bm string, group []buildstep.FetchPackage) *target { - t := &target{pull: p, module: bm, language: st.j.languageOf(bm)} - if tc, none := buildstep.AgreedToolchain(st.j.Toolchains.Entries(t.language)); none == "" { - t.toolchain = tc.Version - t.agreed = &buildstep.ToolchainUsed{Language: t.language, Version: tc.Version, Recipe: tc.Recipe} - } - args := buildstep.Fetch{Repository: p.Repository, Commit: p.Head, Ref: refOf(p.Number), Base: p.Trunk} - if t.language == languageTypeScript { - args.GroupPackages = group - } - if t.language == languageGo { - beside, err := st.j.besideFor(ctx, st.c, p) - if err != nil { - st.fail(forgeMachine(err, bm), err.Error()+unheardWords(err)) - return nil - } - if len(beside) > 0 { - args.Beside = fetchBeside(beside) - t.beside = besideLines(beside) - besideAtTrunk(st.c, beside, st.beside) - } - if p.Repository == catalogueRepository { - t.runner = RunnerWorkspace // used by the build module when the merge changes it (ADR 0535 §1) - } - } - t.fetchArgs = args - st.targets = append(st.targets, t) - return t -} - -// groupPackages are the TypeScript packages the group's merges change (design 47 G A-284, A-285): every package of a -// member whose named paths a merge of that member changes, each at the member's head with its directory there, in the -// order of the members and then of the directories. A change of the manifest alone, or of files outside those paths, -// changes no package (ADR 0500 §5). -func (st *state) groupPackages(pulls []Pull, merged [][]Fetched) []buildstep.FetchPackage { - if st.j.Packages == nil { - return nil - } - var out []buildstep.FetchPackage - for i, p := range pulls { - for _, pkg := range st.j.Packages.TypeScriptPackages(p.Repository) { - if changesPaths(pkg.Paths, merged[i]) { - out = append(out, buildstep.FetchPackage{Repository: p.Repository, Commit: p.Head, Ref: refOf(p.Number), Path: pkg.Dir}) - } - } - } - return out -} - -// failedSince says a failure was recorded among the facts from the nth on. -func (st *state) failedSince(n int) bool { - for _, f := range st.facts[n:] { - if f.Failed != nil { - return true - } - } - return false -} - -// DefaultDeclineBound is an Examiner's DeclineBound when it names none: longer than a check runs, so a node with the -// need that is busy is waited for, and short enough that a mesh where no node has it says so. -const DefaultDeclineBound = 30 * time.Minute - -// askNeeding puts the target's check ask, waits for it and judges its answer, with the levels to run, what the node must have and the packages it tests: none for the first ask -// of a target; for the placed one the unmet packages' needs and those packages alone, so no package the first ask judged -// is run or counted again (ADR 0552 §4). -func (st *state) askNeeding(ctx context.Context, t *target, merged *[]Fetched, levels, needs, packages []string) { - q := st.prepareAsk(ctx, t, merged, levels, needs, packages) - if q == nil || !st.putAsk(ctx, q) { - return - } - q.wait(ctx, st) - st.judgeAsk(ctx, q) -} - -// asking is one check ask put and waited for: its target, the merges its fetch adds to, the ask as put last (a declined -// one is put again under a new id) and, once done is closed, the step it ended with or why it has none. -type asking struct { - t *target - merged *[]Fetched - a buildstep.StepAsk - kind string - needs []string - placed bool - step buildstep.Step - failed bool // the ask ended with no step to judge: failOn and failWords say why - failOn string - failWords string - done chan struct{} -} - -// prepareAsk makes the target's ask with the levels to run, what the node must have and the packages it tests; nil when -// it cannot be asked (said as a failure). -func (st *state) prepareAsk(ctx context.Context, t *target, merged *[]Fetched, levels, needs, packages []string) *asking { - p := t.pull - job := &buildstep.CheckJob{Fetch: t.fetchArgs, Levels: levels, Kept: true, Packages: packages, Toolchain: t.agreed} - if st.j.Nodes != nil { - names, err := st.j.Nodes.Names(ctx) - if err == nil && len(names) == 0 { - err = fmt.Errorf("no node record is on the bus") - } - if err != nil { - st.fail(t.module, fmt.Sprintf("the check of %s#%d is not asked: the nodes' names the names check needs cannot be read: %v", p.Repository, p.Number, err)) - return nil - } - job.NodeNames = names - } - if t.runner != "" { - job.Runner, job.RunnerWhen = t.runner, buildGoDir(st.goModule()) - } - if st.c.Try != nil && st.c.Try.Run != "" { - job.Run, job.Kept = st.c.Try.Run, false // a try of some tests runs them alone: a partial run proves no package - } - kind := buildstep.AskCheck - if st.c.Kind == KindTrunk { - kind = buildstep.AskRecheck // a re-judge after a trunk move goes after every new head's check (ADR 0536 §4) - } - a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: kind, Language: st.j.askLanguageOf(t.module), Asker: st.j.Module, - At: st.j.now().UTC(), Check: job, Needs: needs} - if a.Language == buildstep.AskGo { - a.Packages = st.packagesOf(p.Repository) - } - return &asking{t: t, merged: merged, a: a, kind: kind, needs: needs, placed: len(needs) > 0, done: make(chan struct{})} -} - -// putAsk puts the ask on its build seat's stream; false when it could not be put (said as a failure). -func (st *state) putAsk(ctx context.Context, q *asking) bool { - if err := st.put(ctx, q); err != nil { - st.fail(q.t.module, fmt.Sprintf("the check of %s#%d could not be asked: %v", q.t.pull.Repository, q.t.pull.Number, err)) - return false - } - return true -} - -// put puts the ask as it stands now. It touches only what is safe from a waiting goroutine: the progress, the case's -// ask ids and its watch. -func (st *state) put(ctx context.Context, q *asking) error { - p := q.t.pull - what := fmt.Sprintf("the %s ask %s of %s#%d", q.kind, q.a.ID, p.Repository, p.Number) - if q.placed { - what += " for a node with " + strings.Join(q.needs, ", ") - } - st.c.Progress.Set(what, "") - st.c.Asked(q.a.ID) - if err := st.j.Asks.Put(ctx, q.a); err != nil { - return err - } - if watch := st.c.Watch; watch != nil { - watch(q.a.ID, nil) // put: a try names it at once, not only when it ends (issue 1890) - } - return nil -} - -// wait waits for the step of the node that pulled the ask, putting a declined ask again for a node that has its need, -// and closes done. It runs on its own goroutine beside the phase's other asks, so it changes nothing of the check but -// the asking itself (the facts and failures are the judging's, in order). -func (q *asking) wait(ctx context.Context, st *state) { - defer close(q.done) - p := q.t.pull - var firstDecline time.Time - for { - waiting := ctx - if watch := st.c.Watch; watch != nil { - id := q.a.ID - waiting = buildrun.WithStepSeen(ctx, func(s buildstep.Step) { watch(id, &s) }) - } - step, err := st.j.Asks.Wait(waiting, q.a) - if err != nil { - q.failed, q.failOn = true, q.t.module - if ctx.Err() != nil { - q.failWords = ctx.Err().Error() - } else { - q.failWords = fmt.Sprintf("the check of %s#%d: %v", p.Repository, p.Number, err) - } - return - } - q.step = step - d, declined := buildstep.DeclinedOf(step) - if !declined { - return - } - // A node that lacks the need dropped the ask (issue 890): it is put again, for a node that has it to take; the - // node that declined looks at the stream again only after its next pull's wait. - now := st.j.now() - if firstDecline.IsZero() { - firstDecline = now - } - bound := st.j.DeclineBound - if bound <= 0 { - bound = DefaultDeclineBound - } - if now.Sub(firstDecline) > bound { - lacks := strings.Join(q.needs, ", ") - if lacks == "" { - lacks = strings.Join(d.Lacks, ", ") // a node off the agreed toolchain declined it (ADR 0584) - } - q.failed, q.failOn = true, step.Node - q.failWords = fmt.Sprintf("the check of %s#%d needs a node with %s, and none took it in %s: every node that pulled it lacks it (last %s)", - p.Repository, p.Number, lacks, bound, step.Node) - return - } - st.j.logf("%s#%d: the ask %s was declined on %s, which lacks %s; asked again", p.Repository, p.Number, q.a.ID, step.Node, strings.Join(d.Lacks, ", ")) - q.a.ID, q.a.At = buildstep.NewID(), now.UTC() - if err := st.put(ctx, q); err != nil { - q.failed, q.failOn = true, q.t.module - q.failWords = fmt.Sprintf("the check of %s#%d could not be asked: %v", p.Repository, p.Number, err) - return - } - } -} - -// judgeAsk judges the step an ask ended with: the fetch, then each level's digest, kept verdicts and tests. When the -// answer leaves packages unmet, their tests needing what that node lacks (issue 890), the passes are kept and the levels -// from the first such one are asked again of a node that has it (placed). -func (st *state) judgeAsk(ctx context.Context, q *asking) { - if q.failed { - st.fail(q.failOn, q.failWords) - return - } - t, merged, needs, placed, step := q.t, q.merged, q.needs, q.placed, q.step - p := t.pull - // The fetch and the digests are what of the ask's time its levels' running did not take (Took.Clone). - took := time.Duration(0) - if !step.Started.IsZero() && step.Ended.After(step.Started) { - took = step.Ended.Sub(step.Started) - } - t.node = step.Node - st.facts = append(st.facts, rules.Step{Repository: p.Repository, Number: p.Number, Module: t.module, Node: step.Node}) - st.c.Progress.Set(fmt.Sprintf("judge the check of %s#%d", p.Repository, p.Number), step.Node) - if step.State != buildstep.StepPassed { - // A step that failed after its fetch merged answers the fetch beside its error (design 47 G A-286): the merge is - // previewed from it, so its manifests are judged and the change composed whatever the step ended with. - var failed buildstep.CheckAnswer - if !placed && json.Unmarshal(step.Result, &failed) == nil && failed.Fetch.Workspace != "" && len(failed.Fetch.Conflicts) == 0 { - t.fetched, t.changed = failed.Fetch, failed.Fetch.Changed - *merged = append(*merged, t.fetched) - st.checkBinariesOf(t) - } - st.fail(step.Node, fmt.Sprintf("the check of %s#%d %s: %s", p.Repository, p.Number, step.State, step.Reason)) - return - } - var answer buildstep.CheckAnswer - if err := json.Unmarshal(step.Result, &answer); err != nil { - st.fail(step.Node, fmt.Sprintf("the check of %s#%d answered what is not a check: %s", p.Repository, p.Number, step.Result)) - return - } - if t.fetched = answer.Fetch; t.fetched.Workspace == "" { - st.fail(step.Node, fmt.Sprintf("the fetch of %s#%d answered no workspace: %s", p.Repository, p.Number, step.Result)) - return - } - if len(t.fetched.Conflicts) > 0 { - if st.conflicted == nil { - st.conflicted = map[string]bool{} - } - st.conflicted[pullKey(p)] = true - if !st.narrowTry() { - st.j.writePreview(ctx, p, append(*merged, t.fetched)) - } - st.fail(step.Node, fmt.Sprintf("%s#%d %s%s", p.Repository, p.Number, ConflictWords, strings.Join(t.fetched.Conflicts, ", "))) - return - } - t.changed = t.fetched.Changed - if !changesBuildGo(p.Repository, st.goModule(), t.changed) { - t.runner = "" // the build module used no runner: the merge does not change it - } - if !placed { // the placed ask fetched the same merge: its preview was read from the first - *merged = append(*merged, t.fetched) - st.checkBinariesOf(t) // the levels still run: the verdict names every failure - } - ran := 0.0 - for _, la := range answer.Levels { - if placed { - if len(la.Unmet) > 0 { - st.clone += max(0, took-time.Duration(ran*float64(time.Second))) - st.fail(step.Node, fmt.Sprintf("the %s level of %s#%d left %s untested on %s, which was asked for a node with %s", - la.Level, p.Repository, p.Number, unmetNames(la.Unmet), step.Node, strings.Join(needs, ", "))) - return - } - la.Kept = nil // it names its packages and takes no other's kept verdict; this is only a guard against an older module - } - ran += st.level(ctx, t, la) // the next level was run too (buildstep): its failures are named as well - } - st.clone += max(0, took-time.Duration(ran*float64(time.Second))) - if unmet := buildstep.UnmetNeeds(answer.Levels); len(unmet) > 0 && !placed { - // Every level ran, its passes kept, and some packages were left to a node with what their tests need: the levels - // from the first that left one are asked of such a node, which takes the kept passes and tests those (issue 890). - var again, packages []string - seen := map[string]bool{} - for _, la := range answer.Levels { - if len(again) > 0 || len(la.Unmet) > 0 { - again = append(again, la.Level) - } - for _, u := range la.Unmet { - if !seen[u.Package] { - seen[u.Package] = true - packages = append(packages, u.Package) - } - } - } - st.j.logf("%s#%d: %s on %s left untested; asked of a node with %s", p.Repository, p.Number, unmetOf(answer.Levels), step.Node, strings.Join(unmet, ", ")) - st.askNeeding(ctx, t, merged, again, unmet, packages) - } -} - -// unmetNames names the unmet packages and their needs. -func unmetNames(unmet []buildstep.PackageNeeds) string { - var out []string - for _, u := range unmet { - out = append(out, u.Package+" (needs "+strings.Join(u.Needs, ", ")+")") - } - return strings.Join(out, ", ") -} - -// unmetOf names the unmet packages of every level. -func unmetOf(levels []buildstep.LevelAnswer) string { - var out []string - for _, la := range levels { - if len(la.Unmet) > 0 { - out = append(out, "at "+la.Level+" "+unmetNames(la.Unmet)) - } - } - return strings.Join(out, "; ") -} - -// level judges one level of a check ask's answer as the tools' answers were judged: the digest keys the kept verdicts -// of the packages that passed, the kept ones taken are counted, and every test result is read and counted, also after -// one that did not pass, so the verdict names every failed test of the level (issue 1921). It answers the level's -// running time (its tests' and setup's). -func (st *state) level(ctx context.Context, t *target, la buildstep.LevelAnswer) float64 { - if t.runner != "" && t.language == languageGo && la.Digest != nil { - t.judgedBy(la.Digest.JudgedBy) // the installed module judged it: the runner is not used again - } - if t.runner != "" && la.Judged != "" { - t.judgedBy(la.Judged) // the candidate judged the level: nothing is kept (ADR 0535 §4) - } - _, elapsed, results := st.levels.Level(t.pull.Repository, t.pull.Number, t.module, t.language, t.node, la) - st.facts = append(st.facts, rules.Step{Repository: t.pull.Repository, Number: t.pull.Number, Module: t.module, Language: t.language, Node: t.node, Level: rules.LevelFact(la)}) - var digests map[string]string - if t.language == languageGo && la.Digest != nil { - // The packages come as a list, never keyed by a package path (issue 1930); an answer stored before reads too. - digests = la.Digest.Map() - } - for _, res := range results { - if t.runner != "" { - t.judgedBy(res.JudgedBy) - } - st.stepOutOfStep(t.pull, res.OutOfStep) - if len(digests) > 0 { - if _, err := st.j.Kept.KeepPasses(ctx, t.pull.Repository, la.Level, t.toolchain, res, digests, st.j.now()); err != nil { - st.j.logf("%s#%d: a passing package could not be kept: %v", t.pull.Repository, t.pull.Number, err) - } - } - } - return elapsed -} - -// changesPaths says whether a merge changes a file inside one of the named paths (repository-relative). -func changesPaths(paths []string, merged []Fetched) bool { - for _, f := range merged { - for _, changed := range f.Changed { - for _, named := range paths { - named = strings.TrimSuffix(strings.TrimPrefix(named, "./"), "/") - if changed == named || strings.HasPrefix(changed, named+"/") { - return true - } - } - } - } - return false -} diff --git a/modules/mesh-delivery-checker/internal/check/judged_test.go b/modules/mesh-delivery-checker/internal/check/judged_test.go deleted file mode 100644 index 080e20c2..00000000 --- a/modules/mesh-delivery-checker/internal/check/judged_test.go +++ /dev/null @@ -1,208 +0,0 @@ -package check - -import ( - "context" - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// The judged_by answer of mesh-build-go's digest and test steps (ADR 0535 §5; the milestone file's interface for issue -// 1898): "installed" for a step its installed program ran, "candidate " for one the candidate's program ran -// under runner workspace; an installed module older than the runner names nothing (it ignores the unknown argument: the -// SDK's tool server checks no argument against the input schema). - -const buildGoFile = "modules/mesh-build-go/cmd/mesh-build-go/digest.go" - -// candidateBench is a bench whose fetch changes the Go build module's directory, and whose build module runs the candidate -// when asked to (a module with the runner) or ignores the runner (one without). -func candidateBench(t *testing.T, takesRunner bool) *bench { - b := newBench(t) - b.fetch.Changed = []string{"README.md", buildGoFile} - judged := func(c stepCall) string { - if !takesRunner { - return "" - } - if c.args["runner"] == RunnerWorkspace { - return "candidate " + b.fetch.Merge - } - return "installed" - } - b.steps.handlers["build_go_digest"] = func(c stepCall) (any, error) { - d := echoBeside(b, b.digest[c.args["level"].(string)]) - d.JudgedBy = judged(c) - return d, nil - } - b.test = func(c stepCall) (any, error) { - r := captured[Tested](t, "go-test-slow") - r.Level, _ = c.args["level"].(string) - r.JudgedBy = judged(c) - return r, nil - } - return b -} - -func TestAMergeChangingTheGoBuildModuleIsAskedWithTheCandidateRunner(t *testing.T) { // 1898/AC1 - b := candidateBench(t, true) - b.judge(t, caseOf(t, pullOf(catalogueRepository, 9, head1))) - asked := append(b.steps.tool("digest"), b.steps.tool("test")...) - if len(asked) < 3 { - t.Fatalf("asked %+v, want the digest and both levels", asked) - } - for _, c := range asked { - if c.args["runner"] != RunnerWorkspace { - t.Errorf("%s %v was asked with runner %v, want %s", c.tool, c.args["level"], c.args["runner"], RunnerWorkspace) - } - } -} - -func TestAMergeNotChangingTheGoBuildModuleIsAskedWithoutARunner(t *testing.T) { // 1898/AC1 - for _, tc := range []struct { - name, repo, path string - }{ - {"another module of the catalogue", catalogueRepository, "modules/mesh-build-node/cmd/mesh-build-node/main.go"}, - {"a look-alike path in another repository", repoA, buildGoFile}, - } { - t.Run(tc.name, func(t *testing.T) { - b := candidateBench(t, true) - b.fetch.Changed = []string{tc.path} - out := b.judge(t, caseOf(t, pullOf(tc.repo, 9, head1))) - for _, c := range append(b.steps.tool("digest"), b.steps.tool("test")...) { - if _, ok := c.args["runner"]; ok { - t.Errorf("%s was asked with runner %v", c.tool, c.args["runner"]) - } - } - if len(out.Judged) != 0 { - t.Errorf("judged = %v, want nothing said of the program", out.Judged) - } - }) - } -} - -func TestAnInstalledModuleWithoutTheRunnerJudgesAsTodayAndTheLineSaysSo(t *testing.T) { // 1898/AC2 - b := candidateBench(t, false) - cs := caseOf(t, pullOf(catalogueRepository, 9, head1)) - out := b.judge(t, cs) - if out.Verdict.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", out.Verdict) - } - // As today: the digests key kept verdicts, and the levels are asked without the runner the module ignored. - for _, c := range b.steps.tool("test") { - if _, ok := c.args["runner"]; ok { - t.Errorf("the %v level was asked again with the runner the module does not take", c.args["level"]) - } - } - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 2 { - t.Errorf("kept %v, want the passing package at both levels, as today", keys) - } - p := cs.Pulls[0] - want := "judged by the installed mesh-build-go: it does not run a candidate yet" - if got := out.Judged[pullKey(p)]; got != want { - t.Fatalf("judged = %q, want %q", got, want) - } - if l := Line(out.Verdict, cs, p, out.Builds, out.Slowest, out.Judged); !strings.Contains(l, want) { - t.Errorf("line %q does not say %q", l, want) - } -} - -func TestACandidateJudgedCheckTakesNoKeptVerdictAndWritesNone(t *testing.T) { // 1898/AC3 - b := candidateBench(t, true) - if _, err := (Kept{Store: b.kept}).Keep(context.Background(), "unit", digA, keptValue("fixture/slow", 2)); err != nil { - t.Fatal(err) - } - out := b.judge(t, caseOf(t, pullOf(catalogueRepository, 9, head1))) - if out.Verdict.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", out.Verdict) - } - tests := b.steps.tool("test") - if len(tests) != 2 { - t.Fatalf("test calls = %+v, want both levels", tests) - } - for _, c := range tests { - if _, ok := c.args["packages"]; ok { - t.Errorf("the %v level was asked for %v, want it whole", c.args["level"], c.args["packages"]) - } - } - if u := out.Verdict.Levels[buildstep.LevelUnit]; u.Kept != 0 { - t.Errorf("unit = %+v, want nothing taken", u) - } - if keys, _ := b.kept.Keys(context.Background()); len(keys) != 1 || keys[0] != "unit."+digA { - t.Errorf("kept keys = %v, want only the one kept before", keys) - } -} - -func TestTheLineNamesTheCandidateThatJudged(t *testing.T) { // 1898/AC6 - b := candidateBench(t, true) - cs := caseOf(t, pullOf(catalogueRepository, 9, head1)) - out := b.judge(t, cs) - p := cs.Pulls[0] - want := "judged by the candidate's mesh-build-go at " + b.fetch.Merge[:12] - for name, l := range map[string]string{ - "line": Line(out.Verdict, cs, p, out.Builds, out.Slowest, out.Judged), - "report": Report(out.Verdict, cs, p, out.Builds, out.Slowest, out.Judged), - } { - if !strings.Contains(l, want) { - t.Errorf("the %s %q does not say %q", name, l, want) - } - } - // A long failing line keeps the program it was judged by; only the lesser parts go. - v := out.Verdict - v.State = meshdeliverycheckerclient.VerdictFail - v.Failed = &FailedFirst{Test: "unit: git.novox.be/novox/mesh-catalog/modules/mesh-build-go/cmd/mesh-build-go.TestADigestFoldsTheSiblings", Words: strings.Repeat("x", 60)} - if l := Line(v, cs, p, out.Builds, out.Slowest, out.Judged); !strings.Contains(l, "judged by the candidate's") { - t.Errorf("the long line %q dropped the program", l) - } -} - -func TestInAGroupOnlyTheBuildModulesPullRequestNamesItsProgram(t *testing.T) { // 1898/AC6 - b := candidateBench(t, true) - cs := caseOf(t, pullOf(catalogueRepository, 9, head1), pullOf(repoA, 7, head1)) - out := b.judge(t, cs) - for _, p := range cs.Pulls { - l := Report(out.Verdict, cs, p, out.Builds, out.Slowest, out.Judged) - says := strings.Contains(l, "judged by") - if says != (p.Repository == catalogueRepository) { - t.Errorf("%s#%d: %q", p.Repository, p.Number, l) - } - } -} - -func TestACandidateThatDoesNotCompileFailsTheCheckWithTheCompilersWords(t *testing.T) { // ADR 0535 §3, checker side - b := candidateBench(t, true) - refusal := "the candidate's mesh-build-go does not compile: modules/mesh-build-go/cmd/mesh-build-go/digest.go:12:2: undefined: x" - b.steps.handlers["build_go_digest"] = func(stepCall) (any, error) { return nil, errorString(refusal) } - b.test = func(stepCall) (any, error) { return nil, errorString(refusal) } - out := b.judge(t, caseOf(t, pullOf(catalogueRepository, 9, head1))) - if out.Verdict.State != meshdeliverycheckerclient.VerdictFail || !strings.Contains(out.Verdict.Failed.Words, "undefined: x") { - t.Fatalf("verdict = %+v, want a failure naming the compile error", out.Verdict) - } - if n := len(b.steps.tool("test")); n != 1 { - t.Errorf("%d test steps, want the first one's failure to end the check", n) - } -} - -type errorString string - -func (e errorString) Error() string { return string(e) } - -func TestTheStatusTheForgeShowsNamesTheProgramThatJudged(t *testing.T) { // 1898/AC6, the forge's line - ctx := context.Background() - words := judgedByCandidate(goBuildModule) + "fedcba987654" - j := &judgeFunc{f: func(context.Context, *Case, int) (Outcome, error) { - return Outcome{Verdict: passing(), Judged: map[string]string{repoA + "#7": words}}, nil - }} - r := newRig(t, j) - r.ch.Candidate(ctx, "feat/x", candidateOf(t, "feat/x", pullOf(repoA, 7, head1))) - r.ch.Wait() - key, _ := CheckerOwedKey(repoA, 7, head1) - raw, _, _, _ := r.owed.Get(ctx, key) - o, err := DecodeCheckerOwed(raw) - if err != nil { - t.Fatal(err) - } - if o.State != "success" || !strings.Contains(o.Text, words) { - t.Errorf("status %+v, want success saying %q", o, words) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/kept.go b/modules/mesh-delivery-checker/internal/check/kept.go deleted file mode 100644 index e00b5b2f..00000000 --- a/modules/mesh-delivery-checker/internal/check/kept.go +++ /dev/null @@ -1,101 +0,0 @@ -package check - -import ( - "context" - "errors" - "fmt" - "sort" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// Kept is the checker's bucket of kept verdicts (ADR 0444, ADR 0484 clause 13): a passing verdict per package and level, -// under the digest the language's build module named for it. A key is written once, by a create that fails when it -// exists, from the result the checker read from the test step and never from anything the code under test wrote; nothing -// changes it afterwards. -type Kept struct{ Store KV } - -// Lookup is the kept verdict of a level under a digest, or none. -func (k Kept) Lookup(ctx context.Context, level, digest string) (meshdeliverychecker.KeptByLevelDigestValue, bool, error) { - key, err := meshdeliverycheckerclient.KeptKey(level, digest) - if err != nil { - return meshdeliverychecker.KeptByLevelDigestValue{}, false, err - } - value, _, found, err := k.Store.Get(ctx, key) - if err != nil || !found { - return meshdeliverychecker.KeptByLevelDigestValue{}, false, err - } - v, err := meshdeliverycheckerclient.DecodeKept(value) - if err != nil { - return meshdeliverychecker.KeptByLevelDigestValue{}, false, fmt.Errorf("%s holds what is not a kept verdict: %w", key, err) - } - return v, true, nil -} - -// Keep writes v under level and digest by a create. It answers false, and writes nothing, when the key exists: the first -// value stands. -func (k Kept) Keep(ctx context.Context, level, digest string, v meshdeliverychecker.KeptByLevelDigestValue) (bool, error) { - key, err := meshdeliverycheckerclient.KeptKey(level, digest) - if err != nil { - return false, err - } - v.Level = level - data, err := meshdeliverycheckerclient.EncodeKept(v) - if err != nil { - return false, err - } - if _, err := k.Store.Create(ctx, key, data); err != nil { - if errors.Is(err, ErrConflict) { - return false, nil - } - return false, fmt.Errorf("%s: %w", key, err) - } - return true, nil -} - -// KeepPasses keeps, for the packages of a test result that passed with tests, a verdict under the digest the build module -// named for the package at the level. A package that failed, has no tests or has no digest is never kept (ADR 0444 clause -// 1): it runs every check. A package with skipped tests is not kept either: a pass that skipped (a test needing a -// toolchain the node lacks) would be reused for its digest and never run anywhere (issue 890). A build module that -// counts skips only per result, not per package, keeps nothing of a result in which a test skipped. It answers the -// packages it kept now. -func (k Kept) KeepPasses(ctx context.Context, repository, level, toolchain string, res Tested, digests map[string]string, at time.Time) ([]string, error) { - var kept []string - perPackage := false - for _, p := range res.Packages { - perPackage = perPackage || p.Skipped > 0 - } - if res.Skipped > 0 && !perPackage { - return kept, nil // an older build module: the skip cannot be placed in a package - } - for _, p := range res.Packages { - digest, ok := digests[p.Package] - if !ok || !p.Passed || p.NoTests || p.Tests == 0 || p.Skipped > 0 { - continue - } - if failedIn(res, p.Package) { - continue - } - made, err := k.Keep(ctx, level, digest, meshdeliverychecker.KeptByLevelDigestValue{State: meshdeliverycheckerclient.VerdictPass, Repository: repository, Package: p.Package, - Level: level, Tests: int64(p.Tests), Took: int64(p.Elapsed * 1000), Toolchain: toolchain, At: at.UTC().Format(time.RFC3339)}) - if err != nil { - return kept, err - } - if made { - kept = append(kept, p.Package) - } - } - sort.Strings(kept) - return kept, nil -} - -func failedIn(res Tested, pkg string) bool { - for _, f := range res.Failed { - if f.Package == pkg { - return true - } - } - return false -} diff --git a/modules/mesh-delivery-checker/internal/check/kept_test.go b/modules/mesh-delivery-checker/internal/check/kept_test.go deleted file mode 100644 index f6a7abd5..00000000 --- a/modules/mesh-delivery-checker/internal/check/kept_test.go +++ /dev/null @@ -1,130 +0,0 @@ -package check - -import ( - "context" - "strings" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -var at0 = time.Date(2026, 10, 21, 19, 0, 0, 0, time.UTC) - -const ( - digA = "aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11aa11" - digB = "bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22bb22" -) - -func keptValue(pkg string, tests int) meshdeliverychecker.KeptByLevelDigestValue { - return meshdeliverychecker.KeptByLevelDigestValue{State: meshdeliverycheckerclient.VerdictPass, Repository: "novox/mesh-delivery", Package: pkg, Tests: int64(tests), Took: 120, Toolchain: "go1.26.0", At: at0.UTC().Format(time.RFC3339)} -} - -func TestAPassIsKeptByACreateUnderItsLevelAndDigest(t *testing.T) { // 1287/AC1 - ctx, st := context.Background(), newMemKV() - k := Kept{Store: st} - made, err := k.Keep(ctx, buildstep.LevelUnit, digA, keptValue("m/a", 3)) - if err != nil || !made { - t.Fatalf("Keep = %v, %v, want made", made, err) - } - key, _ := meshdeliverycheckerclient.KeptKey(buildstep.LevelUnit, digA) - if st.creates[key] != 1 { - t.Fatalf("the key %s was created %d times, want once", key, st.creates[key]) - } - got, found, err := k.Lookup(ctx, buildstep.LevelUnit, digA) - if err != nil || !found || got.Package != "m/a" || got.Tests != 3 || got.Level != buildstep.LevelUnit || got.Toolchain != "go1.26.0" { - t.Fatalf("Lookup = %+v, %v, %v", got, found, err) - } -} - -func TestASecondKeepUnderTheSameDigestIsRefusedAndTheFirstStands(t *testing.T) { // 1287/AC2 - ctx, st := context.Background(), newMemKV() - k := Kept{Store: st} - if made, err := k.Keep(ctx, buildstep.LevelUnit, digA, keptValue("m/a", 3)); err != nil || !made { - t.Fatal(made, err) - } - made, err := k.Keep(ctx, buildstep.LevelUnit, digA, keptValue("m/other", 9)) - if err != nil || made { - t.Fatalf("the second Keep = %v, %v, want refused without an error", made, err) - } - got, _, _ := k.Lookup(ctx, buildstep.LevelUnit, digA) - if got.Package != "m/a" || got.Tests != 3 { - t.Errorf("the first value did not stand: %+v", got) - } -} - -func TestOnlyPassingPackagesWithADigestAreKept(t *testing.T) { // 1287/AC3, AC4 - ctx, st := context.Background(), newMemKV() - k := Kept{Store: st} - res := Tested{Level: "unit", Passed: false, Packages: []GoPackage{ - {Package: "m/a", Passed: true, Tests: 4, Elapsed: 0.2}, - {Package: "m/b", Passed: false, Tests: 2}, - {Package: "m/c", Passed: true, Tests: 1}, // no digest named - {Package: "m/d", Passed: true, NoTests: true}, // no tests - }, Failed: []Failure{{Package: "m/b", Test: "TestB"}}} - kept, err := k.KeepPasses(ctx, "novox/mesh-delivery", "unit", "go1.26.0", res, map[string]string{"m/a": digA, "m/b": digB, "m/d": digB}, at0) - if err != nil { - t.Fatal(err) - } - if strings.Join(kept, ",") != "m/a" { - t.Fatalf("kept %v, want only m/a", kept) - } - if keys, _ := st.Keys(ctx); len(keys) != 1 { - t.Errorf("the bucket holds %v, want one key", keys) - } -} - -func TestAResultWithSkippedTestsKeepsNothing(t *testing.T) { // issue 890: a pass that skipped proved nothing - ctx, st := context.Background(), newMemKV() - k := Kept{Store: st} - res := Tested{Level: "integration", Passed: true, Skipped: 2, Packages: []GoPackage{{Package: "m/a", Passed: true, Tests: 4}}} - kept, err := k.KeepPasses(ctx, "novox/mesh-catalog", "integration", "go1.26.0", res, map[string]string{"m/a": digA}, at0) - if err != nil || len(kept) != 0 { - t.Fatalf("kept %v, %v, want nothing", kept, err) - } - if keys, _ := st.Keys(ctx); len(keys) != 0 { - t.Errorf("the bucket holds %v, want none", keys) - } -} - -func TestOnlyTheSkippingPackageOfAResultIsWithheld(t *testing.T) { // issue 890 - ctx, st := context.Background(), newMemKV() - k := Kept{Store: st} - res := Tested{Level: "integration", Passed: true, Skipped: 2, Packages: []GoPackage{ - {Package: "m/a", Passed: true, Tests: 4, Skipped: 2}, - {Package: "m/b", Passed: true, Tests: 3}, - }} - kept, err := k.KeepPasses(ctx, "novox/mesh-catalog", "integration", "go1.26.0", res, map[string]string{"m/a": digA, "m/b": digB}, at0) - if err != nil || strings.Join(kept, ",") != "m/b" { - t.Fatalf("kept %v, %v, want only m/b", kept, err) - } -} - -func TestAKeptValueOfAnotherDigestIsNotRead(t *testing.T) { // 1287/AC7 - ctx, st := context.Background(), newMemKV() - k := Kept{Store: st} - if _, err := k.Keep(ctx, buildstep.LevelUnit, digA, keptValue("m/a", 3)); err != nil { - t.Fatal(err) - } - // A toolchain change changes the digest, so the new digest finds nothing and the old key is not deleted. - if _, found, _ := k.Lookup(ctx, buildstep.LevelUnit, digB); found { - t.Error("a digest that was not kept was found") - } - if _, found, _ := k.Lookup(ctx, buildstep.LevelIntegration, digA); found { - t.Error("a kept unit verdict was found at the integration level") - } - if keys, _ := st.Keys(ctx); len(keys) != 1 { - t.Errorf("the old key was removed: %v", keys) - } -} - -func TestAKeptVerdictThatIsNotAPassIsRefused(t *testing.T) { - k := Kept{Store: newMemKV()} - v := keptValue("m/a", 1) - v.State = meshdeliverycheckerclient.VerdictFail - if _, err := k.Keep(context.Background(), buildstep.LevelUnit, digA, v); err == nil { - t.Error("a failure was kept") - } -} diff --git a/modules/mesh-delivery-checker/internal/check/line.go b/modules/mesh-delivery-checker/internal/check/line.go deleted file mode 100644 index 0dca6e35..00000000 --- a/modules/mesh-delivery-checker/internal/check/line.go +++ /dev/null @@ -1,394 +0,0 @@ -package check - -import ( - "fmt" - "mesh-delivery-checker/rules" - "slices" - "strings" - "unicode/utf8" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// MaxLine is the most characters a status's line has: the forge shows a status's description in a short space, and the full -// report is linked (ADR 0447 clause 3, ADR 0484 clause 7). A line that would be longer drops its lesser parts in a fixed -// order, and is cut last. -const MaxLine = 140 - -// seconds is a time in milliseconds in the unit a person reads: 350ms, 4.1s, 72s. -func seconds(ms int64) string { - switch { - case ms < 1000: - return fmt.Sprintf("%dms", ms) - case ms < 10000: - return fmt.Sprintf("%.1fs", float64(ms)/1000) - } - return fmt.Sprintf("%ds", (ms+500)/1000) -} - -func short12(s string) string { - if len(s) > 12 { - return s[:12] - } - return s -} - -// firstFailed is what failed first, in words: a conflict, a refused step or a test, named before anything else. -func firstFailed(v meshdeliverychecker.VerdictsByGroupHeadsValue) string { - f := failedOf(v) - switch { - case f.Test != "": - if w := firstWordsLine(f.Words); w != "" { - return f.Test + ": " + w - } - return f.Test - case f.Machine != "" && firstWordsLine(f.Words) != "": - return f.Machine + ": " + firstWordsLine(f.Words) - case f.Machine != "": - return f.Machine - } - return firstWordsLine(f.Words) -} - -// failedLines is everything a verdict names as failed, one line each: every failed test with its first line (issue -// 1921), or what failed first when the verdict names no list (a conflict, a refused step, an older verdict). -func failedLines(v meshdeliverychecker.VerdictsByGroupHeadsValue) []string { - if len(v.Failures) == 0 { - if f := firstFailed(v); f != "" { - return []string{f} - } - return nil - } - lines := make([]string, 0, len(v.Failures)) - for _, f := range v.Failures { - lines = append(lines, firstFailed(meshdeliverychecker.VerdictsByGroupHeadsValue{Failed: &FailedFirst{Machine: f.Machine, Test: f.Test, Words: f.Words}})) - } - return lines -} - -// failedHead is the head of a failed verdict's line: what failed first, and when more did, how many failed and "and N -// more" after it (the operator, 2026-11-02), so a line cut to MaxLine still says that more failed. The words of the first -// are cut to fit room characters when room is not negative; the count and "and N more" are never cut. -func failedHead(v meshdeliverychecker.VerdictsByGroupHeadsValue, room int) string { - first := firstFailed(v) - n := rules.FailedCount(v) - if n <= 1 { - return clipRunes("failed: "+first, room) - } - prefix, more := fmt.Sprintf("failed (%d): ", n), fmt.Sprintf("; and %d more", n-1) - if room >= 0 { - first = clipRunes(first, room-utf8.RuneCountInString(prefix+more)) - } - return prefix + first + more -} - -// clipRunes cuts s to at most n characters, the last an ellipsis; a negative n leaves it whole. -func clipRunes(s string, n int) string { - r := []rune(s) - if n < 0 || len(r) <= n { - return s - } - if n < 1 { - return "" - } - return string(r[:n-1]) + "…" -} - -// firstWordsLine is the first line of a failure's words: the words are several lines (issue 1901) and the status line one. -func firstWordsLine(w string) string { return rules.FirstLine(w) } - -// pieces are the parts of a line, from the most to the least needed. -type pieces struct { - head, commits, counts, shortCounts, times, shortTimes, over, builds, composition, shortComposition, group string - // judged names the program that judged a change to a build module (ADR 0535 §5); never dropped. - judged string - // carried says, of a carried verdict, the commits it was carried from (ADR 0548 §8); never dropped. - carried string - // warning says that a part of the check did not run, for instance that an older build module could not refuse a compiled program; never dropped. - warning string - // series names each change of a package series the pull request makes (design 32, DLV-C4); never dropped. - series string -} - -// pullKey names a pull request of a case: `#`. -func pullKey(p Pull) string { return fmt.Sprintf("%s#%d", p.Repository, p.Number) } - -func (p pieces) join(drop int) string { - parts := []string{p.head, p.commits, p.carried, p.warning, p.counts, p.judged, p.series} - switch { - case drop < 3 && p.times != "": - parts = append(parts, p.times) - case drop == 3 && p.shortTimes != "": - parts = []string{p.head, p.commits, p.carried, p.warning, p.shortCounts, p.judged, p.series, p.shortTimes} - } - if p.over != "" { - parts = append(parts, p.over) - } - if drop < 1 && p.builds != "" { - parts = append(parts, p.builds) - } - if drop < 2 && p.group != "" { - parts = append(parts, p.group) - } - switch { - case drop >= 3 && p.shortComposition != "": - parts = append(parts, p.shortComposition) - case p.composition != "": - parts = append(parts, p.composition) - } - return joinSet(parts...) -} - -func levelWords(name string, r meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue) string { - s := fmt.Sprintf("%s %d run, %d kept", name, r.Run, r.Kept) - if r.Skipped > 0 { - s += fmt.Sprintf(", %d skipped", r.Skipped) - } - return s -} - -// compositionWords says the composition: not yet run, or once the engines answered (ADR 0593 §7) passed, with the nodes -// that gave no answer, or failed, with the time it took and the machines it composed (issue 1300). -func compositionWords(c *meshdeliverychecker.VerdictsByGroupHeadsValueComposition, took int64) string { - return composition(c, took, false) -} - -// composition is compositionWords; short counts the machines and leaves the SDK commit to the report. -func composition(c *meshdeliverychecker.VerdictsByGroupHeadsValueComposition, took int64, short bool) string { - if c != nil && c.State == meshdeliverycheckerclient.CompositionNotRun && c.Words != "" { - return "composition not judged: " + c.Words - } - if c == nil || c.State == meshdeliverycheckerclient.CompositionNotRun { - return "composition not yet run" - } - in := "" - if took > 0 { - in = " in " + seconds(took) - } - on := "" - if len(c.Machines) > 0 { - machines := slices.Sorted(slices.Values(c.Machines)) - on = " on " + strings.Join(machines, ", ") - switch { - case len(machines) > 1 && short: - on = fmt.Sprintf(" on %d machines", len(machines)) - case len(machines) > 1: - on = fmt.Sprintf(" on %d machines: %s", len(machines), strings.Join(machines, ", ")) - } - } - warned := "" - if c.State == meshdeliverycheckerclient.CompositionPass && c.Words != "" { - warned = " (" + c.Words + ")" // a node that did not answer (ADR 0593 §9) - } - switch { - case c.State == meshdeliverycheckerclient.CompositionPass && short: - return "composition passed" + in + on + warned // what it composed with is in the report - case c.State == meshdeliverycheckerclient.CompositionPass: - return "composition passed" + in + " with " + short12(c.Sdk) + on + warned - } - return "composition failed" + in + on + ": " + c.Words -} - -func buildWords(builds []BuildNote) string { - if len(builds) == 0 { - return "" - } - parts := make([]string, len(builds)) - for i, b := range builds { - parts[i] = b.Module + " " + b.State - } - return "builds: " + strings.Join(parts, ", ") -} - -// carriedWords say the commits a verdict was carried from, for the line of pull request p (ADR 0548 §8): its own trunk's -// commit as twelve characters, a sibling's with its name before it; only those that moved, sorted. Empty when none did. -func carriedWords(from map[string]string, v meshdeliverychecker.VerdictsByGroupHeadsValue, cs *Case, p Pull) string { - var own string - var others []string - for r, old := range from { - now, ok := v.Trunk[r] - if cs != nil && !ok { - now, ok = cs.Trunk[r] - } - if !ok { - now = v.Beside[r] - } - if now == "" || now == old { - continue - } - if strings.EqualFold(r, p.Repository) { - own = short12(old) - continue - } - name := r - if i := strings.LastIndex(r, "/"); i >= 0 { - name = r[i+1:] - } - others = append(others, name+" "+short12(old)) - } - slices.Sort(others) - if own != "" { - others = append([]string{own}, others...) - } - return strings.Join(others, ", ") -} - -// parts makes the pieces of the line of a pull request of a case. -func parts(v meshdeliverychecker.VerdictsByGroupHeadsValue, cs *Case, p Pull, builds []BuildNote, slowest []string, judged map[string]string) pieces { - var pc pieces - pc.judged = judged[pullKey(p)] - pc.series = seriesWords(cs, p) - if cs != nil { - pc.warning = cs.Warning(pullKey(p)) - } - commits := short12(p.Head) + " on " + short12(p.Trunk) - switch v.State { - case meshdeliverycheckerclient.VerdictRunning: - pc.head = "checking " + commits - if cs != nil && cs.CarriedFrom != nil { - // Out of date and being carried to the new commit (ADR 0548 §6): pending, and saying so. - pc.head = "being carried to " + commits - if w := carriedWords(cs.CarriedFrom, v, cs, p); w != "" { - pc.carried = "from " + w - } - } - case meshdeliverycheckerclient.VerdictPass: - pc.head = "pass " + commits - if w := carriedWords(v.CarriedFrom, v, cs, p); w != "" { - pc.carried = "carried from " + w // the counts that follow say what the carry ran and kept - } - default: - pc.head = failedHead(v, -1) - pc.commits = commits - } - var counts []string - for _, level := range []string{buildstep.LevelUnit, buildstep.LevelIntegration} { - if r, ok := v.Levels[level]; ok { - counts = append(counts, levelWords(level, r)) - } - } - pc.counts = strings.Join(counts, " | ") - var short []string - for _, level := range []string{buildstep.LevelUnit, buildstep.LevelIntegration} { - if r, ok := v.Levels[level]; ok { - name := map[string]string{buildstep.LevelUnit: "unit", buildstep.LevelIntegration: "int"}[level] - w := fmt.Sprintf("%s %d run %d kept", name, r.Run, r.Kept) - if r.Skipped > 0 { - w += fmt.Sprintf(" %d skipped", r.Skipped) - } - short = append(short, w) - } - } - pc.shortCounts = strings.Join(short, " | ") - if v.State != meshdeliverycheckerclient.VerdictRunning { - t := tookOf(v) - var times []string - for _, x := range []struct { - name string - ms int64 - }{{"queue", t.Queue}, {"clone", t.Clone}, {"lint", t.Lint}, {"unit", t.Unit}, {"int setup", t.IntegrationSetup}, {"int run", t.IntegrationRun}} { - if x.ms > 0 { - times = append(times, x.name+" "+seconds(x.ms)) - } - } - if len(times) > 0 { - pc.times = strings.Join(times, ", ") - } - // The compact form for a line that is too long: the parts that dominate, the integration level's setup and run as one. - short = short[:0:0] - if t.Clone > 0 { - short = append(short, "clone "+seconds(t.Clone)) - } - if t.Lint > 0 { - short = append(short, "lint "+seconds(t.Lint)) - } - if t.Unit > 0 { - short = append(short, "unit "+seconds(t.Unit)) - } - switch { - case t.IntegrationSetup > 0 && t.IntegrationRun > 0: - short = append(short, "int "+seconds(t.IntegrationSetup)+"+"+seconds(t.IntegrationRun)) - case t.IntegrationRun > 0: - short = append(short, "int "+seconds(t.IntegrationRun)) - } - pc.shortTimes = strings.Join(short, " ") - } - if len(v.OverBound) > 0 { - pc.over = "over bound: " + strings.Join(v.OverBound, ", ") - if len(slowest) > 0 { - pc.over += " (slowest " + strings.Join(slowest, ", ") + ")" - } - } - pc.builds = buildWords(builds) - if v.State != meshdeliverycheckerclient.VerdictRunning { - pc.composition = compositionWords(v.Composition, tookOf(v).Composition) - pc.shortComposition = composition(v.Composition, tookOf(v).Composition, true) - } - if cs != nil && len(cs.Pulls) > 1 { - pc.group = fmt.Sprintf("group %s of %d pull requests", cs.Group, len(cs.Pulls)) - if v.State != meshdeliverycheckerclient.VerdictPass { - pc.group = fmt.Sprintf("%s#%d in group %s", p.Repository, p.Number, cs.Group) - } - } - return pc -} - -// Report is the full line of a pull request's status, with no limit: what the read tools and the full report say. -func Report(v meshdeliverychecker.VerdictsByGroupHeadsValue, cs *Case, p Pull, builds []BuildNote, slowest []string, judged map[string]string) string { - return parts(v, cs, p, builds, slowest, judged).join(0) -} - -// Line is the words of a status for one pull request of a case (ADR 0447 clause 3, ADR 0484 clause 7): the verdict first (a -// failure names the conflict, the refused step or the test before anything), the head and the trunk commit as twelve -// characters each, the tests run, kept and skipped per level, the time of each part, a level over its bound with its slowest -// tests, the builds of the touched modules, and that the composition was not yet run; for a change to a build module, the -// program that judged it (judged, by pullKey; ADR 0535 §5). It is at most MaxLine characters: the -// builds, then the group drop first, then the times are given in their compact form, then dropped, and the line is cut at last. -// The program that judged is never dropped: a line naming it gives the counts in their compact form, then drops them and -// what follows, and is cut in its first part rather than lose it. -func Line(v meshdeliverychecker.VerdictsByGroupHeadsValue, cs *Case, p Pull, builds []BuildNote, slowest []string, judged map[string]string) string { - pc := parts(v, cs, p, builds, slowest, judged) - if v.State == meshdeliverycheckerclient.VerdictFail { - // The head gives way first to the commits and what is never dropped: its count and "and N more" stay whole. - kept := joinSet(pc.commits, pc.carried, pc.warning, pc.judged, pc.series) - pc.head = failedHead(v, MaxLine-utf8.RuneCountInString(" | "+kept)) - } - for drop := 0; drop <= 4; drop++ { - if s := pc.join(drop); utf8.RuneCountInString(s) <= MaxLine { - return s - } - } - if pc.judged != "" || pc.series != "" { - for _, counts := range []string{pc.shortCounts, ""} { - if s := joinSet(pc.head, pc.commits, counts, pc.judged, pc.series); utf8.RuneCountInString(s) <= MaxLine { - return s - } - } - rest := " | " + joinSet(pc.commits, pc.judged, pc.series) - room := MaxLine - utf8.RuneCountInString(rest) - 1 - if head := []rune(pc.head); room > 0 && len(head) > room { - return string(head[:room]) + "…" + rest - } - } - if v.State == meshdeliverycheckerclient.VerdictFail { - // A failure's head, sized above, and the commits fit: the counts and the composition are in the report. - if s := joinSet(pc.head, pc.commits, pc.carried, pc.warning, pc.judged, pc.series); utf8.RuneCountInString(s) <= MaxLine { - return s - } - } - runes := []rune(pc.join(4)) - return string(runes[:MaxLine-1]) + "…" -} - -// joinSet joins the parts that are not empty. -func joinSet(parts ...string) string { - out := make([]string, 0, len(parts)) - for _, s := range parts { - if s != "" { - out = append(out, s) - } - } - return strings.Join(out, " | ") -} diff --git a/modules/mesh-delivery-checker/internal/check/line_test.go b/modules/mesh-delivery-checker/internal/check/line_test.go deleted file mode 100644 index 2b80bb72..00000000 --- a/modules/mesh-delivery-checker/internal/check/line_test.go +++ /dev/null @@ -1,193 +0,0 @@ -package check - -import ( - "fmt" - "strings" - "testing" - "unicode/utf8" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -func lineCase(t testing.TB, pulls ...meshcatalog.CandidatesByGroupValuePullsItem) (*Case, Pull) { - cs := caseOf(t, pulls...) - return cs, cs.Pulls[0] -} - -func passVerdict() meshdeliverychecker.VerdictsByGroupHeadsValue { - return meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictPass, - Levels: map[string]meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue{buildstep.LevelUnit: {Run: 12, Kept: 301}, buildstep.LevelIntegration: {Run: 3, Kept: 40}}, - Took: &meshdeliverychecker.VerdictsByGroupHeadsValueTook{Queue: 800, Clone: 4100, Unit: 400, IntegrationSetup: 3200, IntegrationRun: 12000}, - Composition: &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionNotRun}} -} - -func TestAPassOpensWithTheVerdictAndSaysTheCommitsTheCountsTheTimesAndThatTheCompositionWasNotRun(t *testing.T) { // 1300/AC1 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - full := Report(passVerdict(), cs, p, nil, nil, nil) - for _, want := range []string{"pass 111111111111 on aaaaaaaaaaaa", "unit 12 run, 301 kept", "integration 3 run, 40 kept", "queue 800ms", "clone 4.1s", "unit 400ms", "int setup 3.2s", "int run 12s", "composition not yet run"} { - if !strings.Contains(full, want) { - t.Errorf("the report %q lacks %q", full, want) - } - } - if !strings.HasPrefix(full, "pass ") || strings.Contains(full, "composition passed") { - t.Errorf("report = %q", full) - } - line := Line(passVerdict(), cs, p, nil, nil, nil) - if n := utf8.RuneCountInString(line); n > MaxLine { - t.Errorf("the line is %d characters, want at most %d: %q", n, MaxLine, line) - } - if !strings.HasPrefix(line, "pass 111111111111 on aaaaaaaaaaaa") || !strings.Contains(line, "composition not yet run") || !strings.Contains(line, "unit 12 run 301 kept") || - !strings.Contains(line, "clone 4.1s") || !strings.Contains(line, "int 3.2s+12s") { - t.Errorf("line = %q", line) - } -} - -func TestAFailureNamesTheTestTheConflictOrTheRefusedStepFirst(t *testing.T) { // 1300/AC2 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - long := FailedFirst{Test: "integration: " + strings.Repeat("pkg/", 50) + "TestSomething", Words: strings.Repeat("because ", 40)} - for name, c := range map[string]struct { - v meshdeliverychecker.VerdictsByGroupHeadsValue - want string - }{ - "test": {meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Test: "unit: m/a.TestX", Words: "want 4"}}, "failed: unit: m/a.TestX: want 4"}, - "conflict": {meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Machine: "shanks", Words: "novox/mesh-delivery#7 does not merge into the trunk: files in conflict: go.mod"}}, "failed: shanks: novox/mesh-delivery#7 does not merge into the trunk: files in conflict: go.mod"}, - "refused": {meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Machine: "mesh-build-go", Words: "no go build node qualifies: builders disagree"}}, "failed: mesh-build-go: no go build node qualifies"}, - // ADR 0591: a first failure longer than the forge's limit is shortened; "failed (N)" and "and N-1 more" are never cut. - "many, the first too long": {meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &long, Failures: failureItems([]FailedFirst{long, {Machine: "g14", Words: "route-proxy is defined twice"}, - {Test: "unit: m/b.TestY", Words: "boom"}})}, "failed (3): integration: pkg/pkg/"}, - } { - line := Line(c.v, cs, p, nil, nil, nil) - if more := len(c.v.Failures) - 1; more > 0 && (!strings.Contains(line, fmt.Sprintf("…; and %d more | 111111111111", more)) || utf8.RuneCountInString(line) > MaxLine) { - t.Errorf("%s: line = %q (%d), want the first's words shortened, the count and \"and %d more\" whole, within %d", name, line, utf8.RuneCountInString(line), more, MaxLine) - } - if !strings.HasPrefix(line, c.want) || !strings.Contains(line, "111111111111 on aaaaaaaaaaaa") { - t.Errorf("%s: line = %q, want it to open with %q and name the commits", name, line, c.want) - } - } -} - -// The status line and its full report say each part of a verdict, within the forge's limit (issue 1300, ADR 0484). -func TestTheLineAndTheReportSayEachPartOfTheVerdict(t *testing.T) { - for _, row := range []struct { - name string - test func(t *testing.T) - }{ - {"a level over its bound is named with its slowest tests and the verdict is not changed", func(t *testing.T) { // 1300/AC3 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - v := passVerdict() - v.OverBound = []string{"unit"} - line := Line(v, cs, p, nil, []string{"unit pkg.TestSlow 7.0s"}, nil) - if !strings.HasPrefix(line, "pass ") || !strings.Contains(Report(v, cs, p, nil, []string{"unit pkg.TestSlow 7.0s"}, nil), "over bound: unit (slowest unit pkg.TestSlow 7.0s)") { - t.Errorf("line = %q", line) - } - }}, - {"skipped tests are said and never a flat pass", func(t *testing.T) { // 1300/AC6 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - v := passVerdict() - v.Levels[buildstep.LevelUnit] = meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue{Run: 12, Kept: 301, Skipped: 2} - if line := Line(v, cs, p, nil, nil, nil); !strings.Contains(line, "unit 12 run, 301 kept, 2 skipped") { - t.Errorf("line = %q", line) - } - }}, - {"a groups members each carry the same verdict", func(t *testing.T) { // 1300/AC4 - cs := caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2)) - a := Line(passVerdict(), cs, cs.Pulls[0], nil, nil, nil) - b := Line(passVerdict(), cs, cs.Pulls[1], nil, nil, nil) - if !strings.HasPrefix(a, "pass ") || !strings.HasPrefix(b, "pass ") || !strings.Contains(Report(passVerdict(), cs, cs.Pulls[0], nil, nil, nil), "group feat/x of 2 pull requests") { - t.Errorf("lines %q and %q", a, b) - } - if !strings.Contains(a, "111111111111") || !strings.Contains(b, "222222222222") { - t.Errorf("each member's line names its own head: %q and %q", a, b) - } - }}, - {"the builds of the touched modules are said and dropped first when the line is too long", func(t *testing.T) { // ADR 0484 clause 7 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - builds := []BuildNote{{"avahi", "built"}, {"mesh-tools", "waiting"}} - if r := Report(passVerdict(), cs, p, builds, nil, nil); !strings.Contains(r, "builds: avahi built, mesh-tools waiting") { - t.Errorf("report = %q", r) - } - line := Line(passVerdict(), cs, p, builds, nil, nil) - if utf8.RuneCountInString(line) > MaxLine { - t.Errorf("line %q is too long", line) - } - short := passVerdict() - short.Took = &meshdeliverychecker.VerdictsByGroupHeadsValueTook{} - if l := Line(short, cs, p, builds[:1], nil, nil); !strings.Contains(l, "builds: avahi built") { - t.Errorf("a short line keeps its builds: %q", l) - } - }}, - {"a line is never longer than the limit", func(t *testing.T) { // 1300/AC1 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - v := meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Test: "integration: " + strings.Repeat("pkg/", 50) + ".TestSomething", Words: strings.Repeat("because ", 40)}} - if line := Line(v, cs, p, nil, nil, nil); utf8.RuneCountInString(line) > MaxLine || !strings.HasPrefix(line, "failed: integration: ") { - t.Errorf("line = %q (%d)", line, utf8.RuneCountInString(line)) - } - }}, - {"a running check is pending", func(t *testing.T) { - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - if line := Line(meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictRunning}, cs, p, nil, nil, nil); line != "checking 111111111111 on aaaaaaaaaaaa" { - t.Errorf("line = %q", line) - } - }}, - {"the passed composition is said only when it was run", func(t *testing.T) { // ADR 0484 clause 6 - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - v := passVerdict() - v.Composition = &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionPass, Sdk: "afbe371003a570f088be4a394d83aa7a9458f7ab"} - if r := Report(v, cs, p, nil, nil, nil); !strings.Contains(r, "composition passed with afbe371003a5") { - t.Errorf("report = %q", r) - } - v.Composition = nil - if r := Report(v, cs, p, nil, nil, nil); !strings.Contains(r, "composition not yet run") || strings.Contains(r, "composition passed") { - t.Errorf("a verdict with no composition: %q", r) - } - }}, - {"the compositions time and machines are said once the assigner reports them", func(t *testing.T) { // 1300 (C10), the assigner's verdict (issue 1297) - cs, p := lineCase(t, pullOf(repoA, 7, head1)) - v := passVerdict() - v.Took.Composition = 2400 - v.Composition = &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionPass, Sdk: "afbe371003a570f088be4a394d83aa7a9458f7ab", Machines: []string{"g14", "ace", "novox", "shanks"}} - r := Report(v, cs, p, nil, nil, nil) - for _, want := range []string{"composition passed in 2.4s with afbe371003a5 on 4 machines: ace, g14, novox, shanks"} { - if !strings.Contains(r, want) { - t.Errorf("report %q lacks %q", r, want) - } - } - if l := Line(v, cs, p, nil, nil, nil); !strings.Contains(l, "composition passed in 2.4s") || !strings.Contains(l, "on 4 machines") || utf8.RuneCountInString(l) > MaxLine { - t.Errorf("line = %q", l) - } - v.State, v.Failed = meshdeliverycheckerclient.VerdictFail, &FailedFirst{Machine: "novox", Words: "composition refused"} - v.Composition = &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionFail, Words: "novox: two seats claim dns", Machines: []string{"novox"}} - if r := Report(v, cs, p, nil, nil, nil); !strings.Contains(r, "composition failed in 2.4s on novox: novox: two seats claim dns") { - t.Errorf("failed composition report = %q", r) - } - }}, - } { - t.Run(row.name, row.test) - } -} - -// 1887/D7-go, review round 2 item 5: the line says the unit level's gofmt and go vet time beside its tests'. -func TestTheLineSaysTheLintTime(t *testing.T) { - b := newBench(t) - test := b.test - b.test = func(c stepCall) (any, error) { - r, err := test(c) - if res, ok := r.(Tested); ok && res.Level == buildstep.LevelUnit { - res.Lint = 1.5 - return res, err - } - return r, err - } - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if out.Verdict.Took.Lint != 1500 { - t.Fatalf("took = %+v, want the lint's 1.5 s", out.Verdict.Took) - } - cs := caseOf(t, pullOf(repoA, 7, head1)) - pc := parts(out.Verdict, cs, cs.Pulls[0], out.Builds, out.Slowest, out.Judged) - if !strings.Contains(pc.times, "lint 1.5s") || !strings.Contains(pc.shortTimes, "lint 1.5s") { - t.Errorf("times = %q, short %q, want the lint's time in both forms of the line", pc.times, pc.shortTimes) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/lostask.go b/modules/mesh-delivery-checker/internal/check/lostask.go deleted file mode 100644 index 8672fd62..00000000 --- a/modules/mesh-delivery-checker/internal/check/lostask.go +++ /dev/null @@ -1,36 +0,0 @@ -package check - -import ( - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - sdkrun "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildrun" -) - -// **An ask the build seat gave up on ends its step** (novox/hq issue 734): mesh-sdk buildrun.LostAskWaiter hands the -// waiting asker a failed step on the node buildrun.LostNode when DEAD_LETTERS keeps the ask's copy (buildrun.HearDeadLetters, -// granted by buscompose DeadLetterReads), and, under buildrun.NotTakenBound, when no build node took the ask within the -// bound. What follows is the checker's: a try ends as error (Tryer.run), with the not-taken bound at the step bound -// (Tryer.NotTaken); a check is asked again under its claim, at most LostAskTries times, then fails as not heard and is -// asked again when the part it could not hear runs (Checker.try). A check's ask has no not-taken bound: it waits in the stream as long as -// the backlog is (ADR 0525 §9), and a check ended for a backlog would owe its pull request a failure. - -// LostAskTries is how often a check asks again whose ask was given up, before it fails as not heard (UnheardWords) and is -// asked again when the part it could not hear runs. -const LostAskTries = 3 - -// IsLostAsk says whether a verdict failed because its ask judged nothing: the build seat gave it up (buildrun.LostWords), or -// the build module that ran its step was replaced under it, and its next process ended the step it left running -// (sdkrun.RestartReason; a delivery of the build module, as on 2026-10-28). Neither is the change's failure: the check -// is asked again, as for a given-up ask. -func IsLostAsk(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictFail && (strings.Contains(failedOf(v).Words, buildrun.LostWords) || - strings.Contains(failedOf(v).Words, sdkrun.RestartReason)) -} - -// IsNotTaken says whether a verdict failed because no build node took its ask within the bound (buildrun.NotTakenWords). -func IsNotTaken(v meshdeliverychecker.VerdictsByGroupHeadsValue) bool { - return v.State == meshdeliverycheckerclient.VerdictFail && strings.Contains(failedOf(v).Words, buildrun.NotTakenWords) -} diff --git a/modules/mesh-delivery-checker/internal/check/lostask_test.go b/modules/mesh-delivery-checker/internal/check/lostask_test.go deleted file mode 100644 index d1073b8d..00000000 --- a/modules/mesh-delivery-checker/internal/check/lostask_test.go +++ /dev/null @@ -1,418 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "fmt" - "maps" - "slices" - "strings" - "sync" - "testing" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - sdkrun "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// losingAsks is the build seat over a bus that gives up the first `lose` asks put (DEAD_LETTERS keeps them, as on -// 2026-10-26 during a bus reload: try-1793017340003993788) and answers the rest; with never set it neither answers nor -// gives up (an ask no node takes). -type losingAsks struct { - *buildrun.FakeAsks - answer func(buildstep.StepAsk) buildstep.Step - dead *buildrun.DeadLetters - never bool - - mu sync.Mutex - lose int -} - -func (l *losingAsks) PublishAsk(ctx context.Context, subject, id string, data []byte) error { - if err := l.FakeAsks.PublishAsk(ctx, subject, id, data); err != nil { - return err - } - l.mu.Lock() - lost := l.lose > 0 - if lost { - l.lose-- - } - l.mu.Unlock() - switch { - case l.never: - case lost: - h := map[string][]string{buildrun.DeadHeaderMsgID: {id}, buildrun.DeadHeaderDeliveries: {"5"}, buildrun.DeadHeaderStream: {"SEAT_NODE_BUILD_GO"}, - buildrun.DeadHeaderGaveUp: {"2026-10-26T12:26:40Z"}} - g, ok := buildrun.GivenUpOf(h) - if !ok { - return nil - } - go l.dead.Heard(g) - default: - a, err := buildstep.DecodeStepAsk(data) - if err != nil { - return err - } - l.Write(l.answer(a)) - } - return nil -} - -func losing(b *bench, lose int) *losingAsks { - l := &losingAsks{FakeAsks: &buildrun.FakeAsks{}, answer: b.answer, dead: &buildrun.DeadLetters{}, lose: lose} - b.ex.Asks = buildrun.Asker{Seats: testSeats(), Publisher: b.asker(l, l.FakeAsks.Write), Waiter: buildrun.LostAskWaiter{Inner: l.FakeAsks, Dead: l.dead}, Bound: 5 * time.Second} - return l -} - -// endable is the tries state as the end tool sees it. -type endable struct{ kv *memKV } - -func (e endable) Entry(key string) (json.RawMessage, uint64, error) { - v, rev, _, err := e.kv.Get(context.Background(), key) - return v, rev, err -} -func (e endable) Update(key string, value []byte, revision uint64) error { - _, err := e.kv.Update(context.Background(), key, value, revision) - return err -} - -// Issue 734: a try whose ask the build seat gave up on ends as error saying so, and the next ask of its head is a new try; -// one no node takes ends at the step bound; one ended by hand frees its place and stops being waited for. -func TestAnAskGivenUpOrNeverTakenEndsItsTryAsErrorAndItsHeadIsAskedAnew(t *testing.T) { - ctx := context.Background() - for _, row := range []struct { - name string - lose int - never bool - // notTaken is the try's bound on an ask no node takes: short only where it is what ends the try, an hour where the - // dead letter must (a loaded machine let 200 ms pass before the dead letter was heard). - notTaken time.Duration - want string - }{ - {"given up by the build seat", 1, false, time.Hour, buildrun.LostWords + " after 5 deliveries at 2026-10-26T12:26:40Z"}, - {"taken by no build node within the bound", 0, true, 200 * time.Millisecond, buildrun.NotTakenWords + " within 200ms"}, - } { - t.Run(row.name, func(t *testing.T) { - kv := newMemKV() - at := time.Date(2026, 10, 26, 12, 22, 20, 0, time.UTC) - id, err := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, at) - if err != nil { - t.Fatal(err) - } - b := newBench(t) - l := losing(b, row.lose) - l.never = row.never - tr := &Tryer{Tries: kv, Judge: b.ex, NotTaken: row.notTaken} - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - got := readTry(t, kv, id) - if got.State != TryError || len(got.Failed) != 1 || !strings.Contains(got.Failed[0], row.want) || !strings.Contains(got.Said, row.want) { - t.Fatalf("try = %+v, want error saying %q", got, row.want) - } - again, err := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, at.Add(time.Minute)) - if err != nil || again == id { - t.Errorf("the head asked again answered %q, %v, want a new try", again, err) - } - }) - } - t.Run("ended by hand", func(t *testing.T) { - kv := newMemKV() - id, _ := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, time.Now()) - b := newBench(t) - losing(b, 0).never = true - tr := &Tryer{Tries: kv, Judge: b.ex} // no bound: only the hand ends it - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - deadline := time.Now().Add(10 * time.Second) - for readTry(t, kv, id).State != TryRunning && time.Now().Before(deadline) { - time.Sleep(5 * time.Millisecond) - } - if _, err := EndTry(endable{kv}, id, "", time.Now()); err == nil { - t.Error("an end without a why was taken") - } - ended, err := EndTry(endable{kv}, id, "its ask was lost in the bus reload", time.Now()) - if err != nil || ended.State != TryError || !strings.HasPrefix(ended.Said, "ended by hand ("+TryEndTool+"): its ask was lost") { - t.Fatalf("ended = %+v, %v", ended, err) - } - raw, _, _, _ = kv.Get(ctx, id) - tr.Put(ctx, id, raw) // the watch of the tries hands the end over - tr.Wait() // returns: the try's judging stopped - if got := readTry(t, kv, id); got.State != TryError || got.Said != ended.Said { - t.Errorf("try = %+v, want the hand's end kept", got) - } - if _, err := EndTry(endable{kv}, id, "again", time.Now()); err == nil || !strings.Contains(err.Error(), "ended already") { - t.Errorf("a second end answered %v", err) - } - }) -} - -// troubled is the build seat as a check meets it when its step's end does not reach its wait: the first `restarts` asks' -// steps are ended by the build module's next process (sdkrun.RestartReason), and the first `deaf` asks' watches hear -// nothing though their steps end (the lost check of 2026-10-28). Its steps state is read through AskSteps and Steps. -type troubled struct { - *buildrun.FakeAsks - answer func(buildstep.StepAsk) buildstep.Step - - mu sync.Mutex - restarts, deaf int - deafIDs map[string]bool - steps map[string]buildstep.Step -} - -func (tr *troubled) PublishAsk(ctx context.Context, subject, id string, data []byte) error { - if err := tr.FakeAsks.PublishAsk(ctx, subject, id, data); err != nil { - return err - } - a, err := buildstep.DecodeStepAsk(data) - if err != nil { - return err - } - step := tr.answer(a) - read, _ := buildstep.AskAs[buildstep.Ask](a) - step.What = sdkrun.AskWhat(read) - tr.mu.Lock() - if tr.restarts > 0 { - tr.restarts-- - step.State, step.Reason, step.Result = buildstep.StepFailed, sdkrun.RestartReason, nil - } - deaf := tr.deaf > 0 - if deaf { - tr.deaf-- - tr.deafIDs[id] = true - } - tr.steps[id] = step - tr.mu.Unlock() - if !deaf { - tr.Write(step) - } - return nil -} - -func (tr *troubled) WatchAsk(ctx context.Context, module, asker, askID string) (<-chan buildstep.Step, error) { - tr.mu.Lock() - deaf := tr.deafIDs[askID] - tr.mu.Unlock() - if deaf { - return make(chan buildstep.Step), nil // open, and silent for good - } - return tr.FakeAsks.WatchAsk(ctx, module, asker, askID) -} - -func (tr *troubled) AskSteps(_ context.Context, _, _, askID string) ([]buildstep.Step, error) { - tr.mu.Lock() - defer tr.mu.Unlock() - if s, ok := tr.steps[askID]; ok { - return []buildstep.Step{s}, nil - } - return nil, nil -} - -// Steps is the steps state as the read tools read it, with running in place of every step the hand has not let end. -func (tr *troubled) Steps(running bool) StateRead { - tr.mu.Lock() - defer tr.mu.Unlock() - vals := map[string]json.RawMessage{} - for id, s := range tr.steps { - if running { - s.State, s.Ended, s.Started = buildstep.StepRunning, time.Time{}, time.Now() - } - raw, _ := buildstep.EncodeStep(s) - vals[s.Node+"."+id] = raw - } - return StateRead{Keys: func() ([]string, error) { - var out []string - for k := range vals { - out = append(out, k) - } - return out, nil - }, Get: func(k string) (json.RawMessage, error) { return vals[k], nil }} -} - -// kvRead is a bucket in memory as the read tools read it, live. -func kvRead(kv *memKV) StateRead { - return StateRead{Keys: func() ([]string, error) { return kv.Keys(context.Background()) }, - Get: func(k string) (json.RawMessage, error) { - v, _, _, err := kv.Get(context.Background(), k) - return v, err - }} -} - -// asVerdicts is the rig's verdicts as the ask-again tool reads and writes them. -type asVerdicts struct{ kv *memKV } - -func (a asVerdicts) Entry(key string) (json.RawMessage, uint64, error) { - v, rev, _, err := a.kv.Get(context.Background(), key) - return v, rev, err -} -func (a asVerdicts) Update(key string, value []byte, revision uint64) error { - _, err := a.kv.Update(context.Background(), key, value, revision) - return err -} - -// Issue 734 and the lost check of 2026-10-28: a check whose ask judged nothing is asked again, and one whose step ended -// unheard is judged. Given up by the build seat once, or its step ended by the build module's next process after a -// delivery replaced it, the check is asked again under its claim and passes; given up every time it fails loudly as not -// heard, could not run, asked again when its part runs. A step whose watch went deaf is read at the next step end of its build module -// (a nudge) and judged with no new ask; one no event reaches is named lost by checker_status, refused by checker_ask_again -// while its step still runs, and asked again by it once its step ended. -func TestACheckWhoseAskJudgedNothingIsAskedAgainOrRead(t *testing.T) { - ctx := context.Background() - for _, row := range []struct { - name string - lose, restarts, deaf int - how string // "nudge": a step of the build module ends; "hand": checker_ask_again - state string - asks int - }{ - {name: "given up once", lose: 1, state: meshdeliverycheckerclient.VerdictPass, asks: 2}, - {name: "given up every time", lose: LostAskTries, state: meshdeliverycheckerclient.VerdictFail, asks: LostAskTries}, - {name: "its build module replaced under it", restarts: 1, state: meshdeliverycheckerclient.VerdictPass, asks: 2}, - {name: "replaced under every ask", restarts: LostAskTries, state: meshdeliverycheckerclient.VerdictFail, asks: LostAskTries}, - {name: "its watch deaf, a step of its build module ends", deaf: 1, how: "nudge", state: meshdeliverycheckerclient.VerdictPass, asks: 1}, - {name: "its watch deaf, asked again by hand", deaf: 1, how: "hand", state: meshdeliverycheckerclient.VerdictPass, asks: 2}, - {name: "its watch deaf, asked again by hand after its build module replaced it", deaf: 1, restarts: 1, how: "hand", state: meshdeliverycheckerclient.VerdictPass, asks: 2}, - } { - t.Run(row.name, func(t *testing.T) { - b := newBench(t) - var asked func() int - var heard *buildrun.HeardEnds - var tr *troubled - if row.lose > 0 { - l := losing(b, row.lose) - asked = func() int { return len(l.Asks()) } - } else { - tr = &troubled{FakeAsks: &buildrun.FakeAsks{}, answer: b.answer, restarts: row.restarts, deaf: row.deaf, - deafIDs: map[string]bool{}, steps: map[string]buildstep.Step{}} - heard = &buildrun.HeardEnds{Inner: tr, Read: tr} - b.ex.Asks = buildrun.Asker{Seats: testSeats(), Publisher: b.asker(tr, tr.Write), Waiter: heard, Bound: 5 * time.Second} - asked = func() int { return len(tr.Asks()) } - } - r := newRig(t, b.ex) - asksKept := newMemKV() - r.ch.Asks = asksKept - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - key := keyOf(t, "feat/x", cand) - r.ch.Candidate(ctx, "feat%2Fx", cand) - if row.deaf > 0 { - for deadline := time.Now().Add(10 * time.Second); heard.Waiting() == 0 && time.Now().Before(deadline); { - time.Sleep(2 * time.Millisecond) - } - if v := r.verdict(t, key); v.State != meshdeliverycheckerclient.VerdictRunning { - t.Fatalf("a check whose step ended unheard = %s, want running until it is read", v.State) - } - } - switch row.how { - case "nudge": - heard.Nudge(nodeBuildModule) // another build module's step: not this one's to read - heard.Nudge(goBuildModule) - case "hand": - cands := newMemKV() - ckey, _ := meshcatalogclient.CandidatesKey("feat/x") - _, _ = cands.Create(ctx, ckey, cand) - none := StateRead{Keys: func() ([]string, error) { return nil, nil }, Get: func(string) (json.RawMessage, error) { return nil, nil }} - steps := map[string]StateRead{goBuildModule: none} - rd := Reader{CandidateState: kvRead(cands), VerdictState: kvRead(r.verdicts), AskState: kvRead(asksKept), - StepStates: func() map[string]StateRead { return steps }} // no node took its ask yet - if _, err := rd.AskAgain(asVerdicts{r.verdicts}, "feat/x", "its watch went deaf"); err == nil || !strings.Contains(err.Error(), "waits in its build seat's stream") { - t.Errorf("asked again while its ask waits in the stream (issue 1791's kind): %v", err) - } - steps[goBuildModule] = tr.Steps(true) - if _, err := rd.AskAgain(asVerdicts{r.verdicts}, "feat/x", "its watch went deaf"); err == nil || !strings.Contains(err.Error(), "a step of it runs") { - t.Errorf("asked again while its step runs: %v", err) - } - steps[goBuildModule] = tr.Steps(false) - if st, _ := rd.Status(); !strings.Contains(st.Lost["feat/x"], AskAgainTool) { - t.Errorf("status lost = %v, want feat/x named with %s", st.Lost, AskAgainTool) - } - // Issue 1373: a check that names no ask is asked again only when no check ask waits or is held in any build seat's stream. - { - raw, _, _, _ := r.verdicts.Get(ctx, key) - vcopy := newMemKV() - _, _ = vcopy.Create(ctx, key, raw) - noAsk := rd - noAsk.AskState = kvRead(newMemKV()) - for _, c := range []struct { - name string - rows []BacklogRow - bad string - }{{"a check ask waits", []BacklogRow{{Language: "go", Kind: "check", Waiting: 1}}, "holds asks"}, - {"a check ask is held", []BacklogRow{{Language: "go", Kind: "check", Held: 1}}, "holds asks"}, - {"a recheck ask waits", []BacklogRow{{Language: "go", Kind: "recheck", Waiting: 1}}, "holds asks"}, - {"a recheck ask is held", []BacklogRow{{Language: "go", Kind: "recheck", Held: 1}}, "holds asks"}, - {"a stream cannot be read", []BacklogRow{{Language: "go", Kind: "check", Error: "no worker"}}, "cannot be read"}, - {"only a delivery ask waits", []BacklogRow{{Language: "go", Kind: "delivery", Waiting: 3}}, ""}} { - noAsk.Backlog = func() ([]BacklogRow, error) { return c.rows, nil } - w := VerdictEntry(asVerdicts{r.verdicts}) - if c.bad == "" { - w = asVerdicts{vcopy} - } - got, err := noAsk.AskAgain(w, "feat/x", "no ask") - if (c.bad == "") != (err == nil) || (c.bad != "" && !strings.Contains(err.Error(), c.bad)) || (c.bad == "" && !strings.HasPrefix(got.Said, AskedAgainWords)) { - t.Errorf("a check naming no ask, %s: %+v, %v", c.name, got, err) - } - } - } - got, err := rd.AskAgain(asVerdicts{r.verdicts}, "feat/x", "its watch went deaf") - if err != nil || got.Key != key || !strings.HasPrefix(got.Said, AskedAgainWords) { - t.Fatalf("asked again = %+v, %v", got, err) - } - raw, _, _, _ := r.verdicts.Get(ctx, key) - r.ch.VerdictWritten(ctx, key, raw) // the checker's watch of its verdicts hands it over - } - r.ch.Wait() - v := r.verdict(t, key) - if v.State != row.state || asked() != row.asks { - t.Errorf("verdict %s (%s) after %d asks, want %s after %d", v.State, v.Failed.Words, asked(), row.state, row.asks) - } - if _, _, kept, _ := asksKept.Get(ctx, key); kept { - t.Errorf("the asks of the ended check are still kept under %s", key) - } - if row.state == meshdeliverycheckerclient.VerdictFail && (!IsLostAsk(v) || !IsCouldNotRun(v)) { - t.Errorf("a check that judged nothing every time = %q, want lost and could not run", v.Failed.Words) - } - if row.how == "hand" { - rd := Reader{VerdictState: kvRead(r.verdicts), CandidateState: kvRead(newMemKV())} - if _, err := rd.AskAgain(asVerdicts{r.verdicts}, "feat/x", "again"); err == nil { - t.Error("a judged check was asked again") - } - // ADR 0664 (issue 1748, operator answer 5): a failed verdict whose failing steps all ended on a transport fault - // is asked again; one with a failing step that did not, or with none read, stands. - for _, c := range []struct { - name string - passing []bool - ok bool - }{{"every failing step on a transport fault", []bool{true, true}, true}, {"one step failed on the source", []bool{true, false}, false}, {"no failed step read", nil, false}} { - failedKV := newMemKV() - judgedRaw, _, _, _ := r.verdicts.Get(ctx, key) - failed, _ := meshdeliverycheckerclient.DecodeVerdict(judgedRaw) - failed.State, failed.Failed = meshdeliverycheckerclient.VerdictFail, &FailedFirst{Machine: "ace", Words: "a transport fault on 3 runs"} - raw, _ := meshdeliverycheckerclient.EncodeVerdict(failed) - failedKV.Create(ctx, key, raw) - vals := map[string]json.RawMessage{} - for i, p := range c.passing { - id := fmt.Sprint("mvl0frv18d19", 80+i) - vals["ace."+id], _ = buildstep.EncodeStep(buildstep.Step{ID: id, Node: "ace", Tool: "check ask", State: buildstep.StepFailed, Passing: p, Ended: time.Now(), What: "check " + repoA + "@" + short12(head1)}) - } - rd := Reader{CandidateState: kvRead(cands2(t, cand)), VerdictState: kvRead(failedKV), AskState: kvRead(newMemKV()), StepStates: stepStatesOf(map[string]StateRead{goBuildModule: { - Keys: func() ([]string, error) { return slices.Collect(maps.Keys(vals)), nil }, Get: func(k string) (json.RawMessage, error) { return vals[k], nil }}})} - if got, err := rd.AskAgain(asVerdicts{failedKV}, "feat/x", "the network"); (err == nil) != c.ok || (c.ok && !strings.HasPrefix(got.Said, AskedAgainWords)) { - t.Errorf("%s: asked again = %+v, %v, want asked again %v", c.name, got, err, c.ok) - } - } - } - }) - } -} - -// cands2 is a candidates state holding cand under feat/x. -func cands2(t *testing.T, cand []byte) *memKV { - t.Helper() - kv := newMemKV() - ckey, _ := meshcatalogclient.CandidatesKey("feat/x") - _, _ = kv.Create(context.Background(), ckey, cand) - return kv -} diff --git a/modules/mesh-delivery-checker/internal/check/manifests_judge.go b/modules/mesh-delivery-checker/internal/check/manifests_judge.go deleted file mode 100644 index f665de95..00000000 --- a/modules/mesh-delivery-checker/internal/check/manifests_judge.go +++ /dev/null @@ -1,401 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "maps" - "mesh-delivery-checker/rules" - "slices" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" - "git.novox.be/novox/mesh-sdk/go/catalogue" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/packagename" -) - -// A change's manifests are judged by the indexer's judge (novox/hq ADR 0578 §2): the checker asks the Go build seat to -// build the judge's command (mesh-delivery's modules/mesh-delivery-indexer, cmd/mesh-judge) at mesh-delivery's trunk, or -// at the group's mesh-delivery member head when that member changes the judge, and to run it in its sandbox over the -// catalogue as the change leaves it, exactly as the composer is run (buildstep.ComposeJob, ADR 0482 §4). A manifest the -// change touches that the judge refuses fails the check, naming the manifest and each problem. The checker links no -// judge of its own. - -// The judge the checker runs. -const ( - DeliveryRepository = "novox/mesh-delivery" - JudgeDir = "modules/mesh-delivery-indexer" - JudgePackage = "mesh-delivery-indexer/cmd/mesh-judge" - // JudgeCase is the case of a judge request holding the catalogue as the change leaves it, and JudgeTrunk the one - // holding it as the trunk holds it: a problem the change case has and the trunk case lacks is the change's (ADR 0579 §2). - JudgeCase = "change" - JudgeTrunk = "trunk" - // judgeBetween is how the judge names the problems between manifests that no one module's removal ends. - judgeBetween = rules.BetweenManifests -) - -// judgePaths are the paths of mesh-delivery whose change changes the judge: a group whose mesh-delivery member changes -// one is judged by that member's head. -var judgePaths = []string{JudgeDir + "/judge/", JudgeDir + "/cmd/mesh-judge/", JudgeDir + "/go.mod", JudgeDir + "/go.sum"} - -// changesJudge says whether a merge of mesh-delivery with these changed paths changes the judge. -func changesJudge(repository string, merged []Fetched) bool { - if repository != DeliveryRepository { - return false - } - for _, f := range merged { - for _, p := range f.Changed { - for _, j := range judgePaths { - if p == j || strings.HasPrefix(p, j) { - return true - } - } - } - } - return false -} - -// TrunkManifests says the manifest digest of every module the indexer holds (its modules state), by module. -type TrunkManifests interface { - ManifestDigests() map[string]string - // ManifestFingerprints is the fingerprint of the entry of every such module in the trunk revision, by module, whose - // catalog graph entry holds that manifest (design 47 G A-310). - ManifestFingerprints() map[string]string -} - -// SeatList gives the seat definitions the manifests are judged against, whole, as raw definitions (a request's Seats): the -// list the seat list reader holds. It is an error when the list has not been read from the seat yet, since a manifest judged -// against the bootstrapped seats alone would be refused for a seat it names that the mesh defines (novox/hq ADR 0636 §1). -type SeatList interface { - Definitions() ([]json.RawMessage, error) -} - -// PredefinedList is the catalogue's list of predefined keys the indexer keeps (its state predefined, key list), the one a -// config value falling back to a key is judged against (ADR 0348 §7); nil when it keeps none. -type PredefinedList interface { - PredefinedList(ctx context.Context) (json.RawMessage, error) -} - -// judgeRequest is the judge's request over the catalogue as the case leaves it: every trunk manifest by its digest, each -// one a pull request touches replaced by the digest its candidate names; touched are the modules whose manifest the -// change adds or changes (a digest the trunk does not hold for it), sorted (novox/hq ADR 0579 §2). -func judgeRequest(trunk, trunkFps map[string]string, pulls []Pull) (req composer.Request, touched []string) { - manifests, before := map[string]composer.Manifest{}, map[string]composer.Manifest{} - for module, digest := range trunk { - if digest != "" { - manifests[module] = composer.Manifest{Digest: digest, Fingerprint: trunkFps[module]} - before[module] = composer.Manifest{Digest: digest, Fingerprint: trunkFps[module]} - } - } - seen := map[string]bool{} - for _, p := range pulls { - for module, cm := range p.Fps { - if cm.Manifest == "" { - continue - } - manifests[module] = composer.Manifest{Digest: cm.Manifest, Fingerprint: cm.Fp2} - if trunk[module] != cm.Manifest { - seen[module] = true - } - } - } - return composer.Request{V: composer.Version, Cases: []composer.Case{{Name: JudgeCase, Manifests: manifests}, - {Name: JudgeTrunk, Manifests: before}}}, slices.Sorted(maps.Keys(seen)) -} - -// judgeManifests runs the indexer's judge over the case's manifests and records its answers as a fact the rules judge -// (rules.JudgeManifests), with the trunk validator's answer on a new indexer (ADR 0633 clause 6). A case that touches no -// manifest, or an examiner that reads no trunk manifests, judges nothing; a judge that cannot be asked or does not answer -// is a failure, said, never a pass. -func (st *state) judgeManifests(ctx context.Context) { - if st.j.Manifests == nil || st.narrowTry() { - return - } - req, touched := judgeRequest(st.j.Manifests.ManifestDigests(), st.j.Manifests.ManifestFingerprints(), st.c.Pulls) - if len(touched) == 0 { - return - } - commit, at := st.judgeHead, "the group's mesh-delivery head "+st.judgeHead - if commit == "" { - if st.j.Trunks != nil { - commit = st.j.Trunks.Heads()[DeliveryRepository] - } - at = "mesh-delivery's trunk " + commit - } - if commit == "" { - st.fail(st.goModule(), "the change's manifests cannot be judged: the trunk head of "+DeliveryRepository+" is not known") - return - } - // The list of predefined keys the manifests are judged against (ADR 0578 §2): the catalogue member's predefined.json - // when the change alters it, else the one the indexer keeps. - if list, from := st.predefinedList(ctx); list != nil { - req.Predefined = list - st.c.note("the manifests are judged against the predefined keys of " + from) - } - req.Packages = st.knownPackages(ctx) - // The heads' seat list, for the change case and the trunk case both (ADR 0636 §4). - req.Seats = st.c.Seats - cv, trunkCase, ok := st.runJudge(ctx, req, touched, commit, at, st.packagesOf(DeliveryRepository)) - if !ok { - return - } - st.judgedVerdicts(cv, at) - m := rules.Manifests{Touched: touched, At: at, Change: cv, Trunk: trunkCase} - if !st.indexerOf(ctx, req, touched, cv, at, &m) { - return - } - st.facts = append(st.facts, rules.Step{Module: st.goModule(), Manifests: &m}) -} - -// runJudge asks the Go build seat to build the judge at the commit and run it over the request, and reads its change and -// trunk cases; false, the failure recorded, when it cannot be asked or does not answer. -func (st *state) runJudge(ctx context.Context, req composer.Request, touched []string, commit, at string, versions buildstep.PackageVersions) (change, trunk composer.CaseVerdict, ok bool) { - raw, err := json.Marshal(req) - if err != nil { - st.fail(st.goModule(), err.Error()) - return change, trunk, false - } - job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Dir: JudgeDir, Packages: versions}, Dir: JudgeDir, - Package: JudgePackage, Request: raw, Reader: "the indexer's judge at " + at} - a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: st.j.Module, - At: st.j.now().UTC(), Compose: &job} - st.c.Progress.Set(fmt.Sprintf("the judge ask %s of the manifests of %s", a.ID, strings.Join(touched, ", ")), "") - st.c.Asked(a.ID) - if err := st.j.Asks.Put(ctx, a); err != nil { - st.fail(st.goModule(), "the judge of the change's manifests could not be asked: "+err.Error()) - return change, trunk, false - } - step, err := st.j.Asks.Wait(ctx, a) - if err != nil { - st.fail(st.goModule(), "the judge of the change's manifests: "+err.Error()) - return change, trunk, false - } - change, trunk, why := judgeAnswer(step) - if why != "" { - st.fail(st.goModule(), fmt.Sprintf("the indexer's judge at %s did not judge the change's manifests: %s", at, why)) - return change, trunk, false - } - return change, trunk, true -} - -// CatalogSeat is the seat the indexer holds (rules.CatalogSeat). -const CatalogSeat = rules.CatalogSeat - -// indexerOf finds the touched module whose manifest claims the seat mesh-catalog, the indexer, and puts in m the trunk's -// manifest validator's change case on it, the one the running parts hold (ADR 0633 clause 6): when the change judges -// with its own head's validator, or at other package versions than the latest published, the trunk's is asked as well. -// False, the failure recorded, when a manifest cannot be read or the trunk's validator cannot be asked. -func (st *state) indexerOf(ctx context.Context, req composer.Request, touched []string, cv composer.CaseVerdict, judgedAt string, m *rules.Manifests) bool { - if st.j.Read == nil { - return true - } - var indexer string - for _, module := range touched { - man, err := st.j.Read.Manifest(ctx, req.Cases[0].Manifests[module].Digest) - if err != nil { - st.fail(st.goModule(), fmt.Sprintf("the manifest of %s cannot be read, so the indexer cannot be ruled out: %v", module, err)) - return false - } - for _, c := range man.Claims { - if c.Name == CatalogSeat { - indexer = module - } - } - } - if indexer == "" { - return true - } - // The validator the running parts hold is the trunk's, built at the latest published versions alone, never at the group's - // heads (ADR 0633 clause 6): a group's mesh-sdk or mesh-contracts head must not change the validator that judges the new - // indexer. The head's run is reused when it was that validator already. - if trunkVersions := st.trunkJudgeVersions(); st.judgeHead != "" || !maps.Equal(st.packagesOf(DeliveryRepository), trunkVersions) { - trunk := "" - if st.j.Trunks != nil { - trunk = st.j.Trunks.Heads()[DeliveryRepository] - } - if trunk == "" { - st.fail(st.goModule(), "the new indexer cannot be judged by the trunk's manifest validator: the trunk head of "+DeliveryRepository+" is not known") - return false - } - judgedAt = "mesh-delivery's trunk " + trunk - var ok bool - if cv, _, ok = st.runJudge(ctx, req, touched, trunk, judgedAt, trunkVersions); !ok { - return false - } - } - m.Indexer, m.IndexerAt, m.OfIndexer = indexer, judgedAt, &cv - return true -} - -// judgeAnswer reads the judge's change and trunk cases from its step, or why it cannot. -func judgeAnswer(step buildstep.Step) (change, trunk composer.CaseVerdict, why string) { - if step.State != buildstep.StepPassed { - return change, trunk, fmt.Sprintf("its step %s: %s", step.State, step.Reason) - } - var a buildstep.ComposeAnswer - if err := json.Unmarshal(step.Result, &a); err != nil { - return change, trunk, "its step's answer cannot be read: " + err.Error() - } - var v composer.Verdict - if err := json.Unmarshal(a.Verdict, &v); err != nil || v.V != composer.Version { - return change, trunk, fmt.Sprintf("its verdict cannot be read (version %d): %v", v.V, err) - } - found := 0 - for _, c := range v.Cases { - switch c.Name { - case JudgeCase: - change, found = c, found+1 - case JudgeTrunk: - trunk, found = c, found+1 - } - } - if found != 2 { - return change, trunk, "its verdict does not hold both the cases " + JudgeCase + " and " + JudgeTrunk - } - return change, trunk, "" -} - -// predefinedList is the list of predefined keys a case's manifests are judged against, and where it comes from: the -// catalogue member's predefined.json at its head when its merge changes it, else the one the indexer keeps; nil when -// neither can be read, said, and the judge then takes each fallback as its value declares it. -func (st *state) predefinedList(ctx context.Context) (catalogue.PredefinedList, string) { - read := func(raw []byte, from string) (catalogue.PredefinedList, string) { - list, err := catalogue.ParsePredefined(raw) - if err != nil { - st.c.note("the predefined keys of " + from + " cannot be read, so fallbacks are judged as their values declare them: " + err.Error()) - return nil, "" - } - return list, from - } - if st.predefinedHead != "" && st.j.Forge != nil { - text, err := st.j.Forge.File(ctx, catalogueRepository, catalogue.PredefinedFile, st.predefinedHead) - if err == nil { - return read([]byte(text), "the catalogue member's head "+st.predefinedHead) - } - st.c.note("the catalogue member's predefined.json cannot be read: " + err.Error()) - } - if st.j.Predefined == nil { - return nil, "" - } - raw, err := st.j.Predefined.PredefinedList(ctx) - if err != nil || raw == nil { - if err != nil { - st.c.note("the indexer's predefined keys cannot be read: " + err.Error()) - } - return nil, "" - } - return read(raw, "the indexer's kept list") -} - -// judgedByMember notes the group's mesh-delivery member head as the judge's when its merge changes the judge, and the -// catalogue member's head as where the predefined keys are read when its merge changes predefined.json. -func (st *state) judgedByMember(p Pull, merged []Fetched) { - if changesJudge(p.Repository, merged) { - st.judgeHead = p.Head - } - if p.Repository == catalogueRepository { - for _, f := range merged { - if slices.Contains(f.Changed, catalogue.PredefinedFile) { - st.predefinedHead = p.Head - } - } - } -} - -// knownPackages are the packages a manifest's `packages` may name, sorted (DLV-I14, design 32): every name the indexer's -// packages state holds, and, of each package a member of the case declares that the state does not know by its -// `/`, the name read at that member's head through the forge (packagename.Of, the indexer's own reader -// at a merge). A name that cannot be read is said and left out, so a manifest naming it is refused naming it. Nil, which -// judges no name, when the checker follows no packages state or has not read it yet (PackageNames nil); an answered -// state that holds no name is an empty list, never nil, so every name is judged against it. -func (st *state) knownPackages(ctx context.Context) []string { - if st.j.KnownPackages == nil { - return nil - } - names := st.j.KnownPackages.PackageNames() - if names == nil { - return nil - } - built := map[string]bool{} - for _, b := range names { - built[b] = true - } - known := make([]string, 0, len(names)) - known = append(known, slices.Collect(maps.Keys(names))...) - declared, err := st.declaredPackages(ctx) - if err != nil { - st.c.note("the packages the group's members declare are not known, so only the packages state's names are known to the judge: " + err.Error()) - } - for _, d := range declared { - if built[d.module+"/"+d.name] { - continue - } - if st.j.Forge == nil { - st.c.note(fmt.Sprintf("the name of the package %s/%s new in the group is not read: this checker reads no forge", d.module, d.name)) - continue - } - read := func(ctx context.Context, repository, commit, file string) ([]byte, error) { - text, err := st.j.Forge.File(ctx, repository, file, commit) - if errors.Is(err, ErrNotFound) { - return nil, nil - } - return []byte(text), err - } - dirs := []string{d.dir} - if d.dir == "" { - dirs = []string{"modules/" + d.module, meshcatalogclient.RootPath} - } - var why []string - for _, dir := range dirs { - a := catalogue.Artifact{Name: d.name, Kind: catalogue.ArtifactPackage, Language: d.language, Paths: d.paths} - name, err := packagename.Of(ctx, read, d.pull.Repository, d.pull.Head, dir, a) - if err == nil { - known, why = append(known, name), nil - break - } - why = append(why, err.Error()) - } - if len(why) > 0 { - st.c.note(fmt.Sprintf("the name of the package %s/%s new in the group is not read at the head of %s: %s", d.module, d.name, pullKey(d.pull), strings.Join(why, "; "))) - } - } - slices.Sort(known) - return slices.Compact(known) -} - -// trunkJudgeVersions are the versions the trunk's manifest validator is built at: the latest published version of each -// package, with no group member's head (ADR 0633 clause 6). -func (st *state) trunkJudgeVersions() buildstep.PackageVersions { - return packagesFor(st.j.Published, &Case{}, DeliveryRepository) -} - -// judgedVerdicts puts the check's own judge's verdict on each manifest the change brings on the case, as the seat -// mesh-catalog's verdict value, for the composer's request (ADR 0578 §2, §3; F5 of milestone 47/G): accepted, or refused -// with its words; a manifest the judge gave no verdict on carries none, which the composer reads as accepted. -func (st *state) judgedVerdicts(cv composer.CaseVerdict, at string) { - for _, p := range st.c.Pulls { - for name, fp := range p.Fps { - read, ok := cv.Manifests[name] - if fp.Manifest == "" || !ok || (!read.Accepted && read.Refused == "") { - continue - } - v := meshcatalog.VerdictsByDigestValue{Module: name, State: meshcatalogclient.VerdictAccepted, Judge: at} - if !read.Accepted { - v.State, v.Problems = meshcatalogclient.VerdictRefused, []string{read.Refused} - } - raw, err := json.Marshal(v) - if err != nil { - continue - } - if st.c.Judged == nil { - st.c.Judged = map[string]json.RawMessage{} - } - st.c.Judged[name] = raw - } - } -} diff --git a/modules/mesh-delivery-checker/internal/check/manifests_judge_test.go b/modules/mesh-delivery-checker/internal/check/manifests_judge_test.go deleted file mode 100644 index edf3ae6a..00000000 --- a/modules/mesh-delivery-checker/internal/check/manifests_judge_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package check - -import ( - "reflect" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" -) - -// Design 47 G A-310: a manifest the judge's request names by its digest names the fingerprint whose catalog graph entry holds -// it: a pull's own fingerprint for a module the pull changes, the trunk revision's entry for the rest. -func TestTheJudgeRequestNamesEachManifestsFingerprint(t *testing.T) { - pull := Pull{Fps: map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"changed": {Manifest: "d2", Fp2: "src2:pull"}}} - req, _ := judgeRequest(map[string]string{"changed": "d1", "same": "d3"}, map[string]string{"changed": "src2:trunk", "same": "src2:same"}, []Pull{pull}) - got, trunk := req.Cases[0].Manifests, req.Cases[1].Manifests - if !reflect.DeepEqual(got["changed"], composer.Manifest{Digest: "d2", Fingerprint: "src2:pull"}) || !reflect.DeepEqual(got["same"], composer.Manifest{Digest: "d3", Fingerprint: "src2:same"}) { - t.Errorf("the change's manifests = %+v", got) - } - if !reflect.DeepEqual(trunk["changed"], composer.Manifest{Digest: "d1", Fingerprint: "src2:trunk"}) { - t.Errorf("the trunk's manifest = %+v, want the trunk entry's fingerprint", trunk["changed"]) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/names.go b/modules/mesh-delivery-checker/internal/check/names.go deleted file mode 100644 index 18c199f8..00000000 --- a/modules/mesh-delivery-checker/internal/check/names.go +++ /dev/null @@ -1,83 +0,0 @@ -package check - -import ( - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshwatchdogs" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// The holders and buckets the checker names. No contract names a holder (novox/hq ADR 0625 §4, ADR 0634 §1), so these are its -// own constants, each a state of a seat (the seat's state name beside the holder's module name) and each declared in its -// manifest (module.json: its own states, its `reads`); a unit row checks them against the manifest (TestTheNamesAreTheManifests). -const ( - // GateModule holds the seat mesh-delivery's states source and turns, which the checker reads (reads: mesh-delivery-gate.source, - // mesh-delivery-gate.turns). - GateModule = "mesh-delivery-gate" - - // IndexerModule holds the seat mesh-catalog's states, which the checker follows by their views (consumes: - // mesh-delivery-indexer.views.*). - IndexerModule = "mesh-delivery-indexer" - CandidatesBucket = IndexerModule + "_" + meshcatalog.StateCandidates - ModulesBucket = IndexerModule + "_" + meshcatalog.StateModules - ManifestsBucket = IndexerModule + "_" + meshcatalog.StateManifests - IndexerPredefinedState = meshcatalog.StatePredefined - - // WatchmanModule holds the seat mesh-watchdogs' presence (reads: mesh-delivery-watchman.presence). - WatchmanModule = "mesh-delivery-watchman" - PresenceBucket = WatchmanModule + "_" + meshwatchdogs.StatePresence - - // HaveBucket is the node-engine's state have (reads: node-engine.have); a node's own key ends in HaveNodeWord. - HaveBucket = "node-engine_" + nodeengine.StateHave - HaveNodeWord = "node" - - // compositionWaits is the state of the assigner's composition answer that waits for what it composes from. - compositionWaits = "waits" -) - -// FailedFirst names what failed: a test (its package and name) or a machine, with the words of the failure. It is the shape of -// the verdict's `failed` and of each entry of its `failures` (the seat's two types of it have the same fields), so the check -// judges with one and converts at the verdict's edge (failureItems, failedList). -type FailedFirst = checker.VerdictsByGroupHeadsValueFailed - -// failedOf is the first failure a verdict names: the zero value of a verdict that names none. -func failedOf(v checker.VerdictsByGroupHeadsValue) FailedFirst { - if v.Failed == nil { - return FailedFirst{} - } - return *v.Failed -} - -// tookOf is the time of each part of a check a verdict names: the zero value of a verdict that names none. -func tookOf(v checker.VerdictsByGroupHeadsValue) checker.VerdictsByGroupHeadsValueTook { - if v.Took == nil { - return checker.VerdictsByGroupHeadsValueTook{} - } - return *v.Took -} - -func failureItems(list []FailedFirst) []checker.VerdictsByGroupHeadsValueFailuresItem { - if list == nil { - return nil - } - out := make([]checker.VerdictsByGroupHeadsValueFailuresItem, len(list)) - for i, f := range list { - out[i] = checker.VerdictsByGroupHeadsValueFailuresItem(f) - } - return out -} - -func failedList(items []checker.VerdictsByGroupHeadsValueFailuresItem) []FailedFirst { - if items == nil { - return nil - } - out := make([]FailedFirst, len(items)) - for i, f := range items { - out[i] = FailedFirst(f) - } - return out -} - -// Bucket is the bucket of one of the checker's own states, `_`, module its credential's, never a constant -// (design 47 G A-296, §428). -func Bucket(module, state string) string { return module + "_" + state } diff --git a/modules/mesh-delivery-checker/internal/check/owed.go b/modules/mesh-delivery-checker/internal/check/owed.go deleted file mode 100644 index 4de3ad97..00000000 --- a/modules/mesh-delivery-checker/internal/check/owed.go +++ /dev/null @@ -1,49 +0,0 @@ -package check - -import ( - "fmt" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// The checker's owed state holds the one act it owes, the status mesh/check on a pull request at a head: the gate's owed act -// with the context mesh/check. Its value has the shape of the gate's (the seat mesh-delivery's owed), so its rules and its -// codec are the mesh-delivery client's; only the checker reads it, so the checker's own narrowing to its one act lives here. - -// CheckerOwedAct is the act the checker owes. -const CheckerOwedAct = meshdeliveryclient.OwedStatus + "=" + meshdeliveryclient.StatusContextCheck - -// CheckerOwedKey is the key, in the checker's owed state, of the status the checker owes on a pull request at a head. -func CheckerOwedKey(repository string, number int, head string) (string, error) { - return meshdeliveryclient.OwedKey(repository, number, head, CheckerOwedAct) -} - -func checkCheckerOwed(o meshdeliverychecker.OwedByRepositoryNumberHeadActValue) error { - if o.Act != meshdeliveryclient.OwedStatus || o.Context != meshdeliveryclient.StatusContextCheck { - return fmt.Errorf("the checker owes only a status with the context %s, not the act %q with the context %q", meshdeliveryclient.StatusContextCheck, o.Act, o.Context) - } - return nil -} - -// EncodeCheckerOwed is o as the gate's owed value, refused for any act but the checker's status. -func EncodeCheckerOwed(o meshdeliverychecker.OwedByRepositoryNumberHeadActValue) ([]byte, error) { - if err := checkCheckerOwed(o); err != nil { - return nil, err - } - return meshdeliveryclient.EncodeOwed(meshdelivery.OwedByRepositoryNumberHeadActValue(o)) -} - -// DecodeCheckerOwed reads an owed act of the checker's state. -func DecodeCheckerOwed(data []byte) (meshdeliverychecker.OwedByRepositoryNumberHeadActValue, error) { - g, err := meshdeliveryclient.DecodeOwed(data) - if err != nil { - return meshdeliverychecker.OwedByRepositoryNumberHeadActValue{}, err - } - o := meshdeliverychecker.OwedByRepositoryNumberHeadActValue(g) - if err := checkCheckerOwed(o); err != nil { - return meshdeliverychecker.OwedByRepositoryNumberHeadActValue{}, err - } - return o, nil -} diff --git a/modules/mesh-delivery-checker/internal/check/package_cause_test.go b/modules/mesh-delivery-checker/internal/check/package_cause_test.go deleted file mode 100644 index 7922e012..00000000 --- a/modules/mesh-delivery-checker/internal/check/package_cause_test.go +++ /dev/null @@ -1,109 +0,0 @@ -package check - -import ( - "mesh-delivery-checker/rules" - "strings" - "testing" -) - -// What the build module before this fix sent for two packages that failed after their tests passed (issue 1901, its third -// meeting: a try of mesh-controller kept "PASS" as its failure's words). Each is that build module's Output for the real -// `go test -json` of a throwaway package (mesh-catalog modules/mesh-build-go testdata/captured/go-test-json-pkg-*.jsonl): -// TestMain panicking in a goroutine after m.Run, TestMain exiting 2 after m.Run, and TestMain racing after m.Run. -const ( - oldPassThenPanic = "PASS\npanic: the bus closed after the tests: nats: connection closed\ngoroutine 20 [running]:\n" + - "example.com/passthenfail.TestMain.func1()\n\t/tmp/fix-1901b/passthenfail/p_test.go:13 +0x25\n" + - "created by example.com/passthenfail.TestMain in goroutine 1\n\t/tmp/fix-1901b/passthenfail/p_test.go:13 +0x25\n" + - "FAIL\texample.com/passthenfail\t0.005s" - oldPassThenExit = "PASS\nFAIL\texample.com/mainexit\t0.004s" - // TestMain racing after m.Run passed, under go test -race (go-test-json-pkg-racemain.jsonl). - oldPassThenRace = "PASS\n==================\nWARNING: DATA RACE\nWrite at 0x000000836428 by goroutine 9:\n example.com/racemain.TestMain.func1()\n /tmp/fix-1901b/racemain/p_test.go:15 +0x24\nPrevious write at 0x000000836428 by main goroutine:\n example.com/racemain.TestMain()\n /tmp/fix-1901b/racemain/p_test.go:16 +0x44\n main.main()\n _testmain.go:48 +0x171\nGoroutine 9 (running) created at:\n example.com/racemain.TestMain()\n /tmp/fix-1901b/racemain/p_test.go:15 +0x37\n main.main()\n _testmain.go:48 +0x171\n==================\nFound 1 data race(s)\nFAIL\texample.com/racemain\t1.031s" -) - -// A package's failure is worded by its cause, cut to its bound, and never as pass (issue 1901, AC5). -func TestAPackageFailuresCauseIsWordedNeverPass(t *testing.T) { - for _, row := range []struct { - name string - test func(t *testing.T) - }{ - // A failure with no cause told apart never has "PASS" or "ok" as its words: the checker takes the panic line from the - // output, or says that the tests passed and the program failed after them (1901/AC5). - {"a package failure is never worded pass", func(t *testing.T) { // 1901/AC5 - cases := []struct { - name, output, want string - }{ - {"panic after the tests", oldPassThenPanic, "panic: the bus closed after the tests: nats: connection closed"}, - {"exit after the tests", oldPassThenExit, "the tests passed, then the test program exited with a failure"}, - {"race after the tests", oldPassThenRace, "WARNING: DATA RACE: Write at 0x000000836428 by goroutine 9 in example.com/racemain.TestMain.func1()"}, - {"a panic deep in a long output", "PASS\npanic: the seat row vanished\n" + strings.Repeat("goroutine 7 [chan receive]:\n\tsome/frame.go:1 +0x1\n", 300) + "FAIL\tp\t2.0s", "panic: the seat row vanished"}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - v := rules.LevelFailure("", "", "", "integration", Tested{Failed: []Failure{{Package: "github.com/novox/mesh-controller/cmd/mesh-controller", Output: c.output}}}) - for _, l := range strings.Split(v.Failed.Words, "\n") { - if l = strings.TrimSpace(l); l == "PASS" || strings.HasPrefix(l, "ok ") || strings.HasPrefix(l, "ok\t") { - t.Errorf("1901/AC5: the words keep %q: %q", l, v.Failed.Words) - } - } - if !strings.HasPrefix(afterHid(v.Failed.Words), c.want) { - t.Errorf("1901/AC5: words after the loud line start %q, want %q", rules.FirstLine(afterHid(v.Failed.Words)), c.want) - } - if got := firstFailed(*v); !strings.Contains(got, "the build module hid the failure") || strings.HasSuffix(got, ": PASS") { - t.Errorf("1901/AC5, AC8: status = %q", got) - } - }) - } - }}, - // A cause the build module told apart is cut to a line's bound, so the words keep their bound (the 1901 review's note). - {"a long cause is cut to a lines bound", func(t *testing.T) { // 1901/AC5 - f := Failure{Package: "p", Test: "TestX", Cause: strings.Repeat("c", 5000), Output: "x_test.go:1: something"} - v := rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{f}}) - if len(v.Failed.Words) > rules.MaxWords+200 { - t.Errorf("1901/AC5: words are %d bytes, bound %d", len(v.Failed.Words), rules.MaxWords) - } - }}, - // The build module on main sends a package that stopped (a timeout, an exit, a kill) as only go test's last line, with no - // cause: the words then say so, never nothing (review round 1). Each output is what that build module sends for the - // capture of the same name (go-test-json-pkg-timeout, -exiting, -killed): the package's own output, its "FAIL" line. - {"a package stopped with only its fail line is still worded", func(t *testing.T) { // 1901/AC5 - for _, out := range []string{"FAIL\texample.com/timeout\t2.017s", "FAIL\texample.com/exiting\t0.006s", "FAIL\texample.com/killed\t0.006s"} { - v := rules.LevelFailure("", "", "", "integration", Tested{Failed: []Failure{{Package: "example.com/x", Output: out}}}) - if !strings.HasPrefix(afterHid(v.Failed.Words), "the package failed with no test to name and no panic, signal or build error in its output") { - t.Errorf("1901/AC5: %q is worded %q", out, v.Failed.Words) - } - } - }}, - // A line of the test's own that starts as go's summary does, or that holds a runtime's words indented, is not taken for - // either (review round 1): go prints its summary in exact forms and the runtime's lines at column 0. - {"only gos exact forms are summary or cause", func(t *testing.T) { // 1901/AC5 - out := " x_test.go:3: ok so far\nok then: the seat is free\n panic: child retried and recovered\npanic: the real one\nFAIL\tp\t1.0s" - v := rules.LevelFailure("", "", "", "unit", Tested{Failed: []Failure{{Package: "p", Output: out}}}) - if !strings.HasPrefix(afterHid(v.Failed.Words), "panic: the real one") || !strings.Contains(v.Failed.Words, "ok then: the seat is free") { - t.Errorf("1901/AC5: words = %q", v.Failed.Words) - } - }}, - // The words keep rules.MaxWords exactly, counting the cause, the marker and the newlines (review round 1). - {"the words keep their bound exactly", func(t *testing.T) { // 1901/AC5 - for _, cause := range []string{"", "a cause", strings.Repeat("c", 3000)} { - for _, n := range []int{100, 170, 171, 172, 500} { - f := Failure{Package: "p", Test: "TestX", Cause: cause, Output: strings.Repeat("a log line of twenty\n", n) + "the end"} - if w := rules.FailureWords(f); len(w) > rules.MaxWords { - t.Errorf("1901/AC5: cause %d bytes, %d lines: words are %d bytes, bound %d", len(cause), n, len(w), rules.MaxWords) - } - } - } - }}, - } { - t.Run(row.name, row.test) - } -} - -// afterHid is a verdict's words after the checker's loud line, which a failure with no cause from an older build module -// now starts with (1901/AC8). -func afterHid(w string) string { - if strings.HasPrefix(w, "the build module hid the failure") { - _, rest, _ := strings.Cut(w, "\n") - return rest - } - return w -} diff --git a/modules/mesh-delivery-checker/internal/check/pins.go b/modules/mesh-delivery-checker/internal/check/pins.go deleted file mode 100644 index 277bedc5..00000000 --- a/modules/mesh-delivery-checker/internal/check/pins.go +++ /dev/null @@ -1,76 +0,0 @@ -package check - -import ( - "context" - "errors" - "maps" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/grouppackages" -) - -// **A check builds against the group's own package heads, not against what a member names** (novox/hq ADR 0573 §2, §4; -// issue 1585). Every Go check ask carries the version of each mesh package to build against (buildstep.StepAsk.Packages): -// the head of the group's member that publishes it, else its latest published version as the indexer holds it. The build -// module writes them into the workspace, whatever version or commit a member's go.mod names, so no member is refused -// for naming no version of the group's package, an older head of it, a merge commit or a commit on no pull request: that -// refusal (issue 1624's pin check) was a fault of the check (§4), and is gone. - -// SDKRepository is the repository of mesh-sdk, and SDKModulePath its Go module. -const ( - SDKRepository = "novox/mesh-sdk" - SDKModulePath = "git.novox.be/novox/mesh-sdk/go" -) - -// ErrNotFound is what Forge.File wraps when the ref holds no such file (the forge answered 404): a file the ref does not hold, -// told from a forge that could not be read (issue 1845). -var ErrNotFound = errors.New("the ref holds no such file") - -// Forge reads a file of a repository at a ref. -type Forge interface { - // File is the text of a file at a ref (a branch, a tag or a commit). - File(ctx context.Context, repository, path, ref string) (string, error) -} - -// packagesOf is the version of each mesh package a Go build of repository (a check ask, the judge, the composer) builds -// against (ADR 0573 §2, §4, as ADR 0607 §5 changes §4): packagesFor over the latest published version of each package the -// mesh's modules use (Published) and the heads of the case's pull requests. Nil for none. -func (st *state) packagesOf(repository string) buildstep.PackageVersions { - return packagesFor(st.j.Published, st.c, repository) -} - -// packagesFor is packagesOf for a case and the published versions: every producer of a build at a group's heads takes its -// versions from here, so none leaves a member out (issue 1921). grouppackages.Heads names each package at its member's -// head, also a member that publishes no package yet. A package of repository itself comes with the tree the build -// fetched, and is left out. -func packagesFor(published interface { - LatestPackages() buildstep.PackageVersions -}, c *Case, repository string) buildstep.PackageVersions { - latest := buildstep.PackageVersions{} - if published != nil { - maps.Copy(latest, published.LatestPackages()) - } - heads := map[string]string{} - for _, m := range c.Pulls { - heads[m.Repository] = m.Head - } - versions := grouppackages.Heads(latest, heads, repository) - return versions -} - -// unheardWords ends the words of a failed read of the forge that reached nobody: the forge was not heard (UnheardWords). -func unheardWords(err error) string { - if isUnheard(err) { - return " (the forge was " + UnheardWords + ")" - } - return "" -} - -// forgeMachine is the machine a failed read of the forge is put at: the forge when nobody answered it (no build node is to -// blame, issue 1820), the build node whose workspace was read otherwise. -func forgeMachine(err error, node string) string { - if isUnheard(err) { - return "forge" - } - return node -} diff --git a/modules/mesh-delivery-checker/internal/check/pins_test.go b/modules/mesh-delivery-checker/internal/check/pins_test.go deleted file mode 100644 index e7cc68d2..00000000 --- a/modules/mesh-delivery-checker/internal/check/pins_test.go +++ /dev/null @@ -1,301 +0,0 @@ -package check - -import ( - "context" - "maps" - "slices" - "strings" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/grouppackages" - "git.novox.be/novox/mesh-sdk/go/catalogue" -) - -// published is the latest published version of each mesh package, as the indexer's modules say (Examiner.Published). -type published buildstep.PackageVersions - -func (p published) LatestPackages() buildstep.PackageVersions { - return maps.Clone(buildstep.PackageVersions(p)) -} - -// packagesOfFetch is the package versions the fetch of repository was handed (buildstep.StepAsk.Packages, issue 1585). -func packagesOfFetch(t *testing.T, b *bench, repository string) buildstep.PackageVersions { - t.Helper() - for _, f := range b.steps.tool("fetch") { - if f.args["repository"] == repository { - p, err := buildstep.PackagesArg(f.args["packages"]) - if err != nil { - t.Fatal(err) - } - return p - } - } - t.Fatalf("%s was not fetched", repository) - return nil -} - -// ADR 0573 §4 (issue 1585 S14): a group's Go member is built against the head of the group's mesh-sdk member, whatever its -// go.mod names (an older head of it included, which issue 1624's pin check refused), and never refused for its pin; a -// pull request alone is built against the latest published version of each package, and its own repository's packages -// come with its tree. -func TestAGroupMemberIsBuiltAgainstTheSDKMembersHeadWhateverItsGoModNames(t *testing.T) { // 1624/AC2, AC4 as ADR 0573 §4 changes them - const contract = "git.novox.be/novox/mesh-delivery/contract" - b := newBench(t) - b.fetch.Modules = []string{"modules/m"} - b.ex.Published = published{SDKModulePath: trunkS, contract: trunkA} - v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf(repoSDK, 12, head2))).Verdict - if v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", v) - } - if got := packagesOfFetch(t, b, repoA); len(got) != 1 || got[SDKModulePath] != head2 { - t.Errorf("the member's packages = %v, want mesh-sdk at the group's head %s alone (its own contract comes with its tree)", got, head2) - } - if s := besideOf(t, b, repoA)[repoSDK]; s.Commit != head2 { - t.Error("mesh-delivery's tests were not given the SDK member at its head") - } - b = newBench(t) - b.ex.Published = published{SDKModulePath: trunkS, contract: trunkA} - if v := b.judge(t, caseOf(t, pullOf("novox/mesh-catalog", 7, head1))).Verdict; v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("a pull request alone: verdict = %+v", v) - } - if got := packagesOfFetch(t, b, "novox/mesh-catalog"); len(got) != 2 || got[SDKModulePath] != trunkS || got[contract] != trunkA { - t.Errorf("a pull request alone is built against %v, want every package at its latest published version", got) - } - // A member that publishes no package yet is still named, by its root module path, at its head (issue 1921). - b = newBench(t) - b.ex.Published = published{} - if v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf("novox/mesh-host", 8, head2))).Verdict; v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("an unpublished member: verdict = %+v", v) - } - if got := packagesOfFetch(t, b, repoA); len(got) != 1 || got["git.novox.be/novox/mesh-host"] != head2 { - t.Errorf("the member's packages = %v, want the unpublished member's root at its head %s alone", got, head2) - } - // The function every producer takes the versions from (issue 1921): rows for what a build at a group's heads is asked. - h := func(c string) string { return strings.Repeat(c, 40) } - const ( - contractsPkg = "git.novox.be/novox/mesh-contracts/go/clients/assignerclient" - toolsPkg = "git.novox.be/novox/mesh-tools/go/x" - ) - for _, tc := range []struct { - name string - latest buildstep.PackageVersions - heads map[string]string - own string - want buildstep.PackageVersions - }{ - {"none", nil, nil, "novox/mesh-host", nil}, - {"trunk latest alone", buildstep.PackageVersions{toolsPkg: h("a")}, nil, "novox/mesh-host", buildstep.PackageVersions{toolsPkg: h("a")}}, - {"a member at its head replaces the latest", buildstep.PackageVersions{SDKModulePath: h("a")}, map[string]string{SDKRepository: h("b")}, "novox/mesh-host", - buildstep.PackageVersions{SDKModulePath: h("b")}}, - {"a member that publishes no package yet is named by its root module", buildstep.PackageVersions{SDKModulePath: h("a")}, - map[string]string{"novox/mesh-contracts": h("c")}, "novox/mesh-host", - buildstep.PackageVersions{SDKModulePath: h("a"), "git.novox.be/novox/mesh-contracts": h("c")}}, - {"mesh-sdk is named by its go module before any package of it is known", nil, map[string]string{SDKRepository: h("b")}, "novox/mesh-host", - buildstep.PackageVersions{SDKModulePath: h("b")}}, - {"a member whose packages are known gets no root", buildstep.PackageVersions{contractsPkg: h("a")}, - map[string]string{"novox/mesh-contracts": h("c")}, "novox/mesh-host", buildstep.PackageVersions{contractsPkg: h("c")}}, - {"the build's own repository is left out", buildstep.PackageVersions{contractsPkg: h("a")}, - map[string]string{"novox/mesh-contracts": h("c")}, "novox/mesh-contracts", nil}, - {"a head that is no full commit names nothing", nil, map[string]string{"novox/mesh-contracts": "abc"}, "novox/mesh-host", nil}, - } { - got := grouppackages.Heads(tc.latest, tc.heads, tc.own) - if !maps.Equal(got, tc.want) { - t.Errorf("%s: got %v, want %v", tc.name, got, tc.want) - } - } - - // Design 47 G §528: a group's check asks no tagged version and waits on none; it builds its members at once, each Go - // build against the group's heads. - sdk := catalogue.Manifest{Module: "mesh-sdk", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{ - {Name: "go", Kind: catalogue.ArtifactPackage, Language: "go", Paths: []string{"go"}}, {Name: "lib", Kind: catalogue.ArtifactPackage, Language: "typescript"}}}} - digest := strings.Repeat("c", 64) - sdkPull := pullOf(repoSDK, 12, head2) - sdkPull.Modules = []string{"mesh-sdk"} - sdkPull.Fps = map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"mesh-sdk": {Fp2: "src2:" + strings.Repeat("f", 64), Manifest: digest}} - b = newBench(t) - b.fetch.Modules = []string{"modules/m"} - b.ex.Read = fixedManifests{digest: sdk} - b.ex.Modules = langs{repoA: {goBuildModule, nodeBuildModule}} - if v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1), sdkPull)).Verdict; v.State != meshdeliverycheckerclient.VerdictPass { - t.Errorf("a group's verdict = %+v", v) - } - if got := packagesOfFetch(t, b, repoA); got[SDKModulePath] != head2 { - t.Errorf("mesh-delivery is built against mesh-sdk %q, want the group's head %s (all: %v)", got[SDKModulePath], head2, got) - } -} - -// headFiles are the forge's files by " "; any other is not found. -type headFiles map[string]string - -func (h headFiles) File(_ context.Context, repository, path, ref string) (string, error) { - if text, ok := h[repository+" "+path+" "+ref]; ok { - return text, nil - } - return "", ErrNotFound -} - -type runsAt map[string]string - -func (r runsAt) CommitOf(module string) string { return r[module] } - -func besideOf(t *testing.T, b *bench, repository string) map[string]BesideRef { - t.Helper() - out := map[string]BesideRef{} - for _, f := range b.steps.tool("fetch") { - if f.args["repository"] == repository { - refs, _ := refsOf(f.args["beside"]), true - for _, r := range refs { - out[r.Repository] = r - } - } - } - return out -} - -func TestTheSiblingsAreWhereTheTestsStateThem(t *testing.T) { // review D2, ADR 0484 clause 4 - const catalogue, host, controller, networking = "novox/mesh-catalog", "novox/mesh-host", "novox/mesh-controller", "novox/mesh-networking" - hostRuns := strings.Repeat("7", 40) - b := newBench(t) - b.ex.Trunks = trunksOf(t, map[string]string{SDKRepository: trunkS, catalogue: trunkA, host: trunkA2}) - b.ex.Runs = runsAt{"mesh-host": hostRuns} - // A group of mesh-sdk and the catalogue: mesh-sdk's tests read the group's catalogue head, the heads the group merges - // (ADR 0482 §2, ADR 0573 §4; issue 1126: a judge in the group was judged against the catalogue's trunk). - out := b.judge(t, caseOf(t, pullOf(SDKRepository, 7, head1), pullOf(catalogue, 12, head2))) - // ADR 0548 §6, issue 568's own example: the verdict names the node-engine at the commit the mesh runs; the catalogue, - // a member here, is not named. - if out.Beside[host] != hostRuns || out.Beside[catalogue] != "" { - t.Errorf("the siblings named for the verdict = %v, want the node-engine at %s", out.Beside, hostRuns[:12]) - } - got := besideOf(t, b, SDKRepository) - if c := got[catalogue]; c.Commit != head2 { - t.Errorf("the catalogue beside mesh-sdk in a group = %+v, want the member's head %s", c, head2) - } - if h := got[host]; h.Commit != hostRuns { - t.Errorf("the node-engine beside mesh-sdk = %+v, want the commit the mesh runs %s", h, hostRuns) - } - // ADR 0593: route-proxy's proofs of a composition moved into the node-engine's tests, which read its manifest in - // mesh-networking: beside a node-engine change, at the group's head when the group holds one, else at its trunk. - b = newBench(t) - b.ex.Trunks = trunksOf(t, map[string]string{SDKRepository: trunkS, catalogue: trunkA, host: trunkA2, networking: trunkA2}) - b.judge(t, caseOf(t, pullOf(host, 8, head1), pullOf(networking, 3, head2))) - if n := besideOf(t, b, host)[networking]; n.Commit != head2 { - t.Errorf("mesh-networking beside the node-engine in a group = %+v, want the member's head %s", n, head2) - } - // Alone, mesh-sdk's tests read the catalogue's trunk, and the verdict names it. - b = newBench(t) - const contracts = "novox/mesh-contracts" - b.ex.Trunks = trunksOf(t, map[string]string{SDKRepository: trunkS, catalogue: trunkA, host: trunkA2, contracts: trunkA, DeliveryRepository: trunkA2}) - if out := b.judge(t, caseOf(t, pullOf(SDKRepository, 7, head1))); out.Beside[catalogue] != trunkA { - t.Errorf("the siblings named for the verdict alone = %v, want the catalogue at its trunk %s", out.Beside, trunkA) - } - // mesh-sdk's tests compare its bootstrapped seats with their contracts files, read beside it: mesh-contracts and - // mesh-delivery, at their trunks alone (a group try is placed by the same besideFor, so it lays them out the same way). - if got := besideOf(t, b, SDKRepository); got[contracts].Commit != trunkA || got[DeliveryRepository].Commit != trunkA2 { - t.Errorf("beside mesh-sdk alone = %+v, want mesh-contracts at %s and mesh-delivery at %s", got, trunkA, trunkA2) - } - if c := besideOf(t, b, SDKRepository)[catalogue]; c.Commit != trunkA || c.Ref != "" { - t.Errorf("the catalogue beside mesh-sdk alone = %+v, want its trunk %s", c, trunkA) - } - // 1126/B8 (novox/hq ADR 0590, ADR 0593 §11): the controller's repository is emptied and archived, so no repository's - // tests read it and it has no siblings of its own: a pull request of it has only its own trunk beside it. - b = newBench(t) - b.ex.Trunks = trunksOf(t, map[string]string{controller: trunkA, catalogue: trunkS, host: trunkA2, SDKRepository: trunkS}) - b.judge(t, caseOf(t, pullOf(controller, 9, head2))) - if got := besideOf(t, b, controller); len(got) != 1 || got[controller].Commit != trunkA { - t.Errorf("beside the controller's own change = %+v, want its own trunk alone", got) - } - for repo, siblings := range besideRules { - if repo == controller || slices.Contains(siblings, controller) { - t.Errorf("the tests of %s read the controller, or it has siblings", repo) - } - } -} - -// 1887/A12: the change's own repository is placed beside it at the trunk it is merged onto, for every repository, so a -// shrink-only list test reads the trunk's copy at $MESH_CHECK_BESIDE/. -func TestTheChangesOwnRepositoryIsBesideItAtItsTrunk(t *testing.T) { - b := newBench(t) - b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - got := besideOf(t, b, repoA) - if own := got[repoA]; own.Commit != trunkA || own.Ref != "" { - t.Fatalf("the repository beside its own change = %+v, want its trunk %s", own, trunkA) - } -} - -// 1887/A12: a catalogue change's siblings hold the catalogue itself at the trunk it is merged onto, beside mesh-sdk, so -// the catalogue's shrink-only list tests read $MESH_CHECK_BESIDE/mesh-catalog. And the node-engine at the commit the mesh -// runs (ADR 0593 §7): mesh-build-go's composer test builds the node-engine's composer command from it. -func TestACatalogueChangeHasTheCatalogueBesideItAtItsTrunk(t *testing.T) { - hostRuns := strings.Repeat("7", 40) - b := newBench(t) - b.ex.Trunks = trunksOf(t, map[string]string{catalogueRepository: trunkA, SDKRepository: trunkS, "novox/mesh-controller": trunkA2, nodeEngineRepo: trunkA2, - contractsRepository: trunkA2, deliveryRepository: trunkA2, networkingRepository: trunkA2, "novox/mesh-tools": trunkA2}) - b.ex.Runs = runsAt{nodeEngineModule: hostRuns} - // The node-engine's go.mod at the commit the mesh runs: what it requires at the zero version is placed beside too, - // derived, not named in a rule (issue 1921); a version a build wrote, or a package outside the forge, is not. - b.ex.Forge = headFiles{nodeEngineRepo + " go.mod " + hostRuns: "module github.com/novox/mesh-host\n\ngo 1.26\n\nrequire (\n" + - "\tgit.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient v0.0.0-00010101000000-000000000000\n" + - "\tgit.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk v0.0.0-00010101000000-000000000000 // indirect\n" + - "\tgit.novox.be/novox/mesh-tools/go v0.1.2\n\tgithub.com/nats-io/nats.go v1.40.0\n)\n\n" + - "require git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go v0.0.0-00010101000000-000000000000\n"} - out := b.judge(t, caseOf(t, pullOf(catalogueRepository, 12, head1))) - // ADR 0548 §6: the outcome names the siblings read at their trunk's head or the commit the mesh runs, never the - // repository it merges. - if out.Beside[SDKRepository] != trunkS || out.Beside[nodeEngineRepo] != hostRuns || out.Beside["novox/mesh-controller"] != "" || out.Beside[catalogueRepository] != "" { - t.Errorf("the siblings named for the verdict = %v, want mesh-sdk at its trunk, the node-engine at the commit the mesh runs, and neither the controller nor the catalogue", out.Beside) - } - got := besideOf(t, b, catalogueRepository) - if c := got[catalogueRepository]; c.Commit != trunkA || c.Ref != "" { - t.Fatalf("the catalogue beside its own change = %+v, want its trunk %s", c, trunkA) - } - // Issue 1921: and every repository the node-engine's composer requires at the zero version, which mesh-build-go's - // composer test builds from what lies beside, with nothing fetched. - for _, repo := range []string{SDKRepository, contractsRepository, deliveryRepository, networkingRepository} { - if _, ok := got[repo]; !ok { - t.Errorf("%s is not beside a catalogue change: %v", repo, got) - } - } - if _, ok := got["novox/mesh-tools"]; ok { - t.Errorf("mesh-tools, required at a version a build wrote, is beside a catalogue change: %v", got) - } - if h := got[nodeEngineRepo]; h.Commit != hostRuns { - t.Errorf("the node-engine beside a catalogue change = %+v, want the commit the mesh runs %s", h, hostRuns) - } - // A group that holds the node-engine is judged against its head, which is what runs after its merge, never the commit - // the mesh runs now; the verdict names it in no carry (it is a member, not read at a trunk or a running commit). - b = newBench(t) - b.ex.Trunks = trunksOf(t, map[string]string{catalogueRepository: trunkA, SDKRepository: trunkS, nodeEngineRepo: trunkA2}) - b.ex.Runs = runsAt{nodeEngineModule: hostRuns} - out = b.judge(t, caseOf(t, pullOf(catalogueRepository, 12, head1), pullOf(nodeEngineRepo, 8, head2))) - if h := besideOf(t, b, catalogueRepository)[nodeEngineRepo]; h.Commit != head2 { - t.Errorf("the node-engine beside a catalogue change in a group holding it = %+v, want the member's head %s", h, head2) - } - if out.Beside[nodeEngineRepo] != "" { - t.Errorf("the verdict names the member node-engine in its carry: %v", out.Beside) - } -} - -// 1887/A12: a mesh-lab head gets a check: with its trunk known it is judged like any repository, its Go fetch finding -// the nested modules itself. -func TestAMeshLabHeadGetsACheck(t *testing.T) { - const lab = "novox/mesh-lab" - raw := candidateOf(t, "fix/x", pullOf(lab, 3, head1)) - c, err := meshcatalog.DecodeCandidatesByGroupValue(raw) - if err != nil { - t.Fatal(err) - } - cs := CaseOf(c, map[string]string{lab: trunkA}) - if cs == nil || len(cs.Pulls) != 1 || cs.Pulls[0].Repository != lab || len(cs.Left) != 0 { - t.Fatalf("the case = %+v, want mesh-lab#3 judged", cs) - } - b := newBench(t) - if v := b.judge(t, cs).Verdict; v.State != meshdeliverycheckerclient.VerdictPass { - t.Fatalf("verdict = %+v", v) - } - if fetched := b.steps.tool("fetch"); len(fetched) == 0 || fetched[0].args["repository"] != lab { - t.Fatalf("mesh-lab was not fetched: %+v", fetched) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/preview.go b/modules/mesh-delivery-checker/internal/check/preview.go deleted file mode 100644 index 8cb11808..00000000 --- a/modules/mesh-delivery-checker/internal/check/preview.go +++ /dev/null @@ -1,87 +0,0 @@ -package check - -import ( - "context" - "errors" - "fmt" - "regexp" - "slices" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -var digest64 = regexp.MustCompile(`^[0-9a-f]{64}$`) - -// PreviewOf is what the fetch steps said of a pull request's head merged onto its trunk head, as the value of a previews -// key (ADR 0484 clause 3): the merge commit and, for each module directory the fetches named with a manifest, its tree, the -// digest of its manifest, the hashes of its lock files and its named paths' objects (ADR 0499 clause 2). The fetches of the repository's build modules merge the same -// trees; the first one's merge commit is kept. A module directory with no tree or no manifest digest is left out, so the -// indexer gives its module no fingerprint and says why. A head that does not merge has a preview of the files in conflict -// alone, so the indexer says the candidate's modules have no fingerprint because it does not merge (issue 1445). It -// answers false when no fetch was made. -func PreviewOf(p Pull, fetched []Fetched) (meshdeliverychecker.PreviewsByRepositoryHeadTrunkValue, bool) { - var merge string - var conflicts []string - mods := map[string]meshdeliverychecker.PreviewsByRepositoryHeadTrunkValueModulesValue{} - for _, f := range fetched { - if len(f.Conflicts) > 0 { - conflicts = append(conflicts, f.Conflicts...) - } - } - if len(conflicts) > 0 { - slices.Sort(conflicts) - return meshdeliverychecker.PreviewsByRepositoryHeadTrunkValue{Repository: p.Repository, Head: p.Head, Trunk: p.Trunk, Conflicts: slices.Compact(conflicts)}, true - } - for _, f := range fetched { - if f.Merge == "" { - continue - } - if merge == "" { - merge = f.Merge - } - for dir, t := range f.Trees { - if t.Tree == "" || !digest64.MatchString(t.Manifest) { - continue - } - mods[dir] = meshdeliverychecker.PreviewsByRepositoryHeadTrunkValueModulesValue{Tree: t.Tree, Manifest: t.Manifest, Locks: t.Locks, Paths: t.Paths, Packages: t.Packages} - } - } - if merge == "" { - return meshdeliverychecker.PreviewsByRepositoryHeadTrunkValue{}, false - } - pv := meshdeliverychecker.PreviewsByRepositoryHeadTrunkValue{Repository: p.Repository, Head: p.Head, Trunk: p.Trunk, Merge: merge} - if len(mods) > 0 { - pv.Modules = mods - } - return pv, true -} - -// writePreview writes the preview of a pull request by a create: one writer per key, and the same head on the same trunk -// head merges to the same trees, so a key that exists stands. A head that did not merge has no preview. A failure is said -// and does not fail the check: the preview is for the indexer's fingerprints, not for the verdict. -func (j *Examiner) writePreview(ctx context.Context, p Pull, fetched []Fetched) { - if j.Previews == nil { - return - } - pv, ok := PreviewOf(p, fetched) - if !ok { - return - } - key, err := meshdeliverycheckerclient.PreviewKey(p.Repository, p.Head, p.Trunk) - if err == nil { - var data []byte - if data, err = meshdeliverycheckerclient.EncodePreview(pv); err == nil { - _, err = j.Previews.Create(ctx, key, data) - if errors.Is(err, ErrConflict) { - return - } - if err == nil && j.Announce != nil { - j.Announce(ctx, EventPreviewWritten, key) - } - } - } - if err != nil { - j.logf("%s#%d: the preview cannot be written: %v", p.Repository, p.Number, fmt.Errorf("%w", err)) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/preview_named_test.go b/modules/mesh-delivery-checker/internal/check/preview_named_test.go deleted file mode 100644 index ebd968a2..00000000 --- a/modules/mesh-delivery-checker/internal/check/preview_named_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package check - -import ( - "encoding/json" - "reflect" - "testing" -) - -// I8, ADR 0499 clause 2: the preview carries each named path's object a fetch's module trees answer (mesh-sdk -// buildstep.ModuleTree's paths), so the indexer computes the candidate's narrowed tree from them by the one function. -func TestAPreviewCarriesTheNamedPathsObjectsOfAFetchsModuleTrees(t *testing.T) { - var f Fetched - // As buildstep.ModuleTrees answers a module naming its paths: the named tree and the objects. - raw := `{"workspace":"w","merge":"6666666666666666666666666666666666666666","trees":{".":{"tree":"named:aa","manifest":"` + - "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + `","paths":{"src":"1111111111111111111111111111111111111111"},"packages":["git.novox.be/novox/mesh-sdk/go"]}}}` - if err := json.Unmarshal([]byte(raw), &f); err != nil { - t.Fatal(err) - } - pv, ok := PreviewOf(Pull{Repository: "novox/mesh-sdk", Head: "h", Trunk: "t"}, []Fetched{f}) - if !ok || !reflect.DeepEqual(pv.Modules["."].Paths, map[string]string{"src": "1111111111111111111111111111111111111111"}) || pv.Modules["."].Tree != "named:aa" || - !reflect.DeepEqual(pv.Modules["."].Packages, []string{"git.novox.be/novox/mesh-sdk/go"}) { // and the packages it uses (issue 1585) - t.Errorf("preview = %+v, want the module's named tree and its objects", pv) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/programs.go b/modules/mesh-delivery-checker/internal/check/programs.go deleted file mode 100644 index 56bfc134..00000000 --- a/modules/mesh-delivery-checker/internal/check/programs.go +++ /dev/null @@ -1,294 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "fmt" - "maps" - "slices" - "strings" - "sync" - "time" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - - "mesh-delivery-checker/rules" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" -) - -// The checking program (novox/hq ADR 0644 §1, ADR 0656 §5; design 47's bootstrap delivery; issue 1921): every check has -// the program built from the group's mesh-delivery member head, else from mesh-delivery's trunk, and run in the build -// seat's sandbox through the seat node-build-go's ask `run`, with every member's head laid for it. It answers the heads' -// seat list first (`-seats`), which the manifest validator's and the composer's requests carry, and then the check's -// verdict of the facts the asking gathered (`-verdict`). The running checker asks, keeps and records; it judges nothing. - -const ( - // InputsStateName is the checker's own state of run inputs and InputsBucket its bucket: every input by the sha256 of - // its exact bytes, read by the checker alone. InputVerb is the seat verb a run ask's input names - // (buildstep.RunInput.Verb), which the checker's tools serve from that state (Reader.Input): the Go build module asks it - // as its manifest's invokes grants it and checks the digest (buildstep.RunInput.Read), never reading the state (ADR 0596 - // §2; the operator's answer on milestone 47/B0). - InputsStateName = "inputs" - InputVerb = meshdeliverycheckerclient.InputVerb - // CheckingProgramDir and CheckingProgramPackage are where in mesh-delivery the checking program is built. - CheckingProgramDir = "modules/mesh-delivery-checker" - CheckingProgramPackage = "mesh-delivery-checker/cmd/mesh-checking-program" - // DefaultBeginBound is how long a run ask may wait for a build node to begin its step before it is put once more, and - // after that once more before the check fails naming the job: a build module that does not know the job `run` drops - // it unanswered (the lead's ruling on milestone 47/B0, 2026-11-06). - DefaultBeginBound = 5 * time.Minute -) - -// Inputs keeps a run's input under its digest, exactly its bytes. -type Inputs interface { - Keep(ctx context.Context, digest string, body []byte) error -} - -func (j *Examiner) beginBound() time.Duration { - if j.BeginBound > 0 { - return j.BeginBound - } - return DefaultBeginBound -} - -// checkingProgram is where this check's checking program is built: the group's mesh-delivery member head, else -// mesh-delivery's trunk; false when neither is known. -func (st *state) checkingProgram() (buildstep.RunProgram, string, bool) { - p := buildstep.RunProgram{Repository: DeliveryRepository, Dir: CheckingProgramDir, Package: CheckingProgramPackage} - for _, pull := range st.c.Pulls { - if pull.Repository == DeliveryRepository { - p.Commit = pull.Head - return p, "the group's mesh-delivery head " + pull.Head, true - } - } - if st.j.Trunks != nil { - p.Commit = st.j.Trunks.Heads()[DeliveryRepository] - } - return p, "mesh-delivery's trunk " + p.Commit, p.Commit != "" -} - -// runHeads are the members' heads, as the program reads them. -func (st *state) runHeads() []buildstep.RunHead { - out := make([]buildstep.RunHead, 0, len(st.c.Pulls)) - for _, p := range st.c.Pulls { - out = append(out, buildstep.RunHead{Repository: p.Repository, Commit: p.Head}) - } - return out -} - -// runProgram has the checking program built and run with args over body, and answers its output and what judged; an -// error says why it did not answer: its input over its bound, no build node beginning the job, a step that did not -// pass, or a program that exited otherwise than 0. -func (st *state) runProgram(ctx context.Context, args []string, body []byte) (json.RawMessage, *meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy, error) { - prog, at, ok := st.checkingProgram() - if !ok { - return nil, nil, fmt.Errorf("it cannot be built: the trunk head of %s is not known", DeliveryRepository) - } - if st.j.Inputs == nil { - return nil, nil, fmt.Errorf("its input cannot be kept: the checker keeps no state %s", InputsStateName) - } - in, err := buildstep.RunInputOf(InputVerb, body) - if err != nil { - return nil, nil, err - } - if err := st.j.Inputs.Keep(ctx, in.Digest, body); err != nil { - return nil, nil, fmt.Errorf("its input could not be kept in %s: %w", InputsStateName, err) - } - job := buildstep.RunJob{Program: prog, Heads: st.runHeads(), Input: in, Args: args, Reader: "the checking program at " + at} - var ids []string - for range 2 { - a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: st.j.Module, - At: st.j.now().UTC(), Packages: st.packagesOf(DeliveryRepository), Run: &job} - ids = append(ids, a.ID) - st.c.Progress.Set(fmt.Sprintf("the run ask %s of the checking program %s", a.ID, strings.Join(args, " ")), "") - st.c.Asked(a.ID) - if err := st.j.Asks.Put(ctx, a); err != nil { - return nil, nil, fmt.Errorf("its run ask could not be put: %w", err) - } - waiting := ctx - if watch := st.c.Watch; watch != nil { - id := a.ID - watch(id, nil) // a try names it at once (issue 1890) - waiting = buildrun.WithStepSeen(ctx, func(s buildstep.Step) { watch(id, &s) }) - } - step, begun, err := st.waitBegun(waiting, a) - if !begun { - continue - } - if err != nil { - return nil, nil, fmt.Errorf("its run ask %s: %w", a.ID, err) - } - var answer buildstep.RunAnswer - if step.State != buildstep.StepPassed { - // A run whose program exited other than 0 ends its key failed with its answer kept (design 47 G A-290). - if json.Unmarshal(step.Result, &answer) == nil && answer.Exit != 0 { - return nil, nil, fmt.Errorf("it exited %d on %s: %s", answer.Exit, step.Node, answer.Said) - } - return nil, nil, fmt.Errorf("its run ask %s ended %s on %s: %s", a.ID, step.State, step.Node, step.Reason) - } - if err := json.Unmarshal(step.Result, &answer); err != nil { - return nil, nil, fmt.Errorf("its run ask %s answered no run answer: %w", a.ID, err) - } - if answer.Exit != 0 { - return nil, nil, fmt.Errorf("it exited %d on %s: %s", answer.Exit, step.Node, answer.Said) - } - return answer.Output, judgedByOf(prog, answer, job.Heads), nil - } - return nil, nil, fmt.Errorf("no build node began the job run of the asks %s within %s each: a build module that does not know the job run drops it", - strings.Join(ids, " and "), st.j.beginBound()) -} - -// waitBegun waits for a's step, and stops waiting, begun false, when no build node began it within the begin bound: a -// bound on the wait's context, no timer of its own. -func (st *state) waitBegun(ctx context.Context, a buildstep.StepAsk) (buildstep.Step, bool, error) { - wait, cancel := context.WithCancel(ctx) - defer cancel() - begin, stop := context.WithTimeout(ctx, st.j.beginBound()) - defer stop() - seen := make(chan struct{}) - var once sync.Once - type ended struct { - step buildstep.Step - err error - } - done := make(chan ended, 1) - go func() { - step, err := st.j.Asks.Wait(buildrun.WithStepSeen(wait, func(buildstep.Step) { once.Do(func() { close(seen) }) }), a) - done <- ended{step, err} - }() - select { - case e := <-done: - return e.step, true, e.err - case <-seen: - case <-begin.Done(): - if ctx.Err() != nil { - return buildstep.Step{}, true, ctx.Err() - } - return buildstep.Step{}, false, nil - } - e := <-done - return e.step, true, e.err -} - -// seatList asks the checking program for the heads' seat list, which the validator's and the composer's requests carry -// (ADR 0636 §4); the list and what it left out are the check's notes. A list it cannot make fails the check, naming why, -// and answers false: the check ends there, with no verdict asked of a program that could not answer its list (review -// round 1 of milestone 47/B0: a build node with no job run would hold the check two begin bounds more). -func (st *state) seatList(ctx context.Context) bool { - if st.narrowTry() { - return true - } - // The list the checker's reader holds from the seat mesh-catalog: a reader that has not read it acts on nothing new - // (ADR 0636 §1), so the check ends here, said. - var base []json.RawMessage - if st.j.SeatList != nil { - defs, err := st.j.SeatList.Definitions() - if err != nil { - st.fail(st.goModule(), "the change's manifests cannot be judged: the seat list is not read ("+err.Error()+")") - return false - } - base = defs - } - // The program answers only the heads' definitions the list does not hold as they are: the list's digests ride in its - // input, never the list, whose definitions are larger than a run's input or answer may be (review finding 3 of G). - head := st.factsHead() - if len(base) > 0 { - head.SeatDigests = map[string]string{} - for _, raw := range base { - var d struct { - Seat string `json:"seat"` - } - if json.Unmarshal(raw, &d) == nil && d.Seat != "" { - head.SeatDigests[d.Seat] = rules.SeatDigest(raw) - } - } - } - body, err := json.Marshal(head) - if err == nil { - var out json.RawMessage - if out, _, err = st.runProgram(ctx, []string{"-seats"}, body); err == nil { - var a rules.SeatsAnswer - if err = json.Unmarshal(out, &a); err == nil && a.V != rules.SeatsVersion { - err = fmt.Errorf("it answered a seat list of version %d, not %d", a.V, rules.SeatsVersion) - } - if err == nil { - st.c.Seats = overSeats(base, a.Seats) - if len(a.Seats) > 0 { - st.c.note(fmt.Sprintf("the heads carry %d seat definitions new or changed (and %d the seat list holds as they are), laid over the %d the seat list holds", len(a.Seats), a.Same, len(base))) - } - for _, l := range a.Left { - st.c.note("the heads' seat list leaves out " + l.Path + ": " + l.Why) - } - return true - } - } - } - st.fail(st.goModule(), "the heads' seat list could not be made by the checking program: "+err.Error()) - return false -} - -// overSeats is the list's definitions with each of the heads' put in place of the one of its seat, or added, sorted by -// seat: the checker reads of a definition only its seat's name. -func overSeats(list, heads []json.RawMessage) []json.RawMessage { - by := map[string]json.RawMessage{} - for _, l := range [][]json.RawMessage{list, heads} { - for _, raw := range l { - var d struct { - Seat string `json:"seat"` - } - if json.Unmarshal(raw, &d) == nil && d.Seat != "" { - by[d.Seat] = raw - } - } - } - var out []json.RawMessage // none when neither holds one: the requests then carry no list - for _, seat := range slices.Sorted(maps.Keys(by)) { - out = append(out, by[seat]) - } - return out -} - -// factsHead are the facts that name the check, without what the asking gathered. -func (st *state) factsHead() rules.Facts { - f := rules.Facts{V: rules.FactsVersion, Group: st.c.Group, Heads: st.c.Heads, Trunk: st.c.Trunk} - for _, p := range st.c.Pulls { - f.Members = append(f.Members, rules.Member{Repository: p.Repository, Number: p.Number, Head: p.Head, Trunk: p.Trunk}) - } - return f -} - -// judged is the checking program's answer to the check's facts (`-verdict`), with what judged; a program that cannot be -// asked, built or run, or does not answer a verdict, fails the check naming the checking program, never the running -// checker's rules in its place: the facts gain the failure and the verdict is worded from them as a failure. -func (st *state) judged(ctx context.Context) (rules.Answer, *meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy) { - body, err := json.Marshal(st.factsOf()) - var by *meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy - if err == nil { - var out json.RawMessage - if out, by, err = st.runProgram(ctx, []string{"-verdict"}, body); err == nil { - var a rules.Answer - if err = json.Unmarshal(out, &a); err == nil && a.V != rules.AnswerVersion { - err = fmt.Errorf("it answered a verdict of version %d, not %d", a.V, rules.AnswerVersion) - } - if err == nil { - return a, by - } - } - } - st.fail(st.goModule(), "the check could not be judged by the checking program: "+err.Error()) - return rules.Answer{V: rules.AnswerVersion, Verdict: rules.Judge(st.factsOf())}, by -} - -// judgedByOf is the verdict's judged-by of a run of the checking program: where it was built, the key its build is kept -// under, whether this run built it, and the heads it read. -func judgedByOf(prog buildstep.RunProgram, answer buildstep.RunAnswer, heads []buildstep.RunHead) *meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy { - by := &meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy{Program: meshdeliverychecker.VerdictsByGroupHeadsValueJudgedByProgram{ - Repository: prog.Repository, Commit: prog.Commit, Dir: prog.Dir, Package: prog.Package}, Key: answer.Key, Built: answer.Built} - for _, h := range heads { - by.Heads = append(by.Heads, meshdeliverychecker.VerdictsByGroupHeadsValueJudgedByHeadsItem{Repository: h.Repository, Commit: h.Commit}) - } - return by -} diff --git a/modules/mesh-delivery-checker/internal/check/rank_test.go b/modules/mesh-delivery-checker/internal/check/rank_test.go deleted file mode 100644 index 4f3961cc..00000000 --- a/modules/mesh-delivery-checker/internal/check/rank_test.go +++ /dev/null @@ -1,117 +0,0 @@ -package check - -import ( - "context" - "fmt" - "sync" - "testing" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// The checker's ranked start of checks (ADR 0536 §4, issue 1897): a freed place goes to a head never judged (or asked again -// after a failure of the nodes) before a head asked again only because its trunk moved; among equals the oldest asked first. -// A running check is never stopped. - -// rankRig is a checker of one check at a time whose judge records the order checks start in and holds the first check -// after hold is set until release is closed. -type rankRig struct { - *rig - mu sync.Mutex - started []*Case - hold bool - held chan struct{} // closed when the held check started - release chan struct{} - errs []error // ctx errors the held check saw when released -} - -func group(n int) string { return fmt.Sprintf("feat/g%d", n) } - -func groups(cs []*Case) []string { - out := make([]string, len(cs)) - for i, c := range cs { - out[i] = c.Group - } - return out -} - -func TestCheckerStatusNamesTheWaitingChecksByKind(t *testing.T) { // 1897/AC4 - ctx := context.Background() - j := &judgeFunc{f: func(_ context.Context, c *Case, _ int) (Outcome, error) { - if c.Group == group(2) { - return Outcome{Verdict: failure("the forge", "go.mod cannot be read: no responders (the forge was "+UnheardWords+")")}, nil - } - return Outcome{Verdict: passing()}, nil - }} - r := newRig(t, j) - cands := fakeState{} - put := func(n int, head string) { - cand := candidateOf(t, group(n), pullOf(repoA, n, head)) - ckey, _ := meshcatalogclient.CandidatesKey(group(n)) - cands[ckey] = cand - r.ch.Candidate(ctx, group(n), cand) - } - put(1, head1) // judged on the old trunk: a re-judge waits - put(2, head1) // failed for the nodes: waits for them - r.ch.Wait() - r.setTrunks(t, map[string]string{repoA: trunkA2, repoSDK: trunkS}) - put(4, head1) // judged on the new trunk: stands - r.ch.Wait() - cand3 := candidateOf(t, group(3), pullOf(repoA, 3, head1)) // never judged - ckey3, _ := meshcatalogclient.CandidatesKey(group(3)) - cands[ckey3] = cand3 - verdicts := fakeState{} - for k, v := range r.verdicts.vals { - verdicts[k] = v - } - rd := Reader{CandidateState: cands.read(), VerdictState: verdicts.read(), - Trunks: func() (map[string]string, error) { return map[string]string{repoA: trunkA2, repoSDK: trunkS}, nil }} - st, err := rd.Status() - if err != nil { - t.Fatal(err) - } - want := map[string][]string{KindNew: {group(3)}, KindNodes: {group(2)}, KindTrunk: {group(1)}} - if fmt.Sprint(st.Waiting) != fmt.Sprint(want) { - t.Errorf("waiting = %v, want %v", st.Waiting, want) - } -} - -// 568 note 21: a verdict that read the node-engine at its running commit is not waiting for a trunk move while that commit -// is still the one the mesh runs, though the node-engine's trunk has moved on (ADR 0548 §6). -func TestCheckerStatusReadsTheNodeEngineAtItsRunningCommit(t *testing.T) { // 568/21 - cand := candidateOf(t, group(1), pullOf(repoA, 1, head1)) - ckey, _ := meshcatalogclient.CandidatesKey(group(1)) - vkey := keyOf(t, group(1), cand) - dc, _ := meshcatalog.DecodeCandidatesByGroupValue(cand) - judged, err := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: group(1), Heads: dc.Heads, Trunk: map[string]string{repoA: trunkA}, Beside: map[string]string{nodeEngineRepo: "run111"}, State: meshdeliverycheckerclient.VerdictPass, Levels: passing().Levels}) - if err != nil { - t.Fatal(err) - } - heads := func() (map[string]string, error) { - return map[string]string{repoA: trunkA, nodeEngineRepo: "trunk222"}, nil - } - for _, row := range []struct { - name string - runs runsAt - want int - }{ - {"the running commit the verdict read", runsAt{nodeEngineModule: "run111"}, 0}, - {"the running commit moved", runsAt{nodeEngineModule: "run999"}, 1}, - {"no running commit known: the trunk's", nil, 1}, - } { - rd := Reader{CandidateState: fakeState{ckey: cand}.read(), VerdictState: fakeState{vkey: judged}.read(), Trunks: heads} - if row.runs != nil { - rd.Runs = row.runs - } - st, err := rd.Status() - if err != nil { - t.Fatal(err) - } - if got := len(st.Waiting[KindTrunk]); got != row.want { - t.Errorf("%s: waiting for a trunk move = %v, want %d", row.name, st.Waiting[KindTrunk], row.want) - } - } -} diff --git a/modules/mesh-delivery-checker/internal/check/read.go b/modules/mesh-delivery-checker/internal/check/read.go deleted file mode 100644 index ee8f7f1f..00000000 --- a/modules/mesh-delivery-checker/internal/check/read.go +++ /dev/null @@ -1,791 +0,0 @@ -package check - -import ( - "crypto/sha256" - "encoding/hex" - "encoding/json" - "fmt" - "slices" - "sort" - "strings" - "time" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// The read tools (novox/hq ADR 0484 clauses 8 and 13, issue 1686): what the checker stored, as stored, with the line of the -// status it owes in full, so a check is read live without a shell. They write nothing. - -// The read tools, named as the module is: checker_ and the noun. -const ( - VerdictsReadTool = "checker_verdicts" - PullReadTool = "checker_pull" - KeptReadTool = "checker_kept" - InputsReadTool = "checker_inputs" - // PreviewsReadTool reads the previews state (issue 1680); StatusReadTool reads what the checker runs (issue 1685: nothing holds it since R4g). - PreviewsReadTool = "checker_previews" - StatusReadTool = "checker_status" -) - -// StateRead reads one state: its keys and a key's stored value (nil for a key with none). -type StateRead struct { - Keys func() ([]string, error) - Get func(key string) (json.RawMessage, error) -} - -// Reader answers the read tools from the checker's verdicts and kept states and the indexer's candidates. -type Reader struct { - VerdictState, KeptState, CandidateState StateRead - - PreviewState StateRead // the checker's merge previews - InputState StateRead // the checking program's inputs (InputsStateName) - StepStates func() map[string]StateRead // the build modules' steps states, by module: the holders of the build seats (design 47 G A-82), found at each read - HaveState StateRead // the node-engine's have: whether a build module is on a node and running - StepBound time.Duration // how long the checker waits for one step; DefaultStepBound when 0 - // CouldNotRunState is the checker's own state could-not-run (CouldNotRunState); without it none is named. - CouldNotRunState StateRead - // Trunks are the trunk heads of every repository (the gate's source); nil names no re-judge after a trunk move. - Trunks func() (map[string]string, error) - // Runs says which commit the mesh runs of a module (the indexer's modules), as the checker's decision reads it: the - // node-engine a verdict names is compared at its running commit, not at the trunk's (ADR 0548 §6); nil knows none. - Runs interface{ CommitOf(module string) string } - // HearingState is the checker's state hearing: whether it hears DEAD_LETTERS (issue 734). - HearingState StateRead - // BuildState is the builder's builds (mesh-delivery-builder.builds): the builds of a running check's candidate that have - // not ended, which the check waits on before it composes (ADR 0603 §10); without it none is named. - BuildState StateRead - // AskState is the checker's state asks: the asks each running check put (AsksState), which checker_ask_again reads. - AskState StateRead - // Backlog is the build seats' backlog (mesh-delivery-view.build_usage); checker_ask_again reads it for a check that names no ask. - Backlog func() ([]BacklogRow, error) - Now func() time.Time -} - -// VerdictRead is a verdict as stored with every failure it names, one line each, and the full report of the status of each -// pull request it judged (Report), when the candidate still holds those heads; without it the report is that of the verdict alone. -type VerdictRead struct { - Key string `json:"key"` - Verdict json.RawMessage `json:"verdict"` - // Failed is everything the verdict names as failed, one line each, in the order judged (failedLines): every member's - // failed tests, refused steps and conflicts, the manifests' refusals and the composition (the operator, 2026-11-02). - Failed []string `json:"failed,omitempty"` - // Judged says which checking program judged the verdict, in one line (judgedLine): where it was built, the key its build - // is kept under, whether this check built it, and the heads it read (issue 1921); empty for a verdict written before. - Judged string `json:"judged,omitempty"` - Reports map[string]string `json:"reports,omitempty"` - Note string `json:"note,omitempty"` -} - -func (r Reader) candidate(group string) (meshcatalog.CandidatesByGroupValue, bool) { - key, err := meshcatalogclient.CandidatesKey(group) - if err != nil || r.CandidateState.Get == nil { - return meshcatalog.CandidatesByGroupValue{}, false - } - raw, err := r.CandidateState.Get(key) - if err != nil || len(raw) == 0 { - return meshcatalog.CandidatesByGroupValue{}, false - } - c, err := meshcatalog.DecodeCandidatesByGroupValue(raw) - return c, err == nil -} - -func (r Reader) read(key string, raw json.RawMessage) (VerdictRead, error) { - out := VerdictRead{Key: key, Verdict: raw} - v, err := meshdeliverycheckerclient.DecodeVerdict(raw) - if err != nil { - return out, fmt.Errorf("%s holds what is not a verdict: %w", key, err) - } - out.Failed = failedLines(v) - out.Judged = judgedLine(v.JudgedBy) - c, ok := r.candidate(v.Group) - if !ok || (c.Heads != v.Heads && GateHeads(c) != v.Heads) { - out.Note = "the candidate no longer holds these heads" - return out, nil - } - cs := CaseOf(c, v.Trunk) - out.Reports = map[string]string{} - if cs == nil { - if IsUntrunked(v) { - for _, p := range leftOf(c, v.Trunk) { - out.Reports[pullKey(p)] = failedOf(v).Words - } - } - return out, nil - } - for _, p := range cs.Pulls { - out.Reports[pullKey(p)] = Report(v, cs, p, nil, nil, nil) - } - for _, l := range cs.Left { - out.Reports[strings.SplitN(l, ": ", 2)[0]] = strings.SplitN(l, ": ", 2)[1] - } - return out, nil -} - -// Verdicts are the verdicts the checker holds, by key; with a group only that group's. The keys are narrowed by the group -// before any value is read, at most MaxReads are read (sixteen at a time), and cut says when it stopped there. -func (r Reader) Verdicts(group string) (out []VerdictRead, cut string, err error) { - if r.VerdictState.Keys == nil || r.VerdictState.Get == nil { - return nil, "", fmt.Errorf("the verdicts state cannot be read here") - } - keys, err := r.VerdictState.Keys() - if err != nil { - return nil, "", err - } - sort.Strings(keys) - var matching []string - for _, k := range keys { - if group != "" { - if g, _, err := meshdeliverycheckerclient.ParseVerdictKey(k); err != nil || g != group { - continue - } - } - matching = append(matching, k) - } - matching, cut = capKeys(matching, "give a group to narrow the answer") - rows := make([]VerdictRead, len(matching)) - found := make([]bool, len(matching)) - if err := parallel(len(matching), func(i int) error { - raw, err := r.VerdictState.Get(matching[i]) - if err != nil || len(raw) == 0 { - return err - } - rows[i], err = r.read(matching[i], raw) - found[i] = err == nil - return err - }); err != nil { - return nil, "", err - } - for i, row := range rows { - if found[i] { - out = append(out, row) - } - } - return out, cut, nil -} - -// Pull answers for one pull request: the verdict of the candidate that holds it, with its report; for one the indexer holds -// in no candidate, that none does. -func (r Reader) Pull(repository string, number int) (VerdictRead, error) { - if r.CandidateState.Keys == nil || r.CandidateState.Get == nil { - return VerdictRead{}, fmt.Errorf("the candidates state cannot be read here") - } - keys, err := r.CandidateState.Keys() - if err != nil { - return VerdictRead{}, err - } - keys = slices.DeleteFunc(keys, meshcatalogclient.IsTryGroup) - sort.Strings(keys) - keys, cut := capKeys(keys, "") - // The candidates are read in batches, each in parallel and taken in key order, so the read stops at the batch that holds it. - for from := 0; from < len(keys); from += ReadWorkers * 4 { - batch := keys[from:min(from+ReadWorkers*4, len(keys))] - cands := make([]meshcatalog.CandidatesByGroupValue, len(batch)) - ok := make([]bool, len(batch)) - _ = parallel(len(batch), func(i int) error { - raw, err := r.CandidateState.Get(batch[i]) - if err != nil || len(raw) == 0 { - return nil - } - c, err := meshcatalog.DecodeCandidatesByGroupValue(raw) - cands[i], ok[i] = c, err == nil - return nil - }) - for i, c := range cands { - if !ok[i] { - continue - } - for _, p := range c.Pulls { - if p.Repository != repository || int(p.Number) != number { - continue - } - vkey, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads) - if err != nil { - return VerdictRead{}, err - } - vraw, err := r.VerdictState.Get(vkey) - if err != nil { - return VerdictRead{}, err - } - if len(vraw) == 0 { - return VerdictRead{Key: vkey, Note: "no verdict yet for the heads of its candidate"}, nil - } - return r.read(vkey, vraw) - } - } - } - if cut != "" { - return VerdictRead{}, fmt.Errorf("no candidate among the first %d holds %s#%d", MaxReads, repository, number) - } - return VerdictRead{}, fmt.Errorf("no candidate holds %s#%d", repository, number) -} - -// Kept is the kept verdicts: one key's value as stored, or with an empty key the keys of a level (or every level) and their values. -func (r Reader) Kept(level, digest string) (map[string]json.RawMessage, string, error) { - if r.KeptState.Keys == nil || r.KeptState.Get == nil { - return nil, "", fmt.Errorf("the kept state cannot be read here") - } - if digest != "" { - key, err := meshdeliverycheckerclient.KeptKey(level, digest) - if err != nil { - return nil, "", err - } - raw, err := r.KeptState.Get(key) - if err != nil { - return nil, "", err - } - if len(raw) == 0 { - return nil, "", fmt.Errorf("no kept verdict %s", key) - } - return map[string]json.RawMessage{key: raw}, "", nil - } - keys, err := r.KeptState.Keys() - if err != nil { - return nil, "", err - } - sort.Strings(keys) - var matching []string - for _, k := range keys { - if l, _, err := meshdeliverycheckerclient.ParseKeptKey(k); err == nil && (level == "" || l == level) { - matching = append(matching, k) - } - } - matching, cut := capKeys(matching, "give a level and a digest to read one") - values := make([]json.RawMessage, len(matching)) - if err := parallel(len(matching), func(i int) (err error) { - values[i], err = r.KeptState.Get(matching[i]) - return err - }); err != nil { - return nil, "", err - } - out := map[string]json.RawMessage{} - for i, k := range matching { - if len(values[i]) > 0 { - out[k] = values[i] - } - } - return out, cut, nil -} - -// Input is the answer of the seat's verb input (InputVerb): the input kept under digest, its exact bytes, which the Go build -// module hands the checking program a run ask names (buildstep.RunInput.Read). A digest that is no sha256, one the checker -// keeps nothing under, and bytes that read back as another digest are errors, never an answer. -func (r Reader) Input(digest string) (meshdeliverychecker.InputAnswer, error) { - if r.InputState.Get == nil { - return meshdeliverychecker.InputAnswer{}, fmt.Errorf("the state %s cannot be read here", InputsStateName) - } - if len(digest) != 64 || strings.Trim(digest, "0123456789abcdef") != "" { - return meshdeliverychecker.InputAnswer{}, fmt.Errorf("%q is no sha256 digest of 64 lowercase hex digits", digest) - } - raw, err := r.InputState.Get(digest) - if err != nil { - return meshdeliverychecker.InputAnswer{}, fmt.Errorf("the input %s cannot be read: %w", digest, err) - } - if len(raw) == 0 { - return meshdeliverychecker.InputAnswer{}, fmt.Errorf("the checker keeps no input %s (an input is kept a day)", digest) - } - if sum := sha256.Sum256(raw); hex.EncodeToString(sum[:]) != digest { - return meshdeliverychecker.InputAnswer{}, fmt.Errorf("the input kept under %s reads back as %d bytes of another digest", digest, len(raw)) - } - return meshdeliverycheckerclient.InputAnswerOf(raw), nil -} - -// Inputs are the checking program's kept inputs: with a digest that input as kept, else every digest with its size. -func (r Reader) Inputs(digest string) (map[string]json.RawMessage, string, error) { - if r.InputState.Keys == nil || r.InputState.Get == nil { - return nil, "", fmt.Errorf("the state %s cannot be read here", InputsStateName) - } - if digest != "" { - raw, err := r.InputState.Get(digest) - if err != nil { - return nil, "", err - } - if len(raw) == 0 { - return nil, "", fmt.Errorf("no input %s is kept", digest) - } - return map[string]json.RawMessage{digest: raw}, "", nil - } - keys, err := r.InputState.Keys() - if err != nil { - return nil, "", err - } - sort.Strings(keys) - keys, cut := capKeys(keys, "give a digest to read one") - sizes := make([]int, len(keys)) - if err := parallel(len(keys), func(i int) error { - raw, err := r.InputState.Get(keys[i]) - sizes[i] = len(raw) - return err - }); err != nil { - return nil, "", err - } - out := map[string]json.RawMessage{} - for i, k := range keys { - out[k] = json.RawMessage(fmt.Sprintf(`{"size":%d}`, sizes[i])) - } - return out, cut, nil -} - -// PreviewRead is one preview as stored, with the parts of its key. -type PreviewRead struct { - Key string `json:"key"` - Repository string `json:"repository"` - Head string `json:"head"` - Trunk string `json:"trunk"` - Preview json.RawMessage `json:"preview"` -} - -// Previews are the previews the checker holds, each as stored. With a repository only that repository's; with a head (a -// prefix of at least 7 characters is enough) only previews of that head. A key that is no preview key is listed as unreadable. -func (r Reader) Previews(repository, head string) ([]PreviewRead, []string, string, error) { - if r.PreviewState.Keys == nil || r.PreviewState.Get == nil { - return nil, nil, "", fmt.Errorf("the previews state cannot be read here") - } - keys, err := r.PreviewState.Keys() - if err != nil { - return nil, nil, "", err - } - sort.Strings(keys) - type part struct{ repo, head, trunk string } - parts := map[string]part{} - var matching, bad []string - for _, k := range keys { - repo, h, trunk, err := meshdeliverycheckerclient.ParsePreviewKey(k) - if err != nil { - bad = append(bad, k) - continue - } - if (repository != "" && repo != repository) || (head != "" && !strings.HasPrefix(h, head)) { - continue - } - parts[k] = part{repo, h, trunk} - matching = append(matching, k) - } - matching, cut := capKeys(matching, "give a repository and a head to narrow the answer") - values := make([]json.RawMessage, len(matching)) - if err := parallel(len(matching), func(i int) (err error) { - values[i], err = r.PreviewState.Get(matching[i]) - return err - }); err != nil { - return nil, nil, "", err - } - out := []PreviewRead{} - for i, k := range matching { - if len(values[i]) > 0 { - p := parts[k] - out = append(out, PreviewRead{Key: k, Repository: p.repo, Head: p.head, Trunk: p.trunk, Preview: values[i]}) - } - } - return out, bad, cut, nil -} - -// RunningStep is a step in flight on a build module. -type RunningStep struct { - Module string `json:"module"` - Node string `json:"node"` - ID string `json:"id"` - Tool string `json:"tool"` - Since string `json:"since,omitempty"` - // What says what the step is (buildstep.AskWhat): an ask's kind, repository@head and levels. - What string `json:"what,omitempty"` -} - -// LeftStep is a key a build module left running that no step behind it runs any more, and why. -type LeftStep struct { - RunningStep - Why string `json:"why"` -} - -// Status is what runs now, read from the buckets: the steps in flight on the build modules and the candidates without a -// verdict for their heads. Nothing holds a check since R4g: a check is an ask on the build seats' streams, whose backlog -// the delivery view shows (ADR 0525 §9). -type Status struct { - Running []RunningStep `json:"running_steps"` - LeftRunning []LeftStep `json:"left_running"` - RunningByNode map[string]int `json:"running_by_node"` - Unjudged []string `json:"unjudged_candidates"` - // Waiting are the candidates whose check waits, by kind (ADR 0536 §4): new (no verdict for its heads) and nodes (failed - // for the nodes, asked again when they change) start before trunk (judged on trunk heads that moved since). - Waiting map[string][]string `json:"waiting_by_kind"` - // CannotBeJudged are the candidates no pull request of which can be judged, by group, with why: the gate's source.main - // names no trunk head of their repositories (issue 1422). They are judged once it does; until then their status is error. - CannotBeJudged map[string]string `json:"cannot_be_judged"` - // CouldNotRun are the checks that could not run, by verdict key: the part not heard, since when, the running that asked - // it again, and whether it is the finding check-could-not-run (design 47 test 58). Each is asked again when its part runs. - CouldNotRun map[string]CouldNotRun `json:"could_not_run"` - // Outside are the candidates outside the mesh, by group, with why (case.go Outside): judged nothing, owed nothing. - Outside map[string]string `json:"outside_the_mesh"` - // Lost are the candidates whose verdict is running while no step of theirs can still run and their newest step ended, by - // group, with that step: nothing will judge them (the lost check of 2026-10-28); checker_ask_again asks one again. - Lost map[string]string `json:"lost"` - // BuildsNotEnded are, of each candidate whose check runs, the builder's builds of its changed modules that are neither - // done nor failed, by group: ` `, sorted (no key yet is `not begun`). A check waits on them before it - // composes (ADR 0603 §10), but for the modules its line names as composed without them; builder_build_again builds a failed one again, and the check asks itself again when it is done. - BuildsNotEnded map[string]string `json:"builds_not_ended,omitempty"` - // DeadLetters says whether the checker hears the asks the build seats give up on (issue 734): deaf, a try or check - // whose ask is given up waits until its bound. - DeadLetters DeadLettersHeard `json:"dead_letters"` - Notes []string `json:"notes,omitempty"` -} - -// DeadLettersHeard is the checker's hearing of DEAD_LETTERS as the status says it: healthy or not, and why. -type DeadLettersHeard struct { - Heard bool `json:"heard"` - Why string `json:"why"` -} - -// deadLetters reads the checker's kept hearing (buildrun.HearingHealth). -func (r Reader) deadLetters() DeadLettersHeard { - if r.HearingState.Get == nil { - return DeadLettersHeard{Why: "the checker's state hearing is not readable here"} - } - raw, err := r.HearingState.Get(buildrun.HearingKey) - if err != nil { - return DeadLettersHeard{Why: "the checker's state hearing cannot be read: " + err.Error()} - } - a := buildrun.HearingHealth(raw) - return DeadLettersHeard{Heard: a.Healthy, Why: a.Why} -} - -// couldNotRun reads the checks that could not run, by verdict key; nil when they cannot be read, said in a note. -func (r Reader) couldNotRun(st *Status) map[string]CouldNotRun { - if r.CouldNotRunState.Keys == nil || r.CouldNotRunState.Get == nil { - st.Notes = append(st.Notes, "the checker's state could-not-run is not readable here, so no check that could not run is named") - return nil - } - keys, err := r.CouldNotRunState.Keys() - if err != nil { - st.Notes = append(st.Notes, "the checker's state could-not-run cannot be listed: "+err.Error()) - return nil - } - out := map[string]CouldNotRun{} - for _, k := range keys { - var c CouldNotRun - if raw, err := r.CouldNotRunState.Get(k); err == nil && json.Unmarshal(raw, &c) == nil { - out[k] = c - } - } - return out -} - -// Status reads the build modules' steps and the candidates against their verdicts. -func (r Reader) Status() (Status, error) { - st := Status{RunningByNode: map[string]int{}, Lost: map[string]string{}} - read := r.readSteps() - st.Running, st.LeftRunning, st.Notes = read.running, read.left, read.notes - for _, rs := range st.Running { - st.RunningByNode[rs.Node]++ - } - if r.HaveState.Get == nil { - st.Notes = append(st.Notes, "the node-engine's have is not readable here, so a step is not checked against its build module being on its node") - } - if len(st.LeftRunning) > 0 { - st.Notes = append(st.Notes, "left_running are keys a build module left running (it stopped, restarted or was unassigned before it wrote the step's end): the checker's wait for each ended at the step bound, so none holds a place; the build module never ends them") - } - st.Unjudged = []string{} - st.Waiting = map[string][]string{KindNew: {}, KindNodes: {}, KindTrunk: {}} - st.CannotBeJudged, st.Outside = map[string]string{}, map[string]string{} - var heads map[string]string - if r.Trunks == nil { - st.Notes = append(st.Notes, "the trunk heads are not readable here, so no check is named as waiting for a trunk move") - } else if h, err := r.Trunks(); err != nil { - st.Notes = append(st.Notes, "the trunk heads cannot be read, so no check is named as waiting for a trunk move: "+err.Error()) - } else { - heads = h - } - if r.CandidateState.Keys != nil && r.CandidateState.Get != nil && r.VerdictState.Get != nil { - keys, err := r.CandidateState.Keys() - if err != nil { - return st, err - } - keys = slices.DeleteFunc(keys, meshcatalogclient.IsTryGroup) // a try's candidate is judged by its try, never as a check - sort.Strings(keys) - total := len(keys) - keys, cut := capKeys(keys, "") - if cut != "" { - st.Notes = append(st.Notes, fmt.Sprintf("read the first %d candidates of %d", MaxReads, total)) - } - type judged struct { - c meshcatalog.CandidatesByGroupValue - raw json.RawMessage - ok bool - } - rows := make([]judged, len(keys)) - _ = parallel(len(keys), func(i int) error { - raw, err := r.CandidateState.Get(keys[i]) - if err != nil || len(raw) == 0 { - return nil - } - c, err := meshcatalog.DecodeCandidatesByGroupValue(raw) - if err != nil { - return nil - } - vkey, err := meshdeliverycheckerclient.VerdictKey(c.Group, c.Heads) - if err != nil { - return nil - } - rows[i].c = c - if vraw, err := r.VerdictState.Get(vkey); err == nil { - rows[i].raw, rows[i].ok = vraw, true - } - return nil - }) - for _, row := range rows { - if !row.ok { - continue - } - c, raw := row.c, row.raw - if Outside(c, heads) { - st.Outside[c.Group] = OutsideWords - continue - } - if heads != nil && len(leftOf(c, heads)) > 0 { - // Nothing of it can be judged now, whatever its verdict says (issue 1422): never counted as waiting. - var repos []string - for _, p := range leftOf(c, heads) { - repos = append(repos, p.Repository) - } - st.CannotBeJudged[c.Group] = UntrunkedWordsOf(repos) - continue - } - if len(raw) == 0 { - st.Unjudged = append(st.Unjudged, c.Group) - st.Waiting[KindNew] = append(st.Waiting[KindNew], c.Group) - continue - } - v, err := meshdeliverycheckerclient.DecodeVerdict(raw) - switch { - case err != nil: - case v.State == meshdeliverycheckerclient.VerdictRunning: - if why := read.lostWhy(c); why != "" { - st.Lost[c.Group] = why - } - if words := r.buildsNotEnded(c); words != "" { - if st.BuildsNotEnded == nil { - st.BuildsNotEnded = map[string]string{} - } - st.BuildsNotEnded[c.Group] = words - } - case IsCouldNotRun(v): - st.Waiting[KindNodes] = append(st.Waiting[KindNodes], c.Group) - case IsUntrunked(v): - // Its trunk head is known now: it waits for its whole check. - st.Waiting[KindNew] = append(st.Waiting[KindNew], c.Group) - case heads != nil: - if cs := CaseOf(c, heads); cs != nil && (!sameTrunk(v.Trunk, cs.Trunk) || besideMoved(v.Beside, besideAt(heads, r.Runs))) { - st.Waiting[KindTrunk] = append(st.Waiting[KindTrunk], c.Group) - } - } - } - } - st.DeadLetters = r.deadLetters() - st.CouldNotRun = r.couldNotRun(&st) - st.Notes = append(st.Notes, "nothing holds the checker and it holds no place: running_steps are the build modules' keys that can still be running (started within the step bound, their build module running on the node); a candidate without a verdict has its check ask in a build seat's stream, waiting for a node with a free slot, whose backlog the delivery view shows (ADR 0525 §4, §9)") - return st, nil -} - -// stepsRead is what the build modules' steps states hold: the steps that can still run, those left running, and every -// ask step read, by module, for the candidate it belongs to (stepsOf). -type stepsRead struct { - running []RunningStep - left []LeftStep - all []moduleStep - notes []string -} - -type moduleStep struct { - module string - step buildstep.Step -} - -// readSteps reads the newest MaxReads keys of each build module's steps state. -func (r Reader) readSteps() stepsRead { - out := stepsRead{running: []RunningStep{}, left: []LeftStep{}} - var states map[string]StateRead - if r.StepStates != nil { - states = r.StepStates() - } - mods := make([]string, 0, len(states)) - for m := range states { - mods = append(mods, m) - } - sort.Strings(mods) - now, bound := time.Now(), r.StepBound - if r.Now != nil { - now = r.Now() - } - if bound <= 0 { - bound = DefaultStepBound - } - for _, m := range mods { - sr := states[m] - if sr.Keys == nil || sr.Get == nil { - continue - } - keys, err := sr.Keys() - if err != nil { - out.notes = append(out.notes, "the steps of "+m+" cannot be listed: "+err.Error()) - continue - } - // A step that runs started lately: the newest ids are read first, at most MaxReads of them. - newestFirst(keys) - keys, cut := capKeys(keys, "") - if cut != "" { - out.notes = append(out.notes, "the steps of "+m+": read the newest "+fmt.Sprint(MaxReads)+" of its keys; a step older than those is not shown") - } - steps := make([]buildstep.Step, len(keys)) - decoded := make([]bool, len(keys)) - _ = parallel(len(keys), func(i int) error { - raw, err := sr.Get(keys[i]) - if err != nil || len(raw) == 0 { - return nil - } - step, err := buildstep.DecodeStep(raw) - steps[i], decoded[i] = step, err == nil - return nil - }) - for i := range keys { - if !decoded[i] { - continue - } - step := steps[i] - out.all = append(out.all, moduleStep{module: m, step: step}) - if step.State != buildstep.StepRunning { - continue - } - rs := RunningStep{Module: m, Node: step.Node, ID: step.ID, Tool: step.Tool, What: step.What} - if !step.Started.IsZero() { - rs.Since = step.Started.UTC().Format("2006-01-02T15:04:05Z") - } - if why := r.leftWhy(m, step, now, bound); why != "" { - out.left = append(out.left, LeftStep{RunningStep: rs, Why: why}) - continue - } - out.running = append(out.running, rs) - } - } - return out -} - -// asksOf says whether a step is an ask of one of the candidate's pull requests: its What names `@` -// (buildstep.AskWhat). -func asksOf(c meshcatalog.CandidatesByGroupValue, what string) bool { - for _, p := range c.Pulls { - if p.Repository != "" && strings.Contains(what, p.Repository+"@"+short12(p.Head)) { - return true - } - } - return false -} - -// lostWhy says why a candidate whose verdict is running has a check that nothing will judge, or "": no step of its pull -// requests can still run, and its newest one ended. -func (s stepsRead) lostWhy(c meshcatalog.CandidatesByGroupValue) string { - for _, rs := range s.running { - if asksOf(c, rs.What) { - return "" - } - } - var last *buildstep.Step - for i := range s.all { - st := s.all[i].step - if buildstep.Ended(st) && asksOf(c, st.What) && (last == nil || st.Ended.After(last.Ended)) { - last = &s.all[i].step - } - } - if last == nil { - return "" // its ask waits in its build seat's stream: no node took it yet - } - return fmt.Sprintf("its verdict is running, but no step of it runs: its last step %s on %s ended %s at %s and no verdict followed; %s asks it again", - last.ID, last.Node, last.State, last.Ended.UTC().Format(time.RFC3339), AskAgainTool) -} - -// DefaultStepBound is how long one check ask's step may run once a build node took it (its key written running; the fetch, -// the digests and the levels), never counting its wait in the stream; past it the check fails naming the node. -const DefaultStepBound = 30 * time.Minute - -// leftWhy says why a key in the running state runs no step any more, or "" when it can still be running: its build module -// is not on its node or is not running there (the node-engine's have), or it started longer ago than the step bound, when -// the checker stopped waiting for it. -func (r Reader) leftWhy(module string, step buildstep.Step, now time.Time, bound time.Duration) string { - if r.HaveState.Get != nil { - key, err := nodeengineclient.HaveKey(step.Node, module) - if err == nil { - raw, err := r.HaveState.Get(key) - switch { - case err != nil: - case len(raw) == 0: - return fmt.Sprintf("%s is not on %s", module, step.Node) - default: - if h, err := nodeengineclient.DecodeHave(raw); err == nil && h.Phase != nodeengineclient.PhaseRunning { - return fmt.Sprintf("%s on %s is %s", module, step.Node, h.Phase) - } - } - } - } - if step.Started.IsZero() { - return fmt.Sprintf("it says no start, so no wait of the checker's (bound %s) can be behind it", bound) - } - if end := step.Started.Add(bound); now.After(end) { - return fmt.Sprintf("started %s, past the step bound of %s: the checker stopped waiting for it at %s", step.Started.UTC().Format(time.RFC3339), bound, end.UTC().Format(time.RFC3339)) - } - return "" -} - -// buildsNotEnded are the builder's builds of the candidate's changed modules that are neither done nor failed, as -// Status.BuildsNotEnded says them; empty when none, or when the builder's builds are not readable here. -func (r Reader) buildsNotEnded(c meshcatalog.CandidatesByGroupValue) string { - if r.BuildState.Get == nil { - return "" - } - var out []string - for _, p := range c.Pulls { - for module, cm := range p.Fps { - if cm.Fp2 == "" || cm.Manifest == "" { - continue - } - key, err := builds.BuilderBuildKey(module, cm.Fp2) - if err != nil { - continue - } - raw, err := r.BuildState.Get(key) - if err != nil { - continue - } - state := "not begun" - if len(raw) > 0 { - b, err := builds.DecodeBuilderBuild(raw) - if err != nil || b.State == builds.BuildDone || b.State == builds.BuildFailed { - continue - } - state = b.State - } - out = append(out, module+" "+state) - } - } - sort.Strings(out) - return strings.Join(slices.Compact(out), ", ") -} - -// judgedLine is a verdict's JudgedBy in one line, as the verdict tools answer it. -func judgedLine(by *meshdeliverychecker.VerdictsByGroupHeadsValueJudgedBy) string { - if by == nil { - return "" - } - built := "kept" - if by.Built { - built = "built for this check" - } - heads := make([]string, len(by.Heads)) - for i, h := range by.Heads { - heads[i] = h.Repository + " " + h.Commit - } - return fmt.Sprintf("by the checking program %s of %s at %s (%s), %s as %s, over %s", by.Program.Package, by.Program.Repository, - by.Program.Commit, by.Program.Dir, built, by.Key, strings.Join(heads, ", ")) -} diff --git a/modules/mesh-delivery-checker/internal/check/read_test.go b/modules/mesh-delivery-checker/internal/check/read_test.go deleted file mode 100644 index 1ba52ccd..00000000 --- a/modules/mesh-delivery-checker/internal/check/read_test.go +++ /dev/null @@ -1,446 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "fmt" - "strings" - "sync/atomic" - "testing" - "time" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - buildsrec "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -type fakeState map[string][]byte - -func (f fakeState) read() StateRead { - return StateRead{ - Keys: func() ([]string, error) { - var k []string - for key := range f { - k = append(k, key) - } - return k, nil - }, - Get: func(key string) (json.RawMessage, error) { - if v, ok := f[key]; ok { - return json.RawMessage(v), nil - } - return nil, nil - }, - } -} - -// readerOf is a reader over a verdict the checker wrote through its own code and the candidate it judged. -func readerOf(t *testing.T) (Reader, string) { - t.Helper() - r := newRig(t, passJudge()) - r.setTrunks(t, map[string]string{repoA: trunkA, repoSDK: trunkS, hqRepo: trunkA2}) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1), pullOf(hqRepo, 3, head2)) - r.ch.Candidate(context.Background(), "feat%2Fx", cand) - r.ch.Wait() - ckey, _ := meshcatalogclient.CandidatesKey("feat/x") - verdicts, kept := fakeState{}, fakeState{} - for k, v := range r.verdicts.vals { - verdicts[k] = v - } - if _, err := (Kept{Store: r.verdicts}).Keep(context.Background(), "unit", digA, keptValue("m/a", 3)); err != nil { - t.Fatal(err) - } - kept["unit."+digA] = r.verdicts.vals["unit."+digA] - return Reader{VerdictState: verdicts.read(), KeptState: kept.read(), CandidateState: fakeState{ckey: cand}.read()}, keyOf(t, "feat/x", cand) -} - -func TestTheVerdictToolsAnswerTheStoredVerdictWithTheFullReportOfEachPullRequest(t *testing.T) { // N9/AC1, 1686 - rd, key := readerOf(t) - vs, _, err := rd.Verdicts("") - if err != nil || len(vs) != 1 || vs[0].Key != key { - t.Fatalf("verdicts = %+v, %v", vs, err) - } - if _, err := meshdeliverycheckerclient.DecodeVerdict(vs[0].Verdict); err != nil { - t.Errorf("the verdict is not as stored: %v", err) - } - if got := vs[0].Reports["novox/mesh-delivery#7"]; !strings.HasPrefix(got, "pass 111111111111 on aaaaaaaaaaaa") || !strings.Contains(got, "composition not yet run") { - t.Errorf("reports = %v", vs[0].Reports) - } - if vs[0].Judged != "" { - t.Errorf("judged = %q of a verdict with no JudgedBy", vs[0].Judged) - } - if only, _, _ := rd.Verdicts("feat/other"); len(only) != 0 { - t.Errorf("another group's verdicts = %+v", only) - } - // A failed verdict is answered with every failure it names, one line each (the operator, 2026-11-02). - raw, _ := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: "feat/x", Heads: "0123456789ab", State: meshdeliverycheckerclient.VerdictFail, - Failed: &FailedFirst{Test: "unit: m/a.TestA", Words: "a_test.go:3: boom\nmore"}, - Failures: failureItems([]FailedFirst{{Test: "unit: m/a.TestA", Words: "a_test.go:3: boom"}, {Machine: "g14", Words: "route-proxy is defined twice"}}), - // Issue 1921: it names the checking program that judged it, its build and the heads it read. - JudgedBy: judgedByOf(buildstep.RunProgram{Repository: repoA, Commit: head1, Dir: CheckingProgramDir, Package: CheckingProgramPackage}, - buildstep.RunAnswer{Key: "program-0123456789abcdef", Built: true}, []buildstep.RunHead{{Repository: repoA, Commit: head1}})}) - want := "by the checking program " + CheckingProgramPackage + " of " + repoA + " at " + head1 + " (" + CheckingProgramDir + - "), built for this check as program-0123456789abcdef, over " + repoA + " " + head1 - if got, _ := rd.read(key, raw); strings.Join(got.Failed, " | ") != "unit: m/a.TestA: a_test.go:3: boom | g14: route-proxy is defined twice" || got.Judged != want { - t.Errorf("failed = %q, judged %q, want %q", got.Failed, got.Judged, want) - } -} - -// 1887/A10: an hq pull request is answered as any other, its report its verdict's (ADR 0527 §2), never a note that a script -// judges it. -func TestAnHqPullRequestIsAnsweredAsAnyOther(t *testing.T) { - rd, _ := readerOf(t) - hq, err := rd.Pull(hqRepo, 3) - if err != nil || hq.Note != "" || hq.Verdict == nil { - t.Errorf("hq pull = %+v, %v", hq, err) - } - p, err := rd.Pull(repoA, 7) - if err != nil || p.Note != "" || !strings.HasPrefix(p.Reports["novox/mesh-delivery#7"], "pass ") { - t.Errorf("pull = %+v, %v", p, err) - } - if _, err := rd.Pull(repoA, 99); err == nil { - t.Error("a pull request no candidate holds was answered") - } -} - -func TestTheKeptToolAnswersTheKeysAsStoredByLevelAndByDigest(t *testing.T) { // N9/AC1 - rd, _ := readerOf(t) - all, _, err := rd.Kept("", "") - if err != nil || len(all) != 1 { - t.Fatalf("kept = %v, %v", all, err) - } - one, _, err := rd.Kept("unit", digA) - if err != nil || len(one) != 1 { - t.Fatalf("one kept = %v, %v", one, err) - } - for _, raw := range one { - if k, err := meshdeliverycheckerclient.DecodeKept(raw); err != nil || k.Package != "m/a" { - t.Errorf("kept value = %+v, %v", k, err) - } - } - if none, _, _ := rd.Kept("integration", ""); len(none) != 0 { - t.Errorf("integration = %v", none) - } - if _, _, err := rd.Kept("unit", digB); err == nil { - t.Error("a digest nothing kept was answered") - } - // Issue 1921: checker_inputs answers the checking program's inputs, every digest with its size, or one as kept. - inputs := newMemKV() - body := []byte(`{"v":1,"group":"feat/x"}`) - in, _ := buildstep.RunInputOf(InputVerb, body) - _ = memInputs{inputs}.Keep(context.Background(), in.Digest, body) - rd.InputState = kvRead(inputs) - if all, _, err := rd.Inputs(""); err != nil || string(all[in.Digest]) != fmt.Sprintf(`{"size":%d}`, len(body)) { - t.Errorf("inputs = %s, %v", all, err) - } - if one, _, err := rd.Inputs(in.Digest); err != nil || string(one[in.Digest]) != string(body) { - t.Errorf("one input = %s, %v", one, err) - } - if _, _, err := rd.Inputs(strings.Repeat("0", 64)); err == nil { - t.Error("an input nothing kept was answered") - } - // The operator's answer on B0: the seat's verb input answers the exact bytes, which the build module's read takes; - // a digest that is none, one nothing is kept under, and bytes kept under another digest are errors. - if got, err := meshdeliverycheckerclient.ReadInput(func(key string, b any) (json.RawMessage, error) { - if key != "seat:mesh-delivery-checker.input" { - return nil, fmt.Errorf("asked %s", key) - } - a, err := rd.Input(b.(meshdeliverychecker.InputInput).Digest) - if err != nil { - return nil, err - } - return json.Marshal(a) - }, in.Digest); err != nil || string(got) != string(body) { - t.Errorf("the input through the verb = %s, %v", got, err) - } - _, _ = inputs.Create(context.Background(), strings.Repeat("1", 64), []byte(`{"v":2}`)) - for _, digest := range []string{"d1", strings.Repeat("0", 64), strings.Repeat("1", 64)} { - if a, err := rd.Input(digest); err == nil { - t.Errorf("the verb answered %s: %+v", digest, a) - } - } -} - -// 1680 live acceptance: checker_previews shows the preview key of an open pull request, as stored, narrowed by repository and head. -func TestThePreviewsToolShowsTheStoredPreviewOfAPullRequest(t *testing.T) { - pv := meshdeliverychecker.PreviewsByRepositoryHeadTrunkValue{Repository: repoA, Head: head1, Trunk: head2, Merge: "m1", Modules: map[string]meshdeliverychecker.PreviewsByRepositoryHeadTrunkValueModulesValue{}} - data, err := meshdeliverycheckerclient.EncodePreview(pv) - if err != nil { - t.Fatal(err) - } - key, _ := meshdeliverycheckerclient.PreviewKey(repoA, head1, head2) - rd := Reader{PreviewState: fakeState{key: data, "junk": []byte("{}")}.read()} - got, bad, _, err := rd.Previews(repoA, head1[:8]) - if err != nil || len(got) != 1 || got[0].Key != key || got[0].Head != head1 || got[0].Trunk != head2 || string(got[0].Preview) != string(data) { - t.Fatalf("previews = %+v, %v", got, err) - } - if len(bad) != 1 || bad[0] != "junk" { - t.Errorf("unreadable = %v", bad) - } - if got, _, _, _ := rd.Previews("novox/other", ""); len(got) != 0 { - t.Errorf("another repository's = %+v", got) - } - if _, _, _, err := (Reader{}).Previews("", ""); err == nil { - t.Error("answered with no state to read") - } -} - -// checker_status reads the steps in flight by node and the candidates without a verdict; since R4g nothing holds the checker -// and it has no capacity of its own (ADR 0525 §4, §7; 1685 closed by the hold's deletion). -func TestTheStatusToolReadsRunningSteps(t *testing.T) { - running, _ := buildstep.EncodeStep(buildstep.Step{ID: "abc1", Tool: "build_go_test", Node: "shanks", State: buildstep.StepRunning, Started: time.Date(2026, 10, 22, 15, 0, 0, 0, time.UTC)}) - passed, _ := buildstep.EncodeStep(buildstep.Step{ID: "abc2", Tool: "build_go_test", Node: "ace", State: buildstep.StepPassed}) - cand := candidateOf(t, "feat/x", pullOf(repoA, 7, head1)) - ckey, _ := meshcatalogclient.CandidatesKey("feat/x") - // ADR 0603 §10: feat/y's check runs and waits on the builds of its changed modules: web building, mail not begun; api - // is done and named nowhere. - fp, man := "src2:"+strings.Repeat("f", 64), strings.Repeat("e", 64) - py := pullOf(repoA, 8, head2) - py.Modules, py.Fps = []string{"api", "mail", "web"}, map[string]meshcatalog.CandidatesByGroupValuePullsItemFpsValue{"web": {Fp2: fp, Manifest: man}, "mail": {Fp2: fp, Manifest: man}, "api": {Fp2: fp, Manifest: man}} - candY := candidateOf(t, "feat/y", py) - ykey, _ := meshcatalogclient.CandidatesKey("feat/y") - runningV, _ := meshdeliverycheckerclient.EncodeVerdict(meshdeliverychecker.VerdictsByGroupHeadsValue{Group: "feat/y", Heads: "0123456789ab", State: meshdeliverycheckerclient.VerdictRunning}) - builds := fakeState{} - for module, state := range map[string]string{"web": buildsrec.BuildBuilding, "api": buildsrec.BuildDone} { - k, _ := buildsrec.BuilderBuildKey(module, fp) - builds[k], _ = json.Marshal(buildsrec.BuilderBuild{V: 1, State: state}) - } - rd := Reader{ - StepStates: stepStatesOf(map[string]StateRead{"mesh-build-go": fakeState{"shanks.abc1": running, "ace.abc2": passed}.read()}), - CandidateState: fakeState{ckey: cand, ykey: candY}.read(), - VerdictState: fakeState{keyOf(t, "feat/y", candY): runningV}.read(), - BuildState: builds.read(), - HaveState: fakeState{"shanks.mesh-build-go": haveOf(t, nodeengineclient.PhaseRunning)}.read(), - HearingState: fakeState{"dead-letters": []byte(`{"heard":false,"streams":["SEAT_NODE_BUILD_GO"],` + - `"why":"DEAD_LETTERS is not heard, so an ask a build seat gives up on is waited for until its bound: SEAT_NODE_BUILD_GO: permissions violation",` + - `"at":"2026-10-26T13:00:00Z"}`)}.read(), - Now: func() time.Time { return time.Date(2026, 10, 22, 15, 10, 0, 0, time.UTC) }, - } - st, err := rd.Status() - if err != nil { - t.Fatal(err) - } - if len(st.Running) != 1 || st.Running[0].Node != "shanks" || st.RunningByNode["shanks"] != 1 || st.RunningByNode["ace"] != 0 { - t.Errorf("running = %+v %v", st.Running, st.RunningByNode) - } - if len(st.Unjudged) != 1 || st.Unjudged[0] != "feat/x" { - t.Errorf("unjudged = %v", st.Unjudged) - } - if got := st.BuildsNotEnded; len(got) != 1 || got["feat/y"] != "mail not begun, web building" { - t.Errorf("builds not ended = %v, want feat/y's mail not begun and web building", got) - } - // Issue 734, review round 1: a checker that does not hear DEAD_LETTERS says so in its status, with why. - if st.DeadLetters.Heard || !strings.Contains(st.DeadLetters.Why, "permissions violation") { - t.Errorf("dead letters = %+v, want not heard, saying why", st.DeadLetters) - } - // What cannot be read is said, not guessed. - st, err = Reader{}.Status() - if err != nil || len(st.Notes) == 0 || st.DeadLetters.Heard { - t.Errorf("empty status = %+v, %v", st, err) - } -} - -func haveOf(t *testing.T, phase string) []byte { - t.Helper() - raw, err := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Phase: phase, Health: nodeengineclient.HealthOK}) - if err != nil { - t.Fatal(err) - } - return raw -} - -func stepOf(t *testing.T, id, node string, started time.Time) []byte { - t.Helper() - raw, err := buildstep.EncodeStep(buildstep.Step{ID: id, Tool: "build_go_fetch", Node: node, State: buildstep.StepRunning, Started: started}) - if err != nil { - t.Fatal(err) - } - return raw -} - -// 1890: a key a build module left running (it stopped, restarted or was unassigned before it wrote the step's end) holds -// no place in the checker, whose wait for it ended at the step bound; the status says it is left running and why, and -// counts only the steps that can still run. -func TestTheStatusCountsOnlyStepsThatCanStillRunAndSaysWhyTheOthersAreLeft(t *testing.T) { // 1890/AC2, AC3 - now := time.Date(2026, 10, 23, 7, 0, 0, 0, time.UTC) - rd := Reader{ - StepStates: stepStatesOf(map[string]StateRead{ - "mesh-build-go": fakeState{ - "g14.fresh1": stepOf(t, "fresh1", "g14", now.Add(-5*time.Minute)), - "g14.old1": stepOf(t, "old1", "g14", now.Add(-33*time.Hour)), - "ace.gone1": stepOf(t, "gone1", "ace", now.Add(-2*time.Minute)), - "shanks.down1": stepOf(t, "down1", "shanks", now.Add(-time.Minute)), - }.read(), - }), - HaveState: fakeState{ - "g14.mesh-build-go": haveOf(t, nodeengineclient.PhaseRunning), - "shanks.mesh-build-go": haveOf(t, nodeengineclient.PhaseFailed), - }.read(), - StepBound: 30 * time.Minute, - Now: func() time.Time { return now }, - } - st, err := rd.Status() - if err != nil { - t.Fatal(err) - } - if len(st.Running) != 1 || st.Running[0].ID != "fresh1" || len(st.RunningByNode) != 1 || st.RunningByNode["g14"] != 1 { - t.Fatalf("running = %+v by node %v", st.Running, st.RunningByNode) - } - why := map[string]string{} - for _, l := range st.LeftRunning { - why[l.ID] = l.Why - } - if len(why) != 3 { - t.Fatalf("left running = %+v", st.LeftRunning) - } - for id, want := range map[string]string{"old1": "past the step bound of 30m0s", "gone1": "mesh-build-go is not on ace", "down1": "mesh-build-go on shanks is failed"} { - if !strings.Contains(why[id], want) { - t.Errorf("why %s = %q, want it to say %q", id, why[id], want) - } - } -} - -// 1887/A10: a group of hq's pull requests alone is judged by the checker since R4g, so without a verdict it is unjudged. -func TestTheStatusCountsAnHQOnlyGroupAsUnjudged(t *testing.T) { - cand := candidateOf(t, "pb-x", pullOf(hqRepo, 3, head2)) - ckey, _ := meshcatalogclient.CandidatesKey("pb-x") - st, err := Reader{CandidateState: fakeState{ckey: cand}.read(), VerdictState: fakeState{}.read()}.Status() - if err != nil { - t.Fatal(err) - } - if len(st.Unjudged) != 1 || st.Unjudged[0] != "pb-x" { - t.Errorf("unjudged = %v, want pb-x", st.Unjudged) - } - // A check that could not run is named with the part not heard (design 47 test 58). - rec := json.RawMessage(`{"v":1,"group":"feat/x","heads":"0123456789ab","part":{"node":"g14","module":"forge"},"since":"2026-11-09T20:00:00Z"}`) - st, err = Reader{CandidateState: fakeState{}.read(), VerdictState: fakeState{}.read(), CouldNotRunState: fakeState{"feat/x.0123456789ab": rec}.read()}.Status() - if err != nil { - t.Fatal(err) - } - if c := st.CouldNotRun["feat/x.0123456789ab"]; c.Part != (Part{Node: "g14", Module: "forge"}) { - t.Errorf("could_not_run = %+v, want the check of feat/x naming forge on g14", st.CouldNotRun) - } -} - -// slowBucket wraps a state with a Get that takes delay and counts the values read, the lists and the most Gets in flight. -type slowBucket struct { - vals fakeState - reads, lists atomic.Int64 - inFlight, maxFlight atomic.Int64 -} - -func (b *slowBucket) get(key string) (json.RawMessage, error) { - b.reads.Add(1) - now := b.inFlight.Add(1) - for m := b.maxFlight.Load(); now > m && !b.maxFlight.CompareAndSwap(m, now); m = b.maxFlight.Load() { - } - time.Sleep(time.Millisecond) - b.inFlight.Add(-1) - return b.vals.read().Get(key) -} - -func (b *slowBucket) read() StateRead { - return StateRead{Keys: func() ([]string, error) { b.lists.Add(1); return b.vals.read().Keys() }, Get: b.get} -} - -func (b *slowBucket) Keys() ([]string, error) { return b.read().Keys() } -func (b *slowBucket) Get(key string) (json.RawMessage, error) { return b.get(key) } -func (b *slowBucket) Create(string, []byte) error { return nil } - -// 1827: a read tool lists the keys of a bucket of thousands and reads only the values its answer needs, sixteen at a time, at -// most MaxReads, saying when it cut (on the live shape of 2026-10-26: kept 7990 keys, steps 10034, tries 1000s). -func TestReadToolsReadOnlyWhatTheyNeedInParallelAndSayWhenCut(t *testing.T) { // 1827 - kept := fakeState{} - for i := 0; i < 1800; i++ { - level := map[bool]string{true: "unit", false: "integration"}[i%9 != 0] - k, _ := meshdeliverycheckerclient.KeptKey(level, fmt.Sprintf("%064x", i)) - kept[k] = []byte(`{"v":1}`) - } - previews := fakeState{} - for i := 0; i < 1500; i++ { - repo := map[bool]string{true: repoA, false: repoSDK}[i < 300] - k, _ := meshdeliverycheckerclient.PreviewKey(repo, fmt.Sprintf("%08x%032x", i, 0), trunkA) - previews[k] = []byte(`{"v":1}`) - } - for _, row := range []struct { - name string - call func(*slowBucket) (rows int, cut string, err error) - rows int - reads, lists int64 - cut bool - }{ - {"kept of one key", func(b *slowBucket) (int, string, error) { - m, c, err := Reader{KeptState: b.read()}.Kept("unit", fmt.Sprintf("%064x", 1)) - return len(m), c, err - }, 1, 1, 0, false}, - {"kept of a level", func(b *slowBucket) (int, string, error) { - m, c, err := Reader{KeptState: b.read()}.Kept("integration", "") - return len(m), c, err - }, 200, 200, 1, false}, - {"kept of everything", func(b *slowBucket) (int, string, error) { - m, c, err := Reader{KeptState: b.read()}.Kept("", "") - return len(m), c, err - }, MaxReads, MaxReads, 1, true}, - {"previews of a repository", func(b *slowBucket) (int, string, error) { - p, _, c, err := Reader{PreviewState: b.read()}.Previews(repoSDK, "") - return len(p), c, err - }, 1200, 1000, 1, true}, - {"previews of a repository and a head", func(b *slowBucket) (int, string, error) { - p, _, c, err := Reader{PreviewState: b.read()}.Previews(repoA, fmt.Sprintf("%08x", 7)) - return len(p), c, err - }, 1, 1, 1, false}, - } { - b := &slowBucket{} - b.vals = kept - if strings.HasPrefix(row.name, "previews") { - b.vals = previews - } - start := time.Now() - rows, cut, err := row.call(b) - if err != nil { - t.Fatalf("%s: %v", row.name, err) - } - if rows != min(row.rows, MaxReads) || b.reads.Load() != row.reads || b.lists.Load() != row.lists || (cut != "") != row.cut { - t.Errorf("%s: %d rows, %d reads, %d lists, cut %q; want %d, %d, %d, cut %v", row.name, rows, b.reads.Load(), b.lists.Load(), cut, min(row.rows, MaxReads), row.reads, row.lists, row.cut) - } - if row.reads > 20 && b.maxFlight.Load() < 2 { - t.Errorf("%s: values were read one at a time", row.name) - } - t.Logf("%s: %d values in %v (one after the other: %v)", row.name, b.reads.Load(), time.Since(start), time.Duration(b.reads.Load())*time.Millisecond) - } - - // The status reads the newest steps of a bucket of 1500 first, at most MaxReads, and finds the one that runs. - now := time.Date(2026, 10, 26, 7, 0, 0, 0, time.UTC) - steps := fakeState{} - for i := 0; i < 1500; i++ { - id := fmt.Sprintf("mvo5%04dabcdef", i) - step := buildstep.Step{ID: id, Tool: "t", Node: "g14", State: buildstep.StepPassed} - if i == 1499 { - step.State, step.Started = buildstep.StepRunning, now.Add(-time.Minute) - } - raw, _ := buildstep.EncodeStep(step) - steps["g14."+id] = raw - } - sb := &slowBucket{vals: steps} - st, err := Reader{StepStates: stepStatesOf(map[string]StateRead{"mesh-build-go": sb.read()}), HaveState: fakeState{"g14.mesh-build-go": haveOf(t, nodeengineclient.PhaseRunning)}.read(), - Now: func() time.Time { return now }}.Status() - if err != nil || sb.reads.Load() != MaxReads || len(st.Running) != 1 || sb.maxFlight.Load() < 2 { - t.Errorf("status: %d reads (want %d), running %+v, in flight %d, %v", sb.reads.Load(), MaxReads, st.Running, sb.maxFlight.Load(), err) - } - - // A new try reads the newest TryScan of 1500 ended tries, not all, and still finds the same head asked twice. - tries := fakeState{} - for i := 0; i < 1500; i++ { - raw, _ := encodeTry(Try{ID: fmt.Sprintf("try-%d", 1700000000000000000+i), Repository: repoA, Head: head1, Trunk: trunkA, State: TryPass}) - tries[fmt.Sprintf("try-%d", 1700000000000000000+i)] = raw - } - tb := &slowBucket{vals: tries} - if _, err := AskTry(tb, tryTrunks, TryAsk{Repository: repoA, Head: head2, Trunk: trunkA}, now); err != nil || tb.reads.Load() != TryScan { - t.Errorf("AskTry read %d of 1500 tries (want %d), %v", tb.reads.Load(), TryScan, err) - } -} diff --git a/modules/mesh-delivery-checker/internal/check/renames.go b/modules/mesh-delivery-checker/internal/check/renames.go deleted file mode 100644 index fee28b0f..00000000 --- a/modules/mesh-delivery-checker/internal/check/renames.go +++ /dev/null @@ -1,100 +0,0 @@ -package check - -import ( - "context" - "errors" - "mesh-delivery-checker/rules" - - "git.novox.be/novox/mesh-contracts/go/seats/meshconfig" - "git.novox.be/novox/mesh-sdk/go/catalogue" -) - -// A config value renamed (design 32 *A config value renamed*, DLV-C5): the checker asks the seat mesh-config's verb -// renames, never the module, for every change that brings `renamed-from` or drops one. A holder that does not serve the -// verb refuses `renamed-from`, naming that; while a rename's window is open, dropping its `renamed-from` is refused, -// naming the nodes holding it open; a check that cannot ask fails, saying so. - -// RenamesSeat is the verb the checker asks, as its manifest's `invokes` names it. -var RenamesSeat = rules.RenamesSeat - -// ErrRenamesNotServed is the answer of Renames when the seat's holder serves no verb renames. -var ErrRenamesNotServed = errors.New("the holder of the seat " + meshconfig.Seat + " does not serve its verb " + meshconfig.VerbRenames) - -// Renames asks the seat mesh-config's verb renames for a module's open renames. -type Renames interface { - Renames(ctx context.Context, module string) (meshconfig.RenamesAnswer, error) -} - -// renameChange is what a pull request's head does to a module's `renamed-from` against the trunk: the declarations it -// brings (key from old name) and the ones it drops (key, old name). -type renameChange struct { - brought, dropped map[string]string -} - -// renamesOf compares a module's config declarations at the trunk and at the head. -func renamesOf(was, now catalogue.Manifest) renameChange { - rc := renameChange{brought: map[string]string{}, dropped: map[string]string{}} - for key, d := range now.Settings { - if d.RenamedFrom != "" && was.Settings[key].RenamedFrom != d.RenamedFrom { - rc.brought[key] = d.RenamedFrom - } - } - for key, d := range was.Settings { - if d.RenamedFrom != "" && now.Settings[key].RenamedFrom != d.RenamedFrom { - rc.dropped[key] = d.RenamedFrom - } - } - return rc -} - -// judgeRenames records, of each module a member changes that brings or drops a `renamed-from`, what it brings and drops -// and how the seat mesh-config's verb renames answered for it, as a fact the rules judge (rules.JudgeRenames): a rename -// whose value cannot be moved, and the drop of one whose window is open, fail the check (design 32). -func (st *state) judgeRenames(ctx context.Context) { - if st.c.Try != nil { - return - } - for _, p := range st.c.Pulls { - for _, module := range p.Modules { - r := rules.Renames{Module: module, Key: pullKey(p)} - was, now, ok, err := st.manifestPair(ctx, p, module) - if err != nil { - r.Unread = err.Error() - st.facts = append(st.facts, rules.Step{Repository: p.Repository, Number: p.Number, Renames: &r}) - continue - } - if !ok { - was = catalogue.Manifest{} // a module new on the pull request brings every rename it declares - if now, ok = st.headManifest(ctx, p, module); !ok { - continue - } - } - rc := renamesOf(was, now) - if len(rc.brought) == 0 && len(rc.dropped) == 0 { - continue - } - r.Brought, r.Dropped = rc.brought, rc.dropped - if st.j.Renames != nil { - answer, err := st.j.Renames.Renames(ctx, module) - switch { - case err != nil: - r.Unasked, r.NotServed = err.Error(), errors.Is(err, ErrRenamesNotServed) - default: - r.Answer = &answer - } - } - st.facts = append(st.facts, rules.Step{Repository: p.Repository, Number: p.Number, Renames: &r}) - } - } -} - -func (st *state) headManifest(ctx context.Context, p Pull, module string) (catalogue.Manifest, bool) { - if digest := p.Fps[module].Manifest; digest != "" && st.j.Read != nil { - if st.j.Manifests != nil && st.j.Manifests.ManifestDigests()[module] == digest { - return catalogue.Manifest{}, false // unchanged - } - m, err := st.j.Read.Manifest(ctx, digest) - return m, err == nil - } - return catalogue.Manifest{}, false -} diff --git a/modules/mesh-delivery-checker/internal/check/requests.go b/modules/mesh-delivery-checker/internal/check/requests.go deleted file mode 100644 index a18ba5dc..00000000 --- a/modules/mesh-delivery-checker/internal/check/requests.go +++ /dev/null @@ -1,299 +0,0 @@ -package check - -import ( - "bytes" - "compress/gzip" - "context" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "encoding/json" - "fmt" - "io" - "sort" - "strings" - "time" -) - -// The composition requests a check sends (issue 1921, notes 66-67): the request the checker sends the composer for one -// node, the checking program's whole input of a composition, is kept in the checker's own state RequestsStateName, so a -// session reproduces a check's composition exactly. The checker is a foundation part (novox/hq ADR 0619 §1-3), so its -// kept data is a section of its manifest's old form, here `state`, and not an object store asked in `requires`. -// -// **What bounds it.** A request is the node-engine's whole composition input of one node, 0.7 to 0.8 MB as JSON and -// growing with the mesh. A state's value holds at most 256 KiB (kvlimit.ModuleStateValueBytes, headers included), and -// the compressed request already passed it (issue 1966: 300127 bytes), so it is kept gzip-compressed in pieces: the key -// of the check and node holds a small document naming the request's digest, size and number of pieces, and each piece is -// a value of its own under RequestChunkKey, of at most RequestChunkBytes. The kept data is the checker's, a foundation -// part's, so it stays in the old section `state` (ADR 0619 §2) and is read through the tool runner's state read, which -// serves no object store of the old sections. The manifest's ttl-seconds is the lifetime (3 days) of the pointer and of -// every piece and its max-mib the most the state holds (256): the bus drops a value past the one and refuses a put past the -// other, so nothing waits on a timer here; a state that is full says so in the check's words, which name RequestsDropTool. A check kept again overwrites the key; -// a request whose pieces cannot all be put is refused naming the size (never dropped, never half kept: the pointer is -// put after its pieces). -const ( - // RequestsStateName is the checker's state of kept requests and RequestsBucket its bucket. - RequestsStateName = "compositions" - // RequestsReadTool is the tool that reads a kept request. - RequestsReadTool = "checker_composition_requests" - // RequestsDropTool is the tool that drops a check's kept requests by hand (a state that is full is freed with it). - RequestsDropTool = "checker_composition_requests_drop" - // RequestChunkBytes is the most compressed bytes one piece holds: base64 of it, in its document, stays well under - // the state's 256 KiB value. - RequestChunkBytes = 128 << 10 -) - -// KeptRequest is the pointer to a request as the state holds it: whose it is, and what its pieces make. -type KeptRequest struct { - V int `json:"v"` - Check string `json:"check"` - Node string `json:"node"` - KeptAt time.Time `json:"kept_at"` - // Size and Digest are the request's, uncompressed: its bytes and their sha256. - Size int `json:"size"` - Digest string `json:"digest"` - // Pieces is how many pieces (RequestChunkKey of the digest, 0 to Pieces-1) make the request's gzip bytes. - Pieces int `json:"pieces"` -} - -// KeptPiece is one piece of a request's gzip bytes, base64-encoded. -type KeptPiece struct { - V int `json:"v"` - Digest string `json:"digest"` - Index int `json:"index"` - Gzip string `json:"gzip"` -} - -// isPieceKey is whether a key is a piece's: under pieces/ and a sha256 digest, which no check's key (group.heads/node) is. -func isPieceKey(k string) bool { - rest, ok := strings.CutPrefix(k, "pieces/") - if !ok { - return false - } - digest, _, _ := strings.Cut(rest, "/") - return len(digest) == 64 -} - -// RequestChunkKey is the key of a request's piece: under the request's digest, so a request kept again for the same -// bytes writes the same pieces. -func RequestChunkKey(digest string, index int) string { - return fmt.Sprintf("pieces/%s/%d", digest, index) -} - -// RequestKey is the key a check's request to a node is kept under: the check's key (group.heads) and the node. -func RequestKey(key, node string) string { return key + "/" + node } - -// RequestPutter writes a value of the state, replacing one of that key. -type RequestPutter interface { - Put(ctx context.Context, key string, value []byte) (uint64, error) -} - -// RequestKeeper keeps the requests of a check. -type RequestKeeper struct { - Store RequestPutter - Now func() time.Time -} - -// Keep stores body under the check's key and the node. An error says why it could not, for the verdict's words. -func (k RequestKeeper) Keep(ctx context.Context, key, node string, body []byte) error { - var packed bytes.Buffer - zw := gzip.NewWriter(&packed) - if _, err := zw.Write(body); err != nil { - return fmt.Errorf("the composition request of check %s to %s could not be compressed: %w", key, node, err) - } - if err := zw.Close(); err != nil { - return fmt.Errorf("the composition request of check %s to %s could not be compressed: %w", key, node, err) - } - now := time.Now - if k.Now != nil { - now = k.Now - } - sum := sha256.Sum256(body) - digest := hex.EncodeToString(sum[:]) - pieces := (packed.Len() + RequestChunkBytes - 1) / RequestChunkBytes - fail := func(err error) error { - return fmt.Errorf("the composition request of check %s to %s (%d bytes, %d compressed in %d pieces) could not be kept in the state %s: %w (when the state is full, free it by dropping the kept requests of a check no longer read, with the tool %s)", - key, node, len(body), packed.Len(), pieces, RequestsStateName, err, RequestsDropTool) - } - for i := 0; i < pieces; i++ { - end := min((i+1)*RequestChunkBytes, packed.Len()) - doc, err := json.Marshal(KeptPiece{V: 2, Digest: digest, Index: i, Gzip: base64.StdEncoding.EncodeToString(packed.Bytes()[i*RequestChunkBytes : end])}) - if err != nil { - return err - } - if _, err := k.Store.Put(ctx, RequestChunkKey(digest, i), doc); err != nil { - return fail(err) - } - } - doc, err := json.Marshal(KeptRequest{V: 2, Check: key, Node: node, KeptAt: now().UTC(), Size: len(body), Digest: digest, Pieces: pieces}) - if err != nil { - return err - } - if _, err := k.Store.Put(ctx, RequestKey(key, node), doc); err != nil { - return fail(err) - } - return nil -} - -// ReadRequests answers the kept requests: with a check and a node, that request whole; with a check, the nodes it kept -// one for; with neither, every kept request. A node without a check is refused. get is the state's value of a key. -func ReadRequests(s StateRead, key, node string) (any, error) { - if s.Keys == nil || s.Get == nil { - return nil, fmt.Errorf("the state %s cannot be read here", RequestsStateName) - } - if node != "" && key == "" { - return nil, fmt.Errorf("a node is asked for with the check's key (group.heads) of the request") - } - if node != "" { - raw, err := s.Get(RequestKey(key, node)) - if err != nil { - return nil, err - } - if len(raw) == 0 { - return nil, fmt.Errorf("no composition request of check %s to %s is kept (none was sent, or it is past its lifetime)", key, node) - } - kept, body, err := unpackRequest(s, raw) - if err != nil { - return nil, fmt.Errorf("the kept request %s: %w", RequestKey(key, node), err) - } - return map[string]any{"check": kept.Check, "node": kept.Node, "size": kept.Size, "digest": kept.Digest, "kept_at": kept.KeptAt, "request": json.RawMessage(body)}, nil - } - keys, err := s.Keys() - if err != nil { - return nil, err - } - sort.Strings(keys) - listed := []map[string]any{} - for _, k := range keys { - if key != "" && !strings.HasPrefix(k, key+"/") { - continue - } - if isPieceKey(k) { - continue // a piece of a request, not a request: never read here - } - raw, err := s.Get(k) - if err != nil { - return nil, err - } - var kept KeptRequest - if err := json.Unmarshal(raw, &kept); err != nil { - listed = append(listed, map[string]any{"key": k, "unreadable": err.Error()}) - continue - } - listed = append(listed, map[string]any{"check": kept.Check, "node": kept.Node, "size": kept.Size, "digest": kept.Digest, "kept_at": kept.KeptAt}) - } - return map[string]any{"kept": listed}, nil -} - -// unpackRequest reads a kept pointer's pieces and the request's bytes, which must match the digest they were kept with. -func unpackRequest(s StateRead, raw []byte) (KeptRequest, []byte, error) { - var kept KeptRequest - if err := json.Unmarshal(raw, &kept); err != nil { - return kept, nil, fmt.Errorf("is no kept request: %w", err) - } - if kept.V != 2 { - return kept, nil, fmt.Errorf("is a kept request of version %d, which this reader does not read (it reads version 2; an older one is past its lifetime within 3 days)", kept.V) - } - var packed []byte - for i := 0; i < kept.Pieces; i++ { - raw, err := s.Get(RequestChunkKey(kept.Digest, i)) - if err != nil { - return kept, nil, err - } - var piece KeptPiece - if err := json.Unmarshal(raw, &piece); err != nil || len(raw) == 0 { - return kept, nil, fmt.Errorf("lacks its piece %d of %d (past its lifetime, or never kept)", i, kept.Pieces) - } - part, err := base64.StdEncoding.DecodeString(piece.Gzip) - if err != nil { - return kept, nil, fmt.Errorf("holds no base64 in its piece %d: %w", i, err) - } - packed = append(packed, part...) - } - zr, err := gzip.NewReader(bytes.NewReader(packed)) - if err != nil { - return kept, nil, fmt.Errorf("holds no gzip: %w", err) - } - body, err := io.ReadAll(zr) - if err != nil { - return kept, nil, fmt.Errorf("holds no complete gzip: %w", err) - } - if sum := sha256.Sum256(body); hex.EncodeToString(sum[:]) != kept.Digest { - return kept, nil, fmt.Errorf("does not match the digest it was kept with") - } - return kept, body, nil -} - -// StateDrop is the state of kept requests as the drop tool needs it: its keys, a value, and a key removed. -type StateDrop struct { - StateRead - Delete func(key string) error -} - -// DropRequests drops the requests kept for a check, after record (the hand act, recorded first: a drop that is not -// recorded is not made), and answers what it dropped: the nodes, and the pieces. A piece another kept request still names -// (the same request kept for another check has the same digest) stays. A check naming no kept request is refused. -func DropRequests(s StateDrop, key, why string, record func(what string) error) (any, error) { - if strings.TrimSpace(key) == "" || strings.TrimSpace(why) == "" { - return nil, fmt.Errorf("drop takes check (its key, group.heads) and why") - } - if s.Keys == nil || s.Get == nil || s.Delete == nil { - return nil, fmt.Errorf("the state %s cannot be changed here", RequestsStateName) - } - keys, err := s.Keys() - if err != nil { - return nil, err - } - sort.Strings(keys) - var drop []string - kept := map[string]bool{} // digests the requests that stay name - dropping := map[string]bool{} - for _, k := range keys { - if isPieceKey(k) { - continue - } - raw, err := s.Get(k) - if err != nil { - return nil, err - } - var r KeptRequest - if len(raw) == 0 || json.Unmarshal(raw, &r) != nil { - continue - } - if strings.HasPrefix(k, key+"/") { - drop = append(drop, k) - dropping[r.Digest] = true - continue - } - kept[r.Digest] = true - } - if len(drop) == 0 { - return nil, fmt.Errorf("no composition request of check %s is kept (none was sent, or it is past its lifetime): nothing was dropped", key) - } - if err := record(fmt.Sprintf("dropped the %d kept composition requests of check %s (%s)", len(drop), key, RequestsStateName)); err != nil { - return nil, fmt.Errorf("the hand act was not recorded, so nothing was dropped: %w", err) - } - var pieces int - for _, k := range drop { - if err := s.Delete(k); err != nil { - return nil, fmt.Errorf("dropping %s: %w", k, err) - } - } - for _, k := range keys { - if !isPieceKey(k) { - continue - } - digest := strings.Split(strings.TrimPrefix(k, "pieces/"), "/")[0] - if dropping[digest] && !kept[digest] { - if err := s.Delete(k); err != nil { - return nil, fmt.Errorf("dropping %s: %w", k, err) - } - pieces++ - } - } - nodes := make([]string, len(drop)) - for i, k := range drop { - nodes[i] = strings.TrimPrefix(k, key+"/") - } - return map[string]any{"check": key, "dropped_requests": nodes, "dropped_pieces": pieces, "why": why}, nil -} diff --git a/modules/mesh-delivery-checker/internal/check/results.go b/modules/mesh-delivery-checker/internal/check/results.go deleted file mode 100644 index d3accb7c..00000000 --- a/modules/mesh-delivery-checker/internal/check/results.go +++ /dev/null @@ -1,43 +0,0 @@ -package check - -import ( - "mesh-delivery-checker/rules" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// The shapes of what the build modules' steps answer, as their code writes them (mesh-catalog modules/mesh-build-go -// cmd/mesh-build-go levels.go TestResult, digest.go DigestResult, fetch.go FetchResult; modules/mesh-build-node -// cmd/mesh-build-node check.go TestResult, fetch.go FetchResult) with the fields the fetch step adds for a merge (ADR 0484 -// clause 3). Only the fields the checker reads are named; the rest is ignored. - -// Fetched is the answer of a build module's fetch step, whole: the Delivery SDK's FetchAnswer, which a check answer keeps -// (B2g; the build seats' part FetchAnswer): the workspace, the merge preview with its conflicts, changed paths, programs and -// trees. A conflict is an answer. -type Fetched = buildstep.FetchAnswer - -// ProgramFile is a changed file that is a compiled program (rules.ProgramFile). -type ProgramFile = rules.ProgramFile - -// The test step's answer is read by the judging rules (milestone 47/B0); these name their shapes here. -type ( - Failure = rules.Failure - TestTime = rules.TestTime - Tested = rules.Tested - GoPackage = rules.GoPackage -) - -// Digested is the answer of the Go build module's digest step: one digest per package that has tests at the level, by import -// path. -type Digested struct { - // Beside are the lines ` ` of the siblings the digest folded in (DigestVersion 3, lead decision L5), - // sorted; absent when the workspace has none or the build module folds none in. - Beside []string `json:"beside,omitempty"` - Level string `json:"level"` - Packages map[string]string `json:"packages"` - WithoutTests []string `json:"without_tests,omitempty"` - // JudgedBy is the program that ran the digest, as Tested.JudgedBy says. - JudgedBy string `json:"judged_by,omitempty"` - // Needs are the packages whose tests need something of the node at this level (issue 890). - Needs []buildstep.PackageNeeds `json:"needs,omitempty"` -} diff --git a/modules/mesh-delivery-checker/internal/check/seatdefs.go b/modules/mesh-delivery-checker/internal/check/seatdefs.go deleted file mode 100644 index 94e92cc9..00000000 --- a/modules/mesh-delivery-checker/internal/check/seatdefs.go +++ /dev/null @@ -1,41 +0,0 @@ -package check - -import ( - "context" - "mesh-delivery-checker/rules" -) - -// A pull request whose head's seat definition does not parse fails its check, naming the seat and where it lives (design -// 26; the lead's ruling on A2i's finding 1): the indexer keeps such a definition as the pull request's entry of its state -// seat-definitions with `unparsed` set, and cannot refuse the manifest itself, whose digest the trunk may share. - -// UnparsedSeat is one seat definition of a pull request's head that does not parse (rules.UnparsedSeat). -type UnparsedSeat = rules.UnparsedSeat - -// SeatDefinitions reads the indexer's seat definitions of one pull request (its state seat-definitions, through its -// first view, DLV-M2). -type SeatDefinitions interface { - Unparsed(ctx context.Context, repository string, pull int) ([]UnparsedSeat, error) -} - -// refuseUnparsed records, of each pull request, the indexer's seat definitions of its head that do not parse, or why -// they cannot be read, as a fact the rules judge (rules.JudgeUnparsed). -func (st *state) refuseUnparsed(ctx context.Context) { - if st.j.SeatDefinitions == nil || st.c.Try != nil { - return - } - for _, p := range st.c.Pulls { - u := rules.Unparsed{Key: pullKey(p)} - bad, err := st.j.SeatDefinitions.Unparsed(ctx, p.Repository, p.Number) - if err != nil { - u.Unread = err.Error() - } - u.Seats = bad - if u.Unread != "" || len(u.Seats) > 0 { - st.facts = append(st.facts, rules.Step{Repository: p.Repository, Number: p.Number, Unparsed: &u}) - } - } -} - -// SeatDefinitionsMachine names what refused a seat definition in a verdict's failure. -const SeatDefinitionsMachine = rules.SeatDefinitionsMachine diff --git a/modules/mesh-delivery-checker/internal/check/series.go b/modules/mesh-delivery-checker/internal/check/series.go deleted file mode 100644 index 1a6d91db..00000000 --- a/modules/mesh-delivery-checker/internal/check/series.go +++ /dev/null @@ -1,150 +0,0 @@ -package check - -import ( - "context" - "fmt" - "slices" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-sdk/go/catalogue" -) - -// A change of a package series is named in the verdict, so the review of the change sees it (design 32 *A package, its -// series*; DLV-C4): for each module a pull request touches, every artifact both its trunk manifest and its head's -// manifest declare whose series differs, as `/ series → `. An artifact that names none -// is in catalogue.DefaultSeries. A manifest that cannot be read is said in the same words, never left out. - -// seriesChanges names, on the case per pull request, each change of an artifact's series the pull request makes. -func (st *state) seriesChanges(ctx context.Context) { - for _, p := range st.c.Pulls { - var words []string - var changes []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem - for _, module := range p.Modules { - was, now, ok, err := st.manifestPair(ctx, p, module) - if err != nil { - words = append(words, fmt.Sprintf("%s: its series not compared (%v)", module, err)) - continue - } - if ok { - moved := seriesMoved(module, was, now) - changes = append(changes, moved...) - for _, c := range moved { - words = append(words, seriesLine(c)) - } - } - } - if len(words) > 0 { - st.c.series(pullKey(p), words, changes) - } - } -} - -// manifestPair is a touched module's trunk manifest and its manifest at the pull request's head: the head's by the digest -// its candidate names, else read from the forge at the head. ok is false when the module is new on the pull request, -// unchanged, or not read here. -func (st *state) manifestPair(ctx context.Context, p Pull, module string) (was, now catalogue.Manifest, ok bool, err error) { - if st.j.Read == nil || st.j.Manifests == nil { - return was, now, false, nil - } - trunk := st.j.Manifests.ManifestDigests()[module] - digest := p.Fps[module].Manifest - if trunk == "" || digest == trunk { - return was, now, false, nil - } - if was, err = st.j.Read.Manifest(ctx, trunk); err != nil { - return was, now, false, fmt.Errorf("the trunk's manifest not read: %w", err) - } - switch { - case digest != "": - if now, err = st.j.Read.Manifest(ctx, digest); err != nil { - return was, now, false, fmt.Errorf("the head's manifest not read: %w", err) - } - case st.j.Forge != nil: - var found bool - if now, _, found, err = st.manifestAtHead(ctx, p, module); err != nil || !found { - return was, now, false, err - } - default: - return was, now, false, nil - } - return was, now, true, nil -} - -// seriesLine is a series change as the status line names it: `/ series → `. -func seriesLine(c meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem) string { - return fmt.Sprintf("%s/%s series %s → %s", c.Module, c.Artifact, c.From, c.To) -} - -// seriesMoved are the artifacts of module whose series the head's manifest changes from the trunk's, by artifact. An -// artifact new on the head is no series change (the lead's ruling): it has no series on the trunk. -func seriesMoved(module string, was, now catalogue.Manifest) []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem { - if was.Build == nil || now.Build == nil { - return nil - } - before := map[string]string{} - for _, a := range was.Build.Artifacts { - before[a.Name] = a.SeriesOf() - } - var out []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem - for _, a := range now.Build.Artifacts { - if old, ok := before[a.Name]; ok && old != a.SeriesOf() { - out = append(out, meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem{Module: module, Artifact: a.Name, From: old, To: a.SeriesOf()}) - } - } - slices.SortFunc(out, func(a, b meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem) int { - return strings.Compare(a.Artifact, b.Artifact) - }) - return out -} - -// series keeps, of a pull request (pullKey), the words of the series changes it makes and the changes themselves. -func (c *Case) series(key string, words []string, changes []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem) { - c.notesMu.Lock() - defer c.notesMu.Unlock() - if c.seriesOf == nil { - c.seriesOf, c.seriesChanges = map[string][]string{}, map[string][]meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem{} - } - c.seriesOf[key], c.seriesChanges[key] = words, changes -} - -// SeriesChanges are the series changes a pull request (pullKey) makes, as the verdict and its event name them. -func (c *Case) SeriesChanges(key string) []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem { - c.notesMu.Lock() - defer c.notesMu.Unlock() - return slices.Clone(c.seriesChanges[key]) -} - -// allSeries are the series changes of every pull request of the case, each module's artifact once, by module and -// artifact: what the verdict names (meshdeliverychecker.VerdictsByGroupHeadsValue.Series). -func (c *Case) allSeries() []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem { - var out []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem - seen := map[string]bool{} - for _, p := range c.Pulls { - for _, s := range c.SeriesChanges(pullKey(p)) { - if k := s.Module + "/" + s.Artifact; !seen[k] { - seen[k] = true - out = append(out, s) - } - } - } - slices.SortFunc(out, func(a, b meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem) int { - return strings.Compare(a.Module+"/"+a.Artifact, b.Module+"/"+b.Artifact) - }) - return out -} - -// Series are the series changes a pull request (pullKey) makes, as the check named them; none when it makes none. -func (c *Case) Series(key string) []string { - c.notesMu.Lock() - defer c.notesMu.Unlock() - return slices.Clone(c.seriesOf[key]) -} - -// seriesWords is a pull request's series changes for its status line. -func seriesWords(c *Case, p Pull) string { - if c == nil { - return "" - } - return strings.Join(c.Series(pullKey(p)), ", ") -} diff --git a/modules/mesh-delivery-checker/internal/check/store.go b/modules/mesh-delivery-checker/internal/check/store.go deleted file mode 100644 index 6e7dbe22..00000000 --- a/modules/mesh-delivery-checker/internal/check/store.go +++ /dev/null @@ -1,24 +0,0 @@ -package check - -import ( - "context" - "errors" -) - -// ErrConflict is what a KV answers when a Create finds the key or an Update finds another revision than the one given. -var ErrConflict = errors.New("the key exists or changed") - -// KV is one of the checker's buckets: read, create and compare-and-set, each write answering the key's new revision. Only -// the checker's credential writes them (ADR 0444 clause 5, ADR 0484 clause 2). -type KV interface { - Get(ctx context.Context, key string) (value []byte, revision uint64, found bool, err error) - Create(ctx context.Context, key string, value []byte) (uint64, error) - Update(ctx context.Context, key string, value []byte, revision uint64) (uint64, error) - // Keys are every key of the bucket. - Keys(ctx context.Context) ([]string, error) -} - -// Deleter is a KV that can take a key away; a KV that cannot leaves it. -type Deleter interface { - Delete(ctx context.Context, key string) error -} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/README b/modules/mesh-delivery-checker/internal/check/testdata/captured/README deleted file mode 100644 index f2b348a3..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/README +++ /dev/null @@ -1,17 +0,0 @@ -go-test-failing.json, go-test-slow.json, go-test-empty.json and go-digest.json are what mesh-catalog's mesh-build-go answers -(TestResult and DigestResult, cmd/mesh-build-go levels.go and digest.go), marshalled by the module's own code: a throwaway -test beside the module's test_test.go and digest_test.go (workspaceFor + runUnit on the fixtures testdata/captured/failing, -slow and empty, and digestFixture + digests on testdata/repos/digest) at mesh-catalog origin/main cdbdb474, captured on -2026-10-21 for issue 1679 and not kept there. The fixtures' package names are the build module's own (fixture/failing/bad...). - -go-fetch-clean.json and go-fetch-conflict.json are what mesh-build-go's fetch step ends with (FetchResult, cmd/mesh-build-go -fetch.go and preview.go) for a fetch with a base, the Result bytes of the step in mesh-catalog's own tests -TestFetchWithABaseMergesAndAnswersThePreview and TestFetchWithAConflictEndsPassedAndNamesTheFiles (preview_test.go), copied -into a throwaway test that wrote them out, at mesh-catalog feat/r4c5-checker d5804927 (the git commands are the test's fake, -so the shas are its constants; the shape and the field names are the module's own marshalling). node-fetch-clean.json is the -FetchResult json.Marshal of mesh-build-node's fetch (fetch.go, preview.go) in its test TestFetchWithABaseMergesAndAnswersThePreview -(cmd/mesh-build-node/preview_test.go) at the same commit. Captured on 2026-10-21 for issue 1679. Both clean fetches carry `"programs":[]`, which a merging fetch of the build modules answers since issue 1577 (mesh-sdk buildstep.MergeInto's Programs), added by hand to the captured bytes: a fixture without it is an older build module's, and its line warns that no compiled program is refused. - -forge-get-file-go-mod.json is the answer of the forge's gitea_get_file (mesh-catalog modules/gitea, tools/index.ts) for modules/mesh-delivery-builder/go.mod of -novox/mesh-delivery at main, called through the mesh on 2026-10-21 for issue 1624; the checker's whole-module test answers its content through the seat -git's verb file (milestone 47/G W6.14). diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/forge-get-file-go-mod.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/forge-get-file-go-mod.json deleted file mode 100644 index a591e7e9..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/forge-get-file-go-mod.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "file": { - "content": "module mesh-delivery-builder\n\ngo 1.26.0\n\nrequire (\n\tgit.novox.be/novox/mesh-sdk/go v0.1.14-0.20261021100209-cb54756c3865\n\tgithub.com/nats-io/nats-server/v2 v2.11.17\n\tgithub.com/nats-io/nats.go v1.54.0\n)\n\nrequire (\n\tgithub.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op // indirect\n\tgithub.com/google/go-tpm v0.9.8 // indirect\n\tgithub.com/klauspost/compress v1.20.0 // indirect\n\tgithub.com/minio/highwayhash v1.0.4 // indirect\n\tgithub.com/nats-io/jwt/v2 v2.8.1 // indirect\n\tgithub.com/nats-io/nkeys v0.4.16 // indirect\n\tgithub.com/nats-io/nuid v1.0.1 // indirect\n\tgolang.org/x/crypto v0.57.0 // indirect\n\tgolang.org/x/sys v0.48.0 // indirect\n\tgolang.org/x/time v0.15.0 // indirect\n)\n", - "path": "modules/mesh-delivery-builder/go.mod", - "ref": "main", - "sha": "4431597e2e4d2a26b59006f9f8c54659a964ec68", - "size": 691 - } -} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-digest.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/go-digest.json deleted file mode 100644 index 50f848bc..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-digest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "level": "unit", - "packages": { - "fixture/digest/a": "c288afe6252c38d9e7286ecb5f28b3c961780871fcc253670dcc3151c11c1df2", - "fixture/digest/c": "11abf5f32f0f12caafd76c565e4c2c2f3bf2e3ce6c2c7fcb6c2264a06db40087" - }, - "without_tests": [ - "fixture/digest/b", - "fixture/digest/d" - ] -} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-clean.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-clean.json deleted file mode 100644 index a87c2221..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-clean.json +++ /dev/null @@ -1 +0,0 @@ -{"workspace":"mvii1iwu5414e4","commit":"0123456789abcdef0123456789abcdef01234567","modules":["."],"base":"abcdef0123456789abcdef0123456789abcdef01","merge":"fedcba9876543210fedcba9876543210fedcba98","changed":["a.go","modules/m/main.go"],"programs":[],"trees":{"modules/m":{"tree":"1111111111111111111111111111111111111111","manifest":"ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356","locks":{"go.sum":"c5fc83c01e92404452b986527d239140ccf9a48b88e0c268fbf38c2e1429e9c9"}}}} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-conflict.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-conflict.json deleted file mode 100644 index e1d8a999..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-fetch-conflict.json +++ /dev/null @@ -1 +0,0 @@ -{"workspace":"mvii1iwz5050eb","commit":"0123456789abcdef0123456789abcdef01234567","modules":["."],"base":"abcdef0123456789abcdef0123456789abcdef01","conflicts":["a.go","sub/b.go"]} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-empty.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-empty.json deleted file mode 100644 index daee148b..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-empty.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "level": "unit", - "passed": true, - "why": "the repository has no tests at the unit level", - "no_tests": true, - "tests": 0, - "skipped": 0, - "packages": [ - { - "dir": ".", - "package": "fixture/empty", - "passed": true, - "elapsed": 0, - "tests": 0, - "no_tests": true - } - ], - "elapsed": 0, - "bound": 5, - "over_bound": false -} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-failing.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-failing.json deleted file mode 100644 index 2f6d90b0..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-failing.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "level": "unit", - "passed": false, - "why": "1 failed: fixture/failing/bad TestThreeIsFour", - "tests": 2, - "skipped": 0, - "packages": [ - { - "dir": ".", - "package": "fixture/failing/bad", - "passed": false, - "elapsed": 0.003, - "tests": 1 - }, - { - "dir": ".", - "package": "fixture/failing/good", - "passed": true, - "elapsed": 0.002, - "tests": 1 - } - ], - "elapsed": 0.003, - "bound": 5, - "slowest": [ - { - "package": "fixture/failing/bad", - "test": "TestThreeIsFour", - "elapsed": 0 - }, - { - "package": "fixture/failing/good", - "test": "TestTwo", - "elapsed": 0 - } - ], - "failed": [ - { - "package": "fixture/failing/bad", - "test": "TestThreeIsFour", - "output": " bad_test.go:7: Three() = 3, want 4\n--- FAIL: TestThreeIsFour (0.00s)" - } - ], - "over_bound": false -} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-slow.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-slow.json deleted file mode 100644 index aa6e5754..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/go-test-slow.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "level": "unit", - "passed": true, - "tests": 2, - "skipped": 0, - "packages": [ - { - "dir": ".", - "package": "fixture/slow", - "passed": true, - "elapsed": 0.065, - "tests": 2 - } - ], - "elapsed": 0.065, - "bound": 5, - "slowest": [ - { - "package": "fixture/slow", - "test": "TestTakesAWhile", - "elapsed": 0.06 - }, - { - "package": "fixture/slow", - "test": "TestQuick", - "elapsed": 0 - } - ], - "over_bound": false -} diff --git a/modules/mesh-delivery-checker/internal/check/testdata/captured/node-fetch-clean.json b/modules/mesh-delivery-checker/internal/check/testdata/captured/node-fetch-clean.json deleted file mode 100644 index 55ecfeca..00000000 --- a/modules/mesh-delivery-checker/internal/check/testdata/captured/node-fetch-clean.json +++ /dev/null @@ -1 +0,0 @@ -{"workspace":"mvii1sxt979f67","commit":"0123456789abcdef0123456789abcdef01234567","modules":["modules/m"],"installed":[],"refused":[],"base":"abcdef0123456789abcdef0123456789abcdef01","merge":"0123456789abcdef0123456789abcdef01234567","changed":["modules/m/package.json"],"programs":[],"trees":{"modules/m":{"tree":"0123456789abcdef0123456789abcdef01234567","manifest":"0581b699d9d05517e69b21f5cedbeb2eee8aba2b205280b561be731594d7feef"}}} diff --git a/modules/mesh-delivery-checker/internal/check/trunkview.go b/modules/mesh-delivery-checker/internal/check/trunkview.go deleted file mode 100644 index d4f4f13d..00000000 --- a/modules/mesh-delivery-checker/internal/check/trunkview.go +++ /dev/null @@ -1,31 +0,0 @@ -package check - -import ( - "encoding/json" - "fmt" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" -) - -// TrunkVerb is the key of the seat verb the trunk heads are asked by (design 47 G §197). -const TrunkVerb = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbRevision - -// TrunkHeads reads the trunk head of every repository out of the seat mesh-catalog's answer of `revision`. A candidate's -// revision is no trunk's and is refused. -func TrunkHeads(raw json.RawMessage) (map[string]string, error) { - var a meshcatalog.RevisionAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf("the catalog half's revision does not read: %w", err) - } - if a.Revision == nil { - return nil, fmt.Errorf("the catalog half's revision answers no revision (none-yet: %v)", a.NoneYet) - } - if a.Revision.Kind != "trunk" { - return nil, fmt.Errorf("the catalog half's revision %d is a %q revision, not a trunk's", a.Revision.Revision, a.Revision.Kind) - } - heads := map[string]string{} - for _, h := range a.Revision.Trunk { - heads[h.Repository] = h.Commit - } - return heads, nil -} diff --git a/modules/mesh-delivery-checker/internal/check/try.go b/modules/mesh-delivery-checker/internal/check/try.go deleted file mode 100644 index 9b35b4b2..00000000 --- a/modules/mesh-delivery-checker/internal/check/try.go +++ /dev/null @@ -1,852 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "regexp" - "slices" - "sort" - "strconv" - "strings" - "sync" - "time" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// A try is a pushed head judged by the checker as a pull request's head is, before its pull request is opened (ADR 0501 -// §5; issue 686's `mesh-controller.try`, which calls these tools from R4e): the head merged onto its trunk, the unit and the -// integration level through the build modules. It owes the forge nothing (no status, no preview) and writes no verdict; its -// state is the value of its key in the checker's state tries. - -// The try's tools and state. -const ( - TryTool = "checker_try" - TryReadTool = "checker_try_read" - TryEndTool = "checker_try_end" - // TriesTool lists the tries that wait or run (OpenTries). - TriesTool = "checker_tries" - // TriesState is the checker's state of tries: the bucket mesh-delivery-checker_tries, keys try-. - TriesState = "tries" - // MaxTries and MaxTriesWaiting are checked when a try is asked, mesh-wide: a new try is refused while MaxTries tries run - // on a build node or MaxTriesWaiting wait for one (queued, or their asks not yet taken by a node). It is no bound on - // what runs later: tries let in while waiting may later all run at once, and each node's build capacity bounds what - // runs on it. A try waiting behind the seat's other asks holds no node, so it no longer blocks the next try (issue - // 1890: at 19:53 on 2026-10-26 four tries sat queued behind 44 checks for up to 47 minutes and no fifth could be asked). - MaxTries = 4 - MaxTriesWaiting = 8 - // TryScan is how many of the newest tries a new ask reads to find the ones that wait or run (issue 1827). - TryScan = 64 - // TryKeep is how long an ended try's key is kept before the checker removes it. - TryKeep = 7 * 24 * time.Hour -) - -// The states of a try: asked and waiting, running, and its end. -const ( - TryQueued = "queued" - TryRunning = "running" - TryPass = "pass" - TryFail = "fail" - TryError = "error" -) - -var ( - tryHeadOK = regexp.MustCompile(`^([0-9a-f]{40}|[0-9a-f]{64})$`) - tryTestsOK = regexp.MustCompile(`^[A-Za-z0-9_^$|().*+?/\[\]-]+$`) - tryRepoOK = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]*/[A-Za-z0-9][A-Za-z0-9._-]*$`) - tryTrunkOK = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._/-]*$`) -) - -// Try is the value of a tries key. -type Try struct { - V int `json:"v"` - ID string `json:"id"` - // Repository, Head, Trunk and Branch are the first member's (the try's headline, and all a try of one repository - // names); Members are every member of the try, by repository: each an exact commit merged onto a trunk commit (a - // group try, issue 1921). A try written before members read as one member. - Repository string `json:"repository"` - // Head is the commit tried; Trunk the trunk commit it is merged onto, and Branch the trunk's branch when it was asked by name. - Head string `json:"head"` - Trunk string `json:"trunk"` - Branch string `json:"branch,omitempty"` - Members []TryMember `json:"members,omitempty"` - // Tests is a go test -run pattern: only those tests run, and nothing is kept. Level is unit or integration: only that - // level runs. Empty is every test of both levels. - Tests string `json:"tests,omitempty"` - Level string `json:"level,omitempty"` - State string `json:"state"` - // Told is true from the moment a whole try's start is said on the checker's stream until its end is said there: kept in the - // try's own state, so an end that is written and not said (the checker stopped between) is said when the checker starts. - Told bool `json:"told,omitempty"` - // Waiting is what the running try waits for now (its group's candidate from the indexer, ADR 0639 §5), empty when it waits for nothing; - // try-read gives it, so a try that sits still says why. - Waiting string `json:"waiting,omitempty"` - // Said is the try's report in words: what failed first, the tests run, kept and skipped per level, the time of each part. - Said string `json:"said,omitempty"` - // Took is the time from its start to its end, as Go writes a duration. - Took string `json:"took,omitempty"` - // Failed is every test that failed, each with its first line, at most meshdeliverycheckerclient.MaxFailures and then how many more - // (issue 1921); or what else failed first (a conflict, a refused step). - Failed []string `json:"failed,omitempty"` - Levels map[string]meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue `json:"levels,omitempty"` - Machines []string `json:"machines,omitempty"` - // Composition is what the composition on every placed node came to (a whole try, not one narrowed to a level or to - // some tests), and Notes the words the check noted on its way (the manifests judged, the module graph, the kept - // verdicts taken): the same as a group's pull-request check reports. - Composition *meshdeliverychecker.VerdictsByGroupHeadsValueComposition `json:"composition,omitempty"` - Notes []string `json:"notes,omitempty"` - // Asks are the ids of the asks the try put on the build seats' streams, each ending on the step key . of its - // build module: the delivery view counts those steps as a try's, not a candidate's check (build_usage). - Asks []string `json:"asks,omitempty"` - // Steps say where each ask stands while the try runs and after: asked until a node takes it, then the node, its - // state, the phase its step says and when (issue 1890: a 31-minute try could not be told queued from running). - Steps []TryStep `json:"steps,omitempty"` - Asked time.Time `json:"asked"` - Started time.Time `json:"started,omitzero"` - Ended time.Time `json:"ended,omitzero"` -} - -// TryMember is one repository of a try: the exact commit asked, never the branch's head now, and the trunk commit it is -// merged onto. Branch is the trunk's branch when the trunk was asked by name. -type TryMember struct { - Repository string `json:"repository"` - Head string `json:"head"` - Trunk string `json:"trunk"` - Branch string `json:"branch,omitempty"` -} - -// MembersOf are the try's members: its Members, or the one its headline names. -func (t Try) MembersOf() []TryMember { - if len(t.Members) > 0 { - return t.Members - } - return []TryMember{{Repository: t.Repository, Head: t.Head, Trunk: t.Trunk, Branch: t.Branch}} -} - -// TryAsked is a TryStep's state before a build node took its ask: it waits in the seat's stream. -const TryAsked = "asked" - -// TryStep is one ask of a try as its step key last said it. -type TryStep struct { - Ask string `json:"ask"` - Node string `json:"node,omitempty"` - State string `json:"state"` - Phase string `json:"phase,omitempty"` - Started time.Time `json:"started,omitzero"` - PhaseAt time.Time `json:"phase-at,omitzero"` - Ended time.Time `json:"ended,omitzero"` -} - -// tryWriter writes a running try's record again as its asks are put and their steps move: one writer per try, holding -// the revision it wrote last, so the try's end is written at that revision. A write refused (the try ended by hand) -// stops the writes; the end's own write then says it. -type tryWriter struct { - mu sync.Mutex - tr *Tryer - ctx context.Context - key string - t Try - rev uint64 - stopped bool -} - -// heard takes an ask put (step nil) or a value of its step key in, and writes the record when it changed. -func (w *tryWriter) heard(askID string, step *buildstep.Step) { - w.mu.Lock() - defer w.mu.Unlock() - if w.stopped { - return - } - changed := false - if !slices.Contains(w.t.Asks, askID) { - w.t.Asks, changed = append(w.t.Asks, askID), true - } - i := slices.IndexFunc(w.t.Steps, func(s TryStep) bool { return s.Ask == askID }) - if i < 0 { - w.t.Steps, changed = append(w.t.Steps, TryStep{Ask: askID, State: TryAsked}), true - i = len(w.t.Steps) - 1 - } - if step != nil { - now := TryStep{Ask: askID, Node: step.Node, State: step.State, Phase: step.Phase, Started: step.Started, - PhaseAt: step.PhaseAt, Ended: step.Ended} - changed = changed || now != w.t.Steps[i] - w.t.Steps[i] = now - } - if changed { - w.write() - } -} - -// waiting writes what the try waits for now ("" when it waits for nothing). -func (w *tryWriter) waiting(why string) { - w.mu.Lock() - defer w.mu.Unlock() - if w.stopped || w.t.Waiting == why { - return - } - w.t.Waiting = why - w.write() -} - -// write writes the record at the revision written last; a refusal stops the writes. -func (w *tryWriter) write() { - data, err := encodeTry(w.t) - if err != nil { - return - } - rev, err := w.tr.Tries.Update(w.ctx, w.key, data, w.rev) - if err != nil { - w.stopped = true - w.tr.logf("%s: its asks' progress is no longer written: %v", w.key, err) - return - } - w.rev = rev -} - -// end stops the writes and answers the record and its revision, for the try's end. -func (w *tryWriter) end() (Try, uint64) { - w.mu.Lock() - defer w.mu.Unlock() - w.stopped = true - return w.t, w.rev -} - -// HoldsANode says whether the try holds a build node now: it runs, and a step of its asks runs on a node, or it names -// no step (a checker that writes its asks only at the end, or one about to put its first). -func (t Try) HoldsANode() bool { - if t.State != TryRunning { - return false - } - if len(t.Steps) == 0 { - return true - } - return slices.ContainsFunc(t.Steps, func(s TryStep) bool { return s.State == buildstep.StepRunning || s.State == buildstep.StepAgain }) -} - -// Over says whether the try came to its end. -func (t Try) Over() bool { return t.State == TryPass || t.State == TryFail || t.State == TryError } - -// DecodeTry reads a tries value. -func DecodeTry(raw []byte) (Try, error) { - var t Try - if err := json.Unmarshal(raw, &t); err != nil { - return Try{}, fmt.Errorf("not a try: %w", err) - } - if !meshcatalogclient.IsTryGroup(t.ID) || t.Repository == "" || t.Head == "" || t.Trunk == "" { - return Try{}, errors.New("not a try: it names no id, repository, head or trunk") - } - t.Members = t.MembersOf() - return t, nil -} - -func encodeTry(t Try) ([]byte, error) { - t.V = keys.Version - return json.Marshal(t) -} - -// TryAsk is what checker_try is given. -type TryAsk struct { - Repository, Head, Trunk, Tests, Level string - // Members are the repositories of a group try, each an exact commit and, optionally, its trunk (a commit, or the - // trunk's branch for its head now); the single Repository, Head and Trunk above are one member. Both at once are refused. - Members []TryAskMember -} - -// TryAskMember is one repository of a group try as it is asked. -type TryAskMember struct { - Repository, Head, Trunk string -} - -// TryStore is the tries state as the tools see it. -type TryStore interface { - Keys() ([]string, error) - Get(key string) (json.RawMessage, error) - Create(key string, value []byte) error -} - -// NotChecked is the error of a try of a repository the checker judges no level of: one whose trunk the gate's source does -// not name. -func NotChecked(repository string) error { - return fmt.Errorf("no level of %s is checked by the checker", repository) -} - -// tryMember checks one member as it is asked and resolves its trunk: the gate's trunk head of its repository, a commit -// asked, or the trunk's branch (its head now). A repository with no trunk head is no repository the checker checks. -func tryMember(trunks map[string]string, a TryAskMember) (TryMember, error) { - repo := strings.ToLower(strings.TrimSuffix(strings.TrimSpace(a.Repository), ".git")) - head := strings.ToLower(strings.TrimSpace(a.Head)) - switch { - case !tryRepoOK.MatchString(repo) || strings.Contains(repo, ".."): - return TryMember{}, fmt.Errorf("%q is not a repository, /", a.Repository) - case !tryHeadOK.MatchString(head): - return TryMember{}, fmt.Errorf("the head %q of %s is not a full commit, 40 or 64 hex digits", a.Head, repo) - } - trunkHead := "" - for r, h := range trunks { - if strings.EqualFold(r, repo) { - trunkHead = h - } - } - if trunkHead == "" { - return TryMember{}, NotChecked(repo) - } - m := TryMember{Repository: repo, Head: head} - switch trunk := strings.TrimSpace(a.Trunk); { - case trunk == "": - m.Trunk = trunkHead - case tryHeadOK.MatchString(strings.ToLower(trunk)): - m.Trunk = strings.ToLower(trunk) - case tryTrunkOK.MatchString(trunk) && !strings.Contains(trunk, ".."): - // The checker judges pull requests into the trunk alone (ADR 0484 clause 11): a branch named is the trunk's head now. - m.Trunk, m.Branch = trunkHead, trunk - default: - return TryMember{}, fmt.Errorf("the trunk %q of %s is neither a full commit nor a branch", a.Trunk, repo) - } - return m, nil -} - -// sameMembers says whether two tries ask the same commits onto the same trunk commits. -func sameMembers(a, b []TryMember) bool { - return slices.EqualFunc(a, b, func(x, y TryMember) bool { - return x.Repository == y.Repository && x.Head == y.Head && x.Trunk == y.Trunk - }) -} - -// AskTry writes a new try, queued, and answers its id: a try of the same commits that waits or runs is the answer to a second -// ask, and a new try is refused while MaxTries tries run on a build node or MaxTriesWaiting wait for one. A try is a group of -// one or more members (issue 1921), each an exact commit, never the branch's head now: a push after the ask changes nothing -// of what is tried. trunks are the gate's trunk heads of every repository (source.main): a repository with none is no -// repository the checker checks. A trunk asked by name is its trunk head now. -func AskTry(store TryStore, trunks map[string]string, a TryAsk, now time.Time) (string, error) { - asked := a.Members - if a.Repository != "" || a.Head != "" || a.Trunk != "" { - if len(asked) > 0 { - return "", errors.New("name the members, or one repository with its head, not both") - } - asked = []TryAskMember{{Repository: a.Repository, Head: a.Head, Trunk: a.Trunk}} - } - if len(asked) == 0 { - return "", errors.New("name what to try: members (repository and head each), or a repository and its head") - } - switch { - case a.Level != "" && a.Level != buildstep.LevelUnit && a.Level != buildstep.LevelIntegration: - return "", fmt.Errorf("the level %q is neither unit nor integration", a.Level) - case a.Tests != "" && !tryTestsOK.MatchString(a.Tests): - return "", fmt.Errorf("the tests %q are not a go test -run pattern", a.Tests) - } - var members []TryMember - for _, m := range asked { - tm, err := tryMember(trunks, m) - if err != nil { - return "", err - } - if slices.ContainsFunc(members, func(o TryMember) bool { return o.Repository == tm.Repository }) { - return "", fmt.Errorf("%s is named twice: a try holds one commit of a repository", tm.Repository) - } - members = append(members, tm) - } - slices.SortFunc(members, func(x, y TryMember) int { return strings.Compare(x.Repository, y.Repository) }) - first := members[0] - t := Try{Repository: first.Repository, Head: first.Head, Trunk: first.Trunk, Branch: first.Branch, Members: members, - Tests: a.Tests, Level: a.Level, State: TryQueued, Asked: now.UTC()} - keys, err := store.Keys() - if err != nil { - return "", fmt.Errorf("the tries cannot be listed: %w", err) - } - // An ended try's key stays TryKeep, so the bucket holds thousands; one that waits or runs was asked lately. Only the - // newest TryScan keys are read, in parallel (a try id is the time in nanoseconds, so the newest sorts last). - sort.Slice(keys, func(i, j int) bool { - if len(keys[i]) != len(keys[j]) { - return len(keys[i]) > len(keys[j]) - } - return keys[i] > keys[j] - }) - if len(keys) > TryScan { - keys = keys[:TryScan] - } - tries := make([]Try, len(keys)) - live := make([]bool, len(keys)) - if err := parallel(len(keys), func(i int) error { - raw, err := store.Get(keys[i]) - if err != nil || len(raw) == 0 { - return nil - } - cur, err := DecodeTry(raw) - tries[i], live[i] = cur, err == nil && !cur.Over() - return nil - }); err != nil { - return "", err - } - var holding, waiting []string - for i, cur := range tries { - if !live[i] { - continue - } - if sameMembers(cur.MembersOf(), t.Members) && cur.Tests == t.Tests && cur.Level == t.Level { - return cur.ID, nil - } - said := fmt.Sprintf("%s (%s, %s)", cur.ID, sayMembers(cur.MembersOf()), cur.State) - if cur.HoldsANode() { - holding = append(holding, said) - } else { - waiting = append(waiting, said) - } - } - // Checked at this ask only: a try queued behind the seat's checks holds no node; tries let in while waiting may later - // all run at once, and each node's build capacity bounds what runs on it. - if len(holding) >= MaxTries || len(waiting) >= MaxTriesWaiting { - return "", fmt.Errorf("a new try is refused while %d tries run on a build node or %d wait for one; now %d run and %d wait: running %s; waiting %s; ask again when one ends", - MaxTries, MaxTriesWaiting, len(holding), len(waiting), orNone(holding), orNone(waiting)) - } - t.ID = "try-" + strconv.FormatInt(now.UnixNano(), 10) - data, err := encodeTry(t) - if err != nil { - return "", err - } - if err := store.Create(t.ID, data); err != nil { - return "", fmt.Errorf("the try %s cannot be written: %w", t.ID, err) - } - return t.ID, nil -} - -// ReadTry is a try's value, as stored. -func ReadTry(store TryStore, id string) (json.RawMessage, error) { - if !meshcatalogclient.IsTryGroup(id) { - return nil, fmt.Errorf("%q is not a try's id, try-", id) - } - raw, err := store.Get(id) - if err != nil { - return nil, err - } - if len(raw) == 0 { - return nil, fmt.Errorf("no try %s: it was never asked, or it ended more than %s ago and was removed", id, TryKeep) - } - return raw, nil -} - -// TryEnder is the tries state as the end tool sees it: one key with its revision, and a write at that revision. -type TryEnder interface { - Entry(key string) (json.RawMessage, uint64, error) - Update(key string, value []byte, revision uint64) error -} - -// EndTry ends a try that waits or runs as error, saying why and that it was ended by hand (issue 734): its place is -// free at once, and the next checker_try of its head asks anew. A try that ended already is refused, naming its end. -func EndTry(store TryEnder, id, why string, now time.Time) (Try, error) { - if !meshcatalogclient.IsTryGroup(id) { - return Try{}, fmt.Errorf("%q is not a try's id, try-", id) - } - why = strings.TrimSpace(why) - if why == "" { - return Try{}, errors.New("say why the try is ended: the why is kept in what it says") - } - raw, rev, err := store.Entry(id) - if err != nil { - return Try{}, err - } - if len(raw) == 0 { - return Try{}, fmt.Errorf("no try %s: it was never asked, or it ended more than %s ago and was removed", id, TryKeep) - } - t, err := DecodeTry(raw) - if err != nil { - return Try{}, err - } - if t.Over() { - return Try{}, fmt.Errorf("%s ended already, %s at %s", id, t.State, t.Ended.Format(time.RFC3339)) - } - t.State, t.Ended = TryError, now.UTC() - if !t.Started.IsZero() { - t.Took = t.Ended.Sub(t.Started).Round(time.Second).String() - } - t.Said = strings.TrimSpace("ended by hand (" + TryEndTool + "): " + why + " | " + t.Said) - t.Said = strings.TrimSuffix(t.Said, " |") - data, err := encodeTry(t) - if err != nil { - return Try{}, err - } - if err := store.Update(id, data, rev); err != nil { - return Try{}, fmt.Errorf("%s changed while it was ended, read it and end it again: %w", id, err) - } - return t, nil -} - -// TryOptions narrow what a try runs; a pull request's check has none. -type TryOptions struct { - Level string - Run string -} - -// Whole says the try runs everything a group's pull-request check runs (both levels of every member, the manifests judged by -// the manifest validator, the module graph, the composition on every placed node): it is narrowed to neither a level nor -// some tests. Such a try judges by the same code as the check, so the two cannot drift (issue 1921). -func (o *TryOptions) Whole() bool { return o != nil && o.Level == "" && o.Run == "" } - -// TryCase is the case a try is judged as: one pull of the group per member at its exact commit, with no pull request number -// (no ref: the commit is fetched as it is), the group named by the try's key, and the heads hash its candidate is keyed by. -func TryCase(key string, t Try, watch func(string, *buildstep.Step)) *Case { - cs := &Case{Key: key, Group: key, Watch: watch, Trunk: map[string]string{}, Queued: t.Asked, Progress: &Progress{}, - Try: &TryOptions{Level: t.Level, Run: t.Tests}} - var heads []meshdeliveryclient.Head - for _, m := range t.MembersOf() { - cs.Pulls = append(cs.Pulls, Pull{Repository: m.Repository, Head: m.Head, Trunk: m.Trunk}) - cs.Trunk[m.Repository] = m.Trunk - heads = append(heads, meshdeliveryclient.Head{Repository: m.Repository, Head: m.Head}) - } - cs.HeadsHash, _ = meshdeliveryclient.HeadsHash(heads) - cs.Heads = cs.HeadsHash - return cs -} - -// compositionMade says whether a composition was made; notMadeWords what it says when it was not. -func compositionMade(c *meshdeliverychecker.VerdictsByGroupHeadsValueComposition) bool { - return c != nil && c.State != meshdeliverycheckerclient.CompositionNotRun -} - -func notMadeWords(c *meshdeliverychecker.VerdictsByGroupHeadsValueComposition) string { - if c == nil || c.Words == "" { - return "no reason was given" - } - return c.Words -} - -// Tryer runs the tries: it takes a queued try, judges it through the same Judge as a pull request's check (a check ask, ADR -// 0525 §1), and writes its end. It holds no timer: a try starts when its key is written. -type Tryer struct { - Tries KV - Judge Judge - Bound time.Duration - // NotTaken ends a try whose ask no build node took within it as error (issue 734); none when 0. - NotTaken time.Duration - Now func() time.Time - Logf func(format string, args ...any) - - // Say publishes an event of the checker's stream (checkermsg.Started, checkermsg.Ended) with its body; nil says nothing. The - // indexer, which hears them, writes and deletes the candidate of a whole try's group. - // It answers the publish's error, nil only when the stream acknowledged it: an end not acknowledged is said again. - Say func(ctx context.Context, event string, body checkermsg.Event) error - - mu sync.Mutex - ending map[string]bool // tries whose end is being said now - wg sync.WaitGroup - inflight map[string]context.CancelFunc - seen map[string]bool // looked at since this process started: a try left running is taken over the first time -} - -func (tr *Tryer) now() time.Time { - if tr.Now != nil { - return tr.Now() - } - return time.Now() -} - -func (tr *Tryer) logf(format string, args ...any) { - if tr.Logf != nil { - tr.Logf(format, args...) - } -} - -// Wait returns when every try started so far has ended. -func (tr *Tryer) Wait() { tr.wg.Wait() } - -// Put takes a value of the tries state in: a queued try is started, and a try left running is taken over the first time -// this process sees it (the checker that ran it stopped; there is one checker). -func (tr *Tryer) Put(ctx context.Context, key string, value []byte) { - t, err := DecodeTry(value) - if err != nil { - tr.logf("tries.%s holds what is not a try, left: %v", key, err) - return - } - tr.mu.Lock() - if tr.inflight == nil { - tr.inflight, tr.seen = map[string]context.CancelFunc{}, map[string]bool{} - } - if t.Over() { - // Ended while it ran (checker_try_end): its judging stops, and its asks are no longer waited for. - if stop := tr.inflight[key]; stop != nil { - stop() - } - tr.mu.Unlock() - tr.sendEnd(ctx, key) // ended by hand while it ran, or its end was written and not said: the indexer drops its candidate - return - } - if tr.inflight[key] != nil || (t.State == TryRunning && tr.seen[key]) { - tr.mu.Unlock() - return - } - run, stop := context.WithCancel(ctx) - tr.seen[key] = true - tr.inflight[key] = stop - tr.mu.Unlock() - tr.wg.Add(1) - go func() { - defer tr.wg.Done() - defer func() { tr.mu.Lock(); delete(tr.inflight, key); tr.mu.Unlock(); stop() }() - tr.run(run, key) - }() -} - -// Reconsider looks at every try again (a delivery that held them ended), and removes the ended tries older than TryKeep. -func (tr *Tryer) Reconsider(ctx context.Context) { - keys, err := tr.Tries.Keys(ctx) - if err != nil { - tr.logf("the tries cannot be listed: %v", err) - return - } - for _, k := range keys { - raw, _, found, err := tr.Tries.Get(ctx, k) - if err != nil || !found { - continue - } - if t, err := DecodeTry(raw); err == nil && t.Over() && tr.now().Sub(t.Ended) > TryKeep { - if d, ok := tr.Tries.(interface { - Delete(ctx context.Context, key string) error - }); ok { - if err := d.Delete(ctx, k); err != nil { - tr.logf("%s ended %s ago and could not be removed: %v", k, tr.now().Sub(t.Ended).Round(time.Hour), err) - } - } - continue - } - tr.Put(ctx, k, raw) - } -} - -// run claims the try by compare-and-set, judges it within its bound and writes its end. -func (tr *Tryer) run(ctx context.Context, key string) { - raw, rev, found, err := tr.Tries.Get(ctx, key) - if err != nil || !found { - return - } - t, err := DecodeTry(raw) - if err != nil || t.Over() { - return - } - t.State, t.Started = TryRunning, tr.now().UTC() - t.Told = (&TryOptions{Level: t.Level, Run: t.Tests}).Whole() // its start is said below; its end is owed from now on - data, err := encodeTry(t) - if err != nil { - return - } - if rev, err = tr.Tries.Update(ctx, key, data, rev); err != nil { - if !errors.Is(err, ErrConflict) { - tr.logf("%s: %v", key, err) - } - return - } - progress := &tryWriter{tr: tr, ctx: ctx, key: key, t: t, rev: rev} - if t.Told { - started := checkermsg.Event{ID: key} - for _, m := range t.MembersOf() { - started.Members = append(started.Members, checkermsg.Member{Repository: m.Repository, Head: m.Head, Trunk: m.Trunk}) - } - tr.say(ctx, checkermsg.Started, started) - } - cs := TryCase(key, t, progress.heard) - cs.Wait = progress.waiting - judging := ctx - if tr.NotTaken > 0 { - judging = buildrun.NotTakenBound(ctx, tr.NotTaken) - } - out, judged := judgeWithin(judging, tr.Judge, cs, tr.Bound) - if ctx.Err() != nil { - return // left running: the checker takes it over when it starts; or ended by hand, which wrote its end - } - t, rev = progress.end() - t.Waiting = "" - v := out.Verdict - t.Ended = tr.now().UTC() - t.Took = t.Ended.Sub(t.Started).Round(time.Second).String() - t.Levels, t.Machines, t.Asks = v.Levels, v.Machines, cs.Asks() - t.Composition = v.Composition - t.Said = Report(v, cs, cs.Pulls[0], out.Builds, out.Slowest, out.Judged) - if len(cs.Pulls) > 1 { - t.Said = sayMembers(t.MembersOf()) + ": " + t.Said - } - t.Notes = cs.Notes() - for _, n := range t.Notes { - t.Said += " | " + n - } - switch { - case !judged || IsCouldNotRun(v) || IsLostAsk(v) || IsNotTaken(v): - // Not the change's: its ask was given up or never taken (issue 734), or a part of the mesh was not heard. - t.State = TryError - if IsLostAsk(v) || IsNotTaken(v) { - t.Failed = []string{failedOf(v).Words} - } - case v.State == meshdeliverycheckerclient.VerdictPass && cs.Try.Whole() && compositionMade(v.Composition) && strings.Contains(v.Composition.Words, nodeengineclient.NoAnswer): - // A node that gave no answer passes a group's check with a warning; a try that is to say the group composes says it - // did not, naming the node (ADR 0637 §3). - t.State = TryError - t.Failed = []string{"the composition was not made on every placed node: " + v.Composition.Words} - case v.State == meshdeliverycheckerclient.VerdictPass && cs.Try.Whole() && !compositionMade(v.Composition): - // A whole try that judged the tests and not the manifests and the composition has not tried what its group's check - // judges: it is no pass, and it says why (failure must be loud). It is an error, not the change's failure. - t.State = TryError - t.Failed = []string{"the composition was not made: " + notMadeWords(v.Composition)} - case v.State == meshdeliverycheckerclient.VerdictPass: - t.State = TryPass - default: - t.State = TryFail - t.Failed = failedLines(v) - } - if t.Tests != "" { - t.Said += " | only the tests " + t.Tests + " (Go); nothing kept" - } - if data, err = encodeTry(t); err == nil { - _, err = tr.Tries.Update(ctx, key, data, rev) - } - if err != nil { - tr.logf("%s: its end could not be written: %v", key, err) - return - } - tr.logf("%s: %s", key, t.State) - // The end just written comes back on the key's watch, and Put then stops this run's context (it stops judging a try - // ended by hand) while this run says the end, which Put's own say leaves to it: the end is said on a context that - // stop does not cancel, or it is never said and the indexer keeps the candidate of the try's group. - tr.sendEnd(context.WithoutCancel(ctx), key) -} - -// sendEnd says the end of an ended try whose start was said (Told) with the state it ended in, then clears Told in the try's -// own state; a checker that stopped between the two says it again at its start. Every end is said so: pass, fail, error and -// by hand. -func (tr *Tryer) sendEnd(ctx context.Context, key string) { - tr.mu.Lock() - if tr.ending[key] { - tr.mu.Unlock() - return - } - if tr.ending == nil { - tr.ending = map[string]bool{} - } - tr.ending[key] = true - tr.mu.Unlock() - defer func() { tr.mu.Lock(); delete(tr.ending, key); tr.mu.Unlock() }() - raw, rev, found, err := tr.Tries.Get(ctx, key) - if err != nil || !found { - return - } - t, err := DecodeTry(raw) - if err != nil || !t.Over() || !t.Told { - return - } - if tr.say(ctx, checkermsg.Ended, checkermsg.Event{ID: key, State: t.State}) != nil { - return // not acknowledged: Told stays, and the next Put or Reconsider says the end again - } - t.Told = false - data, err := encodeTry(t) - if err == nil { - _, err = tr.Tries.Update(ctx, key, data, rev) - } - if err != nil && !errors.Is(err, ErrConflict) { - tr.logf("%s: its end was said and Told could not be cleared: %v", key, err) - } -} - -// say publishes a try event; a failure is said in the log (the indexer finds the open tries again at its start). -func (tr *Tryer) say(ctx context.Context, event string, body checkermsg.Event) error { - if tr.Say == nil { - return nil - } - err := tr.Say(ctx, event, body) - if err != nil { - tr.logf("%s of %s could not be said: %v", event, body.ID, err) - } - return err -} - -// OpenTries are every try that waits or runs now: what checker_tries answers, so a part that missed an event (the indexer at -// its start) finds them without reading the checker's state. All the keys are read (an old open try is as open as a new one), in -// parallel. -func OpenTries(store TryStore) ([]checkermsg.Open, error) { - keys, err := store.Keys() - if err != nil { - return nil, fmt.Errorf("the tries cannot be listed: %w", err) - } - sort.Slice(keys, func(i, j int) bool { - if len(keys[i]) != len(keys[j]) { - return len(keys[i]) > len(keys[j]) - } - return keys[i] > keys[j] - }) - found := make([]*checkermsg.Open, len(keys)) - if err := parallel(len(keys), func(i int) error { - raw, err := store.Get(keys[i]) - if err != nil || len(raw) == 0 { - return nil - } - t, err := DecodeTry(raw) - if err != nil || t.Over() { - return nil - } - o := checkermsg.Open{ID: t.ID, State: t.State, Whole: (&TryOptions{Level: t.Level, Run: t.Tests}).Whole()} - for _, m := range t.MembersOf() { - o.Members = append(o.Members, checkermsg.Member{Repository: m.Repository, Head: m.Head, Trunk: m.Trunk}) - } - found[i] = &o - return nil - }); err != nil { - return nil, err - } - out := []checkermsg.Open{} // none open is an empty list, never null: a reader tells it from no answer (issue 1921) - for _, o := range found { - if o != nil { - out = append(out, *o) - } - } - return out, nil -} - -// judgeWithin runs a case within the bound (none when 0: the asks' steps are bounded from their start, ADR 0525 §6). A -// judge that fails to judge, and a check that ran past its bound, are verdicts of failure naming the machine and the step, -// and judged says false for them. -func judgeWithin(ctx context.Context, j Judge, cs *Case, bound time.Duration) (Outcome, bool) { - run, cancel := context.WithCancel(ctx) - if bound > 0 { - run, cancel = context.WithTimeoutCause(ctx, bound, errBound) - } - defer cancel() - out, err := j.Judge(run, cs) - stage, node := cs.Progress.Now() - if node == "" { - node = "checker" - } - switch { - case ctx.Err() != nil: - return Outcome{}, false - case context.Cause(run) == errBound: - if stage == "" { - stage = "starting" - } - return Outcome{Verdict: failure(node, fmt.Sprintf("the check ran past its bound of %s, stuck at: %s", bound, stage))}, false - case err != nil: - return Outcome{Verdict: failure(node, err.Error())}, false - } - return out, true -} - -// sayMembers names a try's members, each repository at its short commit. -func sayMembers(ms []TryMember) string { - var out []string - for _, m := range ms { - out = append(out, fmt.Sprintf("%s@%.12s", m.Repository, m.Head)) - } - return strings.Join(out, " + ") -} - -// orNone joins the tries said, or says none. -func orNone(said []string) string { - if len(said) == 0 { - return "none" - } - return strings.Join(said, ", ") -} diff --git a/modules/mesh-delivery-checker/internal/check/try_test.go b/modules/mesh-delivery-checker/internal/check/try_test.go deleted file mode 100644 index d6dc4827..00000000 --- a/modules/mesh-delivery-checker/internal/check/try_test.go +++ /dev/null @@ -1,505 +0,0 @@ -package check - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "mesh-delivery-checker/rules" - "slices" - "strings" - "testing" - "time" - - "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-checker/checkermsg" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// memTries is the tries state as the tools see it, over a memKV. -type memTries struct{ kv *memKV } - -func (m memTries) Keys() ([]string, error) { return m.kv.Keys(context.Background()) } -func (m memTries) Get(key string) (json.RawMessage, error) { - v, _, _, err := m.kv.Get(context.Background(), key) - return v, err -} -func (m memTries) Create(key string, value []byte) error { - _, err := m.kv.Create(context.Background(), key, value) - return err -} - -// writtenTries is a memKV that keeps every running try it was given to write, in order. -type writtenTries struct { - *memKV - running []Try -} - -func (w *writtenTries) Update(ctx context.Context, key string, value []byte, rev uint64) (uint64, error) { - if t, err := DecodeTry(value); err == nil && !t.Over() { - w.running = append(w.running, t) - } - return w.memKV.Update(ctx, key, value, rev) -} - -var tryTrunks = map[string]string{repoA: trunkA, repoSDK: trunkS, hqRepo: trunkA} - -func readTry(t testing.TB, kv *memKV, id string) Try { - t.Helper() - raw, _, found, _ := kv.Get(context.Background(), id) - if !found { - t.Fatalf("no try %s", id) - } - tr, err := DecodeTry(raw) - if err != nil { - t.Fatal(err) - } - return tr -} - -func TestATryIsAskedQueuedOncePerHeadAndAtMostFourAtOnce(t *testing.T) { // ADR 0501 §5 - kv := newMemKV() - store := memTries{kv} - at := time.Date(2026, 10, 22, 18, 0, 0, 0, time.UTC) - id, err := AskTry(store, tryTrunks, TryAsk{Repository: repoA, Head: head1, Trunk: "main"}, at) - if err != nil || !strings.HasPrefix(id, "try-") { - t.Fatalf("id %q, %v", id, err) - } - tr := readTry(t, kv, id) - if tr.State != TryQueued || tr.Trunk != trunkA || tr.Branch != "main" || tr.Head != head1 || tr.Repository != repoA { - t.Errorf("try = %+v, want queued on the trunk's head", tr) - } - again, err := AskTry(store, tryTrunks, TryAsk{Repository: repoA, Head: head1, Trunk: "main"}, at.Add(time.Second)) - if err != nil || again != id { - t.Errorf("a second ask of the same head answered %q, %v, want %q", again, err, id) - } - // Issue 1890: tries on a build node (a step of theirs running, or none named yet) and tries waiting for one (queued, or - // their asks not taken) are bounded apart, MaxTries and MaxTriesWaiting; the refusal names both counts. - // A group try is the same try whatever the order of its members; the commits asked are the commits tried. - group := TryAsk{Members: []TryAskMember{{Repository: repoSDK, Head: head2}, {Repository: repoA, Head: head1}}} - gid, err := AskTry(store, tryTrunks, group, at.Add(time.Second)) - if err != nil || gid == id { - t.Fatalf("the group try = %q, %v, want a try of its own", gid, err) - } - group.Members[0], group.Members[1] = group.Members[1], group.Members[0] - if again, err := AskTry(store, tryTrunks, group, at.Add(time.Minute)); err != nil || again != gid { - t.Errorf("the group asked in another order answered %q, %v, want %q", again, err, gid) - } - if g := readTry(t, kv, gid); len(g.Members) != 2 || g.Members[0].Repository != repoA || g.Members[0].Head != head1 || g.Members[1].Trunk != trunkS { - t.Errorf("group try = %+v, want its members by repository at the commits asked", g.Members) - } - if open, err := OpenTries(store); err != nil || len(open) != 2 || !open[0].Whole || len(open[1].Members) != 2 && len(open[0].Members) != 2 { - t.Errorf("open tries = %+v, %v, want the two queued", open, err) - } - if !meshcatalogclient.IsTryGroup(gid) || meshcatalogclient.IsTryGroup("feat/x") || meshcatalogclient.IsTryGroup("fix/1921-try-1") { - t.Errorf("which candidates keys are a try's group: %s is, a branch is not", gid) - } - onNode := func(i int) Try { - return Try{ID: fmt.Sprintf("try-%d", i), Repository: repoA, Head: fmt.Sprintf("%040x", i), Trunk: trunkA, State: TryRunning, - Steps: []TryStep{{Ask: "a", State: buildstep.StepRunning}}} - } - waitingFor := func(i int) Try { - return Try{ID: fmt.Sprintf("try-%d", i), Repository: repoA, Head: fmt.Sprintf("%040x", i), Trunk: trunkA, State: TryRunning, - Steps: []TryStep{{Ask: "a", State: TryAsked}}} - } - for _, c := range []struct { - what string - holding, wait int - refused string - }{ - {"four queued behind the checks, none on a node: a fifth is taken", 0, 4, ""}, - {"four on a node", MaxTries, 0, "now 4 run and 0 wait"}, - {"three on a node, eight waiting", 3, MaxTriesWaiting, "a new try is refused while 4 tries run on a build node or 8 wait for one; now 3 run and 8 wait"}, - } { - kv := newMemKV() - for i := range c.holding + c.wait { - tr := waitingFor(i + 1) - if i < c.holding { - tr = onNode(i + 1) - } - data, _ := encodeTry(tr) - _, _ = kv.Create(context.Background(), tr.ID, data) - } - _, err := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoSDK, Head: head1}, at.Add(time.Minute)) - if (c.refused == "") != (err == nil) || (err != nil && !strings.Contains(err.Error(), c.refused)) { - t.Errorf("%s: answered %v, want refused %q", c.what, err, c.refused) - } - } - // Issue 1748: a try whose step ended on a transport fault, the bus giving its ask again, still runs. - if !(Try{State: TryRunning, Steps: []TryStep{{Ask: "a", State: buildstep.StepAgain}}}).HoldsANode() { - t.Error("a try with a step given again no longer runs") - } -} - -func TestATryOfARepositoryWithNoCheckedLevelIsRefused(t *testing.T) { // the agreed error of the try - store := memTries{newMemKV()} - for _, repo := range []string{"novox/no-trunk", "novox/mesh-lab"} { // hq is checked since R4g (ADR 0527): see tryTrunks - _, err := AskTry(store, tryTrunks, TryAsk{Repository: repo, Head: head1, Trunk: "main"}, time.Now()) - if err == nil || err.Error() != "no level of "+repo+" is checked by the checker" { - t.Errorf("%s: %v", repo, err) - } - } - for _, bad := range []TryAsk{{Repository: repoA, Head: "abc"}, {Repository: repoA, Head: head1, Level: "e2e"}, - {Repository: repoA, Head: head1, Tests: "a b"}, {Repository: "x", Head: head1}, {Repository: repoA, Head: head1, Trunk: "-x"}, - // A group try (issue 1921): members or one repository, never both or none; one commit per repository; every member checked. - {}, - {Repository: repoA, Head: head1, Members: []TryAskMember{{Repository: repoSDK, Head: head2}}}, - {Members: []TryAskMember{{Repository: repoA, Head: head1}, {Repository: repoA, Head: head2}}}, - {Members: []TryAskMember{{Repository: repoA, Head: head1}, {Repository: repoSDK, Head: "main"}}}, - {Members: []TryAskMember{{Repository: repoA, Head: head1}, {Repository: "novox/no-trunk", Head: head2}}}} { - if _, err := AskTry(store, tryTrunks, bad, time.Now()); err == nil { - t.Errorf("%+v was taken", bad) - } - } -} - -// fakeTryCandidates answers the indexer's candidate of a try's group from memory, recording the keys asked. -type fakeTryCandidates struct { - cand meshcatalog.CandidatesByGroupValue - err error - asked []string - // during is called while the try waits for the candidate. - during func() -} - -func (f *fakeTryCandidates) TryCandidate(_ context.Context, group, heads string, _ time.Duration) (meshcatalog.CandidatesByGroupValue, error) { - if f.during != nil { - f.during() - } - f.asked = append(f.asked, group+"."+heads) - return f.cand, f.err -} - -// wholeBench makes the bench judge a whole try as the checker does: the composition on every placed node and the -// indexer's candidate of the try's group. -func wholeBench(b *bench, cand meshcatalog.CandidatesByGroupValue) (*fakeCompositions, *fakeTryCandidates) { - comps := &fakeCompositions{v: composedOn("v0.1.14-x", 40, "g14", "shanks")} - cands := &fakeTryCandidates{cand: cand} - b.ex.Compositions, b.ex.Candidates = comps, cands - return comps, cands -} - -// A group try (issue 1921): several repositories each at the exact commit asked, judged by the code of a group's pull-request -// check; the two cannot drift, and a later check of the same heads keeps what the try passed. -func TestATryIsJudgedAsAGroupsCheckAndOwesTheForgeNothing(t *testing.T) { // ADR 0501 §5, issue 1921 - ctx := context.Background() - kv := newMemKV() - id, err := AskTry(memTries{kv}, tryTrunks, TryAsk{Members: []TryAskMember{{Repository: repoSDK, Head: head2, Trunk: trunkS}, {Repository: repoA, Head: head1, Trunk: trunkA}}}, time.Now()) - if err != nil { - t.Fatal(err) - } - b := newBench(t) - comps, cands := wholeBench(b, meshcatalog.CandidatesByGroupValue{Fpset: "fps-of-the-try"}) - written := &writtenTries{memKV: kv} - var waiting string - cands.during = func() { waiting = readTry(t, kv, id).Waiting } // ADR 0639 §5: the stored try says what it waits for - var said []string - var tr *Tryer - echoed := false - tr = &Tryer{Tries: written, Judge: b.ex, Say: func(ctx context.Context, event string, e checkermsg.Event) error { - if event == checkermsg.Ended && !echoed { - // The end the run wrote comes back on the key's watch while the run says it: Put stops the run's context and - // leaves the saying to the run, whose say must not be stopped with it (issue 1921). - echoed = true - raw, _, _, _ := kv.Get(context.Background(), id) - tr.Put(context.Background(), id, raw) - } - if err := ctx.Err(); err != nil { - return err // a publish on a stopped context is never acknowledged - } - said = append(said, fmt.Sprintf("%s %s %d %s", event, e.ID, len(e.Members), e.State)) - return nil - }} - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - // The indexer hears the start with the members at their commits, and the end (it writes and deletes the group's candidate). - if len(said) != 2 || said[0] != "try.started "+id+" 2 " || said[1] != "try.ended "+id+" 0 "+TryPass { - t.Errorf("events = %v, want the start with 2 members and the end", said) - } - // What the indexer reads: checkermsg.Decode accepts the events as said and refuses a body that is no try's. - for _, row := range []struct { - name, event, body string - ok bool - }{ - {"a start with its members", checkermsg.Started, `{"id":"` + id + `","members":[{"repository":"` + repoA + `","head":"` + head1 + `","trunk":"` + trunkA + `"}]}`, true}, - {"an end with its state", checkermsg.Ended, `{"id":"` + id + `","state":"pass"}`, true}, - {"an id that is no try's", checkermsg.Ended, `{"id":"pull-7","state":"pass"}`, false}, - {"a start with no member", checkermsg.Started, `{"id":"` + id + `"}`, false}, - {"a body that is no JSON", checkermsg.Ended, `try-7`, false}, - } { - if e, err := checkermsg.Decode(row.event, []byte(row.body)); (err == nil) != row.ok || (row.ok && e.ID != id) { - t.Errorf("Decode of %s = %+v, %v, want ok=%v", row.name, e, err, row.ok) - } - } - got := readTry(t, kv, id) - if !strings.Contains(waiting, "candidate") || got.Waiting != "" { - t.Errorf("waiting while the candidate was awaited = %q, after the end %q: want the reason, then none", waiting, got.Waiting) - } - if got.Told { // the end was said: nothing is owed - t.Errorf("the ended try still owes its end: %+v", got) - } - if open, err := OpenTries(memTries{kv}); err != nil || len(open) != 0 { - t.Errorf("open tries after the end = %v, %v", open, err) - } else if raw, _ := json.Marshal(open); string(raw) != "[]" { // issue 1921: none open is [] on the wire, never null - t.Errorf("none open is answered %s, want []", raw) - } - if got.State != TryPass || got.Took == "" || len(got.Members) != 2 || got.Members[0].Repository != repoA || got.Members[1].Head != head2 || - got.Said == "" || got.Levels[buildstep.LevelUnit].Run+got.Levels[buildstep.LevelUnit].Kept != 4 { // the bench gives both members the same digests - t.Fatalf("try = %+v", got) - } - if got.Composition == nil || got.Composition.State != meshdeliverycheckerclient.CompositionPass || len(got.Machines) == 0 { - t.Errorf("the try's composition = %+v, want the composition on every placed node, as a check's", got.Composition) - } - // The same key the indexer's candidate of the group has: the try's id and the heads of its members. - if len(comps.asked) != 1 || comps.asked[0] != id || len(cands.asked) != 1 || !strings.HasPrefix(cands.asked[0], id+".") { - t.Errorf("composed %v, candidate asked %v, want the try's key %s", comps.asked, cands.asked, id) - } - // Issue 1890: while it runs, the try names its asks as soon as they are put, and then where each step stands. - if len(written.running) < 3 || len(written.running[1].Asks) != 1 || written.running[1].Steps[0].State != TryAsked { - t.Errorf("the running try's writes = %+v, want its ask named while it ran", written.running) - } - // Two check asks and the checking program's two run asks (the seat list and the verdict). - if len(got.Steps) != 4 || got.Steps[0].Node != "shanks" || got.Steps[0].State != buildstep.StepPassed || len(got.Asks) != 4 { - t.Errorf("the ended try's steps = %+v, asks %v", got.Steps, got.Asks) - } - for _, a := range got.Asks { // the delivery view counts their steps as a try's (build_usage) - if _, err := buildstep.AskStepKey("", "shanks", a); err != nil { - t.Errorf("the try names %q, which is no ask id: %v", a, err) - } - } - // Each member is fetched at the exact commit asked, merged onto its own trunk, with no pull request's ref. - fetch := b.steps.tool("fetch") - if len(fetch) != 2 { - t.Fatalf("fetch = %+v, want one per member", fetch) - } - for _, f := range fetch { - want := map[string][2]string{repoA: {head1, trunkA}, repoSDK: {head2, trunkS}}[f.args["repository"].(string)] - if f.args["commit"] != want[0] || f.args["base"] != want[1] || f.args["ref"] != nil { - t.Errorf("fetch = %+v, want the exact commit %s merged onto %s", f.args, want[0], want[1]) - } - } - // A whole try writes the merge previews the indexer makes its candidate from; it writes no status and asks no Approve. - if keys, _ := b.prev.Keys(ctx); len(keys) != 2 { - t.Errorf("a whole try wrote the previews %v, want one per member", keys) - } - // An ended try is not run again. - raw, _, _, _ = kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - if n := len(b.steps.tool("fetch")); n != 2 { - t.Errorf("an ended try was fetched again: %d fetches", n) - } - // The kept verdicts: what the try passed is kept under the digests of the merged trees, so the pull-request check of - // the same head on the same trunk runs none of it again (and a push of other code runs only what changed). - before := len(b.steps.tool("test")) - out := b.judge(t, caseOf(t, pullOf(repoA, 7, head1))) - if out.Verdict.State != meshdeliverycheckerclient.VerdictPass || out.Verdict.Levels[buildstep.LevelUnit].Kept == 0 || out.Verdict.Levels[buildstep.LevelUnit].Run != 0 || - out.Verdict.Levels[buildstep.LevelIntegration].Run != 0 { - t.Errorf("the check of the tried head = %+v, want everything the try passed kept and nothing run", out.Verdict.Levels) - } - if after := len(b.steps.tool("test")); after != before { - t.Errorf("the check of the tried head ran %d test steps, want none: the try's passes are kept", after-before) - } -} - -func TestATryOfOneLevelAndSomeTestsRunsThemAloneAndKeepsNothing(t *testing.T) { - ctx := context.Background() - kv := newMemKV() - id, err := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1, Level: buildstep.LevelIntegration, Tests: "TestBus|TestStore"}, time.Now()) - if err != nil { - t.Fatal(err) - } - b := newBench(t) - tr := &Tryer{Tries: kv, Judge: b.ex, Say: func(context.Context, string, checkermsg.Event) error { - t.Error("a try of one level and some tests said an event: it has no candidate") - return nil - }} - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - if open, _ := OpenTries(memTries{kv}); len(open) != 0 { - t.Errorf("open = %v", open) - } - tests := b.steps.tool("test") - if len(tests) != 1 || tests[0].args["level"] != buildstep.LevelIntegration || tests[0].args["run"] != "TestBus|TestStore" { - t.Fatalf("tests = %+v, want the integration level alone with the run pattern", tests) - } - if n := len(b.steps.tool("digest")); n != 0 { - t.Errorf("%d digests for a try of some tests", n) - } - if keys, _ := b.kept.Keys(ctx); len(keys) != 0 { - t.Errorf("kept %v from a try of some tests", keys) - } - if got := readTry(t, kv, id); got.State != TryPass || !strings.Contains(got.Said, "only the tests TestBus|TestStore") { - t.Errorf("try = %+v", got) - } - t.Run("a try of one level keeps only that level", func(t *testing.T) { - kv := newMemKV() - id, _ := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1, Level: buildstep.LevelUnit}, time.Now()) - b := newBench(t) - tr := &Tryer{Tries: kv, Judge: b.ex} - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - keys, _ := b.kept.Keys(ctx) - if got := readTry(t, kv, id); got.State != TryPass || len(keys) == 0 { - t.Fatalf("try = %+v, kept %v", got, keys) - } - for _, k := range keys { - if !strings.HasPrefix(k, buildstep.LevelUnit+".") { - t.Errorf("a try of the unit level kept %s", k) - } - } - }) -} - -func TestAFailingTryNamesWhatFailedAndAStepThatCannotRunIsAnError(t *testing.T) { - ctx := context.Background() - kv := newMemKV() - b := newBench(t) - b.test = func(c stepCall) (any, error) { return captured[Tested](t, "go-test-failing"), nil } - id, _ := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, time.Now()) - tr := &Tryer{Tries: kv, Judge: b.ex} - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - if got := readTry(t, kv, id); got.State != TryFail || len(got.Failed) != 2 || !strings.Contains(got.Failed[0], "unit: fixture/failing/bad.TestThreeIsFour") || - !strings.Contains(got.Failed[1], "integration: fixture/failing/bad.TestThreeIsFour") { // both levels ran (the operator, 2026-11-02) - t.Errorf("try = %+v", got) - } - // A whole try that could not judge the manifests and the composition is no pass; a failed composition is named beside - // the failed tests (the group's check does as much), and a candidate of other heads is not the try's. - for _, row := range []struct { - name string - cand *fakeTryCandidates - comp *rules.Composed - state, said string - }{ - {name: "the indexer wrote no candidate", cand: &fakeTryCandidates{err: errors.New("the indexer wrote no candidate within 5m0s")}, state: TryError, said: "the indexer wrote no candidate within 5m0s"}, - {name: "a node that gave no composition answer", cand: &fakeTryCandidates{}, comp: &rules.Composed{Composer: "x", Nodes: []string{"g14"}}, - state: TryError, said: "g14: " + nodeengineclient.NoAnswer}, - {name: "a composition refused on a node", cand: &fakeTryCandidates{}, comp: ptr(refusedOn("x", "g14", "web: needs a state mail does not keep")), - state: TryFail, said: "not composed on g14: web: needs a state mail does not keep"}, - } { - kv := newMemKV() - b := newBench(t) - comps, _ := wholeBench(b, meshcatalog.CandidatesByGroupValue{}) - b.ex.Candidates = row.cand - if row.comp != nil { - comps.v = *row.comp - } - id, _ := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, time.Now()) - var ends []string - tr := &Tryer{Tries: kv, Judge: b.ex, Say: func(_ context.Context, event string, e checkermsg.Event) error { - if event == checkermsg.Ended { - ends = append(ends, e.State) - } - return nil - }} - raw, _, _, _ := kv.Get(ctx, id) - tr.Put(ctx, id, raw) - tr.Wait() - if len(ends) != 1 || ends[0] != row.state { // every end says its state: error as well as fail - t.Errorf("%s: ends said = %v, want once %s", row.name, ends, row.state) - } - if got := readTry(t, kv, id); got.State != row.state || !strings.Contains(strings.Join(got.Failed, " | ")+got.Said, row.said) { - t.Errorf("%s: try = %s, failed %v, said %q, want %s naming %q", row.name, got.State, got.Failed, got.Said, row.state, row.said) - } - } - // No build node is no error since R4g: the try's ask waits in the check stream until a node pulls it (ADR 0525 §4). -} - -func TestATryLeftRunningIsTakenOver(t *testing.T) { - ctx := context.Background() - // Whether the start was said is in the try's own state (Told), so a checker that starts later says the end of a try it did - // not start, whatever way the try ended. - for _, row := range []struct { - name string - told bool - failFirst bool // the stream does not acknowledge the first end said - after func(t *testing.T, kv *memKV, id string) - ends []string - }{ - {name: "the first publish of the end is not acknowledged", told: true, failFirst: true, ends: []string{TryPass}}, - {name: "left running after its start was said", told: true, ends: []string{TryPass}}, - {name: "left running with no start said", told: false, ends: []string{TryPass}}, - {name: "ended by hand after the start was said", told: true, ends: []string{TryError}, after: func(t *testing.T, kv *memKV, id string) { - if _, err := EndTry(endable{kv}, id, "stuck", time.Now()); err != nil { - t.Fatal(err) - } - }}, - } { - t.Run(row.name, func(t *testing.T) { - kv := newMemKV() - id, _ := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, time.Now()) - // Left running by a checker that stopped. - raw, rev, _, _ := kv.Get(ctx, id) - cur, _ := DecodeTry(raw) - cur.State, cur.Told = TryRunning, row.told - data, _ := encodeTry(cur) - if _, err := kv.Update(ctx, id, data, rev); err != nil { - t.Fatal(err) - } - if row.after != nil { - row.after(t, kv, id) - } - b := newBench(t) - wholeBench(b, meshcatalog.CandidatesByGroupValue{}) - var ends []string - failed := false - tr := &Tryer{Tries: kv, Judge: b.ex, Say: func(_ context.Context, event string, e checkermsg.Event) error { - if event == checkermsg.Ended { - if row.failFirst && !failed { - failed = true - return errors.New("the stream did not acknowledge") - } - ends = append(ends, e.State) - } - return nil - }} - tr.Reconsider(ctx) - tr.Wait() - if row.failFirst && !readTry(t, kv, id).Told { - t.Errorf("an end the stream did not acknowledge cleared Told: it is never said again") - } - tr.Reconsider(ctx) // said once: the second look finds nothing owed - tr.Wait() - if row.after == nil { - if got := readTry(t, kv, id); got.State != TryPass { - t.Errorf("the try left running = %+v, want taken over and passed", got) - } - } - if !slices.Equal(ends, row.ends) || readTry(t, kv, id).Told { - t.Errorf("ends said = %v, want %v, and nothing owed after", ends, row.ends) - } - }) - } - // An ended try is kept TryKeep and removed by the next Reconsider after. - t.Run("an ended try is kept seven days", func(t *testing.T) { - kv := newMemKV() - id, _ := AskTry(memTries{kv}, tryTrunks, TryAsk{Repository: repoA, Head: head1}, time.Now()) - raw, rev, _, _ := kv.Get(ctx, id) - cur, _ := DecodeTry(raw) - ended := time.Now() - cur.State, cur.Ended = TryPass, ended - data, _ := encodeTry(cur) - if _, err := kv.Update(ctx, id, data, rev); err != nil { - t.Fatal(err) - } - now := ended.Add(TryKeep - time.Hour) - tr := &Tryer{Tries: kv, Now: func() time.Time { return now }} - tr.Reconsider(ctx) - if _, _, found, _ := kv.Get(ctx, id); !found { - t.Fatal("the try was removed before TryKeep") - } - now = ended.Add(TryKeep + time.Hour) - tr.Reconsider(ctx) - if _, _, found, _ := kv.Get(ctx, id); found { - t.Error("the try was kept past TryKeep") - } - }) -} diff --git a/modules/mesh-delivery-checker/internal/check/verdictevent.go b/modules/mesh-delivery-checker/internal/check/verdictevent.go deleted file mode 100644 index 1fcfcc16..00000000 --- a/modules/mesh-delivery-checker/internal/check/verdictevent.go +++ /dev/null @@ -1,44 +0,0 @@ -package check - -import ( - "context" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// EventVerdict is the checker's event that says a pull request's check ended, with the generated files its steps found out -// of step with their seat definitions (design 26 *Out of step*; ADR 0620): on the checker's own family asks (its stream -// asks), so the indexer learns them from the event and runs no generator, and a waiter on the stream checks does not wake. -const EventVerdict = meshdeliverychecker.HolderEventVerdict - -// VerdictEvent is the body of verdict, as the seat definition of mesh-delivery-checker says it. -type VerdictEvent = meshdeliverychecker.VerdictHolderEvent - -// VerdictSayer publishes a verdict event. -type VerdictSayer interface { - Say(ctx context.Context, v VerdictEvent) error -} - -// sayVerdict says, for each pull request of a check that ended in pass or fail, one verdict event naming its head and its -// out-of-step files. A try owes no pull request anything and says none (ADR 0501 §5). A publish that fails is said in the -// log: the verdict and the status are written already, and the next check of the heads says it again. -func (ch *Checker) sayVerdict(ctx context.Context, cs *Case, v meshdeliverychecker.VerdictsByGroupHeadsValue, out Outcome) { - if ch.Says == nil || cs.Try != nil || (v.State != meshdeliverycheckerclient.VerdictPass && v.State != meshdeliverycheckerclient.VerdictFail) { - return - } - for _, p := range cs.Pulls { - key := pullKey(Pull{Repository: p.Repository, Number: p.Number}) - e := VerdictEvent{Repository: p.Repository, Pull: int64(p.Number), Head: p.Head, Verdict: v.State, OutOfStep: out.OutOfStep[key]} - for _, s := range cs.SeriesChanges(key) { - e.Series = append(e.Series, meshdeliverychecker.VerdictHolderEventSeriesItem{Module: s.Module, Artifact: s.Artifact, From: s.From, To: s.To}) - } - if err := ch.Says.Say(ctx, e); err != nil { - ch.logf("%s: the verdict of %s#%d was written, and its event could not be said: %v", cs.Key, p.Repository, p.Number, err) - } - } -} - -// AsksStream is the checker's stream that carries verdict, one that keeps its history (ADR 0592 §6): the bus names it -// ASKS. -const AsksStream = "asks" diff --git a/modules/mesh-delivery-checker/manifest_test.go b/modules/mesh-delivery-checker/manifest_test.go deleted file mode 100644 index 1b393318..00000000 --- a/modules/mesh-delivery-checker/manifest_test.go +++ /dev/null @@ -1,325 +0,0 @@ -package manifest - -import ( - "bytes" - "encoding/json" - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "io/fs" - "os" - "path/filepath" - "reflect" - "slices" - "strings" - "testing" - - "mesh-delivery-checker/internal/check" -) - -// The controller's manifest reader is mesh-controller internal/catalogue (Manifest, manifest.go: Consumes :521, -// Invokes :590, Streams :613, Reads :659; StreamDeclaration, streams.go), an internal package of another repository. -// These tests decode the manifest strictly into the fields those types name (DisallowUnknownFields) and hold the -// rules of issues 1678 and 1683 (ADR 0453 §4, ADR 0484). The merge gate's module check proves the controller takes the manifest. - -type state struct { - Name string `json:"name"` - History int `json:"history,omitempty"` - TTL int `json:"ttl-seconds,omitempty"` - MaxMiB int `json:"max-mib,omitempty"` -} - -type artifact struct { - Name string `json:"name"` - Kind string `json:"kind"` - Language string `json:"language"` - System string `json:"system"` - From string `json:"from"` - Binary string `json:"binary"` - Loads []string `json:"loads"` - Paths []string `json:"paths"` - Series string `json:"series"` -} - -type stream struct { - Name string `json:"name"` - Events []string `json:"events"` - MaxAgeDays int `json:"max-age-days,omitempty"` - MaxMiB int `json:"max-mib,omitempty"` - Retention string `json:"retention,omitempty"` -} - -type manifest struct { - Claims []struct { - Name string `json:"name"` - Scope string `json:"scope"` - Serves []string `json:"serves"` - } `json:"claims"` - Streams []stream `json:"streams"` - Tools []string `json:"tools"` - Module string `json:"module"` - Version string `json:"version"` - Slug string `json:"slug"` - Consumes []string `json:"consumes"` - State []state `json:"state"` - Reads []string `json:"reads"` - Uses []string `json:"uses"` - Invokes []string `json:"invokes"` - Config map[string]struct { - Type string `json:"type"` - Description string `json:"description"` - Pattern string `json:"pattern"` - Default any `json:"default"` - Minimum *float64 `json:"minimum"` - Maximum *float64 `json:"maximum"` - Trusted bool `json:"trusted"` - } `json:"config"` - OwnSecrets map[string]string `json:"own-secrets"` - SecretsOwner string `json:"secrets-owner"` - Resources []map[string]any `json:"resources"` - Build struct { - Artifacts []artifact `json:"artifacts"` - } `json:"build"` -} - -func load(t *testing.T) (manifest, map[string]json.RawMessage) { - t.Helper() - raw, err := os.ReadFile("module.json") - if err != nil { - t.Fatal(err) - } - var m manifest - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&m); err != nil { - t.Fatalf("the controller's reader refuses a key this manifest has: %v", err) - } - var top map[string]json.RawMessage - if err := json.Unmarshal(raw, &top); err != nil { - t.Fatal(err) - } - return m, top -} - -func sorted(s []string) []string { - s = slices.Clone(s) - slices.Sort(s) - return s -} - -func TestManifestDeclarations(t *testing.T) { // 1678/AC1 - m, top := load(t) - // 1373: checker_ask_again asks the delivery view's build_usage for the build seats' backlog; the list below is the rest. - if !slices.Contains(m.Invokes, "mesh-delivery-view.build_usage") { - t.Error("invokes lack mesh-delivery-view.build_usage, which checker_ask_again asks for the build seats' streams") - } - m.Invokes = slices.DeleteFunc(slices.Clone(m.Invokes), func(s string) bool { return s == "mesh-delivery-view.build_usage" }) - if m.Module != "mesh-delivery-checker" { - t.Errorf("module = %q", m.Module) - } - // The histories of the checker's four seat states (checked against internal/check names below); the names follow the seat mesh-delivery-checker. - if want := []state{{Name: "asks", History: 1}, {Name: "hearing", History: 1}, {Name: "inputs", TTL: 86400}, {Name: "compositions", TTL: 259200, MaxMiB: 256}, {Name: "kept", History: 1}, {Name: "owed", History: 5}, {Name: "previews", History: 5}, {Name: "tries", History: 1}, {Name: "verdicts", History: 5}, {Name: "first-views", History: 1}, {Name: "findings", History: 1}, {Name: "could-not-run", History: 1}}; !reflect.DeepEqual(m.State, want) { - t.Errorf("state = %+v, want %+v", m.State, want) - } - // The build modules are no names (design 47 G A-82): the steps and toolchains of the build seats are read as the seat's holder's states. - if want := []string{"mesh-delivery-builder.builds", "mesh-delivery-watchman.presence", "node-engine.have", - "seat:mesh-module-assigner.assignments", "seat:node-build-go.steps", "seat:node-build-go.toolchains", "seat:node-build-node.steps", "seat:node-build-node.toolchains"}; !reflect.DeepEqual(sorted(m.Reads), want) { - t.Errorf("reads = %v, want %v", m.Reads, want) - } - // DLV-M2 (ADR 0615 §1, ADR 0596): the indexer's candidates, modules, manifests, packages and predefined keys and the - // assigner's assignments are asked by their read tools and followed by their views families, never read. - for _, r := range m.Reads { - if strings.HasPrefix(r, "mesh-delivery-indexer.") || strings.HasPrefix(r, "mesh-delivery-assigner.") { - t.Errorf("reads %s: the indexer's and the assigner's state is read by their tools and views families alone", r) - } - } - // 1887/A5b: the checker reads nothing of the controller's plans-building (ADR 0483 superseded by ADR 0525 §7), calls no - // build module's tool and holds no capacity: it puts check asks on the Go and Node build seats (ADR 0525 §1, §4). - // The forge's file read through the seat git, never a module's tool (milestone 47/G W6.14), the build seats' drop, and of - // the node seat node-engine its one verb compose-candidate, asked of every placed node (ADR 0593 §7), never its other verbs. - if want := []string{"mesh-delivery-indexer.indexer_read_candidates", "mesh-delivery-indexer.indexer_read_manifests", - "mesh-delivery-indexer.indexer_read_modules", "mesh-delivery-indexer.indexer_read_packages", "mesh-delivery-indexer.indexer_read_predefined", - "mesh-delivery-indexer.indexer_read_seat_definitions", - "seat:git.file", "seat:mesh-catalog.registrations", "seat:mesh-catalog.revision", "seat:mesh-catalog.seat-definitions", "seat:mesh-delivery.source", "seat:mesh-config.renames", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:node-build-go.drop", "seat:node-build-node.drop", "seat:node-engine.compose-candidate", - // The image build seat's drop too: a check of a module built by it is asked of it, and dropped of it (buildrun.SeatDrops). - "seat:node-build-image.drop", - // A-290, A-291: a step's answer its key keeps as an object, read through each build seat's verb output. - "seat:node-build-go.output", "seat:node-build-node.output", "seat:node-build-image.output", - // A-231: the check asks on each build seat's queues check and recheck. - "seat:node-build-go.accept.check", "seat:node-build-go.accept.recheck", "seat:node-build-node.accept.check", - "seat:node-build-node.accept.recheck", "seat:node-build-image.accept.check", "seat:node-build-image.accept.recheck"}; !reflect.DeepEqual(sorted(m.Invokes), sorted(want)) { - t.Errorf("invokes = %v, want the seat git's file, the seats' drop and compose-candidate", m.Invokes) - } - if want := []string{"node-build-go", "node-build-node"}; !reflect.DeepEqual(sorted(m.Uses), want) { - t.Errorf("uses = %v, want the Go and Node build seats", m.Uses) - } - // The checker is woken by a build seat's report of a toolchain, as the builder is: the bucket may not exist when it starts. - // Design 47 G §717, §614: the catalog half, whose claimant's seat-holders view names the holder of the assignments. - if want := []string{"mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-catalog.seat-definition-changed", "mesh-catalog.seat-definition-removed", "mesh-conditions.findings-asked", "mesh-delivery-indexer.views.candidates", "mesh-delivery-indexer.views.manifests", "mesh-delivery-indexer.views.modules", - "mesh-delivery-indexer.views.packages", "mesh-delivery-indexer.views.predefined", "mesh-delivery-indexer.views.seat-definitions", "mesh-delivery.source-moved", "node-build-go.toolchain-reported", "node-build-node.toolchain-reported", "node-engine.running", "seat:mesh-module-assigner.views.assignments", "seat:mesh-module-assigner.views.seat-holders"}; !reflect.DeepEqual(sorted(m.Consumes), want) { - t.Errorf("consumes = %v, want %v", m.Consumes, want) - } - if b, ok := m.OwnSecrets["broker"]; !ok || len(m.OwnSecrets) != 1 || b != "${dir:state}/broker" { - t.Errorf("own-secrets = %v, want exactly broker", m.OwnSecrets) - } - if m.SecretsOwner != "mesh-delivery-checker" { - t.Errorf("secrets-owner = %q", m.SecretsOwner) - } - // The checker says each time it wrote a preview or a status, so the indexer's and the forge bridge's watches find the buckets (ADR 0484 clauses 2 and 3). - // Its family asks (design 26): verdict, apart from checks so a waiter on a verdict does not wake on a check; a stream that keeps its history, the predefined form of an event family - // (ADR 0592 §6, the manifest validator). - if want := []stream{{Name: "checks", Events: []string{"preview.**", "owed.**", "try.**"}}, {Name: "asks", Events: []string{"verdict"}, Retention: "history"}, {Name: "mesh-delivery-checker-findings", Events: []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}, MaxAgeDays: 7, MaxMiB: 16}}; !reflect.DeepEqual(m.Streams, want) { - t.Errorf("streams = %+v, want %+v", m.Streams, want) - } - // Only the checker's account publishes try.* on its stream checks: the stream is declared by its owner alone, and no other - // module of the repository declares a stream carrying a try event (the indexer and the others only consume them). - siblings, err := filepath.Glob("../*/module.json") - if err != nil || len(siblings) < 2 { - t.Fatalf("the sibling manifests = %v, %v", siblings, err) - } - for _, f := range siblings { - raw, err := os.ReadFile(f) - if err != nil { - t.Fatal(err) - } - var other struct { - Module string `json:"module"` - Streams []stream `json:"streams"` - } - if err := json.Unmarshal(raw, &other); err != nil { - t.Fatalf("%s: %v", f, err) - } - for _, st := range other.Streams { - for _, e := range st.Events { - if strings.HasPrefix(e, "try.") && other.Module != m.Module { - t.Errorf("%s declares the stream %s with %s: only the checker's account publishes try events", other.Module, st.Name, e) - } - } - } - } - // The read tools (issue 1686) are served by the tools bundle, not by the checker's process. - // The try's tools (ADR 0501 §5; the end by hand, issue 734) beside them: mesh-controller's try calls them. A lost check - // is asked again by hand (checker_ask_again). - if want := []string{"checker_ask_again", "checker_composition_requests", "checker_composition_requests_drop", "checker_first_view_again", "checker_first_views", "checker_inputs", "checker_kept", "checker_previews", "checker_pull", "checker_status", "checker_tries", "checker_try", "checker_try_end", "checker_try_read", "checker_verdicts"}; !reflect.DeepEqual(sorted(m.Tools), want) { - t.Errorf("tools = %v, want %v", m.Tools, want) - } - // The try is the checker's own seat's verbs (ADR 0547 §10, issue 774), served beside the tools by the same code; so is - // input, a checking program's input the Go build module asks (issue 1921, ADR 0596 §2). - if len(m.Claims) != 1 || m.Claims[0].Name != "mesh-delivery-checker" || m.Claims[0].Scope != "mesh" || - !reflect.DeepEqual(m.Claims[0].Serves, []string{"try", "try-read", "try-end", "input"}) { - t.Errorf("claims = %+v, want the mesh seat mesh-delivery-checker serving try, try-read, try-end and input", m.Claims) - } - for _, k := range []string{"logs", "emits", "provides", "requires", "defines-seats", "seat", "seats", "bus"} { // config: compose-answer-bound (ADR 0593 §7) - if _, ok := top[k]; ok { - t.Errorf("the manifest declares %q: the checker has none", k) - } - } - // D-11 (ADR 0634 §1): the holders and buckets internal/check names, no contract naming a holder, are the manifest's: a state - // the checker reads is a `reads` (.) and a state of the indexer it follows a `consumes` of its views family. - for bucket, read := range map[string]string{ - check.PresenceBucket: "mesh-delivery-watchman.presence", check.HaveBucket: "node-engine.have"} { - if strings.Replace(bucket, "_", ".", 1) != read || !slices.Contains(m.Reads, read) { - t.Errorf("the bucket %s is not the declared read %s", bucket, read) - } - } - for bucket, view := range map[string]string{check.CandidatesBucket: "candidates", check.ModulesBucket: "modules", check.ManifestsBucket: "manifests"} { - if bucket != check.IndexerModule+"_"+view || !slices.Contains(m.Consumes, check.IndexerModule+".views."+view) { - t.Errorf("the bucket %s is not a followed view of the indexer's %s", bucket, view) - } - } - if !slices.Contains(m.Consumes, check.IndexerModule+".views."+check.IndexerPredefinedState) { - t.Errorf("the indexer's state %s is followed, and not declared", check.IndexerPredefinedState) - } - for own, history := range map[string]int{checker.StateVerdicts: 5, checker.StateKept: 1, checker.StateOwed: 5, checker.StatePreviews: 5} { - if !slices.ContainsFunc(m.State, func(st state) bool { return st.Name == own && st.History == history }) { - t.Errorf("the state %s is not a state of the manifest at history %d", own, history) - } - } -} - -func TestManifestProcess(t *testing.T) { // 1678/AC1 - m, _ := load(t) - var procs []map[string]any - for _, r := range m.Resources { - if r["type"] == "process" { - procs = append(procs, r) - } - if r["type"] == "tool" || r["type"] == "seat" { - t.Errorf("resource %v: the checker serves no tool and holds no seat", r) - } - } - if len(procs) != 1 { - t.Fatalf("%d process resources, want one", len(procs)) - } - p := procs[0] - if p["artifact"] != "program" || !reflect.DeepEqual(p["run"], []any{"./mesh-delivery-checker"}) { - t.Errorf("process = %v", p) - } - env, _ := p["env"].(map[string]any) - if len(env) != 2 || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_CHECKER_SETTINGS"] != "${dir:state}/settings.json" { - t.Errorf("env = %v, want the broker file and the settings file", p["env"]) - } - // Its settings hold its answer bound (ADR 0593 §7: compose-answer-bound, 60 s, the checker's) and its wait for the - // candidate's builds (ADR 0603 §10: build-wait-bound, 1800 s), never a capacity of its own (ADR 0525 §4). - for _, r := range m.Resources { - if r["id"] == "settings" && !reflect.DeepEqual(r["takes-config"], []any{"compose-answer-bound", "build-wait-bound"}) { - t.Errorf("the settings resource %v takes other than compose-answer-bound and build-wait-bound", r) - } - } - if c, ok := m.Config["build-wait-bound"]; !ok || c.Default != float64(1800) || c.Trusted { - t.Errorf("build-wait-bound = %+v, want 1800 by default, not trusted", c) - } - if c, ok := m.Config["compose-answer-bound"]; !ok || c.Default != float64(60) || c.Trusted { - t.Errorf("compose-answer-bound = %+v, want 60 by default, not trusted", c) - } - if _, bus := p["bus"]; bus { - t.Errorf("the process declares a bus: it runs on its own broker credential") - } - // The settings template is packed as the files archive (novox/hq ADR 0349 §2), or the indexer's judge refuses it. - // Issue 1966's bootstrap: the package artifact checkermsg is out of the manifest until the new builder runs; the - // follow-up puts it back with its assertion (ADR 0634 section 2: four artifacts, the fourth the package checkermsg). - if len(m.Build.Artifacts) != 3 { - t.Fatalf("artifacts = %+v, want the program, the tools and the files archive", m.Build.Artifacts) - } - if a := m.Build.Artifacts[2]; a.Name != "files" || a.Kind != "archive" || a.From != "files" { - t.Errorf("files artifact = %+v, want an archive from files/", a) - } - if a := m.Build.Artifacts[1]; a.Name != "tools" || a.Kind != "bundle" || a.Language != "go" || a.Binary != "mesh-delivery-checker-tools" || - !reflect.DeepEqual(a.Loads, []string{"mesh-delivery-checker-tools"}) { - t.Errorf("tools artifact = %+v", a) - } - if st, err := os.Stat(m.Build.Artifacts[1].From); err != nil || !st.IsDir() { - t.Errorf("the tools' source %s: %v", m.Build.Artifacts[1].From, err) - } - a := m.Build.Artifacts[0] - if st, err := os.Stat(a.From); err != nil || !st.IsDir() || a.Binary != "mesh-delivery-checker" || !strings.HasSuffix(a.From, a.Binary) || a.Kind != "bundle" || a.Language != "go" { - t.Errorf("artifact = %+v", a) - } -} - -func TestServesNoRequestSubjectAndHoldsNoTicker(t *testing.T) { // 1678/AC6 (ADR 0437 §8: no timer, a wait is a context's bound) - forbidden := []string{"Subscribe(", "QueueSubscribe", "ChanSubscribe", "time.NewTicker", "time.Tick", "time.NewTimer", "time.AfterFunc", "time.After(", "time.Sleep"} - var files int - for _, root := range []string{"cmd", "internal"} { - err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error { - if err != nil || d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") { - return err - } - files++ - src, err := os.ReadFile(path) - if err != nil { - return err - } - for _, f := range forbidden { - if strings.Contains(string(src), f) { - t.Errorf("%s holds %s: the checker serves no request subject and holds no timer", path, f) - } - } - return nil - }) - if err != nil { - t.Fatal(err) - } - } - if files < 1 { - t.Fatalf("read %d source files, want the program's", files) - } -} diff --git a/modules/mesh-delivery-checker/module.json b/modules/mesh-delivery-checker/module.json deleted file mode 100644 index 9116b3ff..00000000 --- a/modules/mesh-delivery-checker/module.json +++ /dev/null @@ -1,214 +0,0 @@ -{ - "module": "mesh-delivery-checker", - "version": "0.1", - "slug": "checker", - "claims": [ - { - "name": "mesh-delivery-checker", - "scope": "mesh", - "serves": [ - "try", - "try-read", - "try-end", - "input" - ] - } - ], - "consumes": [ - "mesh-catalog.catalog-revision", - "mesh-catalog.registration-changed", - "mesh-delivery.source-moved", - "seat:mesh-module-assigner.views.seat-holders", - "mesh-catalog.seat-definition-changed", - "mesh-catalog.seat-definition-removed", - "mesh-delivery-indexer.views.candidates", - "mesh-delivery-indexer.views.manifests", - "mesh-delivery-indexer.views.modules", - "mesh-delivery-indexer.views.packages", - "mesh-delivery-indexer.views.predefined", - "mesh-delivery-indexer.views.seat-definitions", - "mesh-conditions.findings-asked", - "seat:mesh-module-assigner.views.assignments", - "node-build-go.toolchain-reported", - "node-build-node.toolchain-reported", - "node-engine.running" - ], - "streams": [ - { "name": "checks", "events": ["preview.**", "owed.**", "try.**"] }, - { "name": "asks", "events": ["verdict"], "retention": "history" }, - { "name": "mesh-delivery-checker-findings", "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 16 } - ], - "state": [ - { "name": "asks", "history": 1 }, - { "name": "hearing", "history": 1 }, - { "name": "inputs", "ttl-seconds": 86400 }, - { "name": "compositions", "ttl-seconds": 259200, "max-mib": 256 }, - { "name": "kept", "history": 1 }, - { "name": "owed", "history": 5 }, - { "name": "previews", "history": 5 }, - { "name": "tries", "history": 1 }, - { "name": "verdicts", "history": 5 }, - { "name": "first-views", "history": 1 }, - { "name": "findings", "history": 1 }, - { "name": "could-not-run", "history": 1 } - ], - "reads": [ - "mesh-delivery-builder.builds", - "mesh-delivery-watchman.presence", - "node-engine.have", - "seat:mesh-module-assigner.assignments", - "seat:node-build-go.steps", - "seat:node-build-go.toolchains", - "seat:node-build-node.steps", - "seat:node-build-node.toolchains" - ], - "uses": [ - "node-build-go", - "node-build-node" - ], - "tools": [ - "checker_ask_again", - "checker_composition_requests", - "checker_composition_requests_drop", - "checker_inputs", - "checker_kept", - "checker_previews", - "checker_pull", - "checker_status", - "checker_first_views", - "checker_first_view_again", - "checker_tries", - "checker_try", - "checker_try_end", - "checker_try_read", - "checker_verdicts" - ], - "invokes": [ - "mesh-delivery-indexer.indexer_read_candidates", - "mesh-delivery-indexer.indexer_read_manifests", - "mesh-delivery-indexer.indexer_read_modules", - "mesh-delivery-indexer.indexer_read_packages", - "mesh-delivery-indexer.indexer_read_predefined", - "mesh-delivery-indexer.indexer_read_seat_definitions", - "seat:git.file", - "seat:mesh-catalog.revision", - "seat:mesh-catalog.registrations", - "seat:mesh-delivery.source", - "seat:mesh-catalog.seat-definitions", - "seat:mesh-config.renames", - "mesh-delivery-view.build_usage", - "seat:mesh-hand-acts.hand-act", - "seat:mesh-module-assigner.assignments", - "seat:node-build-go.drop", - "seat:node-build-node.drop", - "seat:node-engine.compose-candidate", - "seat:node-build-image.drop", - "seat:node-build-go.output", - "seat:node-build-node.output", - "seat:node-build-image.output", - "seat:node-build-go.accept.check", - "seat:node-build-go.accept.recheck", - "seat:node-build-node.accept.check", - "seat:node-build-node.accept.recheck", - "seat:node-build-image.accept.check", - "seat:node-build-image.accept.recheck" - ], - - "own-secrets": { - "broker": "${dir:state}/broker" - }, - "secrets-owner": "mesh-delivery-checker", - "config": { - "compose-answer-bound": { - "type": "number", - "description": "seconds a check waits for each placed node's engine to answer compose-candidate (novox/hq ADR 0593 §7, §9); a node that has not answered by then is named in the verdict as not composed on that node: no answer, and the check passes with that warning.", - "minimum": 1, - "maximum": 600, - "trusted": false, - "default": 60 - }, - "build-wait-bound": { - "type": "number", - "description": "seconds a check waits for the builder's builds of its candidate to end before it composes with them (novox/hq ADR 0603 §10); a build failed fails the check, naming it, and a build not ended by then is named in the verdict and the check composes without it.", - "minimum": 60, - "maximum": 7200, - "trusted": false, - "default": 1800 - } - }, - "resources": [ - { - "id": "account", - "type": "user", - "name": "mesh-delivery-checker", - "shell": "/usr/bin/nologin", - "home": "/var/lib/mesh-delivery-checker" - }, - { - "id": "state", - "type": "directory", - "mode": "0700", - "owner": "mesh-delivery-checker", - "place": ".", - "unknown": "program" - }, - { - "id": "settings", - "type": "file", - "path": "${dir:state}/settings.json", - "mode": "0600", - "owner": "mesh-delivery-checker", - "takes-config": [ - "compose-answer-bound", - "build-wait-bound" - ], - "merge": "json", - "template": "files/settings.json" - }, - { - "id": "checker", - "type": "process", - "name": "mesh-delivery-checker", - "artifact": "program", - "run": [ - "./mesh-delivery-checker" - ], - "env": { - "MESH_BROKER_FILE": "${dir:state}/broker", - "MESH_CHECKER_SETTINGS": "${dir:state}/settings.json" - }, - "user": "mesh-delivery-checker", - "health": { - "kind": "unit" - } - } - ], - "build": { - "artifacts": [ - { - "name": "program", - "kind": "bundle", - "language": "go", - "system": "arch", - "from": "cmd/mesh-delivery-checker", - "binary": "mesh-delivery-checker" - }, - { - "name": "tools", - "kind": "bundle", - "language": "go", - "system": "arch", - "from": "cmd/mesh-delivery-checker-tools", - "binary": "mesh-delivery-checker-tools", - "loads": [ - "mesh-delivery-checker-tools" - ] - }, - { - "name": "files", - "kind": "archive", - "from": "files" - } - ] - } -} diff --git a/modules/mesh-delivery-checker/reads-outside b/modules/mesh-delivery-checker/reads-outside deleted file mode 100644 index f6b2d871..00000000 --- a/modules/mesh-delivery-checker/reads-outside +++ /dev/null @@ -1 +0,0 @@ -These tests read files outside this directory (the whole catalogue, the repository, or its root files): mesh-build-go never keeps this package's verdict (issue 1935). diff --git a/modules/mesh-delivery-checker/rules/facts.go b/modules/mesh-delivery-checker/rules/facts.go deleted file mode 100644 index b913e864..00000000 --- a/modules/mesh-delivery-checker/rules/facts.go +++ /dev/null @@ -1,306 +0,0 @@ -// Package rules is the checker's judging rules, the checking program's: given the facts of one check (what the build -// modules, the manifest validator and the composer answered, and what failed in the asking), the verdict (novox/hq ADR -// 0644, ADR 0656; design 47's bootstrap delivery). The running checker asks, waits, keeps and records; it gathers the -// facts and has them judged by the checking program built from the change's heads (cmd/mesh-checking-program), which -// imports this package, so a change to a rule is judged by its own rule. -// -// It is the checker module's own package (novox/hq ADR 0634 §1): no seat carries it and no other module imports it. -package rules - -import ( - "encoding/json" - "fmt" - "path" - "sort" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// FactsVersion is the version of Facts this program reads. A checking program built from a later change reads the facts -// a running checker of this version writes, so a version is added to, never changed; a program refuses one it does not -// read, naming it (DecodeFacts). -const FactsVersion = 1 - -// Facts are everything one check judges, in the order the running checker met it. -type Facts struct { - V int `json:"v"` - // Group and Heads name the check (meshdeliverychecker.VerdictsByGroupHeadsValue's Group and Heads); Trunk is each repository's trunk head merged. - Group string `json:"group"` - Heads string `json:"heads"` - Trunk map[string]string `json:"trunk,omitempty"` - Members []Member `json:"members"` - // SeatDigests are, by seat, the digests (SeatDigest) of the definitions the running checker's reader holds: the - // `-seats` answer leaves out every head definition that is the same (milestone 47/G, the lead's ruling on review - // finding 3: a whole list is over a run answer's bound). None from a checker that hands none: then every head - // definition is answered. - SeatDigests map[string]string `json:"seat-digests,omitempty"` - // Series are the changes of the members' modules' series, as structures, put in the verdict whatever it is (DLV-C4). - Series []meshdeliverychecker.VerdictsByGroupHeadsValueSeriesItem `json:"series,omitempty"` - // Steps are, in the order met, each level a build module answered and each failure the asking met. - Steps []Step `json:"steps,omitempty"` - // CloneMS is how much of the steps' time their levels' running did not take (meshdeliverychecker.VerdictsByGroupHeadsValueTook.Clone). - CloneMS int64 `json:"clone-ms,omitempty"` - // Composition is how the check composed, after every step; nil when it was not composed (a narrowed try, a checker - // that composes nothing): its composition is then not run, unsaid. - Composition *Composition `json:"composition,omitempty"` - // Notes are the running checker's notes of the check, for a reader. - Notes []string `json:"notes,omitempty"` -} - -// Member is one pull request of the check. -type Member struct { - Repository string `json:"repository"` - Number int `json:"number"` - Head string `json:"head"` - Trunk string `json:"trunk,omitempty"` -} - -// Step is one fact of the check, in the order met: the node that ran it, and one of a level its build module answered -// (Level, as the build module gave it), what its fetch read of compiled programs (Programs), the manifest validator's -// answers (Manifests), the module graph's ordering edges (Graph) or a failure the asking met (Failed: a step not asked, refused or not answered, a conflict, worded -// by the running checker). A step with none only says which node ran it. -type Step struct { - Repository string `json:"repository"` - Number int `json:"number"` - Module string `json:"module,omitempty"` - // Language is the language of the toolchain the build module that ran the step builds with (a level's counts differ by it). - Language string `json:"language,omitempty"` - Node string `json:"node,omitempty"` - Level *buildstep.LevelAnswer `json:"level,omitempty"` - Failed *FailedFirst `json:"failed,omitempty"` - Programs *Programs `json:"programs,omitempty"` - Manifests *Manifests `json:"manifests,omitempty"` - // Graph is the module graph's ordering edges, as the change leaves them and as the trunk has them (JudgeGraph). - Graph *Graph `json:"graph,omitempty"` - // Renames is what a module brings and drops of `renamed-from` and how the seat mesh-config answered (JudgeRenames). - Renames *Renames `json:"renames,omitempty"` - // Unparsed is what the indexer keeps of a pull request's seat definitions that do not parse (JudgeUnparsed). - Unparsed *Unparsed `json:"unparsed,omitempty"` -} - -// LevelFact is a level answer as the facts carry it: only what the rules read (Tally.Level), so a group's facts stay -// within the run input's bound (buildstep.RunInputOf). The digest, the unmet packages and the level's judged program -// are left out, the kept packages are one count, and each test result keeps only the fields Tested names, without its -// packages, bounds and judged program (review round 1 of milestone 47/B0). An answer this cannot read is carried as given, -// for the rules to refuse it. -func LevelFact(la buildstep.LevelAnswer) *buildstep.LevelAnswer { - out := &buildstep.LevelAnswer{Level: la.Level} - kept := 0 - for _, k := range la.Kept { - kept += k.Tests - } - if len(la.Kept) > 0 { - out.Kept = []buildstep.KeptTaken{{Tests: kept}} - } - for _, raw := range la.Tests { - var res Tested - if err := json.Unmarshal(raw, &res); err != nil { - out.Tests = append(out.Tests, raw) - continue - } - res.Packages, res.JudgedBy, res.Bound, res.SetupBound, res.OverWhich = nil, "", 0, 0, "" - small, err := json.Marshal(res) - if err != nil { - small = raw - } - out.Tests = append(out.Tests, small) - } - return out -} - -// DecodeFacts reads facts, refusing a version this program does not read, naming it. -func DecodeFacts(data []byte) (Facts, error) { - var f Facts - if err := json.Unmarshal(data, &f); err != nil { - return Facts{}, fmt.Errorf("rules: the facts are not JSON of their shape: %w", err) - } - if f.V != FactsVersion { - return Facts{}, fmt.Errorf("rules: facts of version %d, this checking program reads version %d", f.V, FactsVersion) - } - return f, nil -} - -// Counts are one level's counts across a check's members. -type Counts struct { - Run, Kept, Skipped int - Elapsed, Setup float64 - Lint float64 - Over bool - Slowest []TestTime -} - -// Tally is a check's counts by level. -type Tally map[string]*Counts - -// NewTally is a tally of both levels, at nothing. -func NewTally() Tally { - return Tally{buildstep.LevelUnit: {}, buildstep.LevelIntegration: {}} -} - -// Level judges one level of a member's check step as it was answered: the kept ones taken are counted, and every test -// result is read and counted, also after one that did not pass, so the verdict names every failed test of the level -// (issue 1921). It answers the level's failure (nil when it passed), its running time (its tests' and setup's) and the -// results read, for the running checker to keep the passes from. -func (t Tally) Level(repository string, number int, module, language, node string, la buildstep.LevelAnswer) (*meshdeliverychecker.VerdictsByGroupHeadsValue, float64, []Tested) { - a := t[la.Level] - if a == nil { - return failAt(node, fmt.Sprintf("the check of %s#%d answered the level %q, which is no level", repository, number, la.Level)), 0, nil - } - for _, k := range la.Kept { - a.Kept += k.Tests - } - elapsed := 0.0 - var results, failed []Tested - for _, raw := range la.Tests { - var res Tested - if err := json.Unmarshal(raw, &res); err != nil { - return failAt(node, fmt.Sprintf("the %s level of %s#%d answered what is not a result: %v", la.Level, repository, number, err)), elapsed, results - } - results = append(results, res) - elapsed += res.Elapsed + res.Setup + res.Lint - if language == LanguageTypeScript { - if !res.NoTests { - a.Run++ // a Node package is counted whole: its build module counts no tests (ADR 0484 clause 10) - } - } else { - a.Run += res.Tests - a.Skipped += res.Skipped - a.Slowest = append(a.Slowest, res.Slowest...) - } - a.Elapsed += res.Elapsed - a.Setup += res.Setup - a.Lint += res.Lint - a.Over = a.Over || res.OverBound - if !res.Passed { - failed = append(failed, res) - } - } - if len(failed) > 0 { - return LevelFailure(repository, module, language, la.Level, failed...), elapsed, results - } - return nil, elapsed, results -} - -// Judge is the verdict of the facts (Judged without its notes). -func Judge(f Facts) meshdeliverychecker.VerdictsByGroupHeadsValue { return Judged(f).Verdict } - -// Judged is the answer of the facts: every failure in the order met, joined and settled, or a pass; the levels' -// counts, times, machines and the levels over their bound; then the composition taken in; and the notes the rules give -// a reader (the manifest validator's warnings and acceptances). -func Judged(f Facts) Answer { - var notes []string - tally := NewTally() - var failures []*meshdeliverychecker.VerdictsByGroupHeadsValue - nodes := map[string]bool{} - for _, s := range f.Steps { - if s.Node != "" { - nodes[s.Node] = true - } - switch { - case s.Failed != nil: - failures = append(failures, &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: s.Failed}) - case s.Level != nil: - if v, _, _ := tally.Level(s.Repository, s.Number, s.Module, s.Language, s.Node, *s.Level); v != nil { - failures = append(failures, v) - } - case s.Programs != nil: - if ff := JudgePrograms(s.Node, *s.Programs); ff != nil { - failures = append(failures, &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: ff}) - } - case s.Graph != nil: - ff, said := JudgeGraph(*s.Graph, s.Module) - notes = append(notes, said...) - if ff != nil { - failures = append(failures, &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: ff}) - } - case s.Renames != nil: - ffs, said := JudgeRenames(*s.Renames) - notes = append(notes, said...) - for _, ff := range ffs { - failures = append(failures, &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &ff}) - } - case s.Unparsed != nil: - for _, ff := range JudgeUnparsed(*s.Unparsed) { - failures = append(failures, &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &ff}) - } - case s.Manifests != nil: - ff, said := JudgeManifests(*s.Manifests, s.Module) - notes = append(notes, said...) - if ff != nil { - failures = append(failures, &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: ff}) - } - } - } - v := meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictPass} - if joined := Settled(JoinFailures(failures...)); joined != nil { - v = *joined - } - v.Group, v.Heads, v.Trunk, v.Series = f.Group, f.Heads, f.Trunk, f.Series - Outcome(&v, tally, f.CloneMS, nodes) - if f.Composition != nil { - JudgeComposition(&v, *f.Composition) - } - return Answer{V: AnswerVersion, Verdict: v, Notes: notes} -} - -// Outcome fills a verdict's levels (on a pass, or when it names none), times, machines and levels over their bound from -// the tally, and says its composition is not yet run (ADR 0484 clause 6). -func Outcome(v *meshdeliverychecker.VerdictsByGroupHeadsValue, tally Tally, cloneMS int64, nodes map[string]bool) { - if v.State == meshdeliverycheckerclient.VerdictPass || len(v.Levels) == 0 { - v.Levels = map[string]meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue{} - for level, a := range tally { - v.Levels[level] = meshdeliverychecker.VerdictsByGroupHeadsValueLevelsValue{Run: int64(a.Run), Kept: int64(a.Kept), Skipped: int64(a.Skipped)} - } - } - ms := func(s float64) int64 { return int64(s * 1000) } - u, i := tally[buildstep.LevelUnit], tally[buildstep.LevelIntegration] - v.Took = &meshdeliverychecker.VerdictsByGroupHeadsValueTook{Clone: cloneMS, Unit: ms(u.Elapsed), Lint: ms(u.Lint), IntegrationSetup: ms(i.Setup), IntegrationRun: ms(i.Elapsed)} - v.Machines = nil - for node := range nodes { - v.Machines = append(v.Machines, node) - } - sort.Strings(v.Machines) - v.OverBound = nil - for _, level := range []string{buildstep.LevelUnit, buildstep.LevelIntegration} { - if tally[level].Over { - v.OverBound = append(v.OverBound, level) - } - } - v.Composition = &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionNotRun} -} - -// Slowest are, of each level over its bound, its three slowest tests, worded for the status line. -func Slowest(tally Tally) []string { - var slow []string - for _, level := range []string{buildstep.LevelUnit, buildstep.LevelIntegration} { - a := tally[level] - if !a.Over { - continue - } - sort.SliceStable(a.Slowest, func(x, y int) bool { return a.Slowest[x].Elapsed > a.Slowest[y].Elapsed }) - for n, s := range a.Slowest { - if n == 3 { - break - } - slow = append(slow, fmt.Sprintf("%s %s %.1fs", level, path.Base(s.Package)+"."+s.Test, s.Elapsed)) - } - } - return slow -} - -func failAt(machine, words string) *meshdeliverychecker.VerdictsByGroupHeadsValue { - return &meshdeliverychecker.VerdictsByGroupHeadsValue{State: meshdeliverycheckerclient.VerdictFail, Failed: &FailedFirst{Machine: machine, Words: words}} -} - -// AnswerVersion is the version of Answer this program writes. -const AnswerVersion = 1 - -// Answer is what the checking program answers on the last line of its standard output: its version, the verdict and the -// notes its rules give a reader of the check. -type Answer struct { - V int `json:"v"` - Verdict meshdeliverychecker.VerdictsByGroupHeadsValue `json:"verdict"` - Notes []string `json:"notes,omitempty"` -} diff --git a/modules/mesh-delivery-checker/rules/graph.go b/modules/mesh-delivery-checker/rules/graph.go deleted file mode 100644 index 9e370d4f..00000000 --- a/modules/mesh-delivery-checker/rules/graph.go +++ /dev/null @@ -1,114 +0,0 @@ -package rules - -import ( - "fmt" - "slices" - "strings" -) - -// The module graph's cycle rule (novox/hq ADR 0603 §2, ADR 0614 §3, §6), judged by the checking program (ADR 0656 §5): -// the check refuses a change whose module graph has a cycle and names it; a cycle the trunk already has among the same -// modules is the trunk's, said in the notes. The running checker gathers the graph's ordering edges of the catalogue as -// the change leaves it and as the trunk has it, worked out with the contract's graph (sdk/graph: bases, the provisions -// and bus state a module awaits, the verb edges the graph keeps), as module names and the edge's kind, never the -// manifests themselves, so the facts stay within the run input's bound. - -// The kinds of an ordering edge. -const ( - EdgeBase = "base" - EdgeAwaits = "awaits" - EdgeInvokes = "invokes" -) - -// Edge is one ordering edge: From waits for To. Only is EdgeChange when only the change's graph has it, EdgeTrunk when -// only the trunk's does, empty when both have it. -type Edge struct { - From string `json:"from"` - To string `json:"to"` - Kind string `json:"kind"` - Only string `json:"only,omitempty"` -} - -// Where only one graph has an edge. -const ( - EdgeChange = "change" - EdgeTrunk = "trunk" -) - -// Graph is the module graph's facts: every ordering edge of either graph, between modules of the catalogue. Trunk says -// whether the trunk's graph was read; when it was not, every edge is the change's and no cycle is the trunk's. -type Graph struct { - Edges []Edge `json:"edges"` - Trunk bool `json:"trunk"` -} - -// JudgeGraph is the cycle rule over the graph's facts: the failure of a cycle the change makes, or the note of no cycle -// or of a cycle the trunk already has. -func JudgeGraph(g Graph, machine string) (*FailedFirst, []string) { - cycle := firstCycle(g.Edges, func(e Edge) bool { return e.Only != EdgeTrunk || !g.Trunk }) - if cycle == nil { - return nil, []string{"the change's module graph has no cycle"} - } - words := strings.Join(cycle, " -> ") - if g.Trunk { - among := firstCycle(g.Edges, func(e Edge) bool { - return e.Only != EdgeChange && slices.Contains(cycle, e.From) && slices.Contains(cycle, e.To) - }) - if among != nil { - return nil, []string{"the module graph has the cycle " + words + ", which the trunk already has among the same modules (ADR 0603 §2)"} - } - } - return &FailedFirst{Machine: machine, Words: fmt.Sprintf("the change's module graph has the cycle %s: these modules would "+ - "each wait for the other for good, through their bases, the provisions and bus state they await, or the verbs they invoke (ADR 0603 §2, ADR 0614 §6)", words)}, nil -} - -// firstCycle is the first cycle of the edges kept, as the modules it passes through with the first named again at its -// end, visiting the modules and each one's edges in sorted order (as sdk/graph's Cycle does), or nil for none. -func firstCycle(edges []Edge, keep func(Edge) bool) []string { - next := map[string][]string{} - for _, e := range edges { - if keep(e) && !slices.Contains(next[e.From], e.To) { - next[e.From] = append(next[e.From], e.To) - } - } - var names []string - for name, to := range next { - slices.Sort(to) - names = append(names, name) - } - slices.Sort(names) - const ( - unseen = iota - onPath - done - ) - state := map[string]int{} - var path []string - var visit func(string) []string - visit = func(name string) []string { - state[name] = onPath - path = append(path, name) - for _, to := range next[name] { - switch state[to] { - case onPath: - i := slices.Index(path, to) - return append(slices.Clone(path[i:]), to) - case unseen: - if c := visit(to); c != nil { - return c - } - } - } - path = path[:len(path)-1] - state[name] = done - return nil - } - for _, name := range names { - if state[name] == unseen { - if c := visit(name); c != nil { - return c - } - } - } - return nil -} diff --git a/modules/mesh-delivery-checker/rules/judged.go b/modules/mesh-delivery-checker/rules/judged.go deleted file mode 100644 index e981fc24..00000000 --- a/modules/mesh-delivery-checker/rules/judged.go +++ /dev/null @@ -1,288 +0,0 @@ -package rules - -import ( - "fmt" - nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" - ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - "maps" - "slices" - "sort" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" -) - -// The facts the manifest validator, the fetch's programs and the composer answered, and the rules that judge them -// (milestone 47/B0, D1b): the running checker asks and records; these rules give the verdict. - -// CatalogSeat is the seat the indexer holds: the module whose manifest claims it is the indexer, found by the claim and -// never by its name (novox/hq ADR 0633 clause 6, ADR 0601 §4). -const CatalogSeat = "mesh-catalog" - -// BetweenManifests is the manifest validator's name for what it judges between manifests (the catalogue as a whole). -const BetweenManifests = "(between manifests)" - -// Manifests are the manifest validator's answers on the manifests a check touches (ADR 0578 §2, ADR 0579 §2, ADR 0633 -// clause 6): its change and trunk cases where it judged (At), and, when a touched module claims the seat mesh-catalog, -// that indexer and the trunk validator's change case on it (IndexerAt names where it judged). -type Manifests struct { - Touched []string `json:"touched"` - At string `json:"at"` - Change composer.CaseVerdict `json:"change"` - Trunk composer.CaseVerdict `json:"trunk"` - Indexer string `json:"indexer,omitempty"` - IndexerAt string `json:"indexer-at,omitempty"` - OfIndexer *composer.CaseVerdict `json:"of-indexer,omitempty"` -} - -// Programs are what one member's fetch read of the change's compiled programs (issue 1577): Files nil when the build -// module reported none (an older module: not refused, the running checker warns), else each changed file that is one. -type Programs struct { - Key string `json:"key"` - Files *[]ProgramFile `json:"files"` -} - -// ProgramFile is a changed file that is a compiled program, its format (ELF, Mach-O or PE) and, when it was added in an -// earlier commit of the branch and removed later, that commit: the build step's own (buildstep.Program). -type ProgramFile = buildstep.Program - -// Composition is how the check's composition went (ADR 0593 §7, §9; ADR 0603 §10; ADR 0548 §5): kept from the check it -// carries, not run (NotRun says why), or composed by the engines; BuildsFailed are the candidate's builds that failed -// before it composed, worded by the running checker; Waits are what it composed without waiting on, as warnings. -type Composition struct { - Kept *meshdeliverychecker.VerdictsByGroupHeadsValueComposition `json:"kept,omitempty"` - NotRun string `json:"not-run,omitempty"` - BuildsFailed []FailedFirst `json:"builds-failed,omitempty"` - Waits []string `json:"waits,omitempty"` - Composed *Composed `json:"composed,omitempty"` - FPSet string `json:"fp-set,omitempty"` -} - -// Composed are the engines' answers to one composition: the nodes placed, each answering node's answer, each silent -// node with why (for the journal only), what composed (the node-engine's commit), the composer's own warnings and how -// long it took in milliseconds. -type Composed struct { - Group string `json:"group"` - Heads string `json:"heads"` - Composer string `json:"composer"` - Nodes []string `json:"nodes"` - Answers map[string]ne.ComposeCandidateAnswer `json:"answers,omitempty"` - Silent map[string]string `json:"silent,omitempty"` - Warnings []string `json:"warnings,omitempty"` - Took int64 `json:"took,omitempty"` -} - -// JudgeManifests is the failure of the manifests' facts (nil when they pass) and the notes a reader gets: the trunk -// validator refusing, holding or setting aside the new indexer's manifest fails first (ADR 0633 clause 6); else a new or -// changed manifest is judged in full, a held one is refused, and of one the change leaves as it is a problem the trunk -// already had is a warning while one the change causes fails the check (ADR 0579 §2). -func JudgeManifests(m Manifests, machine string) (*FailedFirst, []string) { - var notes []string - if m.Indexer != "" { - var problems []string - ok := false - var iv composer.ManifestRead - if m.OfIndexer != nil { - iv, ok = m.OfIndexer.Manifests[m.Indexer] - } - switch { - case !ok: - problems = append(problems, "the manifest validator gave no verdict") - case iv.Refused != "": - problems = append(problems, strings.Split(iv.Refused, "\n")...) - case !iv.Accepted: - problems = append(problems, "the manifest validator holds it, with no verdict yet") - case iv.SetAside != "": - problems = append(problems, "the manifest validator does not know its fields "+iv.SetAside+", so it waits") - } - if len(problems) > 0 { - return &FailedFirst{Machine: machine, Words: fmt.Sprintf("the indexer %s, the holder of the seat %s, would never run: the trunk's manifest validator at %s does not accept its manifest: %s", - m.Indexer, CatalogSeat, m.IndexerAt, strings.Join(problems, "; "))}, nil - } - notes = append(notes, fmt.Sprintf("the new indexer's manifest of %s is accepted by the trunk's manifest validator at %s", m.Indexer, m.IndexerAt)) - } - var refused, warned []string - for _, module := range slices.Sorted(maps.Keys(m.Change.Manifests)) { - r := m.Change.Manifests[module] - if r.Accepted { - continue - } - if r.Refused == "" { // held: a verdict not given is not one given (ADR 0633 clause 6) - if slices.Contains(m.Touched, module) { - refused = append(refused, fmt.Sprintf("the indexer's judge at %s holds the manifest of %s: it gave no verdict", m.At, module)) - } - continue - } - had := map[string]bool{} - for _, p := range strings.Split(m.Trunk.Manifests[module].Refused, "\n") { - had[p] = true - } - var caused, old []string - for _, p := range strings.Split(r.Refused, "\n") { - if slices.Contains(m.Touched, module) || !had[p] { - caused = append(caused, p) - } else { - old = append(old, p) - } - } - if len(caused) > 0 { - what := "the manifest of " + module - if module == BetweenManifests { - what = "the catalogue" - } - refused = append(refused, fmt.Sprintf("the indexer's judge at %s refuses %s: %s", m.At, what, strings.Join(caused, "; "))) - } - if len(old) > 0 { - warned = append(warned, module+": "+strings.Join(old, "; ")) - } - } - if len(warned) > 0 { - notes = append(notes, "warnings of the indexer's judge on manifests the change leaves as they are (ADR 0579 §2): "+strings.Join(warned, " | ")) - } - if len(refused) > 0 { - return &FailedFirst{Machine: machine, Words: strings.Join(refused, "\n")}, notes - } - return nil, append(notes, fmt.Sprintf("the manifests of %s are accepted by the indexer's judge at %s", strings.Join(m.Touched, ", "), m.At)) -} - -// JudgePrograms fails a member whose change adds or modifies a compiled program, naming each file (issue 1577); a fetch -// that reported none, or found none, passes. -func JudgePrograms(machine string, p Programs) *FailedFirst { - if p.Files == nil { - return nil - } - var found []string - for _, f := range *p.Files { - if f.Commit != "" { - found = append(found, fmt.Sprintf("%s: a compiled program added in %s and removed later: it stays in history; squash the branch (issue 1577)", f.Path, short12(f.Commit))) - continue - } - found = append(found, f.Path+": a compiled program is build output: remove it and add it to .gitignore (issue 1577)") - } - if len(found) == 0 { - return nil - } - return &FailedFirst{Machine: machine, Words: fmt.Sprintf("%s: %s", p.Key, strings.Join(found, "; "))} -} - -func short12(s string) string { - if len(s) > 12 { - return s[:12] - } - return s -} - -// JudgeEngines is the check's composition verdict from the engines' answers (ADR 0593 §7, §9): failed when any node's -// answer is refused, naming each node and each module refused with its words (the first refusing node is the machine); -// passed otherwise. Every placed node without an answer is named with nec.NoAnswer as a warning. -func JudgeEngines(c Composed) meshwants.CompositionsByGroupHeadsValue { - v := meshwants.CompositionsByGroupHeadsValue{Group: c.Group, Heads: c.Heads, State: meshdeliverycheckerclient.CompositionPass, Sdk: c.Composer, Took: c.Took} - sorted := append([]string(nil), c.Nodes...) - sort.Strings(sorted) - var fails []string - for _, node := range sorted { - a, answered := c.Answers[node] - if !answered { - v.Warnings = append(v.Warnings, node+": "+nec.NoAnswer) - continue - } - if a.Verdict == nec.NotJudged { - // Composed in the sandbox and not judged (ADR 0593 §9): named as no answer, with the composer's words; decided - // by the verdict, never by the words (ADR 0601 §4's kind). - v.Warnings = append(v.Warnings, node+": "+nec.NoAnswer+" ("+a.Refused+")") - continue - } - v.Machines = append(v.Machines, node) - if a.Verdict != nec.Refused { - continue - } - if v.Machine == "" { - v.Machine = node - } - var words []string - if a.Refused != "" { - words = append(words, a.Refused) - } - for _, m := range append(append([]ne.Module(nil), a.Modules...), a.Own) { - if m.State == nec.ModuleRefused { - words = append(words, m.Module+": "+m.Words) - } - } - if len(words) == 0 { - words = append(words, "refused, naming no module") - } - fails = append(fails, "not composed on "+node+": "+strings.Join(words, "; ")) - } - if len(fails) > 0 { - v.State, v.Words = meshdeliverycheckerclient.CompositionFail, strings.Join(fails, "; ") - } - if len(sorted) == 0 { - v.Warnings = append(v.Warnings, "no node is placed, so the change was composed on none") - } - v.Warnings = append(v.Warnings, c.Warnings...) - return v -} - -// JudgeComposition takes the composition's facts into the verdict: a failed build of the candidate fails it, named after -// the tests' failures; a failed composition fails it, naming its machine; a passed one with warnings says them. -func JudgeComposition(v *meshdeliverychecker.VerdictsByGroupHeadsValue, c Composition) { - if c.Kept != nil { - kept := *c.Kept - v.Composition = &kept - return - } - for _, f := range c.BuildsFailed { - if v.State != meshdeliverycheckerclient.VerdictFail { - v.State, v.Failed = meshdeliverycheckerclient.VerdictFail, &f - continue - } - AddFailure(v, f) - } - if c.NotRun != "" { - v.Composition = &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: meshdeliverycheckerclient.CompositionNotRun, Words: c.NotRun} - return - } - if c.Composed == nil { - return - } - comp := JudgeEngines(*c.Composed) - comp.Warnings = append(comp.Warnings, c.Waits...) // ADR 0603 §10 - v.Composition = compositionOf(comp) - if v.Took == nil { - v.Took = &meshdeliverychecker.VerdictsByGroupHeadsValueTook{} - } - v.Took.Composition = comp.Took - if comp.State == meshdeliverycheckerclient.CompositionPass && len(comp.Warnings) > 0 && v.Composition != nil { - v.Composition.Words = strings.Join(comp.Warnings, "; ") // passed with a warning (ADR 0593 §9) - } - if comp.State == meshdeliverycheckerclient.CompositionFail { - machine := comp.Machine - if machine == "" { - machine = "the composition" - } - f := FailedFirst{Machine: machine, Words: comp.Words} - if v.State == meshdeliverycheckerclient.VerdictFail { - AddFailure(v, f) // the tests failed too: the composition is named after them (the operator, 2026-11-02) - } else { - v.State, v.Failed = meshdeliverycheckerclient.VerdictFail, &f - } - } - if v.Composition != nil && v.Composition.State != meshdeliverycheckerclient.CompositionNotRun { - v.Composition.Fpset = c.FPSet // a carry keeps it while the fingerprints stay the same (ADR 0548 §5) - } -} - -// compositionWaits is the state of the assigner's composition answer that waits for what it composes from. -const compositionWaits = "waits" - -// compositionOf is what the verdict carries of a composition answer c: nil while c waits (the check is still running). -func compositionOf(c meshwants.CompositionsByGroupHeadsValue) *meshdeliverychecker.VerdictsByGroupHeadsValueComposition { - if c.State == compositionWaits { - return nil - } - return &meshdeliverychecker.VerdictsByGroupHeadsValueComposition{State: c.State, Words: c.Words, Sdk: c.Sdk, Machines: c.Machines} -} diff --git a/modules/mesh-delivery-checker/rules/language.go b/modules/mesh-delivery-checker/rules/language.go deleted file mode 100644 index ac7e4474..00000000 --- a/modules/mesh-delivery-checker/rules/language.go +++ /dev/null @@ -1,8 +0,0 @@ -package rules - -// LanguageTypeScript is the language of the toolchain whose build module counts a package whole, not its tests (ADR 0484 clause -// 10): the `on` of a build seat's acting rule, never the name of a build module (design 47 G A-82). -const LanguageTypeScript = "typescript" - -// LanguageGo is the language of the toolchain of the build module that judges the Go repositories and the manifests. -const LanguageGo = "go" diff --git a/modules/mesh-delivery-checker/rules/names.go b/modules/mesh-delivery-checker/rules/names.go deleted file mode 100644 index 5915cdd8..00000000 --- a/modules/mesh-delivery-checker/rules/names.go +++ /dev/null @@ -1,38 +0,0 @@ -package rules - -import checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - -// FailedFirst names what failed: a test (its package and name) or a machine, with the words of the failure. It is the shape -// of the verdict's `failed` and of each entry of its `failures` (the seat's two types of it have the same fields), so the -// rules judge with one and convert at the verdict's edge (failureItems, failedList). -type FailedFirst = checker.VerdictsByGroupHeadsValueFailed - -func failureItems(list []FailedFirst) []checker.VerdictsByGroupHeadsValueFailuresItem { - if list == nil { - return nil - } - out := make([]checker.VerdictsByGroupHeadsValueFailuresItem, len(list)) - for i, f := range list { - out[i] = checker.VerdictsByGroupHeadsValueFailuresItem(f) - } - return out -} - -func failedList(items []checker.VerdictsByGroupHeadsValueFailuresItem) []FailedFirst { - if items == nil { - return nil - } - out := make([]FailedFirst, len(items)) - for i, f := range items { - out[i] = FailedFirst(f) - } - return out -} - -// failedOf is the first failure a verdict names: the zero value of a verdict that names none. -func failedOf(v checker.VerdictsByGroupHeadsValue) FailedFirst { - if v.Failed == nil { - return FailedFirst{} - } - return *v.Failed -} diff --git a/modules/mesh-delivery-checker/rules/program.go b/modules/mesh-delivery-checker/rules/program.go deleted file mode 100644 index 9cc8b87b..00000000 --- a/modules/mesh-delivery-checker/rules/program.go +++ /dev/null @@ -1,54 +0,0 @@ -package rules - -import ( - "encoding/json" - "errors" - "flag" - "fmt" - "io" - "io/fs" -) - -// Program is the checking program's work (cmd/mesh-checking-program; novox/hq ADR 0644, ADR 0656): over its arguments, -// its input (read only when asked for the verdict) and the heads laid for it (nil when none are), the one JSON line it -// answers, or why it refuses. `-seats` answers the seat list of the heads (SeatsOf), `-verdict` the verdict of the -// facts in the input (Judged), refusing facts of a version it does not read. -func Program(args []string, input func() ([]byte, error), heads fs.FS) ([]byte, error) { - set := flag.NewFlagSet("mesh-checking-program", flag.ContinueOnError) - set.SetOutput(io.Discard) - verdict := set.Bool("verdict", false, "answer the verdict of the facts in the input") - seats := set.Bool("seats", false, "answer the seat list of the heads laid for it") - if err := set.Parse(args); err != nil { - return nil, err - } - switch { - case *seats: - if heads == nil { - return nil, errors.New("no heads are laid for it") - } - data, err := input() - if err != nil { - return nil, fmt.Errorf("the input cannot be read: %w", err) - } - facts, err := DecodeFacts(data) - if err != nil { - return nil, err - } - answer, err := SeatsOf(heads, facts) - if err != nil { - return nil, err - } - return json.Marshal(answer) - case *verdict: - data, err := input() - if err != nil { - return nil, fmt.Errorf("the input cannot be read: %w", err) - } - facts, err := DecodeFacts(data) - if err != nil { - return nil, err - } - return json.Marshal(Judged(facts)) - } - return nil, errors.New("nothing asked: give -verdict or -seats") -} diff --git a/modules/mesh-delivery-checker/rules/refusals.go b/modules/mesh-delivery-checker/rules/refusals.go deleted file mode 100644 index 88142158..00000000 --- a/modules/mesh-delivery-checker/rules/refusals.go +++ /dev/null @@ -1,99 +0,0 @@ -package rules - -import ( - "fmt" - "maps" - "slices" - "strings" - - "git.novox.be/novox/mesh-contracts/go/seats/meshconfig" -) - -// The refusals of what the running checker asked of other seats for a check (milestone 47/G): it asks and records the -// answers as facts, and these rules decide what fails. - -// RenamesSeat is the verb a change that brings or drops a `renamed-from` is asked of (design 32). -var RenamesSeat = "seat:" + meshconfig.Seat + "." + meshconfig.VerbRenames - -// Renames is what one module of a member brings and drops of `renamed-from` (key to the old key), and how the seat -// mesh-config's verb renames answered for it: Answer when it answered; else Unasked says why it was not asked or did not -// answer, NotServed that its holder does not serve the verb. Unread says the module's manifests could not be read. -type Renames struct { - Module string `json:"module"` - Key string `json:"key"` - Brought map[string]string `json:"brought,omitempty"` - Dropped map[string]string `json:"dropped,omitempty"` - Answer *meshconfig.RenamesAnswer `json:"answer,omitempty"` - Unasked string `json:"unasked,omitempty"` - NotServed bool `json:"not-served,omitempty"` - Unread string `json:"unread,omitempty"` -} - -// JudgeRenames fails a rename the seat cannot move the value of, and the drop of a `renamed-from` while its window is -// open on a node; it says which module the seat answered for. -func JudgeRenames(r Renames) (failed []FailedFirst, notes []string) { - at := func(words string) { failed = append(failed, FailedFirst{Machine: meshconfig.Seat, Words: words}) } - switch { - case r.Unread != "": - at(fmt.Sprintf("%s (%s): its config renames cannot be judged: %s", r.Module, r.Key, r.Unread)) - return failed, nil - case r.NotServed: - for _, key := range slices.Sorted(maps.Keys(r.Brought)) { - at(fmt.Sprintf("%s (%s) renames %s from %s: refused, %s, so the value cannot be moved", r.Module, r.Key, key, r.Brought[key], r.Unasked)) - } - for _, key := range slices.Sorted(maps.Keys(r.Dropped)) { - at(fmt.Sprintf("%s (%s) drops renamed-from %s of %s: refused, %s, so whether its window is open is not known", r.Module, r.Key, r.Dropped[key], key, r.Unasked)) - } - return failed, nil - case r.Answer == nil && r.Unasked == "": - at(fmt.Sprintf("%s (%s) changes a renamed-from, and this checker cannot ask %s", r.Module, r.Key, RenamesSeat)) - return failed, nil - case r.Answer == nil: - at(fmt.Sprintf("%s (%s) changes a renamed-from, and the check cannot ask %s: %s", r.Module, r.Key, RenamesSeat, r.Unasked)) - return failed, nil - } - for _, key := range slices.Sorted(maps.Keys(r.Dropped)) { - for _, n := range r.Answer.Renames { - if n.Module == r.Module && n.From == r.Dropped[key] && n.To == key && len(n.Open) > 0 { - open := slices.Sorted(slices.Values(n.Open)) - at(fmt.Sprintf("%s (%s) drops renamed-from %s of %s while its rename window is open on %s", r.Module, r.Key, n.From, key, strings.Join(open, ", "))) - } - } - } - return failed, []string{fmt.Sprintf("%s.%s answered for %s (%s)", meshconfig.Seat, meshconfig.VerbRenames, r.Module, r.Key)} -} - -// SeatDefinitionsMachine names what refused a seat definition in a verdict's failure. -const SeatDefinitionsMachine = "seat-definitions" - -// UnparsedSeat is one seat definition of a pull request's head that does not parse, as the indexer keeps it in its state -// seat-definitions: the seat (the contracts module's name when its index did not parse), its module's directory and the -// indexer's words of why. -type UnparsedSeat struct { - Seat string `json:"seat"` - Module string `json:"module"` - Directory string `json:"directory"` - Why string `json:"why"` -} - -// Unparsed is what the indexer keeps of one pull request's seat definitions that do not parse; Unread says why its state -// could not be read. -type Unparsed struct { - Key string `json:"key"` - Seats []UnparsedSeat `json:"seats,omitempty"` - Unread string `json:"unread,omitempty"` -} - -// JudgeUnparsed fails a pull request whose head's seat definition does not parse, naming the seat and where it lives -// (design 26; the lead's ruling on A2i's finding 1), and one whose seat definitions cannot be read, since none is then -// known to parse. -func JudgeUnparsed(u Unparsed) []FailedFirst { - if u.Unread != "" { - return []FailedFirst{{Machine: SeatDefinitionsMachine, Words: fmt.Sprintf("%s: the indexer's seat definitions of it cannot be read, so none is known to parse: %s", u.Key, u.Unread)}} - } - var out []FailedFirst - for _, s := range u.Seats { - out = append(out, FailedFirst{Machine: SeatDefinitionsMachine, Words: fmt.Sprintf("%s: the seat definition of %s (module %s, %s) does not parse: %s", u.Key, s.Seat, s.Module, s.Directory, s.Why)}) - } - return out -} diff --git a/modules/mesh-delivery-checker/rules/results.go b/modules/mesh-delivery-checker/rules/results.go deleted file mode 100644 index a0a3af40..00000000 --- a/modules/mesh-delivery-checker/rules/results.go +++ /dev/null @@ -1,63 +0,0 @@ -package rules - -import "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - -// The shapes of a test step's answer, as the build modules' code writes them (mesh-catalog modules/mesh-build-go -// cmd/mesh-build-go levels.go TestResult; modules/mesh-build-node cmd/mesh-build-node check.go TestResult). Only the -// fields the rules read are named; the rest is ignored. - -// GoPackage is one package of a Go test result. -type GoPackage struct { - Dir string `json:"dir"` - Package string `json:"package"` - Passed bool `json:"passed"` - Elapsed float64 `json:"elapsed"` - Tests int `json:"tests"` - NoTests bool `json:"no_tests,omitempty"` - // Skipped is how many of the package's tests skipped; an older build module names none. - Skipped int `json:"skipped,omitempty"` -} - -// Failure is a test that failed, or a package that failed with no test to name: the build modules' failure contract -// (buildstep.Failure, issue 1901), its cause never empty and never a passing line from a build module that keeps it. -type Failure = buildstep.Failure - -// TestTime is one test and the seconds it took. -type TestTime struct { - Package string `json:"package"` - Test string `json:"test"` - Elapsed float64 `json:"elapsed"` -} - -// Tested is the answer of a test step of either build module (the Go one names packages and counts tests; the Node one -// names the package directory as Module and counts none). -type Tested struct { - Level string `json:"level"` - Module string `json:"module,omitempty"` - Passed bool `json:"passed"` - Why string `json:"why,omitempty"` - NoTests bool `json:"no_tests,omitempty"` - Tests int `json:"tests"` - Skipped int `json:"skipped"` - Packages []GoPackage `json:"packages,omitempty"` - Elapsed float64 `json:"elapsed"` - Setup float64 `json:"setup,omitempty"` - // Lint is the unit level's gofmt and go vet time, before its tests (mesh-build-go, ADR 0529 §1). - Lint float64 `json:"lint,omitempty"` - Bound float64 `json:"bound"` - SetupBound float64 `json:"setup_bound,omitempty"` - Slowest []TestTime `json:"slowest,omitempty"` - Failed []Failure `json:"failed,omitempty"` - OverBound bool `json:"over_bound"` - OverWhich string `json:"over_which,omitempty"` - // JudgedBy is the program that ran the step (ADR 0535 §5): "installed", or "candidate " under runner - // workspace; absent from a build module that does not take the runner. - JudgedBy string `json:"judged_by,omitempty"` - // By is the build module that answered and the SDK it was built with (buildstep.By); absent from a build module from - // before the failure contract. - By string `json:"by,omitempty"` - // OutOfStep are the generated files the step's regenerate-and-compare found out of step with their seat definitions, - // each a repository-relative path (design 26): the running checker names them in its verdict event. Absent from a - // build module that does not compare. - OutOfStep []string `json:"out-of-step,omitempty"` -} diff --git a/modules/mesh-delivery-checker/rules/seats.go b/modules/mesh-delivery-checker/rules/seats.go deleted file mode 100644 index 50040e14..00000000 --- a/modules/mesh-delivery-checker/rules/seats.go +++ /dev/null @@ -1,343 +0,0 @@ -package rules - -import ( - "bytes" - "context" - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "io/fs" - "maps" - "path" - "slices" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/seatdefs" -) - -// The seat list a check judges and composes against (novox/hq ADR 0636 §1, §4, ADR 0644 §1; the lead's rulings Q2 on -// milestones 47/B0 and 47/G): the checking program built from the heads reads the definitions the heads' contracts -// modules carry, by the domain SDK's one reading (sdk/seatdefs), the indexer's too, and answers them; the running checker -// lays them by seat over the list its reader holds from the seat mesh-catalog (verb seat-definitions) and reads no file -// of the heads. The reader's list is not in the program's input: it is large, and the answer carries only what the heads -// change. - -// SeatsVersion is the version of SeatsAnswer this program writes. -const SeatsVersion = 1 - -// SeatsAnswer is the checking program's `-seats` answer: every seat definition the heads carry, resolved, as the requests' -// field `seats` carries them, sorted by seat, that is new or differs from the reader's (Facts.SeatDigests); how many -// were the same and left out of it (Same); and each definition left out, with why. -type SeatsAnswer struct { - V int `json:"v"` - Seats []json.RawMessage `json:"seats"` - Same int `json:"same,omitempty"` - Left []LeftOut `json:"left,omitempty"` -} - -// SeatDigest is a definition's digest, the same for the same definition whatever its bytes' order and spacing: the sha256 -// of its JSON with every object's keys sorted, numbers as written. Bytes that are not JSON are digested as given. -func SeatDigest(raw json.RawMessage) string { - d := json.NewDecoder(bytes.NewReader(raw)) - d.UseNumber() - var v any - canonical := []byte(raw) - if d.Decode(&v) == nil { - if out, err := json.Marshal(v); err == nil { - canonical = out - } - } - sum := sha256.Sum256(canonical) - return hex.EncodeToString(sum[:]) -} - -// LeftOut is a seat definition the list does not take from the heads: its file and why. -type LeftOut struct { - Path string `json:"path"` - Why string `json:"why"` -} - -// SeatsOf is the seat definitions of the facts' members' heads that are new or differ from the reader's (Facts.SeatDigests). heads holds each member's head at its repository's path; a contracts module is a manifest there whose package artifact names -// `generated-from` (seatdefs.Of). A seat of the mesh's own a module that is not its domain's defines (seatdefs.Refusal), -// and a seat two modules define where neither hands it over, are left out, said; a definition that does not parse is an -// error. -// Heads with no contracts module give an empty list. -func SeatsOf(heads fs.FS, f Facts) (SeatsAnswer, error) { - out := SeatsAnswer{V: SeatsVersion} - type taken struct { - raw json.RawMessage - module, file string - } - by := map[string]taken{} - refused := map[string]bool{} - repositories := map[string]string{} - for _, m := range f.Members { - repositories[m.Repository] = m.Head - } - for _, repository := range slices.Sorted(maps.Keys(repositories)) { - if _, err := fs.Stat(heads, repository); errors.Is(err, fs.ErrNotExist) { - continue // no head of it is laid: it carries no definition here - } - sub, err := fs.Sub(heads, repository) - if err != nil { - return SeatsAnswer{}, err - } - manifests, err := manifestsIn(sub) - if err != nil { - return SeatsAnswer{}, err - } - forge := localForge(sub) - for _, c := range seatdefs.ContractsModules(manifests) { - defs, unparsed, err := forge.Read(context.Background(), repository, repositories[repository], c) - if err != nil { - return SeatsAnswer{}, fmt.Errorf("the seat definitions of %s at the head of %s cannot be read: %w", c.Module, repository, err) - } - // A head's definition that does not parse, or names another seat than its directory's, leaves the group's seats - // unknown: no list is made, so no manifest is judged by a list without it (design 26). - for _, seat := range slices.Sorted(maps.Keys(unparsed)) { - return SeatsAnswer{}, fmt.Errorf("the seat definition of %s (module %s) at the head of %s is not taken: %s", seat, c.Module, repository, unparsed[seat]) - } - for _, seat := range slices.Sorted(maps.Keys(defs)) { - d, file := defs[seat], defFile(repository, c, seat) - if why := seatdefs.Refusal(c.Module, d); why != "" { - out.Left = append(out.Left, LeftOut{Path: file, Why: why}) - continue - } - if prev, twice := by[seat]; twice || refused[seat] { - switch { - case refused[seat]: - out.Left = append(out.Left, LeftOut{Path: file, Why: "the seat " + seat + " is defined in more than one place"}) - continue - case seatdefs.HandsOver(prev.module, c.Module, d): - case seatdefs.HandsOver(c.Module, prev.module, d): - continue - default: - why := "the seat " + seat + " is defined in more than one place: " + prev.file + ", " + file - out.Left = append(out.Left, LeftOut{Path: prev.file, Why: why}, LeftOut{Path: file, Why: why}) - delete(by, seat) - refused[seat] = true - continue - } - } - raw, err := json.Marshal(d) - if err != nil { - out.Left = append(out.Left, LeftOut{Path: file, Why: err.Error()}) - continue - } - by[seat] = taken{raw: raw, module: c.Module, file: file} - } - } - } - out.Seats = make([]json.RawMessage, 0, len(by)) - for _, seat := range slices.Sorted(maps.Keys(by)) { - if held, ok := f.SeatDigests[seat]; ok && held == SeatDigest(by[seat].raw) { - out.Same++ // the reader holds it as the heads carry it: the checker's own list keeps it - continue - } - raw := by[seat].raw - // The answer is the judging view of a seat, what the manifest validator and the composer read (the lead's ruling after - // the group check of 616c42434ac2), with digests or without: no verb's or message's schema, which neither reads, and - // which the build seat's step state, keeping this answer, would refuse where a property is named like a credential - // (mesh-vault's verb input `credentials`). - raw = withoutMessageSchemas(raw) - if f.SeatDigests == nil { - // A checker from before G hands no digests, so every definition is answered: whole they are over a run answer's - // bound, so every description but the seat's own is left out too, which decides no verdict; review round 2 of G. - raw = withoutInnerDescriptions(raw) - } - out.Seats = append(out.Seats, raw) - } - return out, nil -} - -// defFile is a seat's definition file in a head, by its repository's path. -func defFile(repository string, c seatdefs.Module, seat string) string { - return path.Join(repository, c.Defs, "seats", seat, "seat.json") -} - -// manifestsIn are the raw manifests of a head by their directory (the root's is "."), the generated contracts, the tests' -// data and the packages' dependencies left out. -func manifestsIn(head fs.FS) (map[string]string, error) { - out := map[string]string{} - err := fs.WalkDir(head, ".", func(p string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - if d.IsDir() && (d.Name() == ".git" || d.Name() == "testdata" || d.Name() == "node_modules") { - return fs.SkipDir - } - if !d.IsDir() && d.Name() == "module.json" { - raw, err := fs.ReadFile(head, p) - if err != nil { - return err - } - out[path.Dir(p)] = string(raw) - } - return nil - }) - return out, err -} - -// localForge is the domain SDK's reading bound to a head laid on disk: a directory or a file the head does not hold is -// none. -func localForge(head fs.FS) seatdefs.Forge { - return seatdefs.Forge{ - Files: func(_ context.Context, _, _ string, dirs []string) (map[string]map[string]string, error) { - out := map[string]map[string]string{} - for _, dir := range dirs { - files := map[string]string{} - err := fs.WalkDir(head, dir, func(p string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - if !d.IsDir() { - files[strings.TrimPrefix(p, dir+"/")] = "" - } - return nil - }) - if errors.Is(err, fs.ErrNotExist) { - continue - } - if err != nil { - return nil, err - } - out[dir] = files - } - return out, nil - }, - File: func(_ context.Context, _, _, file string) ([]byte, error) { - raw, err := fs.ReadFile(head, file) - if errors.Is(err, fs.ErrNotExist) { - return nil, nil - } - return raw, err - }, - } -} - -// withoutMessageSchemas is a definition whose verbs' input and answer, and whose accepted messages', events' and holder -// events' bodies, are each the empty schema, and whose types (`defs`) are only those something it keeps still refers to -// (a state's key forms, a provision's form, another kept type). Every other field is kept as written; bytes that are not -// a JSON object are given back as they are. -func withoutMessageSchemas(raw json.RawMessage) json.RawMessage { - d := json.NewDecoder(bytes.NewReader(raw)) - d.UseNumber() - var def map[string]any - if d.Decode(&def) != nil { - return raw - } - empty := func(list any, fields ...string) { - items, _ := list.([]any) - for _, it := range items { - m, ok := it.(map[string]any) - if !ok { - continue - } - for _, f := range fields { - if _, has := m[f]; has { - m[f] = map[string]any{} - } - } - } - } - empty(def["verbs"], "input", "answer") - for _, field := range []string{"accepts", "events", "holder-events"} { - empty(def[field], "body") - } - if defs, ok := def["defs"].(map[string]any); ok { - rest := maps.Clone(def) - delete(rest, "defs") - kept := map[string]bool{} - todo := typesReferred(rest) - for len(todo) > 0 { - name := todo[len(todo)-1] - todo = todo[:len(todo)-1] - if kept[name] || defs[name] == nil { - continue - } - kept[name] = true - todo = append(todo, typesReferred(defs[name])...) - } - maps.DeleteFunc(defs, func(name string, _ any) bool { return !kept[name] }) - if len(defs) == 0 { - delete(def, "defs") - } - } - out, err := json.Marshal(def) - if err != nil { - return raw - } - return out -} - -// typesReferred are the names of the definition's types (`{"$ref": "#/defs/"}`) v refers to, anywhere in it. -func typesReferred(v any) []string { - var out []string - var walk func(any) - walk = func(v any) { - switch t := v.(type) { - case map[string]any: - if ref, ok := t["$ref"].(string); ok { - if name, found := strings.CutPrefix(ref, "#/defs/"); found { - out = append(out, name) - } - } - for _, x := range t { - walk(x) - } - case []any: - for _, x := range t { - walk(x) - } - } - } - walk(v) - return out -} - -// schemaData are the keywords of a schema whose value is data, never a schema: what they hold is kept as written. -var schemaData = map[string]bool{"examples": true, "enum": true, "const": true, "default": true} - -// withoutInnerDescriptions is a definition with only the seat's own description kept: every other `description` string, -// of a verb, an event or anything inside their schemas, is left out, every other field kept (a property named -// description is a schema, kept; a schema's data keywords are kept whole). Bytes that are not a JSON object are given -// back as they are. -func withoutInnerDescriptions(raw json.RawMessage) json.RawMessage { - d := json.NewDecoder(bytes.NewReader(raw)) - d.UseNumber() - var def map[string]any - if d.Decode(&def) != nil { - return raw - } - var walk func(v any) - walk = func(v any) { - switch t := v.(type) { - case map[string]any: - for k, val := range t { - if _, prose := val.(string); prose && k == "description" { - delete(t, k) - continue - } - if !schemaData[k] { - walk(val) - } - } - case []any: - for _, e := range t { - walk(e) - } - } - } - for k, val := range def { - if k != "description" { - walk(val) - } - } - out, err := json.Marshal(def) - if err != nil { - return raw - } - return out -} diff --git a/modules/mesh-delivery-checker/rules/words.go b/modules/mesh-delivery-checker/rules/words.go deleted file mode 100644 index 57c232d0..00000000 --- a/modules/mesh-delivery-checker/rules/words.go +++ /dev/null @@ -1,281 +0,0 @@ -package rules - -import ( - "fmt" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" -) - -// The words rules: how a failed test, a failed package and a list of failures are worded in a verdict (issue 1901, issue -// 1921). Moved whole from the running checker's package (milestone 47/B0): they are the checking program's. - -// FailedName names a failure: its package and test. -func FailedName(f Failure) string { - if f.Test == "" { - return f.Package - } - return f.Package + "." + f.Test -} - -// MaxWords is the most a failed test's words in a verdict hold (issue 1901). **The words keep the failure's last lines**, -// where a test says why it failed: the first line is often something it logged before (the group r4g verdict kept a -// "judged against" line and lost the t.Fatalf after it), and the 120 characters kept before cut a docker command's echo -// before docker's own error. Four kilobytes holds a long message and is small beside a verdict's other parts. -const MaxWords = 4096 - -// FailureWords is a failure's words: its output's last lines up to MaxWords, with the line the build module told apart as -// the test's error first when the output does not start with it, so the first line of the words is the cause and the -// status line, which is cut short, names it. **A failure's words are never "PASS" or "ok"** (issue 1901, its third -// meeting: a package that failed after its tests passed was worded "PASS"): go test's summary lines are dropped, and with -// no cause told apart (an older build module) the cause is the output's first "panic:", "fatal error:" or "signal:" -// line, read before the output is cut, or the words say the tests passed and the program failed after them. -func FailureWords(f Failure) string { - return FailureWordsAfter(f, "") -} - -// FailureWordsAfter is FailureWords with the line loud put first, within the same MaxWords: what the checker itself says of -// the failure (that the build module hid it), which the status line then names. -func FailureWordsAfter(f Failure, loud string) string { - out, passed := DropSummary(strings.TrimSpace(f.Output)) - cause := strings.TrimSpace(f.Cause) - if cause == "" { - cause = CauseIn(out) - } - switch { - case cause == "" && out == "" && passed: - cause = "the tests passed, then the test program exited with a failure: an os.Exit or a panic in TestMain or after the tests" - case cause == "" && out == "": - // The build module on main sends a package that stopped (a timeout, an exit, a kill) as its "FAIL" line alone. - cause = "the package failed with no test to name and no panic, signal or build error in its output (an older build module sent no cause)" - } - if len(cause) > MaxCause { - cause = strings.ToValidUTF8(cause[:MaxCause], "") + "..." - } - // The words keep MaxWords exactly: the loud line, the cause and their newlines, the marker and the kept lines. - budget := MaxWords - if cause != "" { - budget -= len(cause) + 1 - } - if loud != "" { - budget -= len(loud) + 1 - } - if len(out) > budget { - const marker = "... " - tail := out[len(out)-(budget-len(marker)):] - // Start on a whole line, and a whole character. - if i := strings.IndexByte(tail, '\n'); i >= 0 { - tail = strings.TrimLeft(tail[i:], "\n") - } - out = marker + strings.ToValidUTF8(tail, "") - } - if cause != "" && !strings.HasPrefix(FirstLine(out), cause) { - out = strings.TrimRight(cause+"\n"+out, "\n") - } - if loud != "" { - out = strings.TrimRight(loud+"\n"+out, "\n") - } - return out -} - -// HidWords is the checker's loud line for a failure the build module sent hiding its cause (issue 1901, its thorough -// fix): with no cause, or a passing line as its cause, under the failure contract (buildstep.Hidden). It names the build -// module and the version it says it is (Tested.By, " with mesh-sdk "); one from before the contract -// says nothing of itself. "" when the failure keeps the contract. The check fails either way: only its words change. -func HidWords(module, by string, f Failure) string { - why := buildstep.Hidden(f) - if why == "" { - return "" - } - version := "a version before the failure contract" - if module == "" { - module = "an unnamed build module" - } - if m, v, ok := strings.Cut(by, " with "); ok && m != "" { - module, version = m, v - } - return fmt.Sprintf("the build module hid the failure (%s at %s): %s", module, version, why) -} - -// MaxCause is the most a cause in a failure's words holds: one long line (the 1901 review: a cause of a kilobyte could -// push the words past MaxWords). -const MaxCause = 1024 - -// DropSummary drops go test's summary lines from a failure's output ("PASS", "FAIL", "ok ", "FAIL "), and says -// whether a "PASS" was among them: the package's tests passed before it failed. -func DropSummary(out string) (string, bool) { - passed := false - lines := strings.Split(out, "\n") - kept := lines[:0] - for _, l := range lines { - // go's exact forms only (review round 1): "PASS" or "FAIL" alone, "ok \t\t