B0's shape wins: the running checker asks and records facts, the checking program decides. The registry's types win: the rules and the program read the generated checker contract and the domain SDK, and no mesh-sdk delivery import is left. The registry's series, renames and unparsed seat definitions become facts with their refusals as rules; the tagged versions ride on the case. The program reads the heads' seat definitions through sdk/seatdefs and the running checker lays them over its reader's list by seat, reading no file of the heads: the reader's list is larger than a run input's bound. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package rules
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"io/fs"
|
|
)
|
|
|
|
// Program is the checking program's work (cmd/mesh-checking-program; novox/hq ADR 0644, ADR 0656): over its arguments,
|
|
// its input (read only when asked for the verdict) and the heads laid for it (nil when none are), the one JSON line it
|
|
// answers, or why it refuses. `-seats` answers the seat list of the heads (SeatsOf), `-verdict` the verdict of the
|
|
// facts in the input (Judged), refusing facts of a version it does not read.
|
|
func Program(args []string, input func() ([]byte, error), heads fs.FS) ([]byte, error) {
|
|
set := flag.NewFlagSet("mesh-checking-program", flag.ContinueOnError)
|
|
set.SetOutput(io.Discard)
|
|
verdict := set.Bool("verdict", false, "answer the verdict of the facts in the input")
|
|
seats := set.Bool("seats", false, "answer the seat list of the heads laid for it")
|
|
if err := set.Parse(args); err != nil {
|
|
return nil, err
|
|
}
|
|
switch {
|
|
case *seats:
|
|
if heads == nil {
|
|
return nil, errors.New("no heads are laid for it")
|
|
}
|
|
data, err := input()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("the input cannot be read: %w", err)
|
|
}
|
|
facts, err := DecodeFacts(data)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
answer, err := SeatsOf(heads, facts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(answer)
|
|
case *verdict:
|
|
data, err := input()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("the input cannot be read: %w", err)
|
|
}
|
|
facts, err := DecodeFacts(data)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(Judged(facts))
|
|
}
|
|
return nil, errors.New("nothing asked: give -verdict or -seats")
|
|
}
|