Kind: short package names (builds, sshkeys, forgemsg, backupgood, diskreadings, grantsstate, busgrants) in `packages`, which the indexer's judge refuses by design 32's rule (a Go package is named by its go.mod's module path). This held mesh-delivery-gate, the build modules, mounts and restic. Each key is now the import path the module's code uses, with its series kept; the manifest tests read the new keys, and the host/machine-name word tests in mounts, nfs-server, mesh-build-node and mesh-delivery-gate look past the path's `git.novox.be/novox/` prefix. Quick fix: only the gate's manifest. Thorough fix (chosen): all 15, since the same refusal holds each. Follow-up for the checker: the candidate verdict lets such a name through (J7(3)), so the merge check did not stop it. Claude-Session: https://claude.ai/code/session_01NcbgfFfQ4Z9UE5jK32PmE5
124 lines
4.2 KiB
Go
124 lines
4.2 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
|
|
placing "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
|
)
|
|
|
|
type manifest struct {
|
|
Packages map[string]string `json:"packages"`
|
|
Module string `json:"module"`
|
|
RunsAs string `json:"runs-as"`
|
|
Claims []struct {
|
|
Name string `json:"name"`
|
|
Scope string `json:"scope"`
|
|
Serves []string `json:"serves"`
|
|
} `json:"claims"`
|
|
Emits []string `json:"emits"`
|
|
Invokes []string `json:"invokes"`
|
|
Reads []string `json:"reads"`
|
|
Consume []string `json:"consumes"`
|
|
Tools []string `json:"tools"`
|
|
State []json.RawMessage `json:"state"`
|
|
}
|
|
|
|
func readManifest(t *testing.T) manifest {
|
|
t.Helper()
|
|
raw, err := os.ReadFile(filepath.Join("..", "..", "module.json"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var m manifest
|
|
if err := json.Unmarshal(raw, &m); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// The manifest says what the code does: it claims the seat mesh-self-check once for the mesh with the verbs it serves
|
|
// (ADR 0564 §1, §6), runs on its own account, says checked, asks only what its probes ask, keeps a week of verdicts,
|
|
// and reads no bucket of the controller's. Every state it keeps has a tool that reads it, and every act it takes by
|
|
// itself a tool that starts it by hand (ADR 0564 §12).
|
|
func TestTheManifestSaysWhatTheCodeDoes(t *testing.T) {
|
|
m := readManifest(t)
|
|
// The readings' layouts are the owners' published packages, taken by their series (ADR 0634 §4).
|
|
for _, pk := range []string{"git.novox.be/novox/mesh-catalog/modules/disk-load/diskreadings", "git.novox.be/novox/mesh-catalog/modules/restic/backupgood"} {
|
|
if m.Packages[pk] != "0.1" {
|
|
t.Errorf("packages %v: want %s of series 0.1", m.Packages, pk)
|
|
}
|
|
}
|
|
if m.Module != Module || m.RunsAs != Module {
|
|
t.Errorf("module %q runs as %q", m.Module, m.RunsAs)
|
|
}
|
|
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || m.Claims[0].Scope != "mesh" || !slices.Equal(m.Claims[0].Serves, Verbs) {
|
|
t.Errorf("claims %+v, want %s at mesh scope serving %v", m.Claims, Seat, Verbs)
|
|
}
|
|
// checked is the seat's event, said on the seat's subject: a module lists no event of a seat it claims.
|
|
if len(m.Emits) != 0 {
|
|
t.Errorf("emits %v", m.Emits)
|
|
}
|
|
if !slices.Equal(m.Invokes, Invokes) {
|
|
t.Errorf("invokes %v, want what the probes ask, %v", m.Invokes, Invokes)
|
|
}
|
|
if !slices.Equal(m.Reads, Reads) {
|
|
t.Errorf("reads %v, want what the probes read, %v", m.Reads, Reads)
|
|
}
|
|
if !slices.Equal(m.Consume, Consumes) {
|
|
t.Errorf("consumes %v, want the views families the probes follow, %v", m.Consume, Consumes)
|
|
}
|
|
for _, view := range []string{assignerModule + ".views." + placing.StateAssignments, assignerModule + ".views." + placing.StateSeatHolders} {
|
|
if !slices.Contains(m.Consume, view) {
|
|
t.Errorf("the probes follow %s, the manifest consumes %v", view, m.Consume)
|
|
}
|
|
}
|
|
if AssignmentsRead != "mesh-delivery-assigner.assignments" || SeatHoldersRead != "mesh-delivery-assigner.seat-holders" {
|
|
t.Errorf("the states are read as %s and %s", AssignmentsRead, SeatHoldersRead)
|
|
}
|
|
states := map[string]int{}
|
|
for _, s := range m.State {
|
|
var d struct {
|
|
Name string `json:"name"`
|
|
TTL int `json:"ttl-seconds"`
|
|
}
|
|
if json.Unmarshal(s, &d.Name) != nil {
|
|
_ = json.Unmarshal(s, &d)
|
|
}
|
|
states[d.Name] = d.TTL
|
|
}
|
|
if states[VerdictsState] != 7*24*60*60 {
|
|
t.Errorf("verdicts are kept %d s, want a week", states[VerdictsState])
|
|
}
|
|
// ADR 0564 §12: each state with the tool that reads it, each act with the tool that starts it.
|
|
readBy := map[string]string{FindingsState: FindingsTool, VerdictState: DoctorTool, VerdictsState: VerdictsTool,
|
|
"the run": DoctorTool + " run=true"}
|
|
tools := map[string]bool{}
|
|
for _, tool := range Tools(&Checker{}) {
|
|
tools[tool.Name] = true
|
|
}
|
|
for state := range states {
|
|
if _, ok := readBy[state]; !ok {
|
|
t.Errorf("the state %s has no tool that reads it", state)
|
|
}
|
|
}
|
|
for what, tool := range readBy {
|
|
name, _, _ := cutSpace(tool)
|
|
if !tools[name] {
|
|
t.Errorf("%s is read or started by %s, which is not served", what, tool)
|
|
}
|
|
}
|
|
}
|
|
|
|
func cutSpace(s string) (string, string, bool) {
|
|
for i, r := range s {
|
|
if r == ' ' {
|
|
return s[:i], s[i+1:], true
|
|
}
|
|
}
|
|
return s, "", false
|
|
}
|