I6 (1): the judge refuses an uncapped delivery store and a seat claim with no class

A delivery module (one claiming a seat of the delivery system, read from the
seat list's definitions) is refused for a state, log or objects entry with no
cap, in its old section or in requires; a seat-claiming manifest names class
core or leaf; finding-events is 8 MiB, 7 days; the objects template takes
max-age-days. internal/beside says a group's check reads the catalog member's
head beside it, main only when the catalog is not in the group.

Red until the captured catalog is refreshed (I6 (5)): judge
TestRulesSecrets/EveryCatalogueIdentityFitsWhatItRequires,
TestRulesSecrets/ParseManifestForInputsReadsAValueFallingBackToAPredefinedKey,
TestRulesPlacement/TheCataloguesBarPlacesBlocksAndItsShapeCoversEveryShow,
TestRulesBus/NoCatalogueManifestNamesAnInstallation; internal/index
TestAnArtifactOfNoToolchainHasNoLanguageAndNoLock,
TestAMergedManifestIsKeptOnceByItsDigestAndNamedByTheModule,
TestAModuleWithNoToolchainArtifactGetsItsFingerprintAtOnce,
TestAManifestFallingBackToAPredefinedKeyIsRead (each a captured catalog
manifest with no class, or finding-events at 16).

Builds: design 47 H2 §814, §820, §783; H-A-394 (1), H-A-411 (1) (4), H-A-415 (1), H-A-428, H-A-430 (3), H-A-434
This commit is contained in:
2026-11-22 01:49:26 +01:00
parent 40c2870a71
commit ba54f82a70
12 changed files with 148 additions and 43 deletions
@@ -21,8 +21,9 @@
// read mesh-sdk and mesh-catalog. None reads mesh-controller, which ended by its unassignment (novox/hq
// ADR 0590). In a mesh where either module has no source repository nothing is
// cloned, and these tests fail loudly with "not beside this check": a cause in the setup, not in the
// change. And in a delivery group that holds a mesh-catalog pull request, these tests read the
// catalogue's main, not the group's head.
// change. In a delivery group that holds a mesh-catalog member, these tests read that member's head, the
// sibling the group's check places in MESH_CHECK_BESIDE, and the catalogue's main only when the catalogue is
// not in the group: a group is judged against its own heads (ADR 0573 §2; design 47 H2 §814, H-A-428).
// - Anywhere else, the test judges against the copy captured in this repository's testdata/beside, at the
// commit testdata/beside/CAPTURED names. Never against a developer's own checkout: to judge one, set
// MESH_CHECK_BESIDE to the directory holding it, as the check does.
@@ -160,7 +160,9 @@ func TestAContextIsNotPinned(t *testing.T) { // 1450 (the rule 1444 keeps: conte
// build-agent's manifest from mesh-controller at f2d7bc94 has an image artifact built from a context in another repository.
// Its claim of the retired seat node-build-agent is read as a claim of a build seat: the parser refuses a retired seat
// since R4g (mesh-sdk A9a), and the claim is not what this test is about.
// It names no class, which a seat-claiming manifest names since design 47 H2 §814: given here.
raw := strings.ReplaceAll(fixture(t, "controller-f2d7bc94-build-agent"), `"node-build-agent"`, `"node-build-go"`)
raw = strings.Replace(raw, `"claims"`, `"class": "core", "claims"`, 1)
in := inputsOf("build-agent", raw, "t", nil, noBases)
if in.Kept == nil || in.None2 != None2Context {
t.Errorf("kept %+v none2 %q, want none2 %q", in.Kept, in.None2, None2Context)
@@ -208,7 +208,7 @@ func theBuildModuleOfALanguageIsTheHolderOfItsBuildSeat(t *testing.T) {
t.Errorf("two seats building go and two holders of node-build-node: %+v %q, want none, both said", by, problems)
}
// The indexer finds them among the manifests it holds, and a report of a module that holds no build seat is left out.
builder := `{"module":"go-builds","version":"1","claims":[{"name":"node-build-go"}],"streams":[{"name":"toolchains-go","events":["toolchain.**"]}]}`
builder := `{"module":"go-builds","version":"1","class":"core","claims":[{"name":"node-build-go"}],"streams":[{"name":"toolchains-go","events":["toolchain.**"]}]}`
ix, _ := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}, mod{"go-builds", builder})
ix.UseBuildModules(nil)
got, err := ix.BuildModulesNow(context.Background(), defs)
@@ -87,10 +87,12 @@ var busTemplates = map[string]busTemplate{
},
catalogue.TemplateObjects: {
storage: catalogue.StorageObjectStore,
fixed: "what happens when full (a new object is refused) and that objects are kept for good",
fixed: "what happens when full (a new object is refused)",
// max-age-days is how long the bus keeps an object; absent, objects are kept for good (design 47 H2 §820; H-A-434).
options: map[string]optionRule{
catalogue.OptionCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: catalogue.ObjectsMostMiB, required: true},
catalogue.OptionGrant: {kind: optionText},
catalogue.OptionCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: catalogue.ObjectsMostMiB, required: true},
catalogue.OptionAgeDays: {kind: optionInt, least: 1, most: 3650},
catalogue.OptionGrant: {kind: optionText},
},
},
catalogue.TemplateLedger: {
@@ -27,7 +27,7 @@ func TestBusStateIsJudgedOnce(t *testing.T) {
// 1966/AC8: a state, a log, objects and a ledger within bounds
{"within bounds", manifest(`{"name":"cache","storage":"key-value","template":"state","options":{"history":8,"key-ttl":true}},` +
`{"name":"audit","storage":"stream","template":"log","options":{"max-mib":64,"max-age-days":365}},` +
`{"name":"files","storage":"object-store","template":"objects","options":{"max-mib":2048}},` + ledger), nil},
`{"name":"files","storage":"object-store","template":"objects","options":{"max-mib":2048,"max-age-days":7}},` + ledger), nil},
// Design 47: every kept data may say its form and its catch-up tool, in an old section and in `requires` by template,
// and is accepted as read; one saying neither reads as before.
{"a form and a catch-up tool on every kept kind", `{"module":"a","version":"1.0","tools":["a_take_in"],` +
@@ -60,6 +60,7 @@ func TestBusStateIsJudgedOnce(t *testing.T) {
{"deliveries 11", manifest(`{"name":"x","storage":"stream","template":"work-queue","options":{"events":["job"],"max-deliveries":11}}`), []string{"\"x\"", "\"max-deliveries\" is 11", "1 to 10"}},
{"duplicates past the age", manifest(`{"name":"x","storage":"stream","template":"work-queue","options":{"events":["job"],"max-age-days":1,"duplicates":86401}}`), []string{"\"x\"", "\"duplicates\"", "longer than the queue's age of 1 days"}},
{"log age 3651", manifest(`{"name":"x","storage":"stream","template":"log","options":{"max-age-days":3651}}`), []string{"\"x\"", "\"max-age-days\" is 3651"}},
{"objects age 3651 (H2 §820)", manifest(`{"name":"x","storage":"object-store","template":"objects","options":{"max-mib":64,"max-age-days":3651}}`), []string{"\"x\"", "\"max-age-days\" is 3651"}},
{"objects without a cap", manifest(`{"name":"x","storage":"object-store","template":"objects"}`), []string{"\"x\"", "\"max-mib\" is missing"}},
{"when full given as an option", manifest(`{"name":"x","storage":"stream","template":"log","options":{"when-full":"drop-oldest"}}`), []string{"\"x\"", "\"when-full\"", "fixed"}},
// A-277: a state's max-mib is an option of its template; an approvals state is §677's (key-ttl, 48 hours, at most 64 MiB).
@@ -2,6 +2,7 @@ package judge
import (
"git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/seatdef"
"regexp"
"strings"
"testing"
@@ -9,6 +10,9 @@ import (
// Design 47 G §368, §386, §387, §89: the manifest validator reads the manifests' new words before any manifest uses them.
func TestTheJudgeReadsMilestoneGsWords(t *testing.T) {
was := deliverySeats.Load()
useDeliverySeats([]seatdef.Definition{{Seat: "thing", Domain: deliveryDomain}})
t.Cleanup(func() { deliverySeats.Store(was) })
for _, row := range []struct {
name string
raw string
@@ -33,12 +37,24 @@ func TestTheJudgeReadsMilestoneGsWords(t *testing.T) {
`"streams":[{"name":"a-findings","events":["finding-written"],"retention":"history"}],"consumes":["mesh-conditions.findings-asked"]}`, want: "old sections"},
{name: "another part's findings in its requires (§529)", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` +
`{"name":"findings","storage":"key-value","template":"state"},` +
`{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":7,"max-mib":16}}]}`},
`{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":7,"max-mib":8}}]}`},
{name: "another part's findings without the finding events (§529)", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` +
`{"name":"findings","storage":"key-value","template":"state"}]}`, want: "finding-events"},
{name: "another part's finding events not kept 7 days (§529)", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` +
`{"name":"findings","storage":"key-value","template":"state"},` +
`{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":30,"max-mib":16}}]}`, want: "max-age-days"},
`{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":30,"max-mib":8}}]}`, want: "max-age-days"},
{name: "another part's finding events of 16 MiB (H2 §820, H-A-411 (1))", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` +
`{"name":"findings","storage":"key-value","template":"state"},` +
`{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":7,"max-mib":16}}]}`, want: "max-mib"},
{name: "a delivery module's uncapped old-section state (H2 §814)", raw: `{"module":"d","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],"state":["s"]}`, want: `state "s" in its old section names none`},
{name: "a delivery module's uncapped state in requires (H2 §814)", raw: `{"module":"d","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],` +
`"requires":[{"name":"s","storage":"key-value","template":"state"}]}`, want: `state "s" in ` + "`requires`"},
{name: "a delivery module's uncapped objects (H2 §814)", raw: `{"module":"d","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],"objects":[{"name":"o"}]}`, want: `objects "o"`},
{name: "a foundation part's capped old-section state (H2 §814)", raw: `{"module":"mesh-delivery-builder","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],"state":[{"name":"s","max-mib":8}]}`},
{name: "an uncapped state of a module claiming no delivery seat (H2 §814)", raw: `{"module":"a","version":"1.0","state":["s"]}`},
{name: "a seat-claiming manifest with no class (H2 §810, §814)", raw: `{"module":"d","version":"1.0","claims":[{"name":"thing","scope":"mesh"}]}`, want: "no `class`"},
{name: "a seat-claiming manifest of another class (H2 §810, §814)", raw: `{"module":"d","version":"1.0","class":"middle","claims":[{"name":"thing","scope":"mesh"}]}`, want: `class "middle"`},
{name: "a seat-claiming leaf (H2 §810)", raw: `{"module":"d","version":"1.0","class":"leaf","claims":[{"name":"thing","scope":"mesh"}]}`},
} {
module := "a"
if m := regexp.MustCompile(`"module":"([a-z-]+)"`).FindStringSubmatch(row.raw); m != nil {
@@ -88,7 +88,8 @@ func gWordsProblems(m catalogue.Manifest) []string {
}
// findingEventsProblems judges the entry `finding-events` of a part that is no foundation part: it lists the three finding
// events in its option `events` and keeps them 7 days and 16 MiB (design 47 G §529).
// events in its option `events` and keeps them 7 days and 8 MiB (design 47 G §529, H2 §820; H-A-411 (1)); the template
// `events` drops the oldest when full.
func findingEventsProblems(module string, e catalogue.BusStateEntry) []string {
var problems []string
var listed []string
@@ -100,9 +101,9 @@ func findingEventsProblems(module string, e catalogue.BusStateEntry) []string {
problems = append(problems, fmt.Sprintf("%s's %s does not list the event %q in its `events` (design 47 G §529)", module, FindingEventsEntry, want))
}
}
for option, want := range map[string]string{"max-age-days": "7", "max-mib": "16"} {
for option, want := range map[string]string{"max-age-days": "7", "max-mib": "8"} {
if got := strings.TrimSpace(string(e.Options[option])); got != want {
problems = append(problems, fmt.Sprintf("%s's %s sets %s to %q, not %s (design 47 G §529)", module, FindingEventsEntry, option, got, want))
problems = append(problems, fmt.Sprintf("%s's %s sets %s to %q, not %s (design 47 G §529, H2 §820)", module, FindingEventsEntry, option, got, want))
}
}
slices.Sort(problems)
@@ -290,6 +290,7 @@ func UseSeatList(defs []seatdef.Definition) {
seatsMu.Lock() // not while a pass judges with seats put over the list (WithSeats)
defer seatsMu.Unlock()
catalogue.UseSeats(catalogue.SeatsFromDefinitions(defs))
useDeliverySeats(defs)
}
// TrunkCase is the case of a request holding the catalogue as the trunk holds it (the checker's JudgeTrunk).
@@ -43,7 +43,7 @@ func TestTheJudge(t *testing.T) {
{name: "a claimed seat's module with tools of its own",
raws: map[string]string{
"def": `{"module":"def","version":"1.0","seats":[{"name":"enrolment","scope":"mesh","serves":["issue","again"]}]}`,
"enrolment": `{"module":"enrolment","version":"1.0","claims":[{"name":"enrolment","scope":"mesh","serves":["issue","again"]}],` +
"enrolment": `{"module":"enrolment","version":"1.0","class":"core","claims":[{"name":"enrolment","scope":"mesh","serves":["issue","again"]}],` +
`"tools":["enrolment_first_views","enrolment_first_view_again"]}`}},
} {
raws := map[string][]byte{"node-engine": []byte(engineManifest("node-engine"))} // a revision has one claim of the seat node-engine (§527)
@@ -185,7 +185,7 @@ func engineManifest(module string) string {
for _, v := range seat.Serves {
verbs = append(verbs, `"`+v.Name+`"`)
}
return `{"module":"` + module + `","version":"1.0","claims":[{"name":"node-engine","scope":"node","serves":[` + strings.Join(verbs, ",") + `]}]}`
return `{"module":"` + module + `","version":"1.0","class":"core","claims":[{"name":"node-engine","scope":"node","serves":[` + strings.Join(verbs, ",") + `]}]}`
}
// Design 47 G §508, §527: one module of a revision claims the seat node-engine; a second is refused naming both, and none
@@ -2599,6 +2599,8 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M
m.SetPredefined(predefined)
problems := gWordsProblems(m)
problems = append(problems, deliveryStoreProblems(m)...)
problems = append(problems, classProblems(m)...)
if !name.MatchString(m.Module) {
problems = append(problems, fmt.Sprintf(
"%q is not a usable module name: lower-case letters, digits, dashes and dots", m.Module))
@@ -261,7 +261,7 @@ func caseAClaimOnASeatAnotherModuleDeclaresIsAccepted(t *testing.T) {
// would say it where no consumer hears it, so the manifest is refused, naming the seat's subject; the seat's
// holder saying nothing of its own is accepted.
holder := func(emits string) []byte {
return []byte(`{"module":"mesh-self-check","version":"1.0","emits":` + emits + `,"claims":[{"name":"mesh-self-check","scope":"mesh","serves":["doctor","probes"]}]}`)
return []byte(`{"module":"mesh-self-check","version":"1.0","emits":` + emits + `,"class":"core","claims":[{"name":"mesh-self-check","scope":"mesh","serves":["doctor","probes"]}]}`)
}
if _, err := ParseManifest(holder(`["checked"]`)); err == nil || !strings.Contains(err.Error(), "mesh.seat.mesh-self-check.event.checked") {
t.Errorf("a seat's event listed as the module's own: %v", err)
@@ -383,7 +383,7 @@ func caseAContributionPlaceholderOutsideTheHolderIsRefused(t *testing.T) {
if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "laptop does not claim node-hotkeys") {
t.Errorf("a placeholder outside the holder was accepted: %v", err)
}
raw = `{"module":"triggerhappy","claims":[{"name":"node-hotkeys"}],"resources":[{"id":"t","type":"file","path":"/etc/t","content":"${contribution:node-hotkeys:keys}"}]}`
raw = `{"module":"triggerhappy","class":"core","claims":[{"name":"node-hotkeys"}],"resources":[{"id":"t","type":"file","path":"/etc/t","content":"${contribution:node-hotkeys:keys}"}]}`
if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "it receives trigger") {
t.Errorf("a placeholder for a kind the seat does not receive was accepted: %v", err)
}
@@ -508,7 +508,7 @@ func caseADeliveringSeatIsOnlyHeldByAModuleThatProvides(t *testing.T) {
// would be the answer anyway, and every consumer would be sent to it.
// And refused at registration, where the seat set is the store's: what a seat delivers is
// data, so a compiled copy of it may not be what refuses a build (novox/hq ADR 0122).
raw := []byte(`{"module":"thing","version":"1.0","claims":[{"name":"git","scope":"mesh"}]}`)
raw := []byte(`{"module":"thing","version":"1.0","class":"core","claims":[{"name":"git","scope":"mesh"}]}`)
m, err := ParseManifest(raw)
if err != nil {
t.Fatalf("the parser judged what a seat delivers: %v", err)
@@ -723,7 +723,7 @@ func caseAHolderOfNodeFilesDeclaringRunsAsIsRefused(t *testing.T) {
// carry — as the operator's account — is refused at parse.
func caseAHolderOfNodeReadsWithoutAnAccountOfItsOwnIsRefused(t *testing.T) {
_, err := ParseManifest([]byte(`{"module": "reads", "version":"1.0",
"claims": [{"name": "node-reads", "scope": "node"}]}`))
"class":"core","claims":[{"name": "node-reads", "scope": "node"}]}`))
if err == nil || !strings.Contains(err.Error(), "runs-as") || !strings.Contains(err.Error(), "0310") {
t.Errorf("a holder of node-reads without runs-as was not refused for it: %v", err)
}
@@ -745,7 +745,7 @@ func caseAHolderPlacesEveryCombinationOnceWithATemplateThatRendersEveryExample(t
if template != "" {
renders = `,"renders":{"block":` + string(tb) + `}`
}
return `{"module":"a-bar","claims":[{"name":"node-bar"` + renders + `}],"resources":[` + strings.Join(res, ",") + `]}`
return `{"module":"a-bar","class":"core","claims":[{"name":"node-bar"` + renders + `}],"resources":[` + strings.Join(res, ",") + `]}`
}
all := "${contribution:node-bar:block:bar=bottom,place=resources}${contribution:node-bar:block:bar=bottom,place=status}" +
"${contribution:node-bar:block:bar=top,place=resources}${contribution:node-bar:block:bar=top,place=status}"
@@ -1304,7 +1304,7 @@ func caseAModuleDeclaresItsOwnSeatAndHoldsIt(t *testing.T) {
// what it means (novox/hq ADR 0121). But it may not define one in the mesh's own namespace.
func caseAModuleDefinesAndClaimsItsOwnSeat(t *testing.T) {
ok := []byte(`{"module":"showcase","version":"1.0","seats":[{"name":"the-showcase","scope":"node"}],` +
`"claims":[{"name":"the-showcase","scope":"node"}]}`)
`"class":"core","claims":[{"name":"the-showcase","scope":"node"}]}`)
if _, err := ParseManifest(ok); err != nil {
t.Fatalf("a module could not define and claim its own seat: %v", err)
}
@@ -1321,7 +1321,7 @@ func caseAModuleDefinesAndClaimsItsOwnSeat(t *testing.T) {
}
// A module may not carve its seat out of the mesh's own namespace.
bad := []byte(`{"module":"x","version":"1.0","seats":[{"name":"node-mine","scope":"node"}],` +
`"claims":[{"name":"node-mine","scope":"node"}]}`)
`"class":"core","claims":[{"name":"node-mine","scope":"node"}]}`)
if _, err := ParseManifest(bad); err == nil || !strings.Contains(err.Error(), "own namespace") {
t.Fatalf("a module defined a seat in the mesh's namespace and was not refused: %v", err)
}
@@ -2266,14 +2266,14 @@ func caseAnUnknownPlaceholderKeyIsRefused(t *testing.T) {
{"${shell:tcsh:first}", "names ${shell:tcsh:first}; shell code is ${shell:<shell>:<slot>}"},
{"${shell:zsh}", "names ${shell:zsh}; shell code is ${shell:<shell>:<slot>}"},
} {
raw := `{"module":"holder","claims":[{"name":"node-environment","scope":"node"},{"name":"node-login-shell","scope":"node"}],` +
raw := `{"module":"holder","class":"core","claims":[{"name":"node-environment","scope":"node"},{"name":"node-login-shell","scope":"node"}],` +
`"resources":[{"id":"rc","type":"file","path":"/etc/rc","content":"` + c.content + `"}]}`
if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), c.want) {
t.Errorf("%s was accepted: %v", c.content, err)
}
}
// And outside a file's content, where nothing could be placed.
raw := `{"module":"holder","claims":[{"name":"node-environment","scope":"node"}],` +
raw := `{"module":"holder","class":"core","claims":[{"name":"node-environment","scope":"node"}],` +
`"resources":[{"id":"rc","type":"file","path":"/etc/${environment:posix}","content":"x"}]}`
if _, err := ParseManifest([]byte(raw)); err == nil ||
!strings.Contains(err.Error(), "names ${environment:posix} in its path; the environment and the shell's code are placed only in a file's content") {
@@ -2408,7 +2408,7 @@ func caseAPackageParsesLikeABundleAndNeedsALanguage(t *testing.T) {
} {
raw := `{"module":"a","version":"1.0","build":{"artifacts":[` + c.artifact + `]}}`
if before, ok := strings.CutSuffix(c.artifact, claims); ok {
raw = `{"module":"a","version":"1.0","claims":[{"name":"mesh-vault","scope":"mesh"}],"build":{"artifacts":[` + before + `]}}`
raw = `{"module":"a","version":"1.0","class":"core","claims":[{"name":"mesh-vault","scope":"mesh"}],"build":{"artifacts":[` + before + `]}}`
}
_, err := ParseManifest([]byte(raw))
switch {
@@ -2560,7 +2560,7 @@ func caseAProcessBusNamesOnlyTheModulesOwn(t *testing.T) {
func caseAProcessBusNeverServesOrHoldsASeat(t *testing.T) {
for name, c := range map[string]struct{ bus, says string }{
"holds": {`{"emits":["mail.send.sent"],"holds":["mail-sender"]}`, "holds"},
"claims": {`{"emits":["mail.send.sent"],"claims":["mail-sender"]}`, "claims"},
"claims": {`{"emits":["mail.send.sent"],"class":"core","claims":["mail-sender"]}`, "claims"},
"seat": {`{"emits":["mail.send.sent"],"seat":"mail-sender"}`, "seat"},
} {
_, err := ParseManifest([]byte(mailSenderProcessManifest(t, c.bus)))
@@ -2610,7 +2610,7 @@ func caseAProcessDeclaresItsBusAndIsAccepted(t *testing.T) {
// process's, named after its binary and kept through resolution; a removal is from the closed set, alone, and the
// bus module's (mesh-broker) alone.
toolsIn := func(claims, bus, mode, where string) string {
return `{"module":"nats","version":"1.0","claims":` + claims + `,"own-secrets":{"broker":"${dir:mesh-state}/broker",` +
return `{"module":"nats","version":"1.0","class":"core","claims":` + claims + `,"own-secrets":{"broker":"${dir:mesh-state}/broker",` +
`"broker-nats-tools":"${dir:tools-secret}/broker-nats-tools"},"resources":[{"id":"mesh-state","type":"directory",` +
`"mode":"0700","place":"mesh","unknown":"program"},{"id":"tools-secret","type":"directory","mode":"` + mode +
`","path":"` + where + `","unknown":"program"}],"build":{"artifacts":[{"name":"tools","kind":"bundle",` +
@@ -3276,10 +3276,10 @@ func caseAManifestCarryingWaitsIsAFieldNotKnown(t *testing.T) {
func caseAMarkNothingEnforcesIsRefused(t *testing.T) {
const bundle = `"build":{"artifacts":[{"name":"tools","kind":"bundle","language":"typescript","entrypoints":["tools/index.js"]}]}`
const oc = `"uses":["operator-channel"]`
shell := `{"module":"zsh","claims":[{"name":"node-login-shell","scope":"node","serves":["execute"]}],"tools":["zsh_config"],` + bundle
shell := `{"module":"zsh","class":"core","claims":[{"name":"node-login-shell","scope":"node","serves":["execute"]}],"tools":["zsh_config"],` + bundle
for _, row := range []struct{ name, manifest, want string }{
{"a tool its tools do not list", `{"module":"shop","tools":["sell"],"needs-approval":["refund"],` + oc + `,` + bundle + `}`, "its tools do not list"},
{"a verb its claims do not serve", `{"module":"shop","claims":[{"name":"shop-till","serves":["price"]}],"tools":["price"],"needs-approval":["shop-till.refund"],` + oc + `,` + bundle + `}`, "does not serve"},
{"a verb its claims do not serve", `{"module":"shop","class":"core","claims":[{"name":"shop-till","serves":["price"]}],"tools":["price"],"needs-approval":["shop-till.refund"],` + oc + `,` + bundle + `}`, "does not serve"},
{"a marked tool without operator-channel", `{"module":"shop","tools":["sell"],"needs-approval":["sell"],` + bundle + `}`, "without operator-channel"},
{"a held seat verb its seat marks without operator-channel", shell + `}`, "without operator-channel"},
{"every bundle run by its own process", `{"module":"shop","tools":["sell"],"needs-approval":["sell"],` + oc + `,` + bundle +
@@ -4130,7 +4130,7 @@ func caseNodeBuildAgentIsRetiredForTheBuildSeats(t *testing.T) {
t.Errorf("the mesh still defines %s", gone)
}
}
_, err := ParseManifest([]byte(`{"module":"build-agent","version":"1.0","claims":[{"name":"node-build-agent","scope":"node"}]}`))
_, err := ParseManifest([]byte(`{"module":"build-agent","version":"1.0","class":"core","claims":[{"name":"node-build-agent","scope":"node"}]}`))
if err == nil || !strings.Contains(err.Error(), `"node-build-agent", which is retired`) || !strings.Contains(err.Error(), "node-build-go") {
t.Fatalf("the claim is not refused naming its replacement: %v", err)
}
@@ -4193,7 +4193,7 @@ func caseNoModuleMayDeclareTheLoginShell(t *testing.T) {
}
// And a shell module claiming the mesh's seat, serving execute, is what the seat is for.
m, err := ParseManifest([]byte(`{"module":"zsh","tools":["execute"],"uses":["operator-channel"],` +
`"claims":[{"name":"node-login-shell","scope":"node"}]}`))
`"class":"core","claims":[{"name":"node-login-shell","scope":"node"}]}`))
if err != nil {
t.Fatal(err)
}
@@ -4506,7 +4506,7 @@ func caseAStoreHolderThatBuildsIsNotRefusedByItsManifest(t *testing.T) {
// nothing, so it is refused at the parser rather than silently dropped.
func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) {
raw := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}],
"claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"emits":["something.happened"]}`)
_, err := ParseManifest(raw)
if err == nil || !strings.Contains(err.Error(), "granted the bus's snapshot API and nothing else") {
@@ -4514,7 +4514,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) {
}
// Nor what it invokes, with no bundle for the runtime to ask on its behalf.
unbundledInvoke := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}],
"claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"invokes":["seat:mesh-hand-acts.hand-act"]}`)
if _, err := ParseManifest(unbundledInvoke); err == nil || !strings.Contains(err.Error(), "its invokes would be granted nothing") {
t.Fatalf("a bus module with no bundle declaring what it invokes was not refused, or not for the reason: %v", err)
@@ -4525,7 +4525,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) {
// ships one may declare them. The shape of mesh-catalog's modules/nats/module.json at fc5b849d, cut to the
// parts the rule reads, was refused and held every bus user list from 2026-11-02 01:35.
nats := []byte(`{"module":"nats","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh","credential":{"form":"none"}}],
"claims":[{"name":"mesh-broker","scope":"mesh"}],
"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],
"own-secrets":{"broker":"/run/broker","broker-nats-tools":"${dir:tools-secret}/broker-nats-tools"},
"resources":[{"id":"tools-secret","type":"directory","path":"/var/lib/mesh/nats-tools","mode":"0711","unknown":"program"}],
"emits":["consumer-removed","bucket-keys-removed","stream-removed","bucket-expiry-set"],
@@ -4551,7 +4551,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) {
// Its tools bundle says what it emits (novox/hq ADR 0357): the node's runtime carries the bundle and is
// granted the module's events, so a bus module that ships one may declare them.
bundled := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}],
"claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"emits":["bus.slow-consumer"],"tools":["bus_streams"],
"build":{"artifacts":[{"name":"tools","kind":"bundle","language":"go","system":"arch","from":"cmd/t","binary":"t"}]}}`)
m, err := ParseManifest(bundled)
@@ -4577,7 +4577,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) {
// parts the rule reads.
keeper := func(bus string, more string) []byte {
return []byte(`{"module":"nats","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}],
"claims":[{"name":"mesh-broker","scope":"mesh","serves":["list"]}],"own-secrets":{"broker":"/run/broker"},
"class":"core","claims":[{"name":"mesh-broker","scope":"mesh","serves":["list"]}],"own-secrets":{"broker":"/run/broker"},
"tools":["nats_server"],"consumes":["mesh-catalog.manifest-accepted"],"uses":["operator-channel"],
"state":[{"name":"requests","history":5}],"streams":[{"name":"broker-events","events":["created"]}],
"emits":["consumer-removed"],
@@ -4621,7 +4621,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) {
}
quiet := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}],
"claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"},
"tools":["bus_streams"]}`)
m, err = ParseManifest(quiet)
if err != nil {
@@ -4974,7 +4974,7 @@ func caseTheParserDoesNotJudgeWhatOnlyTheStoreKnows(t *testing.T) {
catalogue.UseSeats([]catalogue.Seat{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Delivers: "mesh-bus", Decision: "test"}})
raw := []byte(`{"module":"a-bus","version":"1.0",` +
`"provides":[{"name":"mesh-bus","scope":"mesh","credential":{"form":"none"}}],` +
`"claims":[{"name":"mesh-broker","scope":"mesh"}]}`)
`"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}]}`)
m, err := ParseManifest(raw)
if err != nil {
@@ -5185,13 +5185,13 @@ func caseTheSessionsFilesArePlacedByTheDisplayServersHolderAlone(t *testing.T) {
{`{"name":"node-display-server"}`, "${shell:zsh:normal}", "does not claim node-login-shell"},
{`{"name":"node-display-server"}`, "${shell:xsession:normal}", "the session's file one of xinitrc, xresources"},
} {
raw := `{"module":"holder","claims":[` + c.claims + `],"resources":[{"id":"rc","type":"file","path":"/etc/rc","content":"` +
raw := `{"module":"holder","class":"core","claims":[` + c.claims + `],"resources":[{"id":"rc","type":"file","path":"/etc/rc","content":"` +
c.content + `"}]}`
if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), c.want) {
t.Errorf("%s with claims [%s]: want %q, got %v", c.content, c.claims, c.want, err)
}
}
if _, err := ParseManifest([]byte(`{"module":"xorg","claims":[{"name":"node-display-server"}],` +
if _, err := ParseManifest([]byte(`{"module":"xorg","class":"core","claims":[{"name":"node-display-server"}],` +
`"resources":[{"id":"rc","type":"file","path":"/home/op/.xinitrc","content":"${shell:xinitrc:last}"}]}`)); err != nil {
t.Errorf("the display server's holder could not place the session's slots: %v", err)
}
@@ -5259,7 +5259,7 @@ func caseTheUplinkIsANodeSeatThatDeliversNothing(t *testing.T) {
t.Fatalf("the uplink is %+v, not a node seat delivering nothing by ADR 0117", seat)
}
// And a manager's module can hold it without providing anything.
raw := []byte(`{"module":"networkmanager","version":"1.0","claims":[{"name":"node-uplink","scope":"node"}]}`)
raw := []byte(`{"module":"networkmanager","version":"1.0","class":"core","claims":[{"name":"node-uplink","scope":"node"}]}`)
if _, err := ParseManifest(raw); err != nil {
t.Fatalf("a network manager's module could not hold the uplink: %v", err)
}
@@ -5573,7 +5573,7 @@ func problemsFor(t *testing.T, shelf catalogue.Shelf) string {
}
func claimed(claims string) []byte {
return []byte(`{"module":"thing","version":"1.0","provides":[{"name":"npm-package-registry","scope":"mesh","credential":{"form":"none"}}],"claims":` + claims + `}`)
return []byte(`{"module":"thing","version":"1.0","provides":[{"name":"npm-package-registry","scope":"mesh","credential":{"form":"none"}}],"class":"core","claims":` + claims + `}`)
}
func hostnameSeat(t *testing.T) catalogue.Seat {
@@ -6098,7 +6098,7 @@ func mod(name string, provides, requires, capabilities []string, claims ...catal
}
const collectorZsh = `{"module":"zsh","version":"1.0","moved":true,
"claims":[{"name":"node-login-shell","scope":"node"}],
"class":"core","claims":[{"name":"node-login-shell","scope":"node"}],
"collections":[{"name":"widgets","comment":"#"}],
"build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]},
"resources":[{"id":"rc","type":"file","path":"${machine:account-home}/.zshrc","owner":"${machine:account}",
@@ -6660,7 +6660,7 @@ func caseOneModuleClaimsTheNodeEnginesSeat(t *testing.T) {
t.Cleanup(func() { catalogue.UseSeats(was) })
catalogue.UseSeats([]catalogue.Seat{{Name: NodeEngineSeat, Scope: catalogue.ScopeNode, Decision: "test", HeldByTheEngine: true}})
engine := func(module string) []byte {
return []byte(`{"module":"` + module + `","version":"1.0","claims":[{"name":"node-engine","scope":"node"}]}`)
return []byte(`{"module":"` + module + `","version":"1.0","class":"core","claims":[{"name":"node-engine","scope":"node"}]}`)
}
for _, row := range []struct {
name string
@@ -0,0 +1,79 @@
package judge
import (
"fmt"
"slices"
"sync/atomic"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/seatdef"
)
// The manifest check of design 47 H2 §814 and §810: every kept store of a delivery module names its cap (§812), and a
// module that claims a seat names its class (H-A-394 (1), H-A-411 (4)).
// deliveryDomain is the glossary domain of the delivery system's seats, as a seat definition names it (seatdef.Domains).
const deliveryDomain = "Delivery"
// deliverySeats are the seats of the seat list the judge judges against whose definition is of the delivery system,
// by name: set with the list (UseSeatList), read by deliveryStoreProblems.
var deliverySeats atomic.Pointer[map[string]bool]
// useDeliverySeats keeps the delivery system's seats of defs (deliverySeats).
func useDeliverySeats(defs []seatdef.Definition) {
seats := map[string]bool{}
for _, d := range defs {
if d.Domain == deliveryDomain {
seats[d.Seat] = true
}
}
deliverySeats.Store(&seats)
}
// deliverySeatOf is the first seat of the delivery system m claims, by the seat list's definitions; "" for none.
func deliverySeatOf(m catalogue.Manifest) string {
seats := deliverySeats.Load()
if seats == nil {
return ""
}
for _, c := range m.Claims {
if (*seats)[c.Name] {
return c.Name
}
}
return ""
}
// deliveryStoreProblems refuses each state, log and objects entry of a delivery module (one whose manifest claims a seat
// of the delivery system) that names no cap, in its old section or in `requires` alike (design 47 H2 §812, §814): a
// foundation part's old-section entry names its cap in that section.
func deliveryStoreProblems(m catalogue.Manifest) []string {
seat := deliverySeatOf(m)
if seat == "" {
return nil
}
var problems []string
for _, u := range m.UncappedStores() {
where := "in `requires`"
if u.OldSection {
where = "in its old section"
}
problems = append(problems, fmt.Sprintf("%s claims the seat %s of the delivery system, so every store it keeps names its cap; "+
"its %s %q %s names none (design 47 H2 §812, §814)", m.Module, seat, u.Kind, u.Name, where))
}
return problems
}
// classProblems refuses a manifest that claims a seat and names no class, or a class that is neither core nor leaf
// (design 47 H2 §810, §814; H-A-394 (1)).
func classProblems(m catalogue.Manifest) []string {
if len(m.Claims) == 0 || slices.Contains([]string{catalogue.ClassCore, catalogue.ClassLeaf}, m.Class) {
return nil
}
if m.Class == "" {
return []string{fmt.Sprintf("%s claims a seat and names no `class`; a module that claims a seat names `class` %s or %s "+
"(design 47 H2 §810, §814)", m.Module, catalogue.ClassCore, catalogue.ClassLeaf)}
}
return []string{fmt.Sprintf("%s names the class %q; a class is %s or %s (design 47 H2 §810, §814)", m.Module, m.Class,
catalogue.ClassCore, catalogue.ClassLeaf)}
}