Files
mesh-delivery/modules/mesh-delivery-checker/cmd/mesh-checking-program/main.go
T
jschoubben 71a35a6376 MV1: move contracts and sdk under modules/, importers follow
The delivery repository's contracts and SDK live under modules/ as
mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths
renamed to match the folders (the TypeScript names already did), and
every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools
and mesh-sdk follows in the same group: a design as it should be, one
path per module, checked by the group's check building every importer.

Builds: design 47 G §427, §88

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 05:09:56 +01:00

53 lines
1.7 KiB
Go

// Command mesh-checking-program is the checker's checking program (novox/hq ADR 0644, ADR 0656; design 47's bootstrap
// delivery): built from a check's heads and run in the build seat's sandbox through the seat node-build-go's ask run,
// with no network and no bus account, it reads the check's facts from the file MESH_RUN_INPUT names and answers the
// verdict the judging rules give them, as one JSON line on its standard output (rules.Answer).
//
// mesh-checking-program -verdict
// mesh-checking-program -seats
//
// Asked -seats, it answers the seat list of the heads laid in the directory MESH_RUN_HEADS names (rules.SeatsAnswer).
// It refuses facts of a version it does not read, naming it, with exit 2.
package main
import (
"fmt"
"io"
"io/fs"
"os"
"slices"
"mesh-delivery-checker/rules"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
)
func main() {
os.Exit(run(os.Args[1:], os.Getenv, os.Stdout, os.Stderr))
}
// run is the command over its arguments, environment and outputs, answering its exit.
func run(args []string, getenv func(string) string, stdout, stderr io.Writer) int {
var heads fs.FS
if dir := getenv(buildstep.RunHeadsEnv); dir != "" {
heads = os.DirFS(dir)
}
input := func() ([]byte, error) {
file := getenv(buildstep.RunInputEnv)
if file == "" {
return nil, fmt.Errorf("%s names no file", buildstep.RunInputEnv)
}
return os.ReadFile(file)
}
line, err := rules.Program(args, input, heads)
if err != nil {
if heads == nil && slices.Contains(args, "-seats") {
err = fmt.Errorf("no heads: %s names no directory", buildstep.RunHeadsEnv)
}
fmt.Fprintf(stderr, "mesh-checking-program: %v\n", err)
return 2
}
fmt.Fprintf(stdout, "%s\n", line)
return 0
}