The running indexer's validation before take-in asks its own manifest validator (cmd/mesh-judge under the indexer entry's Go module, at the revision's head) over two cases and refuses only what the revision causes; mesh-judge reads the file MESH_RUN_INPUT names, where a run writes its input. Builds: design 47 G §712, A-213, A-232 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
// Command mesh-judge is the indexer's judge as a program the checker runs (novox/hq ADR 0578 §2): built at the trunk, or
|
|
// at a group's mesh-delivery head when that head changes the judge, and run by a Go build module's compose step in its
|
|
// sandbox exactly as the composer is (ADR 0482 §4; delivery.ComposeJob with this package), and by the running indexer's
|
|
// validation before take-in as a build seat's run (design 47 G §712). It reads a composer request (mesh-sdk
|
|
// composer.Request; `-request <file>`, else the file MESH_RUN_INPUT names, where a run writes its input, else its standard
|
|
// input) and writes one line, a composer verdict, whose
|
|
// cases say of each manifest whether the judge accepts it and, when not, every problem. It reads nothing else: no bus,
|
|
// store, network or environment.
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer"
|
|
|
|
"mesh-delivery-indexer/judge"
|
|
)
|
|
|
|
// Package is this command's import path in the indexer's Go module (the directory delivery.ComposeJob's Dir names).
|
|
const Package = "mesh-delivery-indexer/cmd/mesh-judge"
|
|
|
|
func main() { os.Exit(run(os.Args[1:], os.Stdin, os.Stdout, os.Stderr)) }
|
|
|
|
func run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
|
|
flags := flag.NewFlagSet("mesh-judge", flag.ContinueOnError)
|
|
flags.SetOutput(stderr)
|
|
file := flags.String("request", "", "the request's file; without it, the standard input")
|
|
if err := flags.Parse(args); err != nil {
|
|
return 2
|
|
}
|
|
var raw []byte
|
|
var err error
|
|
if *file == "" {
|
|
*file = os.Getenv(buildstep.RunInputEnv)
|
|
}
|
|
if *file != "" {
|
|
raw, err = os.ReadFile(*file)
|
|
} else {
|
|
raw, err = io.ReadAll(stdin)
|
|
}
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, "mesh-judge:", err)
|
|
return 1
|
|
}
|
|
r, err := composer.Decode(raw)
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, "mesh-judge:", err)
|
|
return 1
|
|
}
|
|
v, err := judge.Request(r)
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, "mesh-judge:", err)
|
|
return 1
|
|
}
|
|
out, err := json.Marshal(v)
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, "mesh-judge:", err)
|
|
return 1
|
|
}
|
|
fmt.Fprintln(stdout, string(out))
|
|
return 0
|
|
}
|