53 lines
2.3 KiB
Go
53 lines
2.3 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 from the store's own files through the store's own container,
|
||
// 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.** A module that provides the artifact store cannot also build an
|
||
// artifact: building publishes to the store, so the store would be needed to create itself. So these tools are a
|
||
// second module, assigned to the machine that holds the store. stdout is the protocol; what this bundle says, it says
|
||
// on stderr.
|
||
package main
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"os"
|
||
"time"
|
||
|
||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||
"git.novox.be/novox/mesh-sdk/go/handacts"
|
||
|
||
"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{
|
||
Container: os.Getenv("MESH_ARTIFACT_STORE_CONTAINER"),
|
||
Run: ExecRunner,
|
||
UID: os.Getuid(),
|
||
}
|
||
v := &views.Reader{Module: "artifact-store-tools", Logf: logf, Findings: views.OwnFindings{}, Acts: handacts.Recorder{Ask: stdio.Ask}}
|
||
v.Follow(delivery.AssignerModule, "wants", WantsTool)
|
||
v.Follow(delivery.IndexerModule, "manifests", ManifestsTool)
|
||
h := &Holder{Bus: runtimeBus{views: v}, Door: DoorAt(os.Getenv("MESH_ARTIFACT_STORE_ADDRESS_FILE")), Listed: s.View,
|
||
Now: time.Now, Logf: logf}
|
||
h.Acts = handacts.Recorder{Ask: stdio.Ask}
|
||
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 = delivery.AssignerModule + ".assigner_read_wants"
|
||
ManifestsTool = delivery.IndexerModule + ".indexer_read_manifests"
|
||
)
|