Files
mesh-delivery/modules/mesh-delivery-indexer/cmd/mesh-judge/main.go
T
jschoubben 4f6f38e16a Keep every strict read of a manifest in the indexer's judge, and add no test to the budget
Issue 1585, S5-S8: the indexer's fingerprint reads go through judge.ForInputs, so judge/ is the one place in
mesh-delivery that calls mesh-sdk's rules; the command's request judging moves into judge.Request, tested in the
judge's table; two predefined tests become one.

Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
2026-11-01 02:21:32 +01:00

62 lines
1.9 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). It reads a composer request
// (mesh-sdk composer.Request; `-request <file>`, or 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-sdk/go/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 != "" {
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
}