Files
mesh-delivery/modules/mesh-delivery-checker/cmd/mesh-checking-program/main.go
T
jschoubben e96f8fd1b6 The manifests, compiled-programs and composition rules judge facts in the checker's rules (issue 1921)
The running checker records the manifest validator's cases, each fetch's programs and the engines' answers as facts,
and the rules package judges them, with the notes it gives a reader, so the checking program judges every rule the
running checker judged. The module graph's cycle stays with the asking: its facts are whole manifests, over a run's
input bound; G's program reads them from the heads.

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
2026-11-06 22:31:22 +01:00

60 lines
1.8 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
//
// It refuses facts of a version it does not read, naming it, with exit 2.
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"os"
"git.novox.be/novox/mesh-sdk/go/delivery"
"mesh-delivery-checker/rules"
)
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 {
fs := flag.NewFlagSet("mesh-checking-program", flag.ContinueOnError)
fs.SetOutput(stderr)
verdict := fs.Bool("verdict", false, "answer the verdict of the facts in the input")
if err := fs.Parse(args); err != nil {
return 2
}
refuse := func(format string, a ...any) int {
fmt.Fprintf(stderr, "mesh-checking-program: "+format+"\n", a...)
return 2
}
if !*verdict {
return refuse("nothing asked: give -verdict")
}
file := getenv(delivery.RunInputEnv)
if file == "" {
return refuse("no input: %s names no file", delivery.RunInputEnv)
}
data, err := os.ReadFile(file)
if err != nil {
return refuse("the input cannot be read: %v", err)
}
facts, err := rules.DecodeFacts(data)
if err != nil {
return refuse("%v", err)
}
line, err := json.Marshal(rules.Judged(facts))
if err != nil {
return refuse("the verdict cannot be written: %v", err)
}
fmt.Fprintf(stdout, "%s\n", line)
return 0
}