A done build whose history read failed was left out of the view for the whole process, so later passes judged from an incomplete keep set, and every build cost one history read. A build's end is now taken from the build-ended entries of the builder's log the pass already reads once, and only a build the log lacks is read from its history. While any done key's end is unread, or the view is not yet taken in, no pass judges: it ends with the finding artifact-builds-unread, written once and cleared by the next pass that judges. Every change heard while a watch's handover is gathered now goes into that handover, so a build finished between the handover and its taking in is not lost by the swap (H-A-257). Builds: design 47 H §H-A-255 (1), §H-A-257, §H-A-258, §H-A-260
64 lines
2.9 KiB
Go
64 lines
2.9 KiB
Go
// The artifact-store-tools module's Go bundle (novox/hq ADR 0251 §1–3, ADR 0571 clause 2, to-be 51): a process the
|
||
// node's runtime launches and speaks MCP over stdio to. It says what the artifact store holds — its repositories, its
|
||
// size, and what the mesh keeps of each manifest — read through the registry seats' list (novox/hq ADR 0632 §4), and it
|
||
// holds the seat mesh-artifact-sweep: the keep set, the sweep at each build's end, and S25's image-missing.
|
||
//
|
||
// **A module beside the store, not the store's own.** It requires no provision: what it reads, holds and removes it asks
|
||
// the registry seats (listed.go, sweepseats.go), never the store's files or its read side. stdout is the protocol; what this bundle says, it says on stderr.
|
||
package main
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"os"
|
||
"time"
|
||
|
||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||
meshconditions "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||
|
||
"git.novox.be/novox/mesh-sdk/go/views"
|
||
)
|
||
|
||
func logf(format string, a ...any) { fmt.Fprintf(os.Stderr, format+"\n", a...) }
|
||
|
||
func main() {
|
||
s := &Store{Ask: stdio.Ask}
|
||
v := &views.Reader{Module: "artifact-store-tools", Logf: logf, Acts: meshhandactsclient.Recorder{Ask: stdio.Ask}}
|
||
v.Follow(assignerModule, "wants", WantsTool)
|
||
v.Follow(indexerModule, "manifests", ManifestsTool)
|
||
h := &Holder{Bus: runtimeBus{views: v}, Door: DoorAt(os.Getenv("MESH_ARTIFACT_STORE_ADDRESS_FILE"), s), Listed: s.View,
|
||
Seats: stdio.Ask, Now: time.Now, Logf: logf}
|
||
h.Acts = meshhandactsclient.Recorder{Ask: stdio.Ask}
|
||
// The module's one held writer (design 47 G §689, A-16, A-29, A-32): the holder's findings and the reader's go through it.
|
||
w, err := views.NewStdioHeldWriter(views.WriterConfig[meshconditions.Finding, meshconditions.FindingCleared, meshconditions.FindingsStated, meshconditions.FindingsAskedEvent]{
|
||
Asked: meshconditions.SubjectFindingsAsked, Module: Module, State: stdio.State("findings"), Kinds: []string{ImageMissing, SweepRefused, ListUnread, BuildsUnread}})
|
||
if err != nil {
|
||
logf("%v", err)
|
||
os.Exit(1)
|
||
}
|
||
h.Findings = w
|
||
v.Findings = w
|
||
// the runtime answers the writer's subscription only once Serve has its channel
|
||
go func() {
|
||
<-stdio.Served()
|
||
if err := w.Start(context.Background()); err != nil {
|
||
logf("%v", err)
|
||
os.Exit(1)
|
||
}
|
||
}()
|
||
v.Start(context.Background())
|
||
go follow(h, v)
|
||
// An empty name serves as the module the runtime names (MESH_SERVED_MODULE): artifact-store-tools.
|
||
if err := stdio.Serve("", append(append(Tools(s, h, &Catalogue{Ask: stdio.Ask}), SeatTools(h, s)...), v.Tools("artifact_store")...)); err != nil {
|
||
fmt.Fprintln(os.Stderr, err)
|
||
os.Exit(1)
|
||
}
|
||
}
|
||
|
||
// The owners' read tools of the states the holder follows, which the manifest invokes (ADR 0615).
|
||
const (
|
||
WantsTool = assignerModule + ".assigner_read_wants"
|
||
ManifestsTool = indexerModule + ".indexer_read_manifests"
|
||
)
|