Files
mesh-delivery/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/unbuildable.go
T
jschoubben bcff47d257 B6 (H-A-425): a plan no seat builds is kept in the state unbuildable and said in one line
A line per module drowned the journal at 6,500 plans; the plans live on the bus, where
builder_unbuildable reads them, and the builder says them once per start and per seat list change.

Builds: design 47 H2 §795, §820; H-A-425
2026-11-22 01:37:32 +01:00

71 lines
2.5 KiB
Go

package main
import (
"encoding/json"
"errors"
"sort"
stdio "git.novox.be/novox/mesh-sdk/go"
"mesh-delivery-builder/internal/build"
"mesh-delivery-builder/internal/versions"
)
// unbuildableTool is builder_unbuildable (design 47 H2 §795, H-A-425): the builder's state unbuildable, the plans no seat builds,
// read in one page of at most 768 KB (capped says what it left out), with the summary line of the rows read.
func unbuildableTool(page func() (versions.StatePage, error)) stdio.Tool {
return stdio.Tool{Name: build.UnbuildableTool,
Description: "The modules whose artifact no build seat builds, or whose build seat no module claims, as the builder judged their plans " +
"(its state " + build.UnbuildableState + ", worked out again at every start and every change of the seat list): each module, the fingerprint " +
"judged, the artifact's language and kind, why and when; with the one summary line the builder says of them. At most 768 KB, capped " +
"saying what was left out. Read-only.",
Input: map[string]any{"type": "object", "properties": map[string]any{}},
Run: func(map[string]any) (any, error) {
pg, err := page()
if err != nil {
return nil, err
}
rows := []build.Unbuildable{}
var unread []string
for k, raw := range pg.Values {
var u build.Unbuildable
if err := json.Unmarshal(raw, &u); err != nil || u.Module == "" {
unread = append(unread, k)
continue
}
rows = append(rows, u)
}
sort.Slice(rows, func(i, j int) bool { return rows[i].Module < rows[j].Module })
sort.Strings(unread)
out := map[string]any{"line": build.UnbuildableLine(rows), "unbuildable": rows}
if len(unread) > 0 {
out["unreadable"] = unread
}
if pg.More {
out["capped"] = versions.StateCapped{State: build.UnbuildableState, KeysRead: len(pg.Values), StateKeys: pg.Keys, StateBytes: pg.Bytes, InfoWords: pg.InfoWords}
}
return out, nil
}}
}
// unbuildablePage is the first page of the state unbuildable; a runtime that pages nothing is read key by key.
func unbuildablePage(s stdio.KeptState) func() (versions.StatePage, error) {
return func() (versions.StatePage, error) {
pg, err := onePage(s.Page, s.Info)
if !errors.Is(err, errors.ErrUnsupported) {
return pg, err
}
keys, err := s.Keys()
if err != nil {
return versions.StatePage{}, err
}
out := versions.StatePage{Values: map[string]json.RawMessage{}}
for _, k := range keys {
if e, err := s.Get(k); err == nil && e != nil {
out.Values[k] = e.Value
}
}
return out, nil
}
}