package seatlist import ( "embed" "fmt" "sort" "git.novox.be/novox/mesh-sdk/go/seatdef" ) // The foundation's bootstrapped definitions (novox/hq ADR 0608 §2, ADR 0635 §3): the seats the foundation's parts claim // and invoke before the indexer has run, kept as the definitions' own files (`bootstrap/.json`, the format's own // text, whole or at the seat list's grain) and embedded as data. A reader holds them until the owner answers, and says so // (Status). **They are copies:** a seat's definition is the one in its contracts module, and a test there holds each of // these files equal to it; where a seat moves or changes, its file here is replaced by the same change. Which seats are // the foundation's, and how a fresh mesh gets them without a copy, is research 075's. // //go:embed bootstrap/*.json var bootstrapFiles embed.FS // Bootstrapped are the foundation's definitions, by seat name. It panics on a file that does not parse, which the // package's test refuses to let ship. func Bootstrapped() []seatdef.Definition { entries, err := bootstrapFiles.ReadDir("bootstrap") if err != nil { panic(err) } var out []seatdef.Definition for _, e := range entries { raw, err := bootstrapFiles.ReadFile("bootstrap/" + e.Name()) if err != nil { panic(err) } d, err := seatdef.Parse(raw) if err != nil { panic(fmt.Sprintf("seatlist: bootstrap/%s does not parse: %v", e.Name(), err)) } out = append(out, d) } sort.Slice(out, func(i, j int) bool { return out[i].Seat < out[j].Seat }) return out }