Compare commits

...
2 Commits
Author SHA1 Message Date
jschoubben bf642c45b7 mesh-delivery: the old hand-kept mesh-catalog contract copy loses the config-candidates layout (issue 1982; ADR 0681 §2)
The copy under contracts/go/seats/meshcatalog still held the layout, its key helpers, its constant and two fixture cases; nothing
in contracts/ or sdk/ uses them, and ADR 0681 §7's check greps the trunk for the name.

Builds: ADR 0681 §2 (mesh-sdk keeps no config-candidate layout; the contract keeps none), §7.
2026-11-19 23:05:21 +01:00
jschoubben 64ae24aef7 mesh-delivery: remove the indexer's state config-candidates and its readers (issue 1982; ADR 0681 §2)
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
2026-11-19 22:47:44 +01:00
26 changed files with 79 additions and 756 deletions
+6 -71
View File
@@ -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 "<digest>".
@@ -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 "<pull>".
func ConfigCandidatesByPullKey(pull string) string { return pull }
// ParseConfigCandidatesByPullKey reads the parts of a key of the form "<pull>", 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 "<pull>", 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 "<module>".
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 <pull>.
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"`
@@ -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}",
@@ -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 "<pull>".
func ConfigCandidatesByPullKey(pull string) string { return pull }
// ParseConfigCandidatesByPullKey reads the parts of a key of the form "<pull>", 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 "<pull>", 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 "<module>".
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 <pull>.
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"`
@@ -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}",
@@ -63,44 +63,6 @@
}
}
},
{
"name": "a pull request's configuration",
"of": "state:config-candidates/<pull>",
"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/<pull>",
"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/<module>",
@@ -1364,107 +1364,6 @@
"description": "the kept predefined list",
"history": 5
},
{
"name": "config-candidates",
"template": "state",
"key-forms": [
{
"key": "<pull>",
"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",
@@ -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 "<pull>". */
export declare function configCandidatesByPullKey(pull: string): string;
/** The parts of a key of the form "<pull>", 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 "<module>". */
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 <pull>. */
export interface ConfigCandidatesByPullValue {
/** when (RFC 3339 time) */
"at"?: string;
/** module to key to declaration */
"declares": Record<string, Record<string, ConfigCandidatesByPullValueDeclaresValueValue>>;
"head": string;
"pull": string;
/** the layout version */
"v"?: number;
}
export interface PackagesByModuleValuePackagesItem {
"digest": string;
"package": string;
@@ -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 "<pull>". */
export function configCandidatesByPullKey(pull) {
return pull;
}
/** The parts of a key of the form "<pull>", 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 "<module>". */
export function packagesByModuleKey(module) {
return module;
@@ -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
}}
}
@@ -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)
@@ -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)
}
@@ -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)
@@ -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.<module>`).
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
}
@@ -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.
@@ -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).
@@ -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)
@@ -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"} {
@@ -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,
}
@@ -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)
}
@@ -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",
@@ -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
@@ -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},
} {
@@ -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
// `<seat>_<state>` (design 47 G §717, A-303): no module is named. Where a name must be the holder's real bucket (the
@@ -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"
)
+2 -2
View File
@@ -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
-2
View File
@@ -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",