MV1: move contracts and sdk under modules/, importers follow
The delivery repository's contracts and SDK live under modules/ as mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths renamed to match the folders (the TypeScript names already did), and every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools and mesh-sdk follows in the same group: a design as it should be, one path per module, checked by the group's check building every importer. Builds: design 47 G §427, §88 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
// Package containerimageregistryclient is the container-image-registry seat's client (novox/hq ADR 0627 §1, §2; ADR 0611, design 51
|
||||
// *Publishing*): it publishes a file in parts to the seat's holder. `publish` opens the transfer naming every part,
|
||||
// the holder answers the parts it lacks, and only those travel by `publish-part`, in chunks a bus message carries; a
|
||||
// cut transfer goes on from what the holder answers when the same transfer is opened again. The sending in parts is
|
||||
// mesh-sdk's seat-neutral runtime (parts); this client binds it to this seat's verbs and types alone. The call is the
|
||||
// caller's own (a bundle's stdio.Ask, a process's call of a seat verb), so it holds no transport.
|
||||
package containerimageregistryclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/containerimageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// Call asks one verb of the seat, `seat:<seat>.<verb>`, with a body, and answers its JSON.
|
||||
type Call func(key string, body any) (json.RawMessage, error)
|
||||
|
||||
// Sent is what a Publish did: the transfer, whether the holder held its digest already, the parts it lacked and were
|
||||
// sent, and the chunks they took.
|
||||
type Sent struct {
|
||||
Transfer string
|
||||
parts.Sent
|
||||
}
|
||||
|
||||
// Publish opens (or opens again) the transfer in on the seat and sends the parts the holder answers it lacks, each in
|
||||
// chunks of at most parts.MaxChunk, in sequence, the last marked. in.Parts is written from parts. A part whose bytes
|
||||
// do not hash to its digest is refused before anything of it is sent; a part the holder does not name is never read.
|
||||
// Its outcome, published or refused, is the holder's event, which the caller waits for.
|
||||
func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Part) (Sent, error) {
|
||||
open := func(_ context.Context, ps []parts.Part) (parts.Opened, error) {
|
||||
in.Parts = make([]seat.Part, 0, len(ps))
|
||||
for _, p := range ps {
|
||||
in.Parts = append(in.Parts, seat.Part{Digest: p.Digest, Size: p.Size})
|
||||
}
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublish, in)
|
||||
if err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's publish of %s: %w", seat.Seat, in.Name, err)
|
||||
}
|
||||
var a seat.PublishAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err)
|
||||
}
|
||||
return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil
|
||||
}
|
||||
chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error {
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part,
|
||||
Sequence: int64(sequence), Last: last, Data: base64.StdEncoding.EncodeToString(data)})
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s's publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
var a seat.PublishPartAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return fmt.Errorf("%s's answer to publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
sent, err := parts.Send(ctx, open, chunk, ps)
|
||||
return Sent{Transfer: in.Transfer, Sent: sent}, err
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package containerimageregistryclient
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/containerimageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// The client publishes over its own seat's verbs alone (ADR 0627 §1): publish names every part, and only the part the
|
||||
// holder lacks travels by publish-part, its bytes whole, the last chunk marked.
|
||||
func TestPublishTalksToItsOwnSeat(t *testing.T) {
|
||||
held, lacked := []byte("held"), []byte("lacked")
|
||||
part := func(b []byte) parts.Part {
|
||||
sum := sha256.Sum256(b)
|
||||
return parts.Part{Digest: "sha256:" + hex.EncodeToString(sum[:]), Size: int64(len(b)),
|
||||
Open: func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(b)), nil }}
|
||||
}
|
||||
ps := []parts.Part{part(held), part(lacked)}
|
||||
var asked []string
|
||||
var got []byte
|
||||
call := func(key string, body any) (json.RawMessage, error) {
|
||||
asked = append(asked, key)
|
||||
raw, _ := json.Marshal(body)
|
||||
switch key {
|
||||
case "seat:container-image-registry.publish":
|
||||
var in seat.PublishInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
if len(in.Parts) != 2 {
|
||||
t.Errorf("publish names %d parts, want 2", len(in.Parts))
|
||||
}
|
||||
return json.Marshal(seat.PublishAnswer{Transfer: in.Transfer, Lacks: []string{ps[1].Digest}})
|
||||
case "seat:container-image-registry.publish-part":
|
||||
var in seat.PublishPartInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
data, _ := base64.StdEncoding.DecodeString(in.Data)
|
||||
if in.Part != ps[1].Digest || !in.Last || in.Transfer != "t1" {
|
||||
t.Errorf("publish-part %+v", in)
|
||||
}
|
||||
got = append(got, data...)
|
||||
return json.Marshal(seat.PublishPartAnswer{Transfer: in.Transfer, Part: in.Part})
|
||||
}
|
||||
t.Fatalf("asked %s", key)
|
||||
return nil, nil
|
||||
}
|
||||
sent, err := Publish(context.Background(), call, seat.PublishInput{Transfer: "t1", Name: "x"}, ps)
|
||||
if err != nil || sent.Transfer != "t1" || sent.Chunks != 1 || len(sent.Parts) != 1 || !bytes.Equal(got, lacked) || len(asked) != 2 {
|
||||
t.Errorf("sent %+v, %q arrived, asked %v, %v", sent, got, asked, err)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/containerimageregistryclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/containerimageregistry v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-delivery/sdk v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/klauspost/compress v1.20.1 // indirect
|
||||
github.com/nats-io/nats.go v1.54.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
@@ -1,116 +0,0 @@
|
||||
// Package reference holds the form of an artifact's reference once a registry seat published it: `<seat>/<module>/<artifact>@<digest>`
|
||||
// (novox/hq ADR 0605 §9), and the older `artifact-store://<path>` form read beside it. It is the rule the holders and callers of the two
|
||||
// registry seats that front the artifact store share (the seats' client, novox/hq ADR 0625 §4, ADR 0634 §2); it names no seat itself (ADR 0634 §4, ADR 0635 §4): the
|
||||
// caller gives the seats' names from their contracts (Seats), so a package here cannot drift from a contract.
|
||||
package reference
|
||||
|
||||
import "strings"
|
||||
|
||||
// ArtifactStoreScheme marks a reference to something in the mesh's artifact store, kept without the store's address.
|
||||
const ArtifactStoreScheme = "artifact-store://"
|
||||
|
||||
// UpstreamPrefix opens the holder's own name for an upstream copy it keeps: `upstream/<host>/<path>@<digest>`, after
|
||||
// `<image seat>/` in the seat's form and after `artifact-store://` in the older one.
|
||||
const UpstreamPrefix = "upstream/"
|
||||
|
||||
// Seats are the names of the two registry seats a reference of the registry form names first: Image the seat that fronts
|
||||
// images and upstream copies (container-image-registry), Object the seat that fronts bundles and archives
|
||||
// (oci-artifact-registry). The caller reads them from the seats' contracts.
|
||||
type Seats struct{ Image, Object string }
|
||||
|
||||
// All is the two names.
|
||||
func (s Seats) All() []string { return []string{s.Image, s.Object} }
|
||||
|
||||
// Recorded is a reference as the mesh records it: the artifact store's address, if the builder wrote one, taken off.
|
||||
func (s Seats) Recorded(reference string) string {
|
||||
if _, _, seat := s.InRegistrySeat(reference); seat || strings.HasPrefix(reference, ArtifactStoreScheme) {
|
||||
return reference
|
||||
}
|
||||
if rest, isURL := strings.CutPrefix(reference, "http://"); isURL {
|
||||
if _, path, ok := strings.Cut(rest, "/v2/"); ok && strings.Contains(path, "/blobs/") {
|
||||
return ArtifactStoreScheme + path
|
||||
}
|
||||
return reference
|
||||
}
|
||||
host, path, ok := strings.Cut(reference, "/")
|
||||
if !ok || !isRegistryHost(host) || !strings.Contains(path, "@sha256:") {
|
||||
return reference
|
||||
}
|
||||
return ArtifactStoreScheme + path
|
||||
}
|
||||
|
||||
// isRegistryHost is the runtime's own rule for reading the first component of a reference as a registry rather than a
|
||||
// namespace: it has a dot or a port in it, or it is localhost.
|
||||
func isRegistryHost(component string) bool {
|
||||
return component == "localhost" || strings.ContainsAny(component, ".:")
|
||||
}
|
||||
|
||||
// InArtifactStore reports whether a reference is a kept one, and what it names there: `<module>/<artifact>@<digest>` for an
|
||||
// image, `<module>/<artifact>/blobs/<digest>` for a bundle or an archive. It reads both forms (ADR 0605 §9).
|
||||
func (s Seats) InArtifactStore(reference string) (path string, kept bool) {
|
||||
if seat, rest, ok := s.InRegistrySeat(reference); ok {
|
||||
if seat == s.Object {
|
||||
name, digest, _ := strings.Cut(rest, "@")
|
||||
return name + "/blobs/" + digest, true
|
||||
}
|
||||
return rest, true
|
||||
}
|
||||
return strings.CutPrefix(reference, ArtifactStoreScheme)
|
||||
}
|
||||
|
||||
// SeatReference is the reference a build names an image, bundle, archive or upstream copy by once it published it through
|
||||
// a registry seat: `<seat>/<module>/<artifact>@sha256:<digest>`, as InRegistrySeat reads it back.
|
||||
func SeatReference(seat, module, artifact, digest string) string {
|
||||
return seat + "/" + module + "/" + artifact + "@" + digest
|
||||
}
|
||||
|
||||
// InRegistrySeat reads a reference in the form a registry seat answers: the seat it came through and the rest. A seat's
|
||||
// name holds no dot or port, so no image of an outside registry reads as one, and a kept `artifact-store://` reference is
|
||||
// not one. It also reads the holder's own naming of an upstream copy through the image seat, whose rest InUpstream reads.
|
||||
func (s Seats) InRegistrySeat(reference string) (seat, path string, ok bool) {
|
||||
first, rest, found := strings.Cut(reference, "/")
|
||||
if !found || !strings.Contains(rest, "@sha256:") {
|
||||
return "", "", false
|
||||
}
|
||||
if _, _, upstream := InUpstream(rest); upstream && first == s.Image {
|
||||
return first, rest, true
|
||||
}
|
||||
if strings.Count(rest, "/") != 1 {
|
||||
return "", "", false
|
||||
}
|
||||
for _, name := range s.All() {
|
||||
if first == name {
|
||||
return name, rest, true
|
||||
}
|
||||
}
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
// InUpstream reads a path in the holder's naming of an upstream copy, `upstream/<host>/<path>@sha256:<digest>`: the
|
||||
// upstream registry host and the image's path there, with its digest.
|
||||
func InUpstream(path string) (host, image string, ok bool) {
|
||||
rest, found := strings.CutPrefix(path, UpstreamPrefix)
|
||||
if !found {
|
||||
return "", "", false
|
||||
}
|
||||
host, image, found = strings.Cut(rest, "/")
|
||||
name, digest, pinned := strings.Cut(image, "@")
|
||||
if !found || !isRegistryHost(host) || name == "" || strings.HasPrefix(name, "/") || strings.HasSuffix(name, "/") ||
|
||||
strings.Contains(name, "//") || !pinned || !strings.HasPrefix(digest, "sha256:") || strings.Contains(digest, "/") {
|
||||
return "", "", false
|
||||
}
|
||||
return host, image, true
|
||||
}
|
||||
|
||||
// Routed is a kept reference as a machine fetches it, through the artifact store at `address` (host:port). A reference
|
||||
// that is not a kept one is what it was.
|
||||
func (s Seats) Routed(reference, address string) string {
|
||||
path, kept := s.InArtifactStore(reference)
|
||||
if !kept {
|
||||
return reference
|
||||
}
|
||||
if strings.Contains(path, "/blobs/") {
|
||||
return "http://" + address + "/v2/" + path
|
||||
}
|
||||
return address + "/" + path
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package reference
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var digest = "sha256:" + strings.Repeat("d", 64)
|
||||
|
||||
var seats = Seats{Image: "container-image-registry", Object: "object-registry"}
|
||||
|
||||
func TestAReferenceIsRecordedWithoutTheStoresAddress(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"anchor.internal:5100/gitea/server@" + digest: ArtifactStoreScheme + "gitea/server@" + digest,
|
||||
"localhost:5000/gitea/server@" + digest: ArtifactStoreScheme + "gitea/server@" + digest,
|
||||
"http://anchor.internal:5100/v2/gitea/config/blobs/" + digest: ArtifactStoreScheme + "gitea/config/blobs/" + digest,
|
||||
ArtifactStoreScheme + "gitea/server@" + digest: ArtifactStoreScheme + "gitea/server@" + digest,
|
||||
digest: digest,
|
||||
"@novox/sdk@1.2.3": "@novox/sdk@1.2.3",
|
||||
"gitea/gitea@" + digest: "gitea/gitea@" + digest,
|
||||
"https://registry.example/v2/gitea/config/blobs/" + digest: "https://registry.example/v2/gitea/config/blobs/" + digest,
|
||||
// The form a registry seat answers is recorded as it is (ADR 0605 §9).
|
||||
"container-image-registry/gitea/server@" + digest: "container-image-registry/gitea/server@" + digest,
|
||||
"object-registry/gitea/config@" + digest: "object-registry/gitea/config@" + digest,
|
||||
}
|
||||
for announced, want := range cases {
|
||||
if got := seats.Recorded(announced); got != want {
|
||||
t.Errorf("Recorded(%q) = %q, want %q", announced, got, want)
|
||||
}
|
||||
}
|
||||
// And every reader reads both forms: a kept reference and the seat's are fetched from the same place.
|
||||
for reference, want := range map[string]string{
|
||||
ArtifactStoreScheme + "gitea/server@" + digest: "10.0.0.1:5000/gitea/server@" + digest,
|
||||
"container-image-registry/gitea/server@" + digest: "10.0.0.1:5000/gitea/server@" + digest,
|
||||
ArtifactStoreScheme + "gitea/config/blobs/" + digest: "http://10.0.0.1:5000/v2/gitea/config/blobs/" + digest,
|
||||
"object-registry/gitea/config@" + digest: "http://10.0.0.1:5000/v2/gitea/config/blobs/" + digest,
|
||||
"registry.example/gitea/server@" + digest: "registry.example/gitea/server@" + digest,
|
||||
"mesh-artifact-store/gitea/server@" + digest: "mesh-artifact-store/gitea/server@" + digest,
|
||||
// An upstream copy under the holder's own naming, in both forms.
|
||||
"container-image-registry/upstream/quay.io:443/org/app@" + digest: "10.0.0.1:5000/upstream/quay.io:443/org/app@" + digest,
|
||||
ArtifactStoreScheme + "upstream/quay.io:443/org/app@" + digest: "10.0.0.1:5000/upstream/quay.io:443/org/app@" + digest,
|
||||
} {
|
||||
if got := seats.Routed(reference, "10.0.0.1:5000"); got != want {
|
||||
t.Errorf("Routed(%q) = %q, want %q", reference, got, want)
|
||||
}
|
||||
}
|
||||
// A build module names what it published in the seat's form, and reads it back as the seat it came through.
|
||||
for _, seat := range seats.All() {
|
||||
ref := SeatReference(seat, "gitea", "config", digest)
|
||||
if got, path, ok := seats.InRegistrySeat(ref); !ok || got != seat || path != "gitea/config@"+digest {
|
||||
t.Errorf("SeatReference(%s) = %q, read back as %q %q %v", seat, ref, got, path, ok)
|
||||
}
|
||||
}
|
||||
// The holder's naming of an upstream copy reads through the image seat only, and InUpstream reads its host and path.
|
||||
for reference, want := range map[string]bool{
|
||||
"container-image-registry/upstream/quay.io:443/org/app@" + digest: true,
|
||||
"object-registry/upstream/quay.io:443/org/app@" + digest: false,
|
||||
"container-image-registry/upstream/org/app@" + digest: false,
|
||||
"container-image-registry/upstream/quay.io/app": false,
|
||||
} {
|
||||
_, path, ok := seats.InRegistrySeat(reference)
|
||||
if ok != want {
|
||||
t.Errorf("InRegistrySeat(%q) read %v, want %v", reference, ok, want)
|
||||
}
|
||||
if host, image, up := InUpstream(path); ok && (!up || host != "quay.io:443" || image != "org/app@"+digest) {
|
||||
t.Errorf("InUpstream(%q) = %q %q %v", path, host, image, up)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Package gopackageregistryclient is the go-package-registry seat's client (novox/hq ADR 0627 §1, §2; ADR 0611, design 51
|
||||
// *Publishing*): it publishes a file in parts to the seat's holder. `publish` opens the transfer naming every part,
|
||||
// the holder answers the parts it lacks, and only those travel by `publish-part`, in chunks a bus message carries; a
|
||||
// cut transfer goes on from what the holder answers when the same transfer is opened again. The sending in parts is
|
||||
// mesh-sdk's seat-neutral runtime (parts); this client binds it to this seat's verbs and types alone. The call is the
|
||||
// caller's own (a bundle's stdio.Ask, a process's call of a seat verb), so it holds no transport.
|
||||
package gopackageregistryclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/gopackageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// Call asks one verb of the seat, `seat:<seat>.<verb>`, with a body, and answers its JSON.
|
||||
type Call func(key string, body any) (json.RawMessage, error)
|
||||
|
||||
// Sent is what a Publish did: the transfer, whether the holder held its digest already, the parts it lacked and were
|
||||
// sent, and the chunks they took.
|
||||
type Sent struct {
|
||||
Transfer string
|
||||
parts.Sent
|
||||
}
|
||||
|
||||
// Publish opens (or opens again) the transfer in on the seat and sends the parts the holder answers it lacks, each in
|
||||
// chunks of at most parts.MaxChunk, in sequence, the last marked. in.Parts is written from parts. A part whose bytes
|
||||
// do not hash to its digest is refused before anything of it is sent; a part the holder does not name is never read.
|
||||
// Its outcome, published or refused, is the holder's event, which the caller waits for.
|
||||
func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Part) (Sent, error) {
|
||||
open := func(_ context.Context, ps []parts.Part) (parts.Opened, error) {
|
||||
in.Parts = make([]seat.Part, 0, len(ps))
|
||||
for _, p := range ps {
|
||||
in.Parts = append(in.Parts, seat.Part{Digest: p.Digest, Size: p.Size})
|
||||
}
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublish, in)
|
||||
if err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's publish of %s: %w", seat.Seat, in.Name, err)
|
||||
}
|
||||
var a seat.PublishAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err)
|
||||
}
|
||||
return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil
|
||||
}
|
||||
chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error {
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part,
|
||||
Sequence: int64(sequence), Last: last, Data: base64.StdEncoding.EncodeToString(data)})
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s's publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
var a seat.PublishPartAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return fmt.Errorf("%s's answer to publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
sent, err := parts.Send(ctx, open, chunk, ps)
|
||||
return Sent{Transfer: in.Transfer, Sent: sent}, err
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package gopackageregistryclient
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/gopackageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// The client publishes over its own seat's verbs alone (ADR 0627 §1): publish names every part, and only the part the
|
||||
// holder lacks travels by publish-part, its bytes whole, the last chunk marked.
|
||||
func TestPublishTalksToItsOwnSeat(t *testing.T) {
|
||||
held, lacked := []byte("held"), []byte("lacked")
|
||||
part := func(b []byte) parts.Part {
|
||||
sum := sha256.Sum256(b)
|
||||
return parts.Part{Digest: "sha256:" + hex.EncodeToString(sum[:]), Size: int64(len(b)),
|
||||
Open: func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(b)), nil }}
|
||||
}
|
||||
ps := []parts.Part{part(held), part(lacked)}
|
||||
var asked []string
|
||||
var got []byte
|
||||
call := func(key string, body any) (json.RawMessage, error) {
|
||||
asked = append(asked, key)
|
||||
raw, _ := json.Marshal(body)
|
||||
switch key {
|
||||
case "seat:go-package-registry.publish":
|
||||
var in seat.PublishInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
if len(in.Parts) != 2 {
|
||||
t.Errorf("publish names %d parts, want 2", len(in.Parts))
|
||||
}
|
||||
return json.Marshal(seat.PublishAnswer{Transfer: in.Transfer, Lacks: []string{ps[1].Digest}})
|
||||
case "seat:go-package-registry.publish-part":
|
||||
var in seat.PublishPartInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
data, _ := base64.StdEncoding.DecodeString(in.Data)
|
||||
if in.Part != ps[1].Digest || !in.Last || in.Transfer != "t1" {
|
||||
t.Errorf("publish-part %+v", in)
|
||||
}
|
||||
got = append(got, data...)
|
||||
return json.Marshal(seat.PublishPartAnswer{Transfer: in.Transfer, Part: in.Part})
|
||||
}
|
||||
t.Fatalf("asked %s", key)
|
||||
return nil, nil
|
||||
}
|
||||
sent, err := Publish(context.Background(), call, seat.PublishInput{Transfer: "t1", Name: "x"}, ps)
|
||||
if err != nil || sent.Transfer != "t1" || sent.Chunks != 1 || len(sent.Parts) != 1 || !bytes.Equal(got, lacked) || len(asked) != 2 {
|
||||
t.Errorf("sent %+v, %q arrived, asked %v, %v", sent, got, asked, err)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/gopackageregistryclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/gopackageregistry v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-delivery/sdk v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/klauspost/compress v1.20.1 // indirect
|
||||
github.com/nats-io/nats.go v1.54.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
@@ -1,53 +0,0 @@
|
||||
// Package meshbuildsclient is the mesh-builds seat's client (novox/hq ADR 0573 §1, ADR 0627 §1; design 47 G §586): the
|
||||
// registry holders' call of `reserved`, its input and each of its answers, written once. The call is the caller's own (a
|
||||
// bundle's stdio.Ask, a process's call of a seat verb), so the client holds no transport.
|
||||
package meshbuildsclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshbuilds"
|
||||
)
|
||||
|
||||
// Address is the seat verb asked, as a manifest's `invokes` names it.
|
||||
const Address = "seat:" + seat.Seat + "." + seat.VerbReserved
|
||||
|
||||
// Call asks one verb of the seat, `seat:<seat>.<verb>`, with a body, and answers its JSON.
|
||||
type Call func(address string, body any) (json.RawMessage, error)
|
||||
|
||||
// Refusal is the error answer of `reserved`: a name no entry carries, or a version neither reserved nor released, in the
|
||||
// builder's words.
|
||||
type Refusal struct{ Words string }
|
||||
|
||||
func (r Refusal) Error() string { return Address + ": " + r.Words }
|
||||
|
||||
// Reservation is a reserved or a released version with each artifact and its digest (design 47 G §679).
|
||||
type Reservation struct {
|
||||
Module string
|
||||
Version string
|
||||
Artifacts []seat.ReservedAnswerArtifactsItem
|
||||
// Released is true when the catalog holds the version released and Artifacts are the digests its release recorded.
|
||||
Released bool
|
||||
}
|
||||
|
||||
// Reserved asks the seat for a module's, or a package's, reserved version. It answers the reservation or release, a
|
||||
// Refusal for the answer `error`, and an error for an answer that cannot be read or lacks a module or a version without
|
||||
// saying error: an answer that cannot be read is never a yes.
|
||||
func Reserved(call Call, in seat.ReservedInput) (Reservation, error) {
|
||||
raw, err := call(Address, in)
|
||||
if err != nil {
|
||||
return Reservation{}, fmt.Errorf("%s did not answer: %w", Address, err)
|
||||
}
|
||||
var a seat.ReservedAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return Reservation{}, fmt.Errorf("%s answered what cannot be read: %s", Address, raw)
|
||||
}
|
||||
if a.Error != "" {
|
||||
return Reservation{}, Refusal{Words: a.Error}
|
||||
}
|
||||
if a.Module == "" || a.Version == "" {
|
||||
return Reservation{}, fmt.Errorf("%s answered no reservation: %s", Address, raw)
|
||||
}
|
||||
return Reservation{Module: a.Module, Version: a.Version, Artifacts: a.Artifacts, Released: a.Released}, nil
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package meshbuildsclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshbuilds"
|
||||
)
|
||||
|
||||
func answers(raw string, err error) Call {
|
||||
return func(address string, body any) (json.RawMessage, error) {
|
||||
if address != "seat:mesh-builds.reserved" {
|
||||
return nil, errors.New("asked " + address)
|
||||
}
|
||||
return json.RawMessage(raw), err
|
||||
}
|
||||
}
|
||||
|
||||
// TestReservedReadsEachAnswer is design 47 G §586's check: the client's input and each answer read (§679's three).
|
||||
func TestReservedReadsEachAnswer(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
call Call
|
||||
want Reservation
|
||||
refusal string
|
||||
failedOn string
|
||||
}{
|
||||
{name: "a reservation", call: answers(`{"module":"m","version":"0.1.2","artifacts":[{"artifact":"m:go-m","digest":"sha256:aa"}]}`, nil),
|
||||
want: Reservation{Module: "m", Version: "0.1.2", Artifacts: []seat.ReservedAnswerArtifactsItem{{Artifact: "m:go-m", Digest: "sha256:aa"}}}},
|
||||
{name: "a release", call: answers(`{"module":"m","version":"0.1.1","artifacts":[{"artifact":"m:go-m","digest":"sha256:bb"}],"released":true}`, nil),
|
||||
want: Reservation{Module: "m", Version: "0.1.1", Artifacts: []seat.ReservedAnswerArtifactsItem{{Artifact: "m:go-m", Digest: "sha256:bb"}}, Released: true}},
|
||||
{name: "an error alone", call: answers(`{"error":"no entry carries the name x"}`, nil), refusal: "no entry carries the name x"},
|
||||
{name: "no module and no error", call: answers(`{}`, nil), failedOn: "answered no reservation"},
|
||||
{name: "a call that fails", call: answers("", errors.New("no responders")), failedOn: "did not answer"},
|
||||
{name: "what cannot be read", call: answers(`[1]`, nil), failedOn: "cannot be read"},
|
||||
} {
|
||||
got, err := Reserved(tc.call, seat.ReservedInput{Name: "x", Version: "0.1.1"})
|
||||
var r Refusal
|
||||
switch {
|
||||
case tc.refusal != "":
|
||||
if !errors.As(err, &r) || r.Words != tc.refusal {
|
||||
t.Errorf("%s: %v, want a refusal %q", tc.name, err, tc.refusal)
|
||||
}
|
||||
case tc.failedOn != "":
|
||||
if err == nil || !strings.Contains(err.Error(), tc.failedOn) {
|
||||
t.Errorf("%s: %v, want an error saying %q", tc.name, err, tc.failedOn)
|
||||
}
|
||||
default:
|
||||
if err != nil || got.Module != tc.want.Module || got.Version != tc.want.Version || got.Released != tc.want.Released ||
|
||||
len(got.Artifacts) != 1 || got.Artifacts[0] != tc.want.Artifacts[0] {
|
||||
t.Errorf("%s: %+v %v, want %+v", tc.name, got, err, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshbuildsclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require git.novox.be/novox/mesh-delivery/contracts/go/seats/meshbuilds v0.0.0-00010101000000-000000000000
|
||||
@@ -1,424 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/sourcebranches"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// SourceVerb is the gate's verb a part reads the branches the gate keeps a source revision of by, before the first
|
||||
// registrations, as its manifest's invokes names it (design 47 G §614); the follower is the SDK's sourcebranches.
|
||||
const SourceVerb = sourcebranches.SourceVerb
|
||||
|
||||
// EntryVerb is the seat verb a part reads an entry by its fingerprint by, as its manifest's invokes names it.
|
||||
const EntryVerb = "seat:" + seat.Seat + "." + seat.VerbEntry
|
||||
|
||||
// Wiring is how Branches puts a view on its part's one reader and takes it off: ReaderWiring for a bundle's
|
||||
// views.Reader, ProcessWiring for a process's views.ProcessReader. Adopt is the reader's Adopt, so a view adopted after
|
||||
// the reader's Start takes its first view at once; Drop is its Drop, which clears every finding the view raised.
|
||||
type Wiring interface {
|
||||
Adopt(f *views.Follower, seat, event string, hear func(context.Context, []byte) error) error
|
||||
Drop(owner, state string) error
|
||||
}
|
||||
|
||||
type readerWiring struct{ r *views.Reader }
|
||||
|
||||
func (w readerWiring) Adopt(f *views.Follower, seat, event string, hear func(context.Context, []byte) error) error {
|
||||
return w.r.Adopt(f, seat, event, hear)
|
||||
}
|
||||
func (w readerWiring) Drop(owner, state string) error { return w.r.Drop(owner + "." + state) }
|
||||
|
||||
type processWiring struct{ r *views.ProcessReader }
|
||||
|
||||
func (w processWiring) Adopt(f *views.Follower, seat, event string, hear func(context.Context, []byte) error) error {
|
||||
_, err := w.r.Adopt(f, seat, event, hear)
|
||||
return err
|
||||
}
|
||||
func (w processWiring) Drop(owner, state string) error { return w.r.Drop(owner, state) }
|
||||
|
||||
// ReaderWiring wires Branches on a bundle's reader.
|
||||
func ReaderWiring(r *views.Reader) Wiring { return readerWiring{r} }
|
||||
|
||||
// Rows adds the list to the reader's `<module>_first_views`.
|
||||
func (w readerWiring) Rows(name string, rows func() any) { w.r.Rows(name, rows) }
|
||||
|
||||
// ProcessWiring wires Branches on a process's reader.
|
||||
func ProcessWiring(r *views.ProcessReader) Wiring { return processWiring{r} }
|
||||
|
||||
// Branches is the one branch follower of design 47 G §614, built once and used by every part that reads the catalog half:
|
||||
// it follows the watched branches of the registrations (the first view of `registrations` at the start, then each
|
||||
// `registration-changed`); before the first registration, the branches the gate's `source` answers (its first view at
|
||||
// the start, then each `source-moved`), which it stops following at the first `registration-changed`; it adopts a Catalog
|
||||
// view on the part's reader for each branch that comes and drops the view of each that goes, and keeps the entries by
|
||||
// fingerprint a part asks of the verb `entry` (Entries). The part declares what §614 says in `consumes` and `invokes`.
|
||||
type Branches struct {
|
||||
// Registrations is the follower of the registrations, also the part's own reading of them.
|
||||
Registrations *Registrations
|
||||
// Entries is the cache of the entries read by fingerprint.
|
||||
Entries *Entries
|
||||
// Changed, when not nil, is told of each change to a branch's view (module, its entry, deleted), set before Wire.
|
||||
Changed func(branch, module string, entry json.RawMessage, deleted bool, at time.Time)
|
||||
// Logf, when not nil, says each view adopted and dropped.
|
||||
Logf func(format string, args ...any)
|
||||
|
||||
call Call
|
||||
w Wiring
|
||||
|
||||
mu sync.Mutex
|
||||
source *sourcebranches.SourceBranches
|
||||
left []string // the source's branches when it was left, kept until the registrations hold one
|
||||
catalogs map[string]*Catalog
|
||||
order []string
|
||||
}
|
||||
|
||||
// NewBranches adopts the registrations and the gate's source on w, so the reader's Start asks them, and then adopts a
|
||||
// Catalog per branch as the picture says. call asks the seat verbs.
|
||||
func NewBranches(w Wiring, call Call) (*Branches, error) {
|
||||
b := &Branches{call: call, w: w, catalogs: map[string]*Catalog{}, Entries: NewEntries(call)}
|
||||
b.Registrations = NewRegistrations(call)
|
||||
b.Registrations.Follower.Changed = func(string, json.RawMessage, bool, time.Time) { b.reconcile() }
|
||||
b.source = sourcebranches.New(sourcebranches.Call(call))
|
||||
b.source.Follower.Changed = func(string, json.RawMessage, bool, time.Time) { b.reconcile() }
|
||||
if err := w.Adopt(b.Registrations.Follower, seat.Seat, seat.EventRegistrationChanged, b.hearRegistration); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := w.Adopt(b.source.Follower, sourcebranches.Seat, sourcebranches.EventSourceMoved, b.source.Hear); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if rw, ok := w.(interface {
|
||||
Rows(name string, rows func() any)
|
||||
}); ok { // the entries by fingerprint are said in the part's `<module>_first_views` (design 47 G A-103)
|
||||
rw.Rows("entries", func() any { return b.EntryStatuses() })
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// FollowBranches is NewBranches on a bundle's reader.
|
||||
func FollowBranches(r *views.Reader, call Call) (*Branches, error) {
|
||||
return NewBranches(ReaderWiring(r), call)
|
||||
}
|
||||
|
||||
// FollowBranchesProcess is NewBranches on a process's reader.
|
||||
func FollowBranchesProcess(r *views.ProcessReader, call Call) (*Branches, error) {
|
||||
return NewBranches(ProcessWiring(r), call)
|
||||
}
|
||||
|
||||
func (b *Branches) logf(format string, args ...any) {
|
||||
if b.Logf != nil {
|
||||
b.Logf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// hearRegistration is the handler of `registration-changed`: the first one ends the following of the gate's source.
|
||||
func (b *Branches) hearRegistration(ctx context.Context, data []byte) error {
|
||||
err := b.Registrations.Hear(ctx, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.mu.Lock()
|
||||
s := b.source
|
||||
if s != nil {
|
||||
b.left, b.source = s.Branches(), nil
|
||||
}
|
||||
b.mu.Unlock()
|
||||
if s != nil {
|
||||
if err := b.w.Drop(sourcebranches.Seat, sourcebranches.StateSourceBranches); err != nil {
|
||||
b.logf("meshcatalogclient: the gate's source is not dropped: %v", err)
|
||||
} else {
|
||||
b.logf("meshcatalogclient: the first registration-changed is heard: the gate's source is followed no more")
|
||||
}
|
||||
b.reconcile()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Followed is the branches (as named) whose views are adopted, in the order they came.
|
||||
func (b *Branches) Followed() []string {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
out := make([]string, 0, len(b.order))
|
||||
for _, e := range b.order {
|
||||
out = append(out, b.catalogs[e].Branch)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Catalog is the view of one branch, as named; false when it is not followed.
|
||||
func (b *Branches) Catalog(branch string) (*Catalog, bool) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
c, ok := b.catalogs[keys.EscapeName(branch)]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
// Resolve reads an entry by its fingerprint: from a branch's held half when one lists it, else from the entries kept
|
||||
// by fingerprint, asked of `entry` once when none is kept. The state is `answered` for an entry at hand, `asked` while the
|
||||
// ask is out, `not-found` once the holder said it holds none.
|
||||
func (b *Branches) Resolve(ctx context.Context, fingerprint string) (seat.CatalogEntry, EntryState) {
|
||||
b.mu.Lock()
|
||||
cs := make([]*Catalog, 0, len(b.order))
|
||||
for _, e := range b.order {
|
||||
cs = append(cs, b.catalogs[e])
|
||||
}
|
||||
b.mu.Unlock()
|
||||
for _, c := range cs {
|
||||
if half, ok := c.View(); ok {
|
||||
for _, e := range half.Entries {
|
||||
if e.Fp == fingerprint {
|
||||
return e, EntryAnswered
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return b.Entries.Need(ctx, fingerprint)
|
||||
}
|
||||
|
||||
// Listed says whether a branch's held half lists fingerprint.
|
||||
func (b *Branches) Listed(fingerprint string) bool {
|
||||
b.mu.Lock()
|
||||
cs := make([]*Catalog, 0, len(b.order))
|
||||
for _, e := range b.order {
|
||||
cs = append(cs, b.catalogs[e])
|
||||
}
|
||||
b.mu.Unlock()
|
||||
for _, c := range cs {
|
||||
if half, ok := c.View(); ok {
|
||||
for _, e := range half.Entries {
|
||||
if e.Fp == fingerprint {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// reconcile adopts the view of each branch that is wanted and drops the view of each that is not: the registrations'
|
||||
// branches, and the gate's source's while it is followed (and, once left, until the registrations hold a branch).
|
||||
func (b *Branches) reconcile() {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
want := map[string]string{} // escaped -> as named
|
||||
for _, reg := range b.Registrations.All() {
|
||||
for _, br := range reg.Branches {
|
||||
want[keys.EscapeName(br)] = br
|
||||
}
|
||||
}
|
||||
var from []string
|
||||
switch {
|
||||
case b.source != nil:
|
||||
from = b.source.Branches()
|
||||
case len(want) == 0:
|
||||
from = b.left
|
||||
default:
|
||||
b.left = nil
|
||||
}
|
||||
for _, e := range from {
|
||||
if name, err := keys.UnescapeName(e); err == nil {
|
||||
want[e] = name
|
||||
}
|
||||
}
|
||||
for _, e := range slices.Sorted(mapsKeys(want)) {
|
||||
if b.catalogs[e] != nil {
|
||||
continue
|
||||
}
|
||||
c, err := NewCatalog(b.call, want[e])
|
||||
if err != nil {
|
||||
b.logf("meshcatalogclient: the branch %q is not followed: %v", want[e], err)
|
||||
continue
|
||||
}
|
||||
branch := want[e]
|
||||
c.Follower.Changed = func(module string, entry json.RawMessage, deleted bool, at time.Time) {
|
||||
if b.Changed != nil {
|
||||
b.Changed(branch, module, entry, deleted, at)
|
||||
}
|
||||
}
|
||||
if err := b.w.Adopt(c.Follower, seat.Seat, seat.EventCatalogRevision, c.Hear); err != nil {
|
||||
b.logf("meshcatalogclient: the view of the branch %q is not adopted: %v", want[e], err)
|
||||
continue
|
||||
}
|
||||
b.catalogs[e] = c
|
||||
b.order = append(b.order, e)
|
||||
b.logf("meshcatalogclient: the branch %q is followed", want[e])
|
||||
}
|
||||
for _, e := range slices.Clone(b.order) {
|
||||
if _, ok := want[e]; ok {
|
||||
continue
|
||||
}
|
||||
c := b.catalogs[e]
|
||||
if err := b.w.Drop(seat.Seat, c.Follower.State); err != nil {
|
||||
b.logf("meshcatalogclient: the view of the branch %q is not dropped: %v", c.Branch, err)
|
||||
}
|
||||
delete(b.catalogs, e)
|
||||
b.order = slices.DeleteFunc(b.order, func(o string) bool { return o == e })
|
||||
b.logf("meshcatalogclient: the branch %q is followed no more", c.Branch)
|
||||
}
|
||||
}
|
||||
|
||||
func mapsKeys(m map[string]string) func(func(string) bool) {
|
||||
return func(yield func(string) bool) {
|
||||
for k := range m {
|
||||
if !yield(k) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EntryState is where an entry read by fingerprint stands.
|
||||
type EntryState string
|
||||
|
||||
// The states of an entry kept by fingerprint (design 47 G §614, An older build's entry).
|
||||
const (
|
||||
EntryAsked EntryState = "asked"
|
||||
EntryAnswered EntryState = "answered"
|
||||
EntryNotFound EntryState = "not-found"
|
||||
)
|
||||
|
||||
// EntryRow is one entry kept by fingerprint: its state, since when, and the entry once answered.
|
||||
type EntryRow struct {
|
||||
Fingerprint string
|
||||
State EntryState
|
||||
Since time.Time
|
||||
// Detail says why an ask is still out when its last try failed.
|
||||
Detail string
|
||||
Entry *seat.CatalogEntry
|
||||
}
|
||||
|
||||
// Entries keeps, beside a part's views, the entries by fingerprint it asked of `entry` (design 47 G §614): each is
|
||||
// asked, answered or not found. The reader a part passes to a pure function answers from the views and these alone.
|
||||
type Entries struct {
|
||||
// Changed, when not nil, is told of each entry that was answered or found missing, so the part starts a new pass at
|
||||
// once, or writes the finding `entry-not-found`.
|
||||
Changed func(row EntryRow)
|
||||
// Released, when not nil, is told of each entry removed by Release.
|
||||
Released func(fingerprint string)
|
||||
// Now is the clock, time.Now when nil.
|
||||
Now func() time.Time
|
||||
|
||||
call Call
|
||||
mu sync.Mutex
|
||||
rows map[string]*EntryRow
|
||||
}
|
||||
|
||||
// NewEntries is an Entries asking the seat through call.
|
||||
func NewEntries(call Call) *Entries { return &Entries{call: call, rows: map[string]*EntryRow{}} }
|
||||
|
||||
func (e *Entries) now() time.Time {
|
||||
if e.Now != nil {
|
||||
return e.Now()
|
||||
}
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
// Need reads fingerprint's entry: one kept is answered as it stands (`asked` as pending, a state apart from none); one
|
||||
// not kept is asked of `entry` once, on its own goroutine, and answered as `asked`.
|
||||
func (e *Entries) Need(ctx context.Context, fingerprint string) (seat.CatalogEntry, EntryState) {
|
||||
e.mu.Lock()
|
||||
row := e.rows[fingerprint]
|
||||
if row == nil {
|
||||
row = &EntryRow{Fingerprint: fingerprint, State: EntryAsked, Since: e.now()}
|
||||
e.rows[fingerprint] = row
|
||||
e.mu.Unlock()
|
||||
go e.ask(ctx, fingerprint)
|
||||
return seat.CatalogEntry{}, EntryAsked
|
||||
}
|
||||
defer e.mu.Unlock()
|
||||
if row.Entry != nil {
|
||||
return *row.Entry, row.State
|
||||
}
|
||||
return seat.CatalogEntry{}, row.State
|
||||
}
|
||||
|
||||
// Again asks fingerprint's entry now, whatever its state (the part's tool `<module>_entry_again`). It waits for the answer.
|
||||
func (e *Entries) Again(ctx context.Context, fingerprint string) error {
|
||||
e.mu.Lock()
|
||||
row := e.rows[fingerprint]
|
||||
if row == nil {
|
||||
e.mu.Unlock()
|
||||
return fmt.Errorf("meshcatalogclient: no entry of %s is kept", fingerprint)
|
||||
}
|
||||
*row = EntryRow{Fingerprint: fingerprint, State: EntryAsked, Since: e.now()}
|
||||
e.mu.Unlock()
|
||||
e.ask(ctx, fingerprint)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Release removes fingerprint's entry: no `running` or `wanted` the part holds names it any more.
|
||||
func (e *Entries) Release(fingerprint string) {
|
||||
e.mu.Lock()
|
||||
delete(e.rows, fingerprint)
|
||||
e.mu.Unlock()
|
||||
if e.Released != nil {
|
||||
e.Released(fingerprint)
|
||||
}
|
||||
}
|
||||
|
||||
// Rows lists the entries kept, by fingerprint (the part's tool `<module>_first_views` lists them with their state and
|
||||
// since when).
|
||||
func (e *Entries) Rows() []EntryRow {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
out := make([]EntryRow, 0, len(e.rows))
|
||||
for _, r := range e.rows {
|
||||
out = append(out, *r)
|
||||
}
|
||||
slices.SortFunc(out, func(a, b EntryRow) int {
|
||||
switch {
|
||||
case a.Fingerprint < b.Fingerprint:
|
||||
return -1
|
||||
case a.Fingerprint > b.Fingerprint:
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
// ask reads fingerprint's entry once. A call that failed to reach the holder leaves the entry asked, with its reason;
|
||||
// the holder's own answer that it holds none is `not-found`.
|
||||
func (e *Entries) ask(_ context.Context, fingerprint string) {
|
||||
raw, err := e.call(EntryVerb, seat.EntryInput{Fingerprint: fingerprint})
|
||||
var row EntryRow
|
||||
e.mu.Lock()
|
||||
cur := e.rows[fingerprint]
|
||||
if cur == nil {
|
||||
e.mu.Unlock()
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case err != nil:
|
||||
cur.Detail = err.Error()
|
||||
e.mu.Unlock()
|
||||
return
|
||||
default:
|
||||
answer, said, ok := buscalls.Unwrap(raw)
|
||||
var a seat.EntryAnswer
|
||||
switch {
|
||||
case !ok:
|
||||
cur.State, cur.Since, cur.Detail = EntryNotFound, e.now(), said
|
||||
case json.Unmarshal(answer, &a) != nil || a.Entry.Module == "":
|
||||
cur.Detail = errors.New("answered no entry: " + clipBytes(answer)).Error()
|
||||
e.mu.Unlock()
|
||||
return
|
||||
default:
|
||||
entry := a.Entry
|
||||
cur.State, cur.Since, cur.Detail, cur.Entry = EntryAnswered, e.now(), "", &entry
|
||||
}
|
||||
}
|
||||
row = *cur
|
||||
e.mu.Unlock()
|
||||
if e.Changed != nil {
|
||||
e.Changed(row)
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/sourcebranches"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// fakeWiring is a part's reader: it keeps the views adopted, by `<owner>.<state>`, and says each drop.
|
||||
type fakeWiring struct {
|
||||
mu sync.Mutex
|
||||
adopted map[string]*views.Follower
|
||||
hears map[string]func(context.Context, []byte) error
|
||||
dropped []string
|
||||
}
|
||||
|
||||
func (w *fakeWiring) Adopt(f *views.Follower, _, _ string, hear func(context.Context, []byte) error) error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
name := f.Owner + "." + f.State
|
||||
if w.adopted[name] != nil {
|
||||
return fmt.Errorf("%s is followed already", name)
|
||||
}
|
||||
w.adopted[name], w.hears[name] = f, hear
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *fakeWiring) Drop(owner, state string) error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
name := owner + "." + state
|
||||
if w.adopted[name] == nil {
|
||||
return fmt.Errorf("%s is not followed", name)
|
||||
}
|
||||
delete(w.adopted, name)
|
||||
delete(w.hears, name)
|
||||
w.dropped = append(w.dropped, name)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *fakeWiring) names() []string {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
out := []string{}
|
||||
for n := range w.adopted {
|
||||
out = append(out, n)
|
||||
}
|
||||
slices.Sort(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (w *fakeWiring) get(name string) (*views.Follower, func(context.Context, []byte) error) {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
return w.adopted[name], w.hears[name]
|
||||
}
|
||||
|
||||
// fakeSeats answers source, registrations, revision and entry from what it is told.
|
||||
type fakeSeats struct {
|
||||
mu sync.Mutex
|
||||
source []string
|
||||
regs map[string][]string // module -> branches
|
||||
version int64
|
||||
entries map[string]seat.CatalogEntry
|
||||
entryAsk int
|
||||
}
|
||||
|
||||
func (f *fakeSeats) call(key string, body any) (json.RawMessage, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
switch key {
|
||||
case sourcebranches.SourceVerb:
|
||||
return json.Marshal(map[string][]string{"branches": f.source})
|
||||
case RegistrationsVerb:
|
||||
a := seat.RegistrationsAnswer{Registrations: []seat.Registration{}}
|
||||
for m, br := range f.regs {
|
||||
a.Registrations = append(a.Registrations, seat.Registration{Module: m, Version: f.version, Branches: br})
|
||||
}
|
||||
return json.Marshal(a)
|
||||
case RevisionVerb:
|
||||
return json.Marshal(seat.RevisionAnswer{NoneYet: true})
|
||||
case EntryVerb:
|
||||
f.entryAsk++
|
||||
e, ok := f.entries[body.(seat.EntryInput).Fingerprint]
|
||||
if !ok {
|
||||
return json.RawMessage(`{"error":"no such entry"}`), nil
|
||||
}
|
||||
return json.Marshal(seat.EntryAnswer{Entry: e})
|
||||
}
|
||||
return nil, fmt.Errorf("asked %s", key)
|
||||
}
|
||||
|
||||
// CT16 (design 47 G §614, A-5): the branch follower follows the gate's source branches (read at the start, then
|
||||
// source-moved) before the first registration-changed, adopts a view per branch and drops the view of a branch that goes:
|
||||
// the first registration-changed ends the gate's source, and the registrations' branches are the views then.
|
||||
func TestBranchesFollowSourceThenRegistrations(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
said := make(chan string, 64)
|
||||
waitFor := func(part string) {
|
||||
t.Helper()
|
||||
for {
|
||||
select {
|
||||
case s := <-said:
|
||||
if strings.Contains(s, part) {
|
||||
return
|
||||
}
|
||||
case <-ctx.Done():
|
||||
t.Fatalf("never said %q", part)
|
||||
}
|
||||
}
|
||||
}
|
||||
seats := &fakeSeats{source: []string{"main"}, regs: map[string][]string{}, version: 1}
|
||||
w := &fakeWiring{adopted: map[string]*views.Follower{}, hears: map[string]func(context.Context, []byte) error{}}
|
||||
b, err := NewBranches(w, seats.call)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b.Logf = func(format string, args ...any) { said <- fmt.Sprintf(format, args...) }
|
||||
want := func(names ...string) {
|
||||
t.Helper()
|
||||
if got := w.names(); !slices.Equal(got, names) {
|
||||
t.Fatalf("views = %v, want %v", got, names)
|
||||
}
|
||||
}
|
||||
want("mesh-catalog.registrations", "mesh-delivery.source")
|
||||
|
||||
// before the first registration: the gate's source says main, and source-moved brings feat/x
|
||||
src, hearSource := w.get("mesh-delivery.source")
|
||||
if err := src.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want("mesh-catalog.catalog-revisions.main", "mesh-catalog.registrations", "mesh-delivery.source")
|
||||
seats.mu.Lock()
|
||||
seats.source = []string{"main", "feat/x"}
|
||||
seats.mu.Unlock()
|
||||
src.Wait = time.Nanosecond
|
||||
if err := hearSource(ctx, []byte(`{"branch":"feat/x","revision":4}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitFor(`"feat/x" is followed`)
|
||||
if got := b.Followed(); !slices.Equal(got, []string{"main", "feat/x"}) {
|
||||
t.Fatalf("followed = %v", got)
|
||||
}
|
||||
|
||||
// the registrations hold one branch, and the first registration-changed ends the source
|
||||
seats.mu.Lock()
|
||||
seats.regs["nats"] = []string{"main"}
|
||||
seats.version = 2
|
||||
seats.mu.Unlock()
|
||||
reg, hearReg := w.get("mesh-catalog.registrations")
|
||||
if err := reg.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := hearReg(ctx, []byte(`{"module":"nats","version":2,"moved":["branches"],"warrant":"a"}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitFor(`"feat/x" is followed no more`)
|
||||
want("mesh-catalog.catalog-revisions.main", "mesh-catalog.registrations")
|
||||
if !slices.Contains(w.dropped, "mesh-delivery.source") {
|
||||
t.Fatalf("the source is still followed: dropped %v", w.dropped)
|
||||
}
|
||||
|
||||
// a branch the registrations add is adopted, one they remove is dropped
|
||||
seats.mu.Lock()
|
||||
seats.regs["nats"] = []string{"dev"}
|
||||
seats.version = 3
|
||||
seats.mu.Unlock()
|
||||
if err := hearReg(ctx, []byte(`{"module":"nats","version":3,"moved":["branches"],"warrant":"b"}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitFor(`"main" is followed no more`)
|
||||
want("mesh-catalog.catalog-revisions.dev", "mesh-catalog.registrations")
|
||||
}
|
||||
|
||||
// CT17 (design 47 G §614, An older build's entry): an entry no branch lists is asked of `entry` once and read as asked,
|
||||
// then answered (the part is told, to start a pass); one the holder does not hold is not-found; a released one is
|
||||
// asked again when next needed.
|
||||
func TestEntriesAreAskedOnceAnsweredOrNotFound(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
seats := &fakeSeats{entries: map[string]seat.CatalogEntry{"src2:a": {Module: "m", Fp: "src2:a"}}}
|
||||
e := NewEntries(seats.call)
|
||||
told := make(chan EntryRow, 4)
|
||||
e.Changed = func(r EntryRow) { told <- r }
|
||||
|
||||
if _, st := e.Need(ctx, "src2:a"); st != EntryAsked {
|
||||
t.Fatalf("state = %s, want asked", st)
|
||||
}
|
||||
if _, st := e.Need(ctx, "src2:a"); st != EntryAsked && st != EntryAnswered {
|
||||
t.Fatalf("state = %s", st)
|
||||
}
|
||||
if r := <-told; r.State != EntryAnswered || r.Entry == nil || r.Entry.Module != "m" {
|
||||
t.Fatalf("told %+v", r)
|
||||
}
|
||||
if got, st := e.Need(ctx, "src2:a"); st != EntryAnswered || got.Module != "m" {
|
||||
t.Fatalf("kept entry = %s %s", st, got.Module)
|
||||
}
|
||||
if seats.entryAsk != 1 {
|
||||
t.Fatalf("entry asked %d times, want once", seats.entryAsk)
|
||||
}
|
||||
e.Need(ctx, "src2:none")
|
||||
if r := <-told; r.State != EntryNotFound || r.Fingerprint != "src2:none" || r.Detail == "" {
|
||||
t.Fatalf("told %+v", r)
|
||||
}
|
||||
if rows := e.Rows(); len(rows) != 2 || rows[1].State != EntryNotFound {
|
||||
t.Fatalf("rows %+v", rows)
|
||||
}
|
||||
e.Release("src2:none")
|
||||
if rows := e.Rows(); len(rows) != 1 {
|
||||
t.Fatalf("rows after release %+v", rows)
|
||||
}
|
||||
if err := e.Again(ctx, "src2:a"); err != nil || seats.entryAsk != 3 {
|
||||
t.Fatalf("again: %v, asks %d", err, seats.entryAsk)
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// FingerprintSet is the `fpset` of a candidate's pull requests: the first 12 hex digits of the sha256 over the lines
|
||||
// `<module>=<fp2>` or `<module>=none:<reason>` of every module with an entry in a pull's fps, sorted and joined by a newline,
|
||||
// so it is the same for every order and changes with any fingerprint or reason. A manifest digest does not enter: the
|
||||
// fingerprint already covers the manifest. It is the empty string when no pull request carries a fingerprint. The checker
|
||||
// keys its verdict by it.
|
||||
func FingerprintSet(pulls []seat.CandidatesByGroupValuePullsItem) string {
|
||||
lines := map[string]bool{}
|
||||
for _, p := range pulls {
|
||||
for module, m := range p.Fps {
|
||||
if m.Fp2 != "" {
|
||||
lines[module+"="+m.Fp2] = true
|
||||
} else {
|
||||
lines[module+"=none:"+m.None2] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(lines) == 0 {
|
||||
return ""
|
||||
}
|
||||
all := make([]string, 0, len(lines))
|
||||
for l := range lines {
|
||||
all = append(all, l)
|
||||
}
|
||||
sort.Strings(all)
|
||||
sum := sha256.Sum256([]byte(strings.Join(all, "\n")))
|
||||
return hex.EncodeToString(sum[:])[:12]
|
||||
}
|
||||
|
||||
// CandidatesKey is the key, in the state candidates, of a group: `<group>` escaped (keys.EscapeName), the branch name the
|
||||
// group's pull requests share (a slash is allowed); a lone pull request is a group of one under its branch name.
|
||||
func CandidatesKey(group string) (string, error) {
|
||||
if group == "" {
|
||||
return "", fmt.Errorf("meshcatalogclient: the group name is empty")
|
||||
}
|
||||
return seat.CandidatesByGroupKey(keys.EscapeName(group)), nil
|
||||
}
|
||||
|
||||
// ParseCandidatesKey is the inverse of CandidatesKey.
|
||||
func ParseCandidatesKey(key string) (string, error) {
|
||||
part, ok := seat.ParseCandidatesByGroupKey(key)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("meshcatalogclient: %q is not a candidates key", key)
|
||||
}
|
||||
group, err := keys.UnescapeName(part)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("meshcatalogclient: %q is not a candidates key: %w", key, err)
|
||||
}
|
||||
return group, nil
|
||||
}
|
||||
|
||||
var tryGroupOK = regexp.MustCompile(`^try-[0-9]{1,20}$`)
|
||||
|
||||
// IsTryGroup says a candidates key is the group of a whole try, try-<digits>, which is also the try's id: the indexer makes the
|
||||
// candidate of a try's group from its previews, and the checker judges it by its try, never as a pull request's check.
|
||||
func IsTryGroup(key string) bool { return tryGroupOK.MatchString(key) }
|
||||
|
||||
// NoneNoPreview is why a candidate's touched module has no fingerprint of the new form yet: its merge preview is not
|
||||
// computed. The indexer writes it; a reader that waits for a try's candidate takes one that still says it as not yet the
|
||||
// candidate of the heads previewed.
|
||||
const NoneNoPreview = "no merge preview is computed"
|
||||
@@ -1,242 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// RevisionVerb is the seat verb a part takes its first view of the catalog half by, as its manifest's invokes names it.
|
||||
const RevisionVerb = "seat:" + seat.Seat + "." + seat.VerbRevision
|
||||
|
||||
// The kinds a catalog graph revision is of.
|
||||
const (
|
||||
KindTrunk = "trunk"
|
||||
KindCandidate = "candidate"
|
||||
)
|
||||
|
||||
// Half is one catalog graph revision whole: the revision with its entries by module.
|
||||
type Half struct {
|
||||
Revision seat.CatalogRevision
|
||||
Entries map[string]seat.CatalogEntry
|
||||
}
|
||||
|
||||
// ViewName is how the catalog half's revision is named in a part's first-view status (views.Status.View, WaitsFor).
|
||||
func ViewName(revision int64) string { return strconv.FormatInt(revision, 10) }
|
||||
|
||||
// catalogCreated stands for the view's Created in its follower: a revision view is never made again, so one fixed time,
|
||||
// never zero, lets the follower tell a revision heard from one it holds.
|
||||
var catalogCreated = time.Unix(0, 0).UTC()
|
||||
|
||||
// Catalog is a part's view of the catalog half of one watched branch (design 47 G §358, §479): a first view of the
|
||||
// branch's newest trunk revision asked of the seat's verb `revision`, then kept from its event `catalog-revision` of that
|
||||
// branch, built on go/views' Follower, so the runtime's tools `<module>_first_views` and `<module>_first_view_again` read
|
||||
// and steer it as every first view. The view is named `mesh-catalog.catalog-revisions.<branch>`, so a part that watches two
|
||||
// branches makes two Catalogs, two views. A `catalog-revision` the view missed (a revision heard that it does not hold)
|
||||
// asks `revision` once more, said in the log (§196, ADR 0615 §5), and is waited for, said in the status and past
|
||||
// views.WaitsBound raised as view-waits.
|
||||
type Catalog struct {
|
||||
Follower *views.Follower
|
||||
// Branch is the watched branch the view is of, as the caller names it.
|
||||
Branch string
|
||||
|
||||
call Call
|
||||
mu sync.Mutex
|
||||
// held is the half the view holds; paging the one being read, page by page, of one revision.
|
||||
held *Half
|
||||
paging *Half
|
||||
// waits is the revision waited for, 0 when none.
|
||||
waits int64
|
||||
}
|
||||
|
||||
// NewCatalog is a Catalog of branch asking the seat through call. Nothing is asked before Start.
|
||||
func NewCatalog(call Call, branch string) (*Catalog, error) {
|
||||
if err := keys.CheckName("branch", branch); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &Catalog{call: call, Branch: branch}
|
||||
c.Follower = &views.Follower{Owner: seat.Seat, Tool: RevisionVerb, State: views.BranchState(seat.StateCatalogRevisions, branch), Ask: c.ask}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// WireCatalog is a Catalog of branch adopted by a stdio part's views.Reader: the reader writes its conditions and its
|
||||
// view-waits finding, reads it as `mesh-catalog.catalog-revisions.<branch>` (a key a module, its value the module's
|
||||
// entry), lists and asks it again in its first-view tools, and at its Start subscribes the seat's event catalog-revision
|
||||
// (the part's manifest consumes it) into Hear and asks the first view. changed, when not nil, is the Follower's Changed.
|
||||
// The part declares the seat's verb revision in invokes. Call it once per watched branch.
|
||||
func WireCatalog(r *views.Reader, call Call, branch string, changed func(module string, entry json.RawMessage, deleted bool, at time.Time)) (*Catalog, error) {
|
||||
c, err := NewCatalog(call, branch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.Follower.Changed = changed
|
||||
if err := r.Adopt(c.Follower, seat.Seat, seat.EventCatalogRevision, c.Hear); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// WireCatalogProcess is WireCatalog for a process's views.ProcessReader: its picture
|
||||
// (`mesh-catalog_catalog-revisions.<branch>`) reads the half as a read-only bucket, and the seat's event catalog-revision
|
||||
// on the module's durable consumer goes to Hear.
|
||||
func WireCatalogProcess(r *views.ProcessReader, call Call, branch string, changed func(module string, entry json.RawMessage, deleted bool, at time.Time)) (*Catalog, *views.Picture, error) {
|
||||
c, err := NewCatalog(call, branch)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
c.Follower.Changed = changed
|
||||
p, err := r.Adopt(c.Follower, seat.Seat, seat.EventCatalogRevision, c.Hear)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return c, p, nil
|
||||
}
|
||||
|
||||
// Start asks the first view, the branch's newest trunk revision, until it is answered or ctx ends.
|
||||
func (c *Catalog) Start(ctx context.Context) error { return c.Follower.Start(ctx) }
|
||||
|
||||
// Ready is closed once the first view is answered.
|
||||
func (c *Catalog) Ready() <-chan struct{} { return c.Follower.Ready() }
|
||||
|
||||
// View is the half the view holds; false while it has none, when the part acts on nothing new.
|
||||
func (c *Catalog) View() (Half, bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.held == nil {
|
||||
return Half{}, false
|
||||
}
|
||||
return Half{Revision: c.held.Revision, Entries: maps.Clone(c.held.Entries)}, true
|
||||
}
|
||||
|
||||
// Entry is one module's entry in the half the view holds.
|
||||
func (c *Catalog) Entry(module string) (seat.CatalogEntry, bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.held == nil {
|
||||
return seat.CatalogEntry{}, false
|
||||
}
|
||||
e, ok := c.held.Entries[module]
|
||||
return e, ok
|
||||
}
|
||||
|
||||
// Hear takes one `catalog-revision` event, as the part's durable consumer of the seat's events hands it. A candidate's
|
||||
// revision and another branch's move nothing here; a trunk revision of this branch the view holds, or one older, is passed
|
||||
// over; a newer one is a revision the view missed: waited for, said in the log, and asked again on its own goroutine, so
|
||||
// the consumer is never held while the holder is away. Data that is no such event is an error.
|
||||
func (c *Catalog) Hear(ctx context.Context, data []byte) error {
|
||||
var ev seat.CatalogRevisionEvent
|
||||
if err := json.Unmarshal(data, &ev); err != nil || ev.Revision <= 0 {
|
||||
return fmt.Errorf("meshcatalogclient: not a %s event: %s", seat.EventCatalogRevision, clipBytes(data))
|
||||
}
|
||||
if ev.Kind != KindTrunk || ev.Branch != keys.EscapeName(c.Branch) {
|
||||
return nil
|
||||
}
|
||||
c.mu.Lock()
|
||||
held := int64(0)
|
||||
if c.held != nil {
|
||||
held = c.held.Revision.Revision
|
||||
}
|
||||
if ev.Revision > c.waits {
|
||||
c.waits = ev.Revision
|
||||
}
|
||||
c.mu.Unlock()
|
||||
if ev.Revision <= held {
|
||||
return nil
|
||||
}
|
||||
// The follower keeps the newest revision heard, so an ask that was running when it was heard is asked once more.
|
||||
c.Follower.Apply(views.Event{Owner: seat.Seat, State: c.Follower.State, Revision: uint64(ev.Revision), Created: catalogCreated, Gap: true})
|
||||
c.Follower.WaitFor(ctx, ViewName(ev.Revision))
|
||||
if c.Follower.Logf != nil {
|
||||
c.Follower.Logf("meshcatalogclient: catalog revision %d of %s said, the view holds %d: %s is asked once more", ev.Revision, c.Branch, held, RevisionVerb)
|
||||
}
|
||||
go func() {
|
||||
_ = c.Follower.Gap(ctx, fmt.Sprintf("catalog revision %d of %s said, the view holds %d", ev.Revision, c.Branch, held))
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
// ask is the Follower's Ask: one page of the branch's newest trunk revision, the next pages of the same revision; once
|
||||
// whole, it is the half the view holds.
|
||||
func (c *Catalog) ask(_ context.Context, after string) (views.Answer, error) {
|
||||
in := seat.RevisionInput{After: after, Branch: keys.EscapeName(c.Branch)}
|
||||
c.mu.Lock()
|
||||
if after != "" && c.paging != nil {
|
||||
in.Revision = c.paging.Revision.Revision
|
||||
}
|
||||
c.mu.Unlock()
|
||||
a, err := askRevision(c.call, in)
|
||||
if errors.Is(err, errNoneYet) {
|
||||
// A branch with no revision yet is ready and empty, and nothing waits for it (§479, §495).
|
||||
return views.Answer{V: 1, Owner: seat.Seat, State: c.Follower.State, Created: catalogCreated, Values: map[string]json.RawMessage{}, At: time.Now()}, nil
|
||||
}
|
||||
if err != nil {
|
||||
return views.Answer{}, err
|
||||
}
|
||||
if a.Revision.Kind != KindTrunk {
|
||||
return views.Answer{}, fmt.Errorf("%s answered a %s revision for the trunk", RevisionVerb, a.Revision.Kind)
|
||||
}
|
||||
c.mu.Lock()
|
||||
if after == "" || c.paging == nil {
|
||||
c.paging = &Half{Revision: *a.Revision, Entries: map[string]seat.CatalogEntry{}}
|
||||
} else if c.paging.Revision.Revision != a.Revision.Revision {
|
||||
was := c.paging.Revision.Revision
|
||||
c.paging = nil
|
||||
c.mu.Unlock()
|
||||
return views.Answer{}, fmt.Errorf("%s answered revision %d for a page of revision %d", RevisionVerb, a.Revision.Revision, was)
|
||||
}
|
||||
values := map[string]json.RawMessage{}
|
||||
for _, e := range a.Entries {
|
||||
c.paging.Entries[e.Module] = e
|
||||
raw, _ := json.Marshal(e)
|
||||
values[e.Module] = raw
|
||||
}
|
||||
rev := a.Revision.Revision
|
||||
holds := false
|
||||
if a.Next == "" {
|
||||
c.held, c.paging = c.paging, nil
|
||||
if c.waits <= rev {
|
||||
c.waits, holds = 0, true
|
||||
}
|
||||
}
|
||||
c.mu.Unlock()
|
||||
if holds {
|
||||
c.Follower.Holds(ViewName(rev))
|
||||
}
|
||||
return views.Answer{V: 1, Owner: seat.Seat, State: c.Follower.State, Revision: uint64(rev), Created: catalogCreated, Values: values, Next: a.Next, At: time.Now()}, nil
|
||||
}
|
||||
|
||||
// errNoneYet is the seat's answer `none-yet`: the branch has no revision yet (design 47 G §530).
|
||||
var errNoneYet = errors.New("none yet")
|
||||
|
||||
func askRevision(call Call, in seat.RevisionInput) (seat.RevisionAnswer, error) {
|
||||
raw, err := call(RevisionVerb, in)
|
||||
if err != nil {
|
||||
return seat.RevisionAnswer{}, err
|
||||
}
|
||||
answer, said, ok := buscalls.Unwrap(raw)
|
||||
if !ok {
|
||||
return seat.RevisionAnswer{}, fmt.Errorf("%s answered: %s", RevisionVerb, said)
|
||||
}
|
||||
var a seat.RevisionAnswer
|
||||
if err := json.Unmarshal(answer, &a); err != nil {
|
||||
return seat.RevisionAnswer{}, fmt.Errorf("%s answered no revision: %s", RevisionVerb, clipBytes(answer))
|
||||
}
|
||||
// An answer is told by its fields, never by its words (§530): `none-yet` is a ready, empty view.
|
||||
if a.NoneYet {
|
||||
return seat.RevisionAnswer{}, errNoneYet
|
||||
}
|
||||
if a.Revision == nil || a.Revision.Revision <= 0 {
|
||||
return seat.RevisionAnswer{}, fmt.Errorf("%s answered no revision: %s", RevisionVerb, clipBytes(answer))
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
func hex64(c string) string { return strings.Repeat(c, 64) }
|
||||
|
||||
// The digest and the candidate's fingerprint set equal what the trunk's go/delivery computed for the same input (the
|
||||
// expected strings are its output), so a key or a verdict written before is read after.
|
||||
func TestDigestAndFingerprintSetKeepTheirForms(t *testing.T) {
|
||||
if got := ManifestDigest([]byte(`{"module":"nats"}`)); got != "19a7450f557153c318558acac91cd6972321a192f6f95c3698a0e4c57edd4359" {
|
||||
t.Errorf("ManifestDigest = %s", got)
|
||||
}
|
||||
pull := func(fps map[string]seat.CandidatesByGroupValuePullsItemFpsValue) []seat.CandidatesByGroupValuePullsItem {
|
||||
return []seat.CandidatesByGroupValuePullsItem{{Fps: fps}}
|
||||
}
|
||||
fps := map[string]seat.CandidatesByGroupValuePullsItemFpsValue{"nats": {Fp2: SourcePrefix2 + hex64("a")}, "zsh": {None2: "no manifest"}}
|
||||
set := FingerprintSet(pull(fps))
|
||||
if set != "50a3f57cc4e2" {
|
||||
t.Errorf("FingerprintSet = %s", set)
|
||||
}
|
||||
fps["zsh"] = seat.CandidatesByGroupValuePullsItemFpsValue{None2: "another reason"}
|
||||
if FingerprintSet(pull(fps)) == set {
|
||||
t.Error("a changed reason leaves the set as it was")
|
||||
}
|
||||
if FingerprintSet(pull(nil)) != "" {
|
||||
t.Error("no fingerprint gives a set")
|
||||
}
|
||||
}
|
||||
|
||||
// A manifest and a module are read back as written, and each rule of the old values is kept: a refusal names its reason.
|
||||
func TestManifestAndModuleValuesKeepTheirRules(t *testing.T) {
|
||||
if _, err := ManifestsKey("abc"); err == nil || !strings.Contains(err.Error(), `"abc"`) {
|
||||
t.Errorf("ManifestsKey(abc) = %v", err)
|
||||
}
|
||||
if k, err := ParseManifestsKey(hex64("b")); err != nil || k != hex64("b") {
|
||||
t.Errorf("ParseManifestsKey = %q, %v", k, err)
|
||||
}
|
||||
raw, err := EncodeManifest(seat.ManifestsByDigestValue{Module: "nats", Manifest: `{"module":"nats"}`})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, err := DecodeManifest(raw); err != nil || m.Module != "nats" || m.V != keys.Version {
|
||||
t.Errorf("DecodeManifest = %+v, %v", m, err)
|
||||
}
|
||||
for _, bad := range []seat.ManifestsByDigestValue{{Module: "a.b", Manifest: "{}"}, {Module: "nats"}, {Module: "nats", Manifest: "not json"}, {Module: "nats", Manifest: "{\"a\":\"\xff\"}"}} {
|
||||
if _, err := EncodeManifest(bad); err == nil {
|
||||
t.Errorf("EncodeManifest(%+v) is accepted", bad)
|
||||
}
|
||||
}
|
||||
if _, err := DecodeManifest([]byte(`{"module":"nats","manifest":"{}"}`)); !errors.Is(err, keys.ErrUnknownVersion) {
|
||||
t.Errorf("a manifest with no version: %v", err)
|
||||
}
|
||||
|
||||
good := seat.ModulesByModuleValue{Fp2: SourcePrefix2 + hex64("a"), Repository: "novox/mesh-catalog", Commit: "c", Manifest: hex64("b"), Path: RootPath}
|
||||
raw, err = EncodeModule(good)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, err := DecodeModule(raw); err != nil || m.Fp2 != good.Fp2 || m.Path != RootPath {
|
||||
t.Errorf("DecodeModule = %+v, %v", m, err)
|
||||
}
|
||||
refused := good
|
||||
refused.Verdict, refused.Problems = VerdictRefused, []string{"p"}
|
||||
if _, err := EncodeModule(refused); err != nil {
|
||||
t.Errorf("a refused module: %v", err)
|
||||
}
|
||||
for name, mutate := range map[string]func(m *seat.ModulesByModuleValue){
|
||||
"neither a fingerprint nor a reason": func(m *seat.ModulesByModuleValue) { m.Fp2 = "" },
|
||||
"both fp2 and none2": func(m *seat.ModulesByModuleValue) { m.None2 = "x" },
|
||||
"an old fingerprint of another form": func(m *seat.ModulesByModuleValue) { m.Fp = "src2:" + hex64("a") },
|
||||
"a fingerprint of the old key form": func(m *seat.ModulesByModuleValue) { m.Fp2 = "src1:" + hex64("a") },
|
||||
"inputs and no manifest": func(m *seat.ModulesByModuleValue) {
|
||||
m.Manifest = ""
|
||||
m.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t"}
|
||||
},
|
||||
"a refusal with no problem": func(m *seat.ModulesByModuleValue) { m.Verdict = VerdictRefused },
|
||||
"problems with no refusal": func(m *seat.ModulesByModuleValue) { m.Problems = []string{"p"} },
|
||||
"unknown fields with no refusal": func(m *seat.ModulesByModuleValue) { m.Unknown = []string{"series"} },
|
||||
"a path outside the directory": func(m *seat.ModulesByModuleValue) { m.Paths = map[string][]string{"tools": {"../x"}} },
|
||||
"a toolchain with no recipe": func(m *seat.ModulesByModuleValue) {
|
||||
m.Toolchains = map[string]seat.ToolchainUsed{"go": {Language: "go", Version: "1.26"}}
|
||||
},
|
||||
"an import form with no imports": func(m *seat.ModulesByModuleValue) {
|
||||
m.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", ImportForm: SourcePrefix2 + hex64("a")}
|
||||
},
|
||||
} {
|
||||
m := good
|
||||
mutate(&m)
|
||||
if _, err := EncodeModule(m); err == nil {
|
||||
t.Errorf("%s: EncodeModule accepts %+v", name, m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A verdict is taken as the readers have always taken it: a missing one accepted, a refusal held with its problems, a wait
|
||||
// held with the fields it waits on, and a module's own verdict field gives the same.
|
||||
func TestVerdictsAreTakenAsTheReadersTookThem(t *testing.T) {
|
||||
if refused, problems := TakeVerdict(nil); refused || problems != nil {
|
||||
t.Errorf("no verdict: %v %v", refused, problems)
|
||||
}
|
||||
waits := seat.VerdictsByDigestValue{Module: "nats", State: VerdictManifestWaits, Unknown: []string{"series"}, Judge: "j"}
|
||||
refused, problems := TakeVerdict(&waits)
|
||||
if !refused || len(problems) != 1 || problems[0] != "it carries series, which the indexer's judge does not know yet" {
|
||||
t.Errorf("a wait: %v %v", refused, problems)
|
||||
}
|
||||
if got := VerdictWhy(waits); got != "the indexer's judge (j) holds the manifest of nats: "+problems[0] {
|
||||
t.Errorf("VerdictWhy(wait) = %q", got)
|
||||
}
|
||||
if as := VerdictAsRefused(waits); as.State != VerdictRefused || len(as.Unknown) != 0 || as.Problems[0] != problems[0] {
|
||||
t.Errorf("VerdictAsRefused = %+v", as)
|
||||
}
|
||||
no := seat.VerdictsByDigestValue{Module: "nats", State: VerdictRefused, Problems: []string{"a", "b"}, Judge: "j"}
|
||||
if got := VerdictWhy(no); got != "the indexer's judge (j) refused the manifest of nats: a; b" {
|
||||
t.Errorf("VerdictWhy(refused) = %q", got)
|
||||
}
|
||||
if !SameVerdict(no, seat.VerdictsByDigestValue{Module: "nats", State: VerdictRefused, Problems: []string{"a", "b"}, Judge: "k"}) {
|
||||
t.Error("another judge is another verdict")
|
||||
}
|
||||
fromModule := ModuleVerdict("nats", seat.ModulesByModuleValue{Verdict: VerdictRefused, Unknown: []string{"series"}, Problems: []string{"x"}})
|
||||
if fromModule == nil || fromModule.State != VerdictManifestWaits || fromModule.Unknown[0] != "series" {
|
||||
t.Errorf("a refusal naming unknown fields is the wait it was written as: %+v", fromModule)
|
||||
}
|
||||
if ModuleVerdict("nats", seat.ModulesByModuleValue{}) != nil {
|
||||
t.Error("a module with no verdict carries one")
|
||||
}
|
||||
for _, bad := range []seat.VerdictsByDigestValue{{Module: "nats", State: "accepted", Problems: []string{"p"}, Judge: "j"}, {Module: "nats", State: "refused", Judge: "j"}, {Module: "nats", State: "accepted"}, {Module: "nats", State: "odd", Judge: "j"}} {
|
||||
if _, err := EncodeVerdict(bad); err == nil {
|
||||
t.Errorf("EncodeVerdict(%+v) is accepted", bad)
|
||||
}
|
||||
}
|
||||
raw, err := EncodeVerdict(no)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, err := DecodeVerdict(raw); err != nil || !SameVerdict(v, no) {
|
||||
t.Errorf("DecodeVerdict = %+v, %v", v, err)
|
||||
}
|
||||
if k, err := VerdictsKey(hex64("c")); err != nil || k != hex64("c") {
|
||||
t.Errorf("VerdictsKey = %q %v", k, err)
|
||||
}
|
||||
if _, err := ModulesKey("a.b"); err == nil {
|
||||
t.Error("ModulesKey accepts a dotted name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidatesKeyEscapesTheGroupAndReadsBack(t *testing.T) {
|
||||
key, err := CandidatesKey("fix/1.2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if key == "fix/1.2" {
|
||||
t.Errorf("the group is not escaped: %q", key)
|
||||
}
|
||||
if group, err := ParseCandidatesKey(key); err != nil || group != "fix/1.2" {
|
||||
t.Errorf("read back = %q, %v", group, err)
|
||||
}
|
||||
if _, err := CandidatesKey(""); err == nil {
|
||||
t.Error("an empty group keys")
|
||||
}
|
||||
}
|
||||
|
||||
// CT15 (design 47 G §476, §493, §648): the seat's `bodies` give the types the indexer writes and the runner reads: a
|
||||
// take-in.taken names its branch, source revision and entries (an entry of a merged message names its pull request),
|
||||
// a take-in.pending its branch, and a revision answer for a branch with no revision yet is `none-yet` alone.
|
||||
func TestTakeInBodiesAndNoneYetAreTheSeatsTypes(t *testing.T) {
|
||||
var taken seat.TakeInTaken
|
||||
body := `{"v":1,"kind":"taken","key":"m.00000000000000000007","what":"revision","branch":"beta","source":3590,"since":"2026-11-11T10:00:00Z",` +
|
||||
`"merges":[{"repository":"novox/mesh-sdk","number":9,"merge":"cc"}],` +
|
||||
`"entries":[{"module":"nats","commit":"cc","fingerprint":"src2:aa","repository":"novox/mesh-sdk","pull":9},{"module":"zsh","commit":"cc","fingerprint":"src2:bb"}]}`
|
||||
if err := json.Unmarshal([]byte(body), &taken); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if taken.Branch != "beta" || taken.Source != 3590 || len(taken.Entries) != 2 || taken.Entries[0].Pull != 9 || taken.Entries[1].Repository != "" {
|
||||
t.Errorf("take-in.taken read as %+v", taken)
|
||||
}
|
||||
var pending seat.TakeInPending
|
||||
if err := json.Unmarshal([]byte(`{"v":1,"kind":"pending","key":"m.1","what":"revision","branch":"beta","since":"2026-11-11T10:00:00Z","merges":[]}`), &pending); err != nil || pending.Branch != "beta" {
|
||||
t.Errorf("take-in.pending read as %+v, %v", pending, err)
|
||||
}
|
||||
var none seat.RevisionAnswer
|
||||
if err := json.Unmarshal([]byte(`{"none-yet":true}`), &none); err != nil || !none.NoneYet || none.Revision != nil {
|
||||
t.Errorf("a none-yet answer read as %+v, %v", none, err)
|
||||
}
|
||||
raw, _ := json.Marshal(seat.RevisionAnswer{NoneYet: true})
|
||||
if string(raw) != `{"none-yet":true}` {
|
||||
t.Errorf("a none-yet answer is written as %s", raw)
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// fakeRevisions answers the verb revision per branch from the newest revision each branch holds, and counts each ask.
|
||||
type fakeRevisions struct {
|
||||
mu sync.Mutex
|
||||
newest map[string]int64 // by escaped branch
|
||||
asks map[string]int
|
||||
branches []string
|
||||
}
|
||||
|
||||
func (f *fakeRevisions) call(key string, body any) (json.RawMessage, error) {
|
||||
in := body.(seat.RevisionInput)
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
rev, ok := f.newest[in.Branch]
|
||||
if ok && rev == 0 {
|
||||
return json.Marshal(seat.RevisionAnswer{NoneYet: true})
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("asked for the branch %q", in.Branch)
|
||||
}
|
||||
f.asks[in.Branch]++
|
||||
return json.Marshal(seat.RevisionAnswer{
|
||||
Revision: &seat.CatalogRevision{Revision: rev, Kind: KindTrunk, Branch: in.Branch},
|
||||
Entries: []seat.CatalogEntry{{Module: fmt.Sprintf("m-of-%s-%d", in.Branch, rev)}},
|
||||
})
|
||||
}
|
||||
|
||||
func (f *fakeRevisions) set(branch string, rev int64) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.newest[keys.EscapeName(branch)] = rev
|
||||
}
|
||||
|
||||
func (f *fakeRevisions) asked(branch string) int {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.asks[keys.EscapeName(branch)]
|
||||
}
|
||||
|
||||
func revisionEvent(branch, kind string, rev int64) []byte {
|
||||
b, _ := json.Marshal(seat.CatalogRevisionEvent{V: 1, Branch: keys.EscapeName(branch), Kind: kind, Revision: rev})
|
||||
return b
|
||||
}
|
||||
|
||||
// CT10 (design 47 G §358, §479, §196): the catalog half is a view per watched branch, named by its caller: two branches
|
||||
// give two views, each named `mesh-catalog.catalog-revisions.<branch>`, each following only its own branch's
|
||||
// `catalog-revision`; a revision the view missed asks `revision` once more, said in the log.
|
||||
func TestCatalogIsAViewPerWatchedBranch(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
f := &fakeRevisions{newest: map[string]int64{"main": 3, keys.EscapeName("release/1"): 7}, asks: map[string]int{}}
|
||||
var logMu sync.Mutex
|
||||
var logged []string
|
||||
logf := func(format string, args ...any) {
|
||||
logMu.Lock()
|
||||
defer logMu.Unlock()
|
||||
logged = append(logged, fmt.Sprintf(format, args...))
|
||||
}
|
||||
main, err := NewCatalog(f.call, "main")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rel, err := NewCatalog(f.call, "release/1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, c := range []*Catalog{main, rel} {
|
||||
c.Follower.Wait = time.Nanosecond
|
||||
c.Follower.Logf = logf
|
||||
}
|
||||
if main.Follower.State == rel.Follower.State || main.Follower.State != "catalog-revisions.main" || rel.Follower.State != views.BranchState(seat.StateCatalogRevisions, "release/1") {
|
||||
t.Fatalf("views are named %q and %q", main.Follower.State, rel.Follower.State)
|
||||
}
|
||||
for _, c := range []*Catalog{main, rel} {
|
||||
if err := c.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
<-c.Ready()
|
||||
}
|
||||
if h, ok := main.View(); !ok || h.Revision.Revision != 3 || len(h.Entries) != 1 {
|
||||
t.Fatalf("main holds %+v, %v", h, ok)
|
||||
}
|
||||
if h, ok := rel.View(); !ok || h.Revision.Revision != 7 {
|
||||
t.Fatalf("release/1 holds %+v, %v", h, ok)
|
||||
}
|
||||
|
||||
// An event of the other branch, a candidate's and one the view holds ask nothing.
|
||||
for _, data := range [][]byte{revisionEvent("release/1", KindTrunk, 8), revisionEvent("main", KindCandidate, 4), revisionEvent("main", KindTrunk, 3)} {
|
||||
if err := main.Hear(ctx, data); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if n := f.asked("main"); n != 1 {
|
||||
t.Errorf("main asked %d times, want only its first view", n)
|
||||
}
|
||||
|
||||
// A missed revision asks `revision` once more, and is said.
|
||||
f.set("main", 4)
|
||||
if err := main.Hear(ctx, revisionEvent("main", KindTrunk, 4)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for {
|
||||
if h, _ := main.View(); h.Revision.Revision == 4 {
|
||||
break
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal("main never held revision 4")
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
if n := f.asked("release/1"); n != 1 {
|
||||
t.Errorf("release/1 asked %d times after main's revision", n)
|
||||
}
|
||||
logMu.Lock()
|
||||
said := false
|
||||
for _, l := range logged {
|
||||
if strings.Contains(l, "catalog revision 4 of main said") {
|
||||
said = true
|
||||
}
|
||||
}
|
||||
logMu.Unlock()
|
||||
if !said {
|
||||
t.Errorf("the gap was not said in the log: %q", logged)
|
||||
}
|
||||
|
||||
// A branch with no revision yet is ready and empty, and nothing waits for it.
|
||||
f.set("new", 0)
|
||||
none, err := NewCatalog(f.call, "new")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := none.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
<-none.Ready()
|
||||
if _, ok := none.View(); ok || none.Follower.Status().WaitsFor != "" {
|
||||
t.Errorf("a branch with no revision yet holds a view or waits: %+v", none.Follower.Status())
|
||||
}
|
||||
|
||||
for _, data := range []string{`{}`, `not json`} {
|
||||
if err := main.Hear(ctx, []byte(data)); err == nil {
|
||||
t.Errorf("Hear(%s) took it", data)
|
||||
}
|
||||
}
|
||||
if _, err := NewCatalog(f.call, ""); err == nil {
|
||||
t.Error("a Catalog of no branch was made")
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// Ready is nil once every watched branch has its first view (`none-yet` counting as one), else says what it waits for
|
||||
// (design 47 G §614, A-103): a part acts on nothing until then.
|
||||
func (b *Branches) Ready() error {
|
||||
followed := b.Followed()
|
||||
if len(followed) == 0 {
|
||||
return fmt.Errorf("the catalog half names no watched branch yet (the registrations of the seat %s are asked until they answer)", seat.Seat)
|
||||
}
|
||||
var waiting []string
|
||||
for _, branch := range followed {
|
||||
if c, ok := b.Catalog(branch); ok {
|
||||
select {
|
||||
case <-c.Ready():
|
||||
default:
|
||||
waiting = append(waiting, branch)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(waiting) > 0 {
|
||||
return fmt.Errorf("the catalog half has no first view of %s yet", strings.Join(waiting, ", "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Entry is a module's entry at the trunk: the module's own registration decides, so the branch followed first, which lists
|
||||
// the module, is the one read (design 47 G A-103). An error says a watched branch has no first view yet, never "no module".
|
||||
func (b *Branches) Entry(module string) (seat.CatalogEntry, bool, error) {
|
||||
if err := b.Ready(); err != nil {
|
||||
return seat.CatalogEntry{}, false, err
|
||||
}
|
||||
for _, branch := range b.Followed() {
|
||||
if c, ok := b.Catalog(branch); ok {
|
||||
if e, ok := c.Entry(module); ok {
|
||||
return e, true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return seat.CatalogEntry{}, false, nil
|
||||
}
|
||||
|
||||
// EntryStatus is one entry kept by fingerprint as a part's `<module>_first_views` says it: its state and since when.
|
||||
type EntryStatus struct {
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
State EntryState `json:"state"`
|
||||
Since time.Time `json:"since"`
|
||||
Detail string `json:"detail,omitempty"`
|
||||
}
|
||||
|
||||
// EntryStatuses are the entries kept by fingerprint, as `<module>_first_views` lists them (design 47 G §614, A-103).
|
||||
func (b *Branches) EntryStatuses() []EntryStatus {
|
||||
rows := b.Entries.Rows()
|
||||
out := make([]EntryStatus, 0, len(rows))
|
||||
for _, r := range rows {
|
||||
out = append(out, EntryStatus{Fingerprint: r.Fingerprint, State: r.State, Since: r.Since, Detail: r.Detail})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// WriteEntryFindings makes the part write the finding `entry-not-found` through w for each entry the holder answered it does not
|
||||
// hold, and clear it when a later ask answers it or the part releases the entry (design 47 G §614, A-15, A-103). then, when not
|
||||
// nil, is told of each change after, so the part starts a new pass. The kind `entry-not-found` is one of w's kinds.
|
||||
func (b *Branches) WriteEntryFindings(w views.WireWriter, then func(EntryRow)) {
|
||||
b.Entries.Changed = func(row EntryRow) {
|
||||
switch row.State {
|
||||
case EntryNotFound:
|
||||
if err := views.WriteEntryNotFound(w, row.Fingerprint, row.Since, time.Now()); err != nil && b.Logf != nil {
|
||||
b.Logf("the finding entry-not-found of %s is not kept: %v", row.Fingerprint, err)
|
||||
}
|
||||
case EntryAnswered:
|
||||
_ = views.ClearEntryNotFound(w, row.Fingerprint)
|
||||
}
|
||||
if then != nil {
|
||||
then(row)
|
||||
}
|
||||
}
|
||||
b.Entries.Released = func(fingerprint string) { _ = views.ClearEntryNotFound(w, fingerprint) }
|
||||
}
|
||||
|
||||
// EntryAgainTool is the part's tool `<module>_entry_again` (design 47 G A-103; class act): it asks one entry by fingerprint
|
||||
// again now, as a hand act recorded first through handAct (what, why, cause), and answers where the entry stands.
|
||||
func (b *Branches) EntryAgainTool(module string, handAct func(what, why, cause string) error) stdio.Tool {
|
||||
name := module + "_entry_again"
|
||||
return stdio.Tool{Name: name,
|
||||
Description: "Ask the catalog's entry of one build, by its fingerprint, again now, whatever its state: a hand act, for an entry the part holds as asked or not found. Answers where it stands after. (a)",
|
||||
Input: map[string]any{"type": "object", "required": []string{"fingerprint", "why"}, "properties": map[string]any{
|
||||
"fingerprint": map[string]any{"type": "string"}, "why": map[string]any{"type": "string"}}},
|
||||
Run: func(a map[string]any) (any, error) {
|
||||
fingerprint, _ := a["fingerprint"].(string)
|
||||
why, _ := a["why"].(string)
|
||||
if fingerprint = strings.TrimSpace(fingerprint); fingerprint == "" {
|
||||
return nil, fmt.Errorf("name the fingerprint of the entry")
|
||||
}
|
||||
if strings.TrimSpace(why) == "" {
|
||||
return nil, fmt.Errorf("say why: a hand act keeps its why")
|
||||
}
|
||||
if err := handAct(name+" "+fingerprint, strings.TrimSpace(why), name); err != nil {
|
||||
return nil, fmt.Errorf("the hand-act log does not hold it, so nothing is asked: %w", err)
|
||||
}
|
||||
if err := b.Entries.Again(context.Background(), fingerprint); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]any{"entries": b.EntryStatuses()}, nil
|
||||
}}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// wireFindings is a part's finding writer in memory: the findings by `<kind>/<id>` it holds.
|
||||
type wireFindings struct {
|
||||
mu sync.Mutex
|
||||
held map[string]bool
|
||||
}
|
||||
|
||||
func (w *wireFindings) WriteWire(_ context.Context, f map[string]any) error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
w.held[f["kind"].(string)+"/"+f["id"].(string)] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *wireFindings) Clear(_ context.Context, _, id, kind, _ string) error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
delete(w.held, kind+"/"+id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *wireFindings) ModuleNode() (string, string) { return "part", "n1" }
|
||||
|
||||
func (w *wireFindings) has(key string) bool {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
return w.held[key]
|
||||
}
|
||||
|
||||
// A-103 (design 47 G §614): the helpers every part uses over the branch follower: Ready and Entry before a first view, the
|
||||
// entries by fingerprint as `first_views` rows, the finding entry-not-found written and cleared, and `<module>_entry_again`.
|
||||
func TestTheBranchFollowerGivesEveryPartItsEntryHelpers(t *testing.T) {
|
||||
seats := &fakeSeats{entries: map[string]seat.CatalogEntry{"fp:a": {Module: "m", Fp: "fp:a"}}}
|
||||
b, err := NewBranches(&fakeWiring{adopted: map[string]*views.Follower{}, hears: map[string]func(context.Context, []byte) error{}}, seats.call)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := b.Ready(); err == nil {
|
||||
t.Error("Ready said ready with no watched branch")
|
||||
}
|
||||
if _, _, err := b.Entry("m"); err == nil {
|
||||
t.Error("Entry answered with no first view: that is an error, never no module")
|
||||
}
|
||||
|
||||
told := make(chan EntryRow, 4)
|
||||
w := &wireFindings{held: map[string]bool{}}
|
||||
b.WriteEntryFindings(w, func(r EntryRow) { told <- r })
|
||||
b.Entries.Need(context.Background(), "fp:none")
|
||||
<-told
|
||||
if !w.has(views.EntryNotFoundKind + "/" + keys.EscapeName("fp:none")) {
|
||||
t.Errorf("entry-not-found not written: %v", w.held)
|
||||
}
|
||||
if st := b.EntryStatuses(); len(st) != 1 || st[0].State != EntryNotFound {
|
||||
t.Errorf("entry statuses = %+v", st)
|
||||
}
|
||||
seats.mu.Lock()
|
||||
seats.entries["fp:none"] = seat.CatalogEntry{Module: "late", Fp: "fp:none"}
|
||||
seats.mu.Unlock()
|
||||
var acts []string
|
||||
tool := b.EntryAgainTool("part", func(what, why, cause string) error { acts = append(acts, what+"|"+why+"|"+cause); return nil })
|
||||
if tool.Name != "part_entry_again" {
|
||||
t.Errorf("tool name %s", tool.Name)
|
||||
}
|
||||
if _, err := tool.Run(map[string]any{"fingerprint": "fp:none"}); err == nil {
|
||||
t.Error("entry_again ran without a why")
|
||||
}
|
||||
if _, err := tool.Run(map[string]any{"fingerprint": "fp:none", "why": "late"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(acts) != 1 || w.has(views.EntryNotFoundKind+"/"+keys.EscapeName("fp:none")) {
|
||||
t.Errorf("hand acts %v, findings %v", acts, w.held)
|
||||
}
|
||||
select {
|
||||
case <-told:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Error("the part was not told of the answer")
|
||||
}
|
||||
b.Entries.Need(context.Background(), "fp:gone")
|
||||
<-told
|
||||
b.Entries.Release("fp:gone")
|
||||
if w.has(views.EntryNotFoundKind + "/" + keys.EscapeName("fp:gone")) {
|
||||
t.Error("a released entry kept its finding")
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// Package meshcatalogclient holds the logic the holders and callers of the seat mesh-catalog share over its contract (novox/hq
|
||||
// ADR 0625 §4, ADR 0634 §2): the form of a module's source fingerprint, `src2:` and 64 lowercase hex digits (ADR 0593 §2),
|
||||
// over the `fp2` field of the seat's `modules` value. The indexer computes a fingerprint alone, in its own package; every part
|
||||
// that keys a state by it, the node-engine among them, reads this form here.
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"git.novox.be/novox/mesh-delivery/sdk/catalogkey"
|
||||
)
|
||||
|
||||
// SourcePrefix2 opens every source fingerprint of the form.
|
||||
const SourcePrefix2 = catalogkey.SourcePrefix2
|
||||
|
||||
// Toolchain2 is what an artifact's toolchain enters the fingerprint as (novox/hq ADR 0405 clause 7): the artifact's
|
||||
// language, the installed toolchain's version and the build module's recipe version.
|
||||
type Toolchain2 struct {
|
||||
Language string
|
||||
Version string
|
||||
Recipe string
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-delivery/sdk v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/klauspost/compress v1.20.0 // indirect
|
||||
github.com/nats-io/nats.go v1.54.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
@@ -1,26 +0,0 @@
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op h1:Z/MZK75wC/NSrkgqeNIa7jexam9uWzhLmFTSCPI/kn0=
|
||||
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
|
||||
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
|
||||
github.com/nats-io/jwt/v2 v2.8.1/go.mod h1:nWnOEEiVMiKHQpnAy4eXlizVEtSfzacZ1Q43LIRavZg=
|
||||
github.com/nats-io/jwt/v2 v2.8.1 h1:V0xpGuD/N8Mi+fQNDynXohVvp7ZztevW5io8CUWlPmU=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats-server/v2 v2.11.17/go.mod h1:B1sFVz4StNosQ903ak4N1G01Fl/9f8e06mXpFIE2K24=
|
||||
github.com/nats-io/nats-server/v2 v2.11.17 h1:GKEghcFK6A+aFx11Yf1LjgLC3txAwvyhnYzhBIQZA8I=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||
@@ -1,22 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"go/build"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// ADR 0625 §4 (design 26, a client package): a client imports its own seat's contract, mesh-sdk's runtime and its domain's
|
||||
// SDK, never another seat's contract or client.
|
||||
func TestTheClientImportsNoOtherSeat(t *testing.T) {
|
||||
p, err := build.ImportDir(".", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
imports := append(append([]string{}, p.Imports...), p.TestImports...)
|
||||
for _, i := range imports {
|
||||
if strings.Contains(i, "/seats/meshdelivery") || strings.Contains(i, "/clients/") {
|
||||
t.Errorf("meshcatalogclient imports %s", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"unicode/utf8"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// ManifestDigest is the hex sha256 of a manifest's bytes exactly as read at the commit: the key of a `manifests` value and
|
||||
// the digest a `modules` value and a candidate's module carry (novox/hq ADR 0429 clause 16).
|
||||
func ManifestDigest(raw []byte) string {
|
||||
sum := sha256.Sum256(raw)
|
||||
return hex.EncodeToString(sum[:])
|
||||
}
|
||||
|
||||
// ManifestsKey is the key of a `manifests` value: the manifest's digest, 64 lowercase hex digits. The indexer writes it
|
||||
// once, by a create that fails when the key exists.
|
||||
func ManifestsKey(digest string) (string, error) {
|
||||
if !keys.IsHex64(digest) {
|
||||
return "", fmt.Errorf("meshcatalogclient: %q is not a manifest digest, 64 lowercase hex digits", digest)
|
||||
}
|
||||
return seat.ManifestsByDigestKey(digest), nil
|
||||
}
|
||||
|
||||
// ParseManifestsKey is the inverse of ManifestsKey.
|
||||
func ParseManifestsKey(key string) (string, error) {
|
||||
digest, err := ManifestsKey(key)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("meshcatalogclient: %q is not a manifests key: %w", key, err)
|
||||
}
|
||||
return digest, nil
|
||||
}
|
||||
|
||||
func checkManifest(m seat.ManifestsByDigestValue) error {
|
||||
if err := keys.CheckName("module", m.Module); err != nil {
|
||||
return err
|
||||
}
|
||||
if m.Manifest == "" {
|
||||
return fmt.Errorf("meshcatalogclient: the manifest of %s is empty", m.Module)
|
||||
}
|
||||
if !utf8.ValidString(m.Manifest) {
|
||||
return fmt.Errorf("meshcatalogclient: the manifest of %s is not UTF-8 text, which a value cannot hold byte for byte", m.Module)
|
||||
}
|
||||
if !json.Valid([]byte(m.Manifest)) {
|
||||
return fmt.Errorf("meshcatalogclient: the manifest of %s is not JSON", m.Module)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeManifest is m as JSON at the kept values' version; it refuses a module that is not a name and a manifest that is
|
||||
// empty, not UTF-8 or not JSON.
|
||||
func EncodeManifest(m seat.ManifestsByDigestValue) ([]byte, error) {
|
||||
if err := checkManifest(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.V = keys.Version
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
// DecodeManifest reads a `manifests` value; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeManifest
|
||||
// refuses.
|
||||
func DecodeManifest(data []byte) (seat.ManifestsByDigestValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.ManifestsByDigestValue{}, err
|
||||
}
|
||||
var m seat.ManifestsByDigestValue
|
||||
if err := json.Unmarshal(data, &m); err != nil {
|
||||
return seat.ManifestsByDigestValue{}, fmt.Errorf("meshcatalogclient: value does not fit its shape: %w", err)
|
||||
}
|
||||
if err := checkManifest(m); err != nil {
|
||||
return seat.ManifestsByDigestValue{}, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/catalogkey"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// RootPath is a `modules` value's path when the module's manifest is its repository's root.
|
||||
const RootPath = "."
|
||||
|
||||
// SourcePrefix1 opens the fingerprint of the old form a `modules` value may still carry in `fp`.
|
||||
const SourcePrefix1 = "src1:"
|
||||
|
||||
// ModulesKey is the key of a `modules` value: the module's name.
|
||||
func ModulesKey(module string) (string, error) {
|
||||
if err := keys.CheckName("module", module); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return seat.ModulesByModuleKey(module), nil
|
||||
}
|
||||
|
||||
// ParseModulesKey is the inverse of ModulesKey.
|
||||
func ParseModulesKey(key string) (string, error) {
|
||||
module, err := ModulesKey(key)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("meshcatalogclient: %q is not a modules key: %w", key, err)
|
||||
}
|
||||
return module, nil
|
||||
}
|
||||
|
||||
// CheckModule refuses a `modules` value that contradicts itself: both or neither of a fingerprint and the reason for none,
|
||||
// of either form, an old fingerprint not of the form `src1:`, kept inputs without a manifest digest, a verdict the indexer
|
||||
// does not write, problems without a refusal (or a refusal without problems), a path that is not clean inside the module's
|
||||
// directory, and a fingerprint or a digest not of its form.
|
||||
func CheckModule(m seat.ModulesByModuleValue) error {
|
||||
switch {
|
||||
case m.Fp != "" && m.None != "":
|
||||
return fmt.Errorf("meshcatalogclient: a module has both a fingerprint and a reason for none")
|
||||
case m.Fp == "" && m.None == "" && m.Fp2 == "" && m.None2 == "":
|
||||
return fmt.Errorf("meshcatalogclient: a module has neither a fingerprint nor a reason for none, of either form")
|
||||
case m.Fp != "" && !strings.HasPrefix(m.Fp, SourcePrefix1):
|
||||
return fmt.Errorf("meshcatalogclient: the module's fingerprint %q does not start with %s", m.Fp, SourcePrefix1)
|
||||
case m.Fp2 != "" && m.None2 != "":
|
||||
return fmt.Errorf("meshcatalogclient: a module has both fp2 and none2")
|
||||
}
|
||||
for language, t := range m.Toolchains {
|
||||
if t.Version == "" || t.Recipe == "" {
|
||||
return fmt.Errorf("meshcatalogclient: the module's toolchain of %q needs its version and its recipe version", language)
|
||||
}
|
||||
}
|
||||
if m.Inputs2 != nil && m.Manifest == "" {
|
||||
return fmt.Errorf("meshcatalogclient: a module keeps new-form inputs but has no manifest digest")
|
||||
}
|
||||
for artifact, paths := range m.Paths {
|
||||
if artifact == "" || len(paths) == 0 {
|
||||
return fmt.Errorf("meshcatalogclient: the module's named paths of the artifact %q are empty or name no artifact", artifact)
|
||||
}
|
||||
for _, p := range paths {
|
||||
if !cleanInside(p) {
|
||||
return fmt.Errorf("meshcatalogclient: the artifact %q names the path %q, not a clean path inside the module's directory", artifact, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
if in := m.Inputs2; in != nil {
|
||||
if f := in.ImportForm; f != "" && (len(in.Imports) == 0 || !strings.HasPrefix(f, SourcePrefix2) || !keys.IsHex64(f[len(SourcePrefix2):])) {
|
||||
return fmt.Errorf("meshcatalogclient: the kept import form %q is set only with imports, and is %s and 64 hex digits", f, SourcePrefix2)
|
||||
}
|
||||
for p, object := range in.Paths {
|
||||
if !cleanInside(p) {
|
||||
return fmt.Errorf("meshcatalogclient: the named path %q is not a clean path inside the module's directory", p)
|
||||
}
|
||||
if object == "" {
|
||||
return fmt.Errorf("meshcatalogclient: the named path %q names no git object", p)
|
||||
}
|
||||
}
|
||||
}
|
||||
switch {
|
||||
case m.Verdict != "" && m.Verdict != VerdictAccepted && m.Verdict != VerdictRefused:
|
||||
return fmt.Errorf("meshcatalogclient: the module's verdict %q is neither %s nor %s", m.Verdict, VerdictAccepted, VerdictRefused)
|
||||
case len(m.Unknown) > 0 && m.Verdict != VerdictRefused:
|
||||
return fmt.Errorf("meshcatalogclient: a module's unknown fields are named only with the refusal a wait is written as")
|
||||
case m.Verdict != "" && m.Manifest == "":
|
||||
return fmt.Errorf("meshcatalogclient: a module carries a verdict and no manifest digest")
|
||||
case (m.Verdict == VerdictRefused) != (len(m.Problems) > 0):
|
||||
return fmt.Errorf("meshcatalogclient: a module's problems are named only with a refusal, and a refusal names them")
|
||||
case m.Verdict == VerdictRefused && len(m.Warnings) > 0:
|
||||
return fmt.Errorf("meshcatalogclient: a refused module warns: a refusal names problems")
|
||||
}
|
||||
if m.Fp2 != "" {
|
||||
if _, err := catalogkey.KeyPart(m.Fp2); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if m.Manifest != "" {
|
||||
if _, err := ManifestsKey(m.Manifest); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cleanInside(p string) bool {
|
||||
return p != "" && p == path.Clean(p) && !strings.HasPrefix(p, "/") && p != ".." && !strings.HasPrefix(p, "../")
|
||||
}
|
||||
|
||||
// EncodeModule is m as JSON at the kept values' version; it refuses what CheckModule refuses.
|
||||
func EncodeModule(m seat.ModulesByModuleValue) ([]byte, error) {
|
||||
if err := CheckModule(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.V = keys.Version
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
// DecodeModule reads a `modules` value; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeModule refuses.
|
||||
func DecodeModule(data []byte) (seat.ModulesByModuleValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.ModulesByModuleValue{}, err
|
||||
}
|
||||
var m seat.ModulesByModuleValue
|
||||
if err := json.Unmarshal(data, &m); err != nil {
|
||||
return seat.ModulesByModuleValue{}, fmt.Errorf("meshcatalogclient: value does not fit its shape: %w", err)
|
||||
}
|
||||
if err := CheckModule(m); err != nil {
|
||||
return seat.ModulesByModuleValue{}, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/sourcebranches"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// RegistrationsVerb is the seat verb a part takes its first view of the registrations by, as its manifest's invokes
|
||||
// names it.
|
||||
const RegistrationsVerb = "seat:" + seat.Seat + "." + seat.VerbRegistrations
|
||||
|
||||
// Call asks one seat verb over the bus and answers what the holder said, whatever wraps it (process.Conn.Call, or
|
||||
// stdio.Ask through the tool runner).
|
||||
type Call = sourcebranches.Call
|
||||
|
||||
// registrationsCreated stands for the picture's Created in its follower: the registrations are followed by the seat's
|
||||
// event, never by an owner's views family, so one fixed time, never zero.
|
||||
var registrationsCreated = sourcebranches.Created
|
||||
|
||||
// Registrations is a part's typed follower of the registrations (design 47 G §353): a first view asked of the seat's verb
|
||||
// `registrations`, then each `registration-changed` heard, built on go/views' Follower, so the runtime's tools
|
||||
// `<module>_first_views` and `<module>_first_view_again` read and steer it as every first view. Its picture is keyed by
|
||||
// module, each value the module's newest registration. Ready is closed at the first view: a part that switches on its
|
||||
// first registrations waits for it.
|
||||
type Registrations struct {
|
||||
Follower *views.Follower
|
||||
|
||||
call Call
|
||||
}
|
||||
|
||||
// NewRegistrations is a Registrations asking the seat through call. Nothing is asked before Start.
|
||||
func NewRegistrations(call Call) *Registrations {
|
||||
r := &Registrations{call: call}
|
||||
r.Follower = &views.Follower{Owner: seat.Seat, Tool: RegistrationsVerb, State: seat.StateRegistrations, Ask: r.ask}
|
||||
return r
|
||||
}
|
||||
|
||||
// WireRegistrations is a Registrations adopted by a stdio part's views.Reader: the reader writes its conditions, reads it
|
||||
// as `mesh-catalog.registrations`, lists and asks it again in its first-view tools, and at its Start subscribes the
|
||||
// seat's event registration-changed (the part's manifest consumes it) into Hear and asks the first view. changed, when
|
||||
// not nil, is told of each module whose registration the picture changes, after the reader's own. The part declares the
|
||||
// seat's verb registrations in invokes.
|
||||
func WireRegistrations(r *views.Reader, call Call, changed func(reg seat.Registration, gone bool)) (*Registrations, error) {
|
||||
g := NewRegistrations(call)
|
||||
g.Follower.Changed = typedChanged(changed)
|
||||
if err := r.Adopt(g.Follower, seat.Seat, seat.EventRegistrationChanged, g.Hear); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// WireRegistrationsProcess is WireRegistrations for a process's views.ProcessReader: its picture
|
||||
// (`mesh-catalog_registrations`) reads the registrations as a read-only bucket, and the seat's event
|
||||
// registration-changed on the module's durable consumer goes to Hear.
|
||||
func WireRegistrationsProcess(r *views.ProcessReader, call Call, changed func(reg seat.Registration, gone bool)) (*Registrations, *views.Picture, error) {
|
||||
g := NewRegistrations(call)
|
||||
g.Follower.Changed = typedChanged(changed)
|
||||
p, err := r.Adopt(g.Follower, seat.Seat, seat.EventRegistrationChanged, g.Hear)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return g, p, nil
|
||||
}
|
||||
|
||||
func typedChanged(changed func(seat.Registration, bool)) func(string, json.RawMessage, bool, time.Time) {
|
||||
if changed == nil {
|
||||
return nil
|
||||
}
|
||||
return func(module string, value json.RawMessage, gone bool, _ time.Time) {
|
||||
reg := seat.Registration{Module: module}
|
||||
if !gone {
|
||||
_ = json.Unmarshal(value, ®)
|
||||
}
|
||||
changed(reg, gone)
|
||||
}
|
||||
}
|
||||
|
||||
// Start asks the first view until it is answered or ctx ends.
|
||||
func (r *Registrations) Start(ctx context.Context) error { return r.Follower.Start(ctx) }
|
||||
|
||||
// Ready is closed once the first view is answered.
|
||||
func (r *Registrations) Ready() <-chan struct{} { return r.Follower.Ready() }
|
||||
|
||||
// Registration is one module's newest registration in the picture.
|
||||
func (r *Registrations) Registration(module string) (seat.Registration, bool) {
|
||||
raw, ok := r.Follower.Get(module)
|
||||
if !ok {
|
||||
return seat.Registration{}, false
|
||||
}
|
||||
var reg seat.Registration
|
||||
if err := json.Unmarshal(raw, ®); err != nil {
|
||||
return seat.Registration{}, false
|
||||
}
|
||||
return reg, true
|
||||
}
|
||||
|
||||
// All is every registration in the picture, by module name.
|
||||
func (r *Registrations) All() []seat.Registration {
|
||||
values := r.Follower.Values()
|
||||
out := make([]seat.Registration, 0, len(values))
|
||||
for _, raw := range values {
|
||||
var reg seat.Registration
|
||||
if json.Unmarshal(raw, ®) == nil {
|
||||
out = append(out, reg)
|
||||
}
|
||||
}
|
||||
slices.SortFunc(out, func(a, b seat.Registration) int {
|
||||
if a.Module < b.Module {
|
||||
return -1
|
||||
}
|
||||
if a.Module > b.Module {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
// Hear takes one `registration-changed` event, as the part's durable consumer of the seat's events hands it. A version
|
||||
// the picture holds, or one older, is passed over; a newer one asks the first view again on its own goroutine, so the
|
||||
// consumer is never held while the holder is away, and again until the picture holds that version or ctx ends (an ask
|
||||
// already running, the first view among them, may have been answered before the change was written). Data that is no such event is an error.
|
||||
func (r *Registrations) Hear(ctx context.Context, data []byte) error {
|
||||
var ev seat.RegistrationChangedEvent
|
||||
if err := json.Unmarshal(data, &ev); err != nil || ev.Module == "" || ev.Version <= 0 {
|
||||
return fmt.Errorf("meshcatalogclient: not a %s event: %s", seat.EventRegistrationChanged, clipBytes(data))
|
||||
}
|
||||
if r.holds(ev.Module, ev.Version) {
|
||||
return nil
|
||||
}
|
||||
go r.catchUp(ctx, ev.Module, ev.Version)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Registrations) holds(module string, version int64) bool {
|
||||
reg, ok := r.Registration(module)
|
||||
return ok && reg.Version >= version
|
||||
}
|
||||
|
||||
func (r *Registrations) catchUp(ctx context.Context, module string, version int64) {
|
||||
sourcebranches.CatchUp(ctx, r.Follower, func() bool { return r.holds(module, version) }, fmt.Sprintf("registration of %s at version %d said", module, version))
|
||||
}
|
||||
|
||||
// ask is the Follower's Ask: every registration, whole in one answer.
|
||||
func (r *Registrations) ask(_ context.Context, _ string) (views.Answer, error) {
|
||||
raw, err := r.call(RegistrationsVerb, seat.RegistrationsInput{})
|
||||
if err != nil {
|
||||
return views.Answer{}, err
|
||||
}
|
||||
answer, said, ok := buscalls.Unwrap(raw)
|
||||
if !ok {
|
||||
return views.Answer{}, fmt.Errorf("%s answered: %s", RegistrationsVerb, said)
|
||||
}
|
||||
var a seat.RegistrationsAnswer
|
||||
if err := json.Unmarshal(answer, &a); err != nil || a.Registrations == nil {
|
||||
return views.Answer{}, fmt.Errorf("%s answered no registrations: %s", RegistrationsVerb, clipBytes(answer))
|
||||
}
|
||||
values := make(map[string]json.RawMessage, len(a.Registrations))
|
||||
for _, reg := range a.Registrations {
|
||||
v, _ := json.Marshal(reg)
|
||||
values[reg.Module] = v
|
||||
}
|
||||
return views.Answer{V: 1, Owner: seat.Seat, State: seat.StateRegistrations, Created: registrationsCreated, Values: values, At: time.Now()}, nil
|
||||
}
|
||||
|
||||
func clipBytes(b []byte) string { return sourcebranches.ClipBytes(b) }
|
||||
@@ -1,140 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
// fakeRegistrations answers the verb registrations from the versions it keeps, and counts each ask.
|
||||
type fakeRegistrations struct {
|
||||
mu sync.Mutex
|
||||
versions map[string]int64
|
||||
asks int
|
||||
// stale answers the next ask from these versions, once: an answer read before a change was written.
|
||||
stale map[string]int64
|
||||
}
|
||||
|
||||
func (f *fakeRegistrations) call(key string, body any) (json.RawMessage, error) {
|
||||
if key != RegistrationsVerb {
|
||||
return nil, fmt.Errorf("asked %s", key)
|
||||
}
|
||||
if in := body.(seat.RegistrationsInput); in.Module != "" || in.History {
|
||||
return nil, fmt.Errorf("asked %+v", in)
|
||||
}
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.asks++
|
||||
versions := f.versions
|
||||
if f.stale != nil {
|
||||
versions, f.stale = f.stale, nil
|
||||
}
|
||||
a := seat.RegistrationsAnswer{Registrations: []seat.Registration{}}
|
||||
for m, v := range versions {
|
||||
a.Registrations = append(a.Registrations, seat.Registration{Module: m, Version: v, Origin: "novox/" + m, Path: "module.json", Branches: []string{"main"}})
|
||||
}
|
||||
return json.Marshal(a)
|
||||
}
|
||||
|
||||
func (f *fakeRegistrations) set(module string, version int64) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.versions[module] = version
|
||||
}
|
||||
|
||||
func (f *fakeRegistrations) asked() int {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.asks
|
||||
}
|
||||
|
||||
func changedEvent(module string, version int64) []byte {
|
||||
b, _ := json.Marshal(seat.RegistrationChangedEvent{V: 1, Module: module, Version: version, Moved: []string{"branches"}, Warrant: "ask-1"})
|
||||
return b
|
||||
}
|
||||
|
||||
// CT10 (design 47 G §353): a part following the registrations takes a first view of the verb registrations, then each
|
||||
// registration-changed: a newer version is asked and held, one it holds asks nothing, a change heard while an answer
|
||||
// read before it was given asks again, and what is no such event is refused.
|
||||
func TestRegistrationsAreAFirstViewThenTheirEvents(t *testing.T) {
|
||||
changed := make(chan seat.Registration, 16)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
next := func() seat.Registration {
|
||||
t.Helper()
|
||||
select {
|
||||
case reg := <-changed:
|
||||
return reg
|
||||
case <-ctx.Done():
|
||||
t.Fatal("no registration changed")
|
||||
return seat.Registration{}
|
||||
}
|
||||
}
|
||||
f := &fakeRegistrations{versions: map[string]int64{"nats": 1, "zsh": 3}}
|
||||
r := NewRegistrations(f.call)
|
||||
r.Follower.Wait = time.Nanosecond
|
||||
r.Follower.Changed = typedChanged(func(reg seat.Registration, gone bool) {
|
||||
if !gone {
|
||||
changed <- reg
|
||||
}
|
||||
})
|
||||
select {
|
||||
case <-r.Ready():
|
||||
t.Fatal("ready before its first view")
|
||||
default:
|
||||
}
|
||||
if err := r.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
<-r.Ready()
|
||||
if reg, ok := r.Registration("nats"); !ok || reg.Version != 1 || reg.Origin != "novox/nats" {
|
||||
t.Fatalf("first view holds nats as %+v, %v", reg, ok)
|
||||
}
|
||||
if all := r.All(); len(all) != 2 || all[0].Module != "nats" || all[1].Module != "zsh" {
|
||||
t.Fatalf("All = %+v", all)
|
||||
}
|
||||
for range 2 {
|
||||
next()
|
||||
}
|
||||
|
||||
if err := r.Hear(ctx, changedEvent("zsh", 3)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n := f.asked(); n != 1 {
|
||||
t.Errorf("a version held asked the first view again: %d asks", n)
|
||||
}
|
||||
|
||||
f.set("nats", 2)
|
||||
if err := r.Hear(ctx, changedEvent("nats", 2)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if reg := next(); reg.Module != "nats" || reg.Version != 2 {
|
||||
t.Fatalf("after registration-changed: %+v", reg)
|
||||
}
|
||||
|
||||
// The answer to the ask the event starts was read before the change was written: it is asked once more.
|
||||
f.mu.Lock()
|
||||
f.stale = map[string]int64{"nats": 2, "zsh": 3}
|
||||
f.mu.Unlock()
|
||||
f.set("zsh", 4)
|
||||
if err := r.Hear(ctx, changedEvent("zsh", 4)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if reg := next(); reg.Module != "zsh" || reg.Version != 4 {
|
||||
t.Fatalf("after a stale answer: %+v", reg)
|
||||
}
|
||||
if n := f.asked(); n != 4 {
|
||||
t.Errorf("asks = %d, want 4 (first view, nats, a stale answer and the one after)", n)
|
||||
}
|
||||
|
||||
for _, data := range []string{`{}`, `not json`, `{"module":"nats"}`} {
|
||||
if err := r.Hear(ctx, []byte(data)); err == nil {
|
||||
t.Errorf("Hear(%s) took it", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// The states of a verdict on a manifest (novox/hq ADR 0578 §1): the indexer judges every manifest it takes in once and
|
||||
// every other part takes the verdict from the seat's state `verdicts`.
|
||||
const (
|
||||
// VerdictAccepted is the state of a manifest the judge found no problem in.
|
||||
VerdictAccepted = "accepted"
|
||||
// VerdictRefused is the state of a manifest the judge found a problem in; the verdict's problems say each.
|
||||
VerdictRefused = "refused"
|
||||
// VerdictManifestWaits is the state of a manifest that carries a field the judge does not know: it is not refused,
|
||||
// because a newer judge may know the field; the verdict's unknown names each. A reader holds the module as a refused
|
||||
// one and keeps what runs. In a `modules` value it is written as a refusal naming the fields.
|
||||
VerdictManifestWaits = "waits"
|
||||
)
|
||||
|
||||
// VerdictsKey is the key of a `verdicts` value: the digest of the manifest it judges.
|
||||
func VerdictsKey(digest string) (string, error) {
|
||||
if !keys.IsHex64(digest) {
|
||||
return "", fmt.Errorf("meshcatalogclient: %q is not a manifest digest, 64 lowercase hex digits", digest)
|
||||
}
|
||||
return seat.VerdictsByDigestKey(digest), nil
|
||||
}
|
||||
|
||||
// VerdictRefuses says whether v refuses its manifest.
|
||||
func VerdictRefuses(v seat.VerdictsByDigestValue) bool { return v.State == VerdictRefused }
|
||||
|
||||
// VerdictWaits says whether v says the manifest waits for a judge that knows its fields.
|
||||
func VerdictWaits(v seat.VerdictsByDigestValue) bool { return v.State == VerdictManifestWaits }
|
||||
|
||||
// VerdictHeld says whether a reader holds the module as refused: the manifest is refused or waits.
|
||||
func VerdictHeld(v seat.VerdictsByDigestValue) bool { return VerdictRefuses(v) || VerdictWaits(v) }
|
||||
|
||||
// WaitsOn says, in words, what a waiting manifest waits on.
|
||||
func WaitsOn(v seat.VerdictsByDigestValue) string {
|
||||
return "it carries " + strings.Join(v.Unknown, ", ") + ", which the indexer's judge does not know yet"
|
||||
}
|
||||
|
||||
// TakeVerdict is how a reader takes the verdict on a manifest (ADR 0578 §3): held, with its problems, when the indexer
|
||||
// wrote a refusal, or, for a manifest that waits, with the words that say which fields it waits on. A missing verdict (nil)
|
||||
// is taken as accepted: every manifest the indexer holds before it has judged it was taken in under the judges that ran
|
||||
// until then. A reader holds a refused module and names it with VerdictWhy, and reads the rest.
|
||||
func TakeVerdict(v *seat.VerdictsByDigestValue) (refused bool, problems []string) {
|
||||
if v == nil || !VerdictHeld(*v) {
|
||||
return false, nil
|
||||
}
|
||||
if VerdictWaits(*v) {
|
||||
return true, []string{WaitsOn(*v)}
|
||||
}
|
||||
return true, v.Problems
|
||||
}
|
||||
|
||||
// VerdictWhy is a refusal in a reader's words: the module, that the indexer's judge refused its manifest, and each problem.
|
||||
func VerdictWhy(v seat.VerdictsByDigestValue) string {
|
||||
if !VerdictHeld(v) {
|
||||
return ""
|
||||
}
|
||||
judge := "the indexer's judge"
|
||||
if v.Judge != "" {
|
||||
judge += " (" + v.Judge + ")"
|
||||
}
|
||||
if VerdictWaits(v) {
|
||||
return fmt.Sprintf("%s holds the manifest of %s: %s", judge, v.Module, WaitsOn(v))
|
||||
}
|
||||
why := fmt.Sprintf("%s refused the manifest of %s:", judge, v.Module)
|
||||
for _, p := range v.Problems {
|
||||
why += " " + p + ";"
|
||||
}
|
||||
return why[:len(why)-1]
|
||||
}
|
||||
|
||||
// VerdictAsRefused is v as a reader that does not know the waiting state takes it: a waiting verdict is a refusal naming what
|
||||
// it waits on, any other verdict is v.
|
||||
func VerdictAsRefused(v seat.VerdictsByDigestValue) seat.VerdictsByDigestValue {
|
||||
if !VerdictWaits(v) {
|
||||
return v
|
||||
}
|
||||
v.State, v.Problems, v.Unknown = VerdictRefused, []string{WaitsOn(v)}, nil
|
||||
return v
|
||||
}
|
||||
|
||||
// SameVerdict says whether v and o say the same of a manifest: the module, the state, the problems, the unknown fields and
|
||||
// the warnings, whoever judged and when. The indexer writes a verdict only when it is not the same as the one it holds.
|
||||
func SameVerdict(v, o seat.VerdictsByDigestValue) bool {
|
||||
return v.Module == o.Module && v.State == o.State && slices.Equal(v.Problems, o.Problems) && slices.Equal(v.Unknown, o.Unknown) && slices.Equal(v.Warnings, o.Warnings)
|
||||
}
|
||||
|
||||
func checkVerdict(v seat.VerdictsByDigestValue) error {
|
||||
if err := keys.CheckName("module", v.Module); err != nil {
|
||||
return err
|
||||
}
|
||||
if v.State != VerdictManifestWaits && len(v.Unknown) > 0 {
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s names unknown fields and does not wait", v.Module)
|
||||
}
|
||||
switch v.State {
|
||||
case VerdictAccepted:
|
||||
if len(v.Problems) > 0 {
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s accepts its manifest and names problems", v.Module)
|
||||
}
|
||||
case VerdictRefused:
|
||||
if len(v.Problems) == 0 {
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s refuses its manifest and names no problem", v.Module)
|
||||
}
|
||||
if len(v.Warnings) > 0 {
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s refuses its manifest and warns: a refusal names problems", v.Module)
|
||||
}
|
||||
case VerdictManifestWaits:
|
||||
if len(v.Unknown) == 0 || len(v.Problems) > 0 || len(v.Warnings) > 0 {
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s waits and names no unknown field, or names problems or warnings: a wait names the fields", v.Module)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s is %q, none of %s, %s and %s", v.Module, v.State, VerdictAccepted, VerdictRefused, VerdictManifestWaits)
|
||||
}
|
||||
if v.Judge == "" {
|
||||
return fmt.Errorf("meshcatalogclient: the verdict on %s names no judge", v.Module)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeVerdict is v as JSON at the kept values' version; it refuses a verdict without a module or a judge, a state other
|
||||
// than accepted, refused or waits, a refusal naming no problem and an acceptance naming one.
|
||||
func EncodeVerdict(v seat.VerdictsByDigestValue) ([]byte, error) {
|
||||
if err := checkVerdict(v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v.V = keys.Version
|
||||
return json.Marshal(v)
|
||||
}
|
||||
|
||||
// DecodeVerdict reads a `verdicts` value; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeVerdict
|
||||
// refuses.
|
||||
func DecodeVerdict(data []byte) (seat.VerdictsByDigestValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.VerdictsByDigestValue{}, err
|
||||
}
|
||||
var v seat.VerdictsByDigestValue
|
||||
if err := json.Unmarshal(data, &v); err != nil {
|
||||
return seat.VerdictsByDigestValue{}, fmt.Errorf("meshcatalogclient: value does not fit its shape: %w", err)
|
||||
}
|
||||
if err := checkVerdict(v); err != nil {
|
||||
return seat.VerdictsByDigestValue{}, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// ModuleVerdict is the verdict a `modules` value carries, or nil when it carries none (taken as accepted, TakeVerdict). A
|
||||
// refusal naming unknown fields is the wait it was written as.
|
||||
func ModuleVerdict(module string, m seat.ModulesByModuleValue) *seat.VerdictsByDigestValue {
|
||||
if m.Verdict == "" && len(m.Warnings) == 0 {
|
||||
return nil
|
||||
}
|
||||
if m.Verdict == "" {
|
||||
return &seat.VerdictsByDigestValue{Module: module, State: VerdictAccepted, Warnings: m.Warnings}
|
||||
}
|
||||
if m.Verdict == VerdictRefused && len(m.Unknown) > 0 {
|
||||
return &seat.VerdictsByDigestValue{Module: module, State: VerdictManifestWaits, Unknown: m.Unknown}
|
||||
}
|
||||
return &seat.VerdictsByDigestValue{Module: module, State: m.Verdict, Problems: m.Problems}
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
// Package meshdeliverycheckerclient holds the logic the holders and callers of the seat mesh-delivery-checker share over its
|
||||
// contract (novox/hq ADR 0625 §4, ADR 0634 §2): the rules a verdict and a kept verdict must keep to be written or read. The
|
||||
// checker writes them, and the view, the gate and the indexer read them; the contract's decoding is strict by schema only, so
|
||||
// these rules are written once here and no caller copies them.
|
||||
package meshdeliverycheckerclient
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
pathpkg "path"
|
||||
"strings"
|
||||
|
||||
checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// The states of a verdict, the levels of a check and the compositions' states.
|
||||
const (
|
||||
VerdictRunning = "running"
|
||||
VerdictPass = "pass"
|
||||
VerdictFail = "fail"
|
||||
|
||||
LevelUnit = "unit"
|
||||
LevelIntegration = "integration"
|
||||
|
||||
CompositionNotRun = "not-run"
|
||||
CompositionPass = "pass"
|
||||
CompositionFail = "fail"
|
||||
)
|
||||
|
||||
// MaxFailures is the most failures a verdict names; it names the count of the rest beside them.
|
||||
const MaxFailures = 50
|
||||
|
||||
func checkLevel(level string) error {
|
||||
if level != LevelUnit && level != LevelIntegration {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the level %q is not %s or %s", level, LevelUnit, LevelIntegration)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isHex12(s string) bool { return len(s) == 12 && strings.Trim(s, "0123456789abcdef") == "" }
|
||||
|
||||
// CheckRepository refuses a repository that is not <owner>/<name> with exactly one slash, each part a key part.
|
||||
func CheckRepository(repository string) error {
|
||||
owner, name, ok := strings.Cut(repository, "/")
|
||||
if !ok || strings.Contains(name, "/") {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the repository %q is not <owner>/<name>, with exactly one slash", repository)
|
||||
}
|
||||
if err := keys.CheckName("repository owner", owner); err != nil {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the repository %q: %w", repository, err)
|
||||
}
|
||||
if err := keys.CheckName("repository name", name); err != nil {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the repository %q: %w", repository, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkComposition(c *checker.VerdictsByGroupHeadsValueComposition) error {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
switch c.State {
|
||||
case CompositionNotRun:
|
||||
if c.Sdk != "" || len(c.Machines) > 0 {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition is not run and names no mesh-sdk commit or machines")
|
||||
}
|
||||
case CompositionPass:
|
||||
if c.Sdk == "" {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition passed and names no mesh-sdk commit")
|
||||
}
|
||||
case CompositionFail:
|
||||
if c.Words == "" {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition failed and gives no words")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition state %q is not %s, %s or %s", c.State, CompositionNotRun, CompositionPass, CompositionFail)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// checkJudgedBy refuses a checking program named at no repository, full commit and package, kept under no program key,
|
||||
// or over no head or a head at no full commit (novox/hq ADR 0644, ADR 0656; issue 1921).
|
||||
func checkJudgedBy(j *checker.VerdictsByGroupHeadsValueJudgedBy) error {
|
||||
const who = "meshdeliverycheckerclient: "
|
||||
if j == nil {
|
||||
return nil
|
||||
}
|
||||
if CheckRepository(j.Program.Repository) != nil || !isCommit(j.Program.Commit) || j.Program.Package == "" {
|
||||
return fmt.Errorf(who+"the verdict is judged by a checking program built at no repository, full commit and package (%+v)", j.Program)
|
||||
}
|
||||
if !strings.HasPrefix(j.Key, "program-") {
|
||||
return fmt.Errorf(who+"the verdict's checking program is kept under %q, which is no program key", j.Key)
|
||||
}
|
||||
if len(j.Heads) == 0 {
|
||||
return fmt.Errorf(who + "the verdict's checking program read no head")
|
||||
}
|
||||
for _, h := range j.Heads {
|
||||
if CheckRepository(h.Repository) != nil || !isCommit(h.Commit) {
|
||||
return fmt.Errorf(who+"the verdict's checking program read %s at %q, which is no full commit", h.Repository, h.Commit)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isCommit(s string) bool { return len(s) == 40 && strings.Trim(s, "0123456789abcdef") == "" }
|
||||
|
||||
// CheckVerdict refuses a verdict a reader could not place: no group, heads that are not 12 lowercase hex digits, a repository
|
||||
// both merged and read beside, a carried-from that carries nothing, a series change from a series to itself or named twice, a
|
||||
// level that is neither unit nor integration or counts a negative number, a time below zero, a pass that says nothing of a
|
||||
// level, a fail that names neither a test nor a machine, and failures on a verdict that did not fail.
|
||||
func CheckVerdict(v checker.VerdictsByGroupHeadsValue) error {
|
||||
const who = "meshdeliverycheckerclient: "
|
||||
if v.Group == "" {
|
||||
return fmt.Errorf(who + "a verdict names no group")
|
||||
}
|
||||
if !isHex12(v.Heads) {
|
||||
return fmt.Errorf(who+"the verdict's heads hash %q is not 12 lowercase hex digits", v.Heads)
|
||||
}
|
||||
for repository, head := range v.Trunk {
|
||||
if head == "" {
|
||||
return fmt.Errorf(who+"the verdict's trunk head of %s is empty", repository)
|
||||
}
|
||||
}
|
||||
for repository, commit := range v.Beside {
|
||||
if commit == "" {
|
||||
return fmt.Errorf(who+"the verdict's sibling commit of %s is empty", repository)
|
||||
}
|
||||
if _, ok := v.Trunk[repository]; ok {
|
||||
return fmt.Errorf(who+"the verdict names %s as a trunk it merged and as a sibling it read", repository)
|
||||
}
|
||||
}
|
||||
if len(v.CarriedFrom) > 0 {
|
||||
if v.State == VerdictRunning {
|
||||
return fmt.Errorf(who + "a running verdict is carried from nothing: carried-from is written with its end")
|
||||
}
|
||||
moved := false
|
||||
for repository, commit := range v.CarriedFrom {
|
||||
now, inTrunk := v.Trunk[repository]
|
||||
if !inTrunk {
|
||||
now = v.Beside[repository]
|
||||
}
|
||||
if commit == "" || now == "" {
|
||||
return fmt.Errorf(who+"the verdict's carried-from names %s, which it judged on no commit of", repository)
|
||||
}
|
||||
moved = moved || commit != now
|
||||
}
|
||||
if !moved {
|
||||
return fmt.Errorf(who + "the verdict's carried-from names the commits it is judged on: nothing moved, so nothing was carried")
|
||||
}
|
||||
}
|
||||
changed := map[string]bool{}
|
||||
for _, c := range v.Series {
|
||||
if c.Module == "" || c.Artifact == "" || c.From == "" || c.To == "" {
|
||||
return fmt.Errorf(who+"the verdict's series change %+v names no module, artifact, from or to", c)
|
||||
}
|
||||
if c.From == c.To {
|
||||
return fmt.Errorf(who+"the verdict's series change of %s/%s is from %s to the same series", c.Module, c.Artifact, c.From)
|
||||
}
|
||||
if changed[c.Module+"/"+c.Artifact] {
|
||||
return fmt.Errorf(who+"the verdict names the series change of %s/%s twice", c.Module, c.Artifact)
|
||||
}
|
||||
changed[c.Module+"/"+c.Artifact] = true
|
||||
}
|
||||
for level, r := range v.Levels {
|
||||
if err := checkLevel(level); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Run < 0 || r.Kept < 0 || r.Skipped < 0 {
|
||||
return fmt.Errorf(who+"the verdict's %s level counts a negative number of tests", level)
|
||||
}
|
||||
}
|
||||
if err := checkComposition(v.Composition); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkJudgedBy(v.JudgedBy); err != nil {
|
||||
return err
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, level := range v.OverBound {
|
||||
if err := checkLevel(level); err != nil {
|
||||
return fmt.Errorf(who+"the verdict's over-bound names: %w", err)
|
||||
}
|
||||
if seen[level] {
|
||||
return fmt.Errorf(who+"the verdict's over-bound names the level %s twice", level)
|
||||
}
|
||||
seen[level] = true
|
||||
}
|
||||
if t := v.Took; t != nil {
|
||||
for part, ms := range map[string]int64{"queue": t.Queue, "clone": t.Clone, "unit": t.Unit, "lint": t.Lint,
|
||||
"integration-setup": t.IntegrationSetup, "integration-run": t.IntegrationRun, "composition": t.Composition} {
|
||||
if ms < 0 {
|
||||
return fmt.Errorf(who+"the verdict's time of the part %s is negative", part)
|
||||
}
|
||||
}
|
||||
}
|
||||
named := v.Failed != nil && (v.Failed.Test != "" || v.Failed.Machine != "")
|
||||
if len(v.Failures) > 0 && v.State != VerdictFail {
|
||||
return fmt.Errorf(who+"a %s verdict names no failures", v.State)
|
||||
}
|
||||
if len(v.Failures) > MaxFailures+1 {
|
||||
return fmt.Errorf(who+"the verdict names %d failures, more than %d and the count of the rest", len(v.Failures), MaxFailures)
|
||||
}
|
||||
switch v.State {
|
||||
case VerdictRunning:
|
||||
if v.Failed != nil && *v.Failed != (checker.VerdictsByGroupHeadsValueFailed{}) {
|
||||
return fmt.Errorf(who + "a running verdict names no failure")
|
||||
}
|
||||
case VerdictPass:
|
||||
if v.Failed != nil && *v.Failed != (checker.VerdictsByGroupHeadsValueFailed{}) {
|
||||
return fmt.Errorf(who + "a pass names no failure")
|
||||
}
|
||||
for _, level := range []string{LevelUnit, LevelIntegration} {
|
||||
if _, ok := v.Levels[level]; !ok {
|
||||
return fmt.Errorf(who+"a pass says nothing of the %s level", level)
|
||||
}
|
||||
}
|
||||
case VerdictFail:
|
||||
if !named {
|
||||
return fmt.Errorf(who + "a fail names neither a test nor a machine")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf(who+"the verdict state %q is not running, pass or fail", v.State)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckKept refuses a kept verdict that is not a pass of a repository's package at a level, with its toolchain and its time:
|
||||
// a failure is never kept.
|
||||
func CheckKept(k checker.KeptByLevelDigestValue) error {
|
||||
const who = "meshdeliverycheckerclient: "
|
||||
if k.State != VerdictPass {
|
||||
return fmt.Errorf(who+"a kept verdict is a pass, never %q: a failure is never kept", k.State)
|
||||
}
|
||||
if err := CheckRepository(k.Repository); err != nil {
|
||||
return err
|
||||
}
|
||||
if k.Package == "" {
|
||||
return fmt.Errorf(who + "a kept verdict names no package")
|
||||
}
|
||||
if err := checkLevel(k.Level); err != nil {
|
||||
return err
|
||||
}
|
||||
if k.Tests < 0 || k.Took < 0 {
|
||||
return fmt.Errorf(who + "a kept verdict counts a negative number of tests or a negative time")
|
||||
}
|
||||
if k.Toolchain == "" {
|
||||
return fmt.Errorf(who + "a kept verdict names no toolchain version")
|
||||
}
|
||||
if k.At == "" {
|
||||
return fmt.Errorf(who + "a kept verdict says no time")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckPreview refuses a preview a reader could not place (the checker writes it, the indexer reads it for the candidates'
|
||||
// fingerprints): a repository, head or trunk commit that does not key, a head in conflict that names no file or has a merge
|
||||
// commit or modules, a head that merged and names no merge commit, and a module with no directory, no tree, a manifest
|
||||
// digest that is not 64 lowercase hex digits, a lock without path or hash, or a named path that is not clean and inside the
|
||||
// module's directory or names no git object.
|
||||
func CheckPreview(p checker.PreviewsByRepositoryHeadTrunkValue) error {
|
||||
const who = "meshdeliverycheckerclient: "
|
||||
if err := CheckRepository(p.Repository); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := keys.CheckName("head", p.Head); err != nil {
|
||||
return fmt.Errorf(who+"the preview: %w", err)
|
||||
}
|
||||
if err := keys.CheckName("trunk commit", p.Trunk); err != nil {
|
||||
return fmt.Errorf(who+"the preview: %w", err)
|
||||
}
|
||||
for _, f := range p.Conflicts {
|
||||
if f == "" {
|
||||
return fmt.Errorf(who + "a preview names a conflicting file with an empty path")
|
||||
}
|
||||
}
|
||||
if len(p.Conflicts) > 0 {
|
||||
if p.Merge != "" || len(p.Modules) > 0 {
|
||||
return fmt.Errorf(who + "a preview of a head in conflict has no merge commit and no modules")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if p.Merge == "" {
|
||||
return fmt.Errorf(who + "a preview names no merge commit")
|
||||
}
|
||||
for dir, m := range p.Modules {
|
||||
if dir == "" {
|
||||
return fmt.Errorf(who + "a preview names a module with an empty directory")
|
||||
}
|
||||
if m.Tree == "" {
|
||||
return fmt.Errorf(who+"the preview's module %q has no tree", dir)
|
||||
}
|
||||
if !keys.IsHex64(m.Manifest) {
|
||||
return fmt.Errorf(who+"the preview's module %q: %q is not a manifest digest, 64 lowercase hex digits", dir, m.Manifest)
|
||||
}
|
||||
for path, hash := range m.Locks {
|
||||
if path == "" || hash == "" {
|
||||
return fmt.Errorf(who+"the lock %q of the preview's module %q has an empty path or hash", path, dir)
|
||||
}
|
||||
}
|
||||
for p, object := range m.Paths {
|
||||
if p == "" || p != pathpkg.Clean(p) || strings.HasPrefix(p, "/") || p == ".." || strings.HasPrefix(p, "../") {
|
||||
return fmt.Errorf(who+"the preview's module %q: the named path %q is not a clean path inside the module's directory", dir, p)
|
||||
}
|
||||
if object == "" {
|
||||
return fmt.Errorf(who+"the preview's module %q: the named path %q names no git object", dir, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// VerdictKey is the key, in the state verdicts, of a group's check at its heads: `<escaped group>.<heads hash>`, the
|
||||
// group escaped so a branch such as `fix/1.2` keys, the heads hash as the mesh-delivery client's HeadsHash gives it
|
||||
// (12 lowercase hex digits).
|
||||
func VerdictKey(group, headsHash string) (string, error) {
|
||||
if group == "" {
|
||||
return "", fmt.Errorf("meshdeliverycheckerclient: the group name is empty")
|
||||
}
|
||||
if !isHex12(headsHash) {
|
||||
return "", fmt.Errorf("meshdeliverycheckerclient: %q is not a heads hash, 12 lowercase hex digits", headsHash)
|
||||
}
|
||||
return keys.EscapeName(group) + "." + headsHash, nil
|
||||
}
|
||||
|
||||
// ParseVerdictKey is the inverse of VerdictKey.
|
||||
func ParseVerdictKey(key string) (group, headsHash string, err error) {
|
||||
i := strings.LastIndex(key, ".")
|
||||
if i < 0 {
|
||||
return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key, <group>.<heads hash>", key)
|
||||
}
|
||||
part, headsHash := key[:i], key[i+1:]
|
||||
if !isHex12(headsHash) {
|
||||
return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: %q is not a heads hash, 12 lowercase hex digits", key, headsHash)
|
||||
}
|
||||
if part == "" || strings.Contains(part, ".") {
|
||||
return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: the group part is empty or holds a dot", key)
|
||||
}
|
||||
if group, err = keys.UnescapeName(part); err != nil {
|
||||
return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: %w", key, err)
|
||||
}
|
||||
return group, headsHash, nil
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
package meshdeliverycheckerclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker"
|
||||
)
|
||||
|
||||
type verdict = checker.VerdictsByGroupHeadsValue
|
||||
|
||||
func passing() verdict {
|
||||
return verdict{Group: "g", Heads: "0123456789ab", State: VerdictPass, Trunk: map[string]string{"novox/a": "c1"},
|
||||
Levels: map[string]checker.VerdictsByGroupHeadsValueLevelsValue{LevelUnit: {Run: 3}, LevelIntegration: {Run: 1}}}
|
||||
}
|
||||
|
||||
// The rules a verdict keeps to be written or read: each case edits a passing verdict and names what the refusal says.
|
||||
func TestAVerdictIsRefusedForWhatAReaderCouldNotPlace(t *testing.T) {
|
||||
if err := CheckVerdict(passing()); err != nil {
|
||||
t.Fatalf("a passing verdict is refused: %v", err)
|
||||
}
|
||||
for name, c := range map[string]struct {
|
||||
edit func(*verdict)
|
||||
says string
|
||||
}{
|
||||
"no group": {func(v *verdict) { v.Group = "" }, "no group"},
|
||||
"heads of 11 digits": {func(v *verdict) { v.Heads = "0123456789a" }, "12 lowercase hex"},
|
||||
"an empty trunk head": {func(v *verdict) { v.Trunk["novox/a"] = "" }, "trunk head"},
|
||||
"merged and read": {func(v *verdict) { v.Beside = map[string]string{"novox/a": "c2"} }, "trunk it merged and as a sibling"},
|
||||
"nothing carried": {func(v *verdict) { v.CarriedFrom = map[string]string{"novox/a": "c1"} }, "nothing moved"},
|
||||
"a running carry": {func(v *verdict) { v.State, v.CarriedFrom = VerdictRunning, map[string]string{"novox/a": "c0"} }, "carried from nothing"},
|
||||
"a series to itself": {func(v *verdict) {
|
||||
v.Series = []checker.VerdictsByGroupHeadsValueSeriesItem{{Module: "m", Artifact: "a", From: "0.1", To: "0.1"}}
|
||||
}, "same series"},
|
||||
"an unknown level": {func(v *verdict) { v.Levels["smoke"] = checker.VerdictsByGroupHeadsValueLevelsValue{} }, "smoke"},
|
||||
"a negative count": {func(v *verdict) { v.Levels[LevelUnit] = checker.VerdictsByGroupHeadsValueLevelsValue{Run: -1} }, "negative"},
|
||||
"a negative time": {func(v *verdict) { v.Took = &checker.VerdictsByGroupHeadsValueTook{Unit: -1} }, "negative"},
|
||||
"a pass without a level": {func(v *verdict) { delete(v.Levels, LevelIntegration) }, "integration level"},
|
||||
"a pass that failed": {func(v *verdict) { v.Failed = &checker.VerdictsByGroupHeadsValueFailed{Test: "T"} }, "names no failure"},
|
||||
"failures of a pass": {func(v *verdict) { v.Failures = []checker.VerdictsByGroupHeadsValueFailuresItem{{Test: "T"}} }, "names no failures"},
|
||||
"a fail naming nothing": {func(v *verdict) { v.State = VerdictFail }, "neither a test nor a machine"},
|
||||
"an unknown state": {func(v *verdict) { v.State = "maybe" }, "maybe"},
|
||||
"a composition passed without a commit": {func(v *verdict) {
|
||||
v.Composition = &checker.VerdictsByGroupHeadsValueComposition{State: CompositionPass}
|
||||
}, "mesh-sdk commit"},
|
||||
"the same level over bound twice": {func(v *verdict) { v.OverBound = []string{LevelUnit, LevelUnit} }, "twice"},
|
||||
// 1921 (B0, G): the checking program that judged it.
|
||||
"judged at no full commit": {func(v *verdict) { j := judgedBy(); j.Program.Commit = "0123456"; v.JudgedBy = &j }, "checking program built at no repository, full commit"},
|
||||
"judged under no key": {func(v *verdict) { j := judgedBy(); j.Key = "composer-1"; v.JudgedBy = &j }, "composer-1"},
|
||||
"judged over no head": {func(v *verdict) { j := judgedBy(); j.Heads = nil; v.JudgedBy = &j }, "no head"},
|
||||
"judged over a branch": {func(v *verdict) { j := judgedBy(); j.Heads[0].Commit = "main"; v.JudgedBy = &j }, "novox/mesh-delivery"},
|
||||
} {
|
||||
v := passing()
|
||||
c.edit(&v)
|
||||
if err := CheckVerdict(v); err == nil || !strings.Contains(err.Error(), c.says) {
|
||||
t.Errorf("%s: %v, want a refusal saying %q", name, err, c.says)
|
||||
}
|
||||
}
|
||||
judged := passing()
|
||||
j := judgedBy()
|
||||
judged.JudgedBy = &j
|
||||
if err := CheckVerdict(judged); err != nil {
|
||||
t.Errorf("a pass judged by a checking program is refused: %v", err)
|
||||
}
|
||||
failed := passing()
|
||||
failed.State, failed.Failed = VerdictFail, &checker.VerdictsByGroupHeadsValueFailed{Machine: "ace"}
|
||||
if err := CheckVerdict(failed); err != nil {
|
||||
t.Errorf("a fail naming a machine is refused: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAKeptVerdictIsAPassOfAPackageAtALevel(t *testing.T) {
|
||||
t.Run("a preview is refused for what a reader of candidates could not place", previewIsRefused)
|
||||
ok := checker.KeptByLevelDigestValue{State: VerdictPass, Repository: "novox/mesh-sdk", Package: "./go/keys", Level: LevelUnit, Toolchain: "1.26.0", At: "2026-11-05T10:00:00Z"}
|
||||
if err := CheckKept(ok); err != nil {
|
||||
t.Fatalf("a kept pass is refused: %v", err)
|
||||
}
|
||||
for name, edit := range map[string]func(*checker.KeptByLevelDigestValue){
|
||||
"a fail": func(k *checker.KeptByLevelDigestValue) { k.State = VerdictFail },
|
||||
"no owner": func(k *checker.KeptByLevelDigestValue) { k.Repository = "mesh-sdk" },
|
||||
"no package": func(k *checker.KeptByLevelDigestValue) { k.Package = "" },
|
||||
"an unknown level": func(k *checker.KeptByLevelDigestValue) { k.Level = "smoke" },
|
||||
"negative tests": func(k *checker.KeptByLevelDigestValue) { k.Tests = -1 },
|
||||
"no toolchain": func(k *checker.KeptByLevelDigestValue) { k.Toolchain = "" },
|
||||
"no time": func(k *checker.KeptByLevelDigestValue) { k.At = "" },
|
||||
} {
|
||||
k := ok
|
||||
edit(&k)
|
||||
if CheckKept(k) == nil {
|
||||
t.Errorf("%s was taken", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A preview is refused for what a reader of candidates could not place.
|
||||
func previewIsRefused(t *testing.T) {
|
||||
good := func() checker.PreviewsByRepositoryHeadTrunkValue {
|
||||
return checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h1", Trunk: "t1", Merge: "m1",
|
||||
Modules: map[string]checker.PreviewsByRepositoryHeadTrunkValueModulesValue{"mod": {Tree: "tr", Manifest: strings.Repeat("a", 64),
|
||||
Locks: map[string]string{"go.sum": "x"}, Paths: map[string]string{"src": "o1"}}}}
|
||||
}
|
||||
if err := CheckPreview(good()); err != nil {
|
||||
t.Fatalf("a good preview is refused: %v", err)
|
||||
}
|
||||
for name, c := range map[string]struct {
|
||||
edit func(*checker.PreviewsByRepositoryHeadTrunkValue)
|
||||
says string
|
||||
}{
|
||||
"a repository with no owner": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Repository = "a" }, "<owner>/<name>"},
|
||||
"a head with a dot": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Head = "h.1" }, "head"},
|
||||
"a conflict with a merge": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Conflicts = []string{"f"} }, "in conflict"},
|
||||
"no merge commit": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Merge = "" }, "no merge commit"},
|
||||
"a module with no tree": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) {
|
||||
m := p.Modules["mod"]
|
||||
m.Tree = ""
|
||||
p.Modules["mod"] = m
|
||||
}, "no tree"},
|
||||
"a short manifest digest": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) {
|
||||
m := p.Modules["mod"]
|
||||
m.Manifest = "abc"
|
||||
p.Modules["mod"] = m
|
||||
}, "manifest digest"},
|
||||
"a path outside the module": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) {
|
||||
m := p.Modules["mod"]
|
||||
m.Paths = map[string]string{"../x": "o"}
|
||||
p.Modules["mod"] = m
|
||||
}, "clean path"},
|
||||
} {
|
||||
p := good()
|
||||
c.edit(&p)
|
||||
if err := CheckPreview(p); err == nil || !strings.Contains(err.Error(), c.says) {
|
||||
t.Errorf("%s: CheckPreview = %v, want it to say %q", name, err, c.says)
|
||||
}
|
||||
}
|
||||
if err := CheckPreview(checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h", Trunk: "t", Conflicts: []string{"f"}}); err != nil {
|
||||
t.Errorf("a head in conflict is refused: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A verdict's key as go/delivery's CheckerVerdictKey wrote it (golden): the group escaped, the heads hash after the
|
||||
// last dot.
|
||||
func TestVerdictKeyAsGoDeliveryWroteIt(t *testing.T) {
|
||||
key, err := VerdictKey("fix/1.2", "0123456789ab")
|
||||
if err != nil || key != "fix/1=2e2.0123456789ab" {
|
||||
t.Fatalf("%q %v", key, err)
|
||||
}
|
||||
group, heads, err := ParseVerdictKey(key)
|
||||
if err != nil || group != "fix/1.2" || heads != "0123456789ab" {
|
||||
t.Fatalf("%q %q %v", group, heads, err)
|
||||
}
|
||||
for _, bad := range []string{"nodot", "g.XYZ", ".0123456789ab", "a.b.0123456789ab", "g=zz.0123456789ab"} {
|
||||
if _, _, err := ParseVerdictKey(bad); err == nil {
|
||||
t.Errorf("%q parses", bad)
|
||||
}
|
||||
}
|
||||
if _, err := VerdictKey("", "0123456789ab"); err == nil {
|
||||
t.Error("an empty group keys")
|
||||
}
|
||||
if _, err := VerdictKey("g", "0123"); err == nil {
|
||||
t.Error("a short hash keys")
|
||||
}
|
||||
}
|
||||
|
||||
// The codecs write a value at the kept values' version after its rules and read it back through them.
|
||||
func TestTheCodecsWriteAtTheVersionAndReadBackThroughTheRules(t *testing.T) {
|
||||
raw, err := EncodeVerdict(passing())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, err := DecodeVerdict(raw); err != nil || got.V == 0 || got.Group != "g" {
|
||||
t.Errorf("verdict read back = %+v, %v", got, err)
|
||||
}
|
||||
bad := passing()
|
||||
bad.Heads = "x"
|
||||
if _, err := EncodeVerdict(bad); err == nil {
|
||||
t.Error("a verdict whose heads are no hash is written")
|
||||
}
|
||||
if _, err := DecodeVerdict([]byte(`{"v":99,"group":"g","heads":"0123456789ab","state":"running"}`)); err == nil {
|
||||
t.Error("a verdict of an unknown version is read")
|
||||
}
|
||||
k := checker.KeptByLevelDigestValue{State: VerdictPass, Repository: "novox/mesh-sdk", Package: "./go/keys", Level: LevelUnit, Toolchain: "1.26.0", At: "2026-11-05T10:00:00Z"}
|
||||
raw, err = EncodeKept(k)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, err := DecodeKept(raw); err != nil || got.Package != k.Package {
|
||||
t.Errorf("kept read back = %+v, %v", got, err)
|
||||
}
|
||||
k.State = VerdictFail
|
||||
if _, err := EncodeKept(k); err == nil {
|
||||
t.Error("a failure is kept")
|
||||
}
|
||||
p := checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h1", Trunk: "t1", Conflicts: []string{"f.go"}}
|
||||
raw, err = EncodePreview(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, err := DecodePreview(raw); err != nil || got.Head != "h1" {
|
||||
t.Errorf("preview read back = %+v, %v", got, err)
|
||||
}
|
||||
p.Conflicts = nil
|
||||
if _, err := EncodePreview(p); err == nil {
|
||||
t.Error("a preview with no merge commit and no conflict is written")
|
||||
}
|
||||
// 1921 (B0, G): a checking program's input is asked of the seat's verb input by its digest, and an answer for
|
||||
// another digest, or bytes that are not the digest, is refused.
|
||||
body := []byte(`{"v":1}`)
|
||||
digest := DigestOf(body)
|
||||
for name, c := range map[string]struct {
|
||||
answer any
|
||||
says string
|
||||
}{
|
||||
"its own bytes": {InputAnswerOf(body), ""},
|
||||
"another digest": {checker.InputAnswer{Digest: DigestOf([]byte("x")), Input: InputAnswerOf(body).Input}, "answered the input"},
|
||||
"bytes that are not it": {checker.InputAnswer{Digest: digest, Input: InputAnswerOf([]byte(`{"v":2}`)).Input}, "whose digest is"},
|
||||
"bytes in no base64": {checker.InputAnswer{Digest: digest, Input: "%%"}, "no base64"},
|
||||
"no answer of the layout": {"nothing", "answered no input"},
|
||||
} {
|
||||
got, err := ReadInput(func(key string, b any) (json.RawMessage, error) {
|
||||
if key != "seat:mesh-delivery-checker.input" || b != (checker.InputInput{Digest: digest}) {
|
||||
t.Errorf("%s: asked %s %+v", name, key, b)
|
||||
}
|
||||
return json.Marshal(c.answer)
|
||||
}, digest)
|
||||
switch {
|
||||
case c.says == "" && (err != nil || string(got) != string(body)):
|
||||
t.Errorf("%s: %q, %v", name, got, err)
|
||||
case c.says != "" && (err == nil || !strings.Contains(err.Error(), c.says)):
|
||||
t.Errorf("%s: %v, want a refusal saying %q", name, err, c.says)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The kept and preview keys: a key reads back to its parts, and a part that does not key is refused.
|
||||
func TestKeptAndPreviewKeysReadBack(t *testing.T) {
|
||||
digest := strings.Repeat("ab", 32)
|
||||
key, err := KeptKey(LevelUnit, digest)
|
||||
if err != nil || key != "unit."+digest {
|
||||
t.Fatalf("kept key = %q, %v", key, err)
|
||||
}
|
||||
if level, d, err := ParseKeptKey(key); err != nil || level != LevelUnit || d != digest {
|
||||
t.Errorf("kept key read back = %q %q, %v", level, d, err)
|
||||
}
|
||||
for _, bad := range []string{"fast." + digest, "unit.XY", "unit"} {
|
||||
if _, _, err := ParseKeptKey(bad); err == nil {
|
||||
t.Errorf("kept key %q is read", bad)
|
||||
}
|
||||
}
|
||||
key, err = PreviewKey("novox/mesh-sdk", "h1", "t1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if repo, h, tr, err := ParsePreviewKey(key); err != nil || repo != "novox/mesh-sdk" || h != "h1" || tr != "t1" {
|
||||
t.Errorf("preview key %q read back = %q %q %q, %v", key, repo, h, tr, err)
|
||||
}
|
||||
for _, bad := range []string{"novox.h1.t1", "a/b.h1", "a/b.h1.t1.x"} {
|
||||
if _, _, _, err := ParsePreviewKey(bad); err == nil {
|
||||
t.Errorf("preview key %q is read", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func judgedBy() checker.VerdictsByGroupHeadsValueJudgedBy {
|
||||
const c = "0123456789abcdef0123456789abcdef01234567"
|
||||
return checker.VerdictsByGroupHeadsValueJudgedBy{
|
||||
Program: checker.VerdictsByGroupHeadsValueJudgedByProgram{Repository: "novox/mesh-delivery", Commit: c, Dir: "modules/mesh-delivery-checker", Package: "p"},
|
||||
Key: "program-0123456789abcdef", Built: true, Heads: []checker.VerdictsByGroupHeadsValueJudgedByHeadsItem{{Repository: "novox/mesh-delivery", Commit: c}}}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package meshdeliverycheckerclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// The codecs of the three states the checker writes and others read (the view and the gate read verdicts, the indexer reads
|
||||
// previews, the checker and the tools read kept verdicts): a value is written at the version of the kept values after its rules
|
||||
// (CheckVerdict, CheckKept, CheckPreview) and read back through the same rules. The checker's owed state is read by no other
|
||||
// part and keeps its own codec.
|
||||
|
||||
// EncodeVerdict is v as JSON at the kept values' version, refused by CheckVerdict's rules.
|
||||
func EncodeVerdict(v checker.VerdictsByGroupHeadsValue) ([]byte, error) {
|
||||
if err := CheckVerdict(v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v.V = keys.Version
|
||||
return json.Marshal(v)
|
||||
}
|
||||
|
||||
// DecodeVerdict reads a `verdicts` value; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeVerdict refuses.
|
||||
func DecodeVerdict(data []byte) (checker.VerdictsByGroupHeadsValue, error) {
|
||||
var v checker.VerdictsByGroupHeadsValue
|
||||
if err := decode(data, &v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if err := CheckVerdict(v); err != nil {
|
||||
return checker.VerdictsByGroupHeadsValue{}, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// EncodeKept is k as JSON at the kept values' version, refused by CheckKept's rules.
|
||||
func EncodeKept(k checker.KeptByLevelDigestValue) ([]byte, error) {
|
||||
if err := CheckKept(k); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
k.V = keys.Version
|
||||
return json.Marshal(k)
|
||||
}
|
||||
|
||||
// DecodeKept reads a `kept` value; it refuses an unknown version and what EncodeKept refuses.
|
||||
func DecodeKept(data []byte) (checker.KeptByLevelDigestValue, error) {
|
||||
var k checker.KeptByLevelDigestValue
|
||||
if err := decode(data, &k); err != nil {
|
||||
return k, err
|
||||
}
|
||||
if err := CheckKept(k); err != nil {
|
||||
return checker.KeptByLevelDigestValue{}, err
|
||||
}
|
||||
return k, nil
|
||||
}
|
||||
|
||||
// EncodePreview is p as JSON at the kept values' version, refused by CheckPreview's rules.
|
||||
func EncodePreview(p checker.PreviewsByRepositoryHeadTrunkValue) ([]byte, error) {
|
||||
if err := CheckPreview(p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.V = keys.Version
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
// DecodePreview reads a `previews` value; it refuses an unknown version and what EncodePreview refuses.
|
||||
func DecodePreview(data []byte) (checker.PreviewsByRepositoryHeadTrunkValue, error) {
|
||||
var p checker.PreviewsByRepositoryHeadTrunkValue
|
||||
if err := decode(data, &p); err != nil {
|
||||
return p, err
|
||||
}
|
||||
if err := CheckPreview(p); err != nil {
|
||||
return checker.PreviewsByRepositoryHeadTrunkValue{}, err
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func decode(data []byte, into any) error {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(data, into); err != nil {
|
||||
return fmt.Errorf("meshdeliverycheckerclient: value does not fit its shape: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// KeptKey is the key, in the state kept, of a kept verdict: `<level>.<digest>`, the level unit or integration and the digest,
|
||||
// lowercase hex, of everything that package's tests read at that level as the language's build module names it.
|
||||
func KeptKey(level, digest string) (string, error) {
|
||||
if err := checkLevel(level); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if digest == "" || strings.Trim(digest, "0123456789abcdef") != "" {
|
||||
return "", fmt.Errorf("meshdeliverycheckerclient: %q is not a digest, lowercase hex", digest)
|
||||
}
|
||||
return checker.KeptByLevelDigestKey(level, digest), nil
|
||||
}
|
||||
|
||||
// ParseKeptKey is the inverse of KeptKey.
|
||||
func ParseKeptKey(key string) (level, digest string, err error) {
|
||||
level, digest, ok := checker.ParseKeptByLevelDigestKey(key)
|
||||
if !ok {
|
||||
return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a kept key, <level>.<digest>", key)
|
||||
}
|
||||
if _, err = KeptKey(level, digest); err != nil {
|
||||
return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a kept key: %w", key, err)
|
||||
}
|
||||
return level, digest, nil
|
||||
}
|
||||
|
||||
// PreviewKey is the key, in the state previews, of a head merged onto a trunk commit: `<repository>.<head>.<trunk>`, the
|
||||
// repository's owner and name each escaped (keys.EscapeName).
|
||||
func PreviewKey(repository, head, trunk string) (string, error) {
|
||||
if err := CheckRepository(repository); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := keys.CheckName("head", head); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := keys.CheckName("trunk commit", trunk); err != nil {
|
||||
return "", err
|
||||
}
|
||||
owner, name, _ := strings.Cut(repository, "/")
|
||||
return checker.PreviewsByRepositoryHeadTrunkKey(keys.EscapeName(owner)+"/"+keys.EscapeName(name), head, trunk), nil
|
||||
}
|
||||
|
||||
// ParsePreviewKey is the inverse of PreviewKey.
|
||||
func ParsePreviewKey(key string) (repository, head, trunk string, err error) {
|
||||
repo, head, trunk, ok := checker.ParsePreviewsByRepositoryHeadTrunkKey(key)
|
||||
if !ok || strings.Contains(trunk, ".") {
|
||||
return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key, <repository>.<head>.<trunk>", key)
|
||||
}
|
||||
owner, name, found := strings.Cut(repo, "/")
|
||||
if !found {
|
||||
return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: the repository has no slash", key)
|
||||
}
|
||||
owner, err1 := keys.UnescapeName(owner)
|
||||
name, err2 := keys.UnescapeName(name)
|
||||
if err1 != nil || err2 != nil {
|
||||
return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: the repository does not unescape", key)
|
||||
}
|
||||
repository = owner + "/" + name
|
||||
if _, err := PreviewKey(repository, head, trunk); err != nil {
|
||||
return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: %w", key, err)
|
||||
}
|
||||
return repository, head, trunk, nil
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshdeliverycheckerclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
@@ -1,53 +0,0 @@
|
||||
package meshdeliverycheckerclient
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker"
|
||||
)
|
||||
|
||||
// InputVerb is the seat's verb input as a manifest's `invokes` names it and a run ask's input names it: asked of the
|
||||
// seat, on no one machine (novox/hq ADR 0644, ADR 0656; issue 1921). A checking program's input is kept by the checker
|
||||
// by the sha256 of its exact bytes, and asked of it by the build module that runs the program (ADR 0596 §2).
|
||||
const InputVerb = "seat:" + checker.Seat + "." + checker.VerbInput
|
||||
|
||||
// InputAnswerOf is the verb input's answer for body: its digest and its exact bytes, base64.
|
||||
func InputAnswerOf(body []byte) checker.InputAnswer {
|
||||
return checker.InputAnswer{Digest: DigestOf(body), Input: base64.StdEncoding.EncodeToString(body)}
|
||||
}
|
||||
|
||||
// DigestOf is the digest a checking program's input is kept and asked by: the sha256 of its bytes, 64 lowercase hex
|
||||
// digits.
|
||||
func DigestOf(body []byte) string {
|
||||
sum := sha256.Sum256(body)
|
||||
return hex.EncodeToString(sum[:])
|
||||
}
|
||||
|
||||
// ReadInput asks the verb input, with ask (a tools bundle's stdio.Ask, a process's Conn.Call), for the input kept by
|
||||
// digest and answers its bytes, refusing an answer for another digest and bytes whose sha256 is not the digest.
|
||||
func ReadInput(ask func(key string, body any) (json.RawMessage, error), digest string) ([]byte, error) {
|
||||
const who = "meshdeliverycheckerclient: "
|
||||
raw, err := ask(InputVerb, checker.InputInput{Digest: digest})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(who+"asking %s for the input %s: %w", InputVerb, digest, err)
|
||||
}
|
||||
var a checker.InputAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return nil, fmt.Errorf(who+"%s answered no input for %s: %w", InputVerb, digest, err)
|
||||
}
|
||||
if a.Digest != digest {
|
||||
return nil, fmt.Errorf(who+"%s answered the input %q, asked %s", InputVerb, a.Digest, digest)
|
||||
}
|
||||
body, err := base64.StdEncoding.DecodeString(a.Input)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(who+"%s answered the input %s in no base64: %w", InputVerb, digest, err)
|
||||
}
|
||||
if got := DigestOf(body); got != digest {
|
||||
return nil, fmt.Errorf(who+"the input %s answered %d bytes whose digest is %s", digest, len(body), got)
|
||||
}
|
||||
return body, nil
|
||||
}
|
||||
@@ -1,304 +0,0 @@
|
||||
// Package meshdeliveryclient holds the logic the holders and callers of the seat mesh-delivery share over its contract
|
||||
// (novox/hq ADR 0625 §4, ADR 0634 §2, ADR 0635 §5): the keys of its states `merges`, `asks` and `owed` and the rules their
|
||||
// values keep, the id the teller gives the router for an ask, and the act an ask's options bind. The gate writes them, the
|
||||
// forge bridge, the teller and the assigner read them; the contract's decoding is strict by schema only, so these rules are
|
||||
// written once here and no caller copies them.
|
||||
package meshdeliveryclient
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// AskKindMerge is the kind of the gate's ask for a group's merge, the first part of its key.
|
||||
const AskKindMerge = "merge"
|
||||
|
||||
// VerbMerge is the act an ask for a group's merge binds in its options, `mesh-delivery.merge` (Approve).
|
||||
const VerbMerge = "merge"
|
||||
|
||||
// Head is one pull request at one commit: the repository as `<owner>/<name>` and the full sha.
|
||||
type Head struct {
|
||||
Repository string `json:"repository"`
|
||||
Number int `json:"number"`
|
||||
Head string `json:"head"`
|
||||
}
|
||||
|
||||
// HeadsHash is the first 12 hex digits of the sha256 over the lines `<repository>#<number>=<head>`, sorted and joined by a
|
||||
// newline: the same for every order of heads, different when any head changes. An empty list is refused.
|
||||
func HeadsHash(heads []Head) (string, error) {
|
||||
if len(heads) == 0 {
|
||||
return "", fmt.Errorf("meshdeliveryclient: a heads hash needs at least one pull request")
|
||||
}
|
||||
lines := make([]string, len(heads))
|
||||
for i, h := range heads {
|
||||
lines[i] = fmt.Sprintf("%s#%d=%s", h.Repository, h.Number, h.Head)
|
||||
}
|
||||
sort.Strings(lines)
|
||||
sum := sha256.Sum256([]byte(strings.Join(lines, "\n")))
|
||||
return hex.EncodeToString(sum[:])[:12], nil
|
||||
}
|
||||
|
||||
var hashOK = regexp.MustCompile(`^[0-9a-f]{12}$`)
|
||||
|
||||
func groupKey(group string) (string, error) {
|
||||
if group == "" {
|
||||
return "", fmt.Errorf("meshdeliveryclient: the group name is empty")
|
||||
}
|
||||
return keys.EscapeName(group), nil
|
||||
}
|
||||
|
||||
// MergesKey is the key, in the state merges, of a group: `<group>`, escaped so a branch such as `fix/1.2` keys.
|
||||
func MergesKey(group string) (string, error) { return groupKey(group) }
|
||||
|
||||
// MergeAskKey is the key, in the state asks, of the ask for merging a group at these heads: `merge.<group>.<heads hash>`.
|
||||
// The teller's answer has the same key.
|
||||
func MergeAskKey(group string, heads []Head) (string, error) {
|
||||
part, err := groupKey(group)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
hash, err := HeadsHash(heads)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return AskKindMerge + "." + part + "." + hash, nil
|
||||
}
|
||||
|
||||
// ParseAskKey is the inverse of MergeAskKey: the kind, the group and the heads hash.
|
||||
func ParseAskKey(key string) (kind, group, hash string, err error) {
|
||||
parts := strings.Split(key, ".")
|
||||
if len(parts) != 3 || parts[0] != AskKindMerge {
|
||||
return "", "", "", fmt.Errorf("meshdeliveryclient: %q is not an ask key, merge.<group>.<heads hash>", key)
|
||||
}
|
||||
if parts[1] == "" {
|
||||
return "", "", "", fmt.Errorf("meshdeliveryclient: %q is not an ask key: the group name is empty", key)
|
||||
}
|
||||
if group, err = keys.UnescapeName(parts[1]); err != nil {
|
||||
return "", "", "", fmt.Errorf("meshdeliveryclient: %q is not an ask key: %w", key, err)
|
||||
}
|
||||
if !hashOK.MatchString(parts[2]) {
|
||||
return "", "", "", fmt.Errorf("meshdeliveryclient: %q is not an ask key: %q is not 12 hex digits", key, parts[2])
|
||||
}
|
||||
return parts[0], group, parts[2], nil
|
||||
}
|
||||
|
||||
// AskVerb is the act the options of an ask bind, `mesh-delivery.merge`; the settle ask went with the verb settle (design 47
|
||||
// G §431). The gate composes the act with it and the teller checks a warrant against it.
|
||||
func AskVerb(group string) string { return seat.Seat + "." + VerbMerge }
|
||||
|
||||
// AskID is the id the teller gives the router for the ask at askKey. The router's ids refuse dots, so in the readable part a
|
||||
// dot becomes `-` and any other byte outside letters, digits, `_` and `-` becomes `_`; that part is cut to fit, and every id
|
||||
// ends in `-` and the first 12 hex digits of the sha256 of the whole key, so two keys never give one id. It cannot be read
|
||||
// back: the teller keeps the key beside it.
|
||||
func AskID(askKey string) string {
|
||||
const most = 64 // the router's bound on an id
|
||||
const tail = 13 // "-" and 12 hex digits
|
||||
readable := []byte(askKey)
|
||||
for i, c := range readable {
|
||||
switch {
|
||||
case c >= 'A' && c <= 'Z', c >= 'a' && c <= 'z', c >= '0' && c <= '9':
|
||||
case c == '.':
|
||||
readable[i] = '-'
|
||||
default: // a slash, an equals sign or any other byte the router's id refuses
|
||||
readable[i] = '_'
|
||||
}
|
||||
}
|
||||
if len(readable) > 0 && (readable[0] == '-' || readable[0] == '_') {
|
||||
readable[0] = 'k' // an id starts with a letter or digit
|
||||
}
|
||||
if len(readable) > most-tail {
|
||||
readable = readable[:most-tail]
|
||||
}
|
||||
sum := sha256.Sum256([]byte(askKey))
|
||||
return string(readable) + "-" + hex.EncodeToString(sum[:])[:12]
|
||||
}
|
||||
|
||||
// AskingID is the id of the asking-th writing of the ask at askKey. Asking 0 and 1 give AskID(askKey), so the first asking's
|
||||
// id is unchanged; asking n of 2 or more gives the AskID form of askKey + "." + n, so each asking has an id of its own and the
|
||||
// router, which drops an ask under an id it keeps as a redelivery, takes each as new and an answer to an earlier asking is
|
||||
// never taken for a later one.
|
||||
func AskingID(askKey string, asking int) string {
|
||||
if asking < 2 {
|
||||
return AskID(askKey)
|
||||
}
|
||||
return AskID(askKey + "." + strconv.Itoa(asking))
|
||||
}
|
||||
|
||||
// The acts the gate owes the forge, the last part of an owed key.
|
||||
const (
|
||||
OwedStatus = "status"
|
||||
OwedView = "view"
|
||||
OwedNote = "note"
|
||||
OwedComment = "comment"
|
||||
)
|
||||
|
||||
// The status contexts the mesh owes the forge.
|
||||
const (
|
||||
StatusContextMergeGate = "mesh/merge-gate"
|
||||
StatusContextDelivery = "mesh/delivery"
|
||||
StatusContextDeliveryGroup = "mesh/delivery-group"
|
||||
StatusContextRepoCheck = "mesh/repo-check"
|
||||
StatusContextCheck = "mesh/check"
|
||||
)
|
||||
|
||||
var statusContexts = []string{StatusContextMergeGate, StatusContextDelivery, StatusContextDeliveryGroup, StatusContextRepoCheck, StatusContextCheck}
|
||||
|
||||
// StatusContexts is the contexts, in a new slice.
|
||||
func StatusContexts() []string { return append([]string(nil), statusContexts...) }
|
||||
|
||||
// The states a status the gate owes the forge may carry.
|
||||
var statusStates = []string{"pending", "success", "failure", "error", "warning"}
|
||||
|
||||
func checkStatusContext(context string) error {
|
||||
for _, c := range statusContexts {
|
||||
if context == c {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("meshdeliveryclient: the status context %q is not one of %s", context, strings.Join(statusContexts, ", "))
|
||||
}
|
||||
|
||||
// ParseOwedAct splits an owed act into its kind and, for a status, its context, for a comment its sequence as digits. The act
|
||||
// is `status=<context>`, `view`, `note` or `comment.<seq>`.
|
||||
func ParseOwedAct(act string) (kind, context string, err error) {
|
||||
kind, context, hasContext := strings.Cut(act, "=")
|
||||
switch kind {
|
||||
case OwedStatus:
|
||||
if !hasContext {
|
||||
return "", "", fmt.Errorf("meshdeliveryclient: the owed act %q is a status without its context, status=<context>", act)
|
||||
}
|
||||
if err := checkStatusContext(context); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return kind, context, nil
|
||||
case OwedView, OwedNote:
|
||||
if hasContext {
|
||||
return "", "", fmt.Errorf("meshdeliveryclient: the owed act %q takes no context", act)
|
||||
}
|
||||
return kind, "", nil
|
||||
}
|
||||
if kind, seq, ok := strings.Cut(act, "."); ok && kind == OwedComment {
|
||||
if n, err := strconv.Atoi(seq); err != nil || n < 1 || strconv.Itoa(n) != seq {
|
||||
return "", "", fmt.Errorf("meshdeliveryclient: the owed act %q is a comment without its sequence, comment.<seq> with seq of 1 or more", act)
|
||||
}
|
||||
return OwedComment, seq, nil
|
||||
}
|
||||
return "", "", fmt.Errorf("meshdeliveryclient: the owed act %q is not status=<context>, view, note or comment.<seq>", act)
|
||||
}
|
||||
|
||||
// OwedCommentAct is the act of the seq-th comment on a head: `comment.<seq>`, seq of 1 or more, so a second comment has a key
|
||||
// of its own and does not overwrite the first.
|
||||
func OwedCommentAct(seq int) (string, error) {
|
||||
if seq < 1 {
|
||||
return "", fmt.Errorf("meshdeliveryclient: a comment's sequence is 1 or more, not %d", seq)
|
||||
}
|
||||
return OwedComment + "." + strconv.Itoa(seq), nil
|
||||
}
|
||||
|
||||
func escapeRepository(repository string) (string, error) {
|
||||
owner, name, ok := strings.Cut(repository, "/")
|
||||
if !ok || owner == "" || name == "" || strings.Contains(name, "/") {
|
||||
return "", fmt.Errorf("meshdeliveryclient: the repository %q is not <owner>/<name>, with exactly one slash", repository)
|
||||
}
|
||||
return keys.EscapeName(owner) + "/" + keys.EscapeName(name), nil
|
||||
}
|
||||
|
||||
func unescapeRepository(part string) (string, error) {
|
||||
owner, name, ok := strings.Cut(part, "/")
|
||||
if !ok || owner == "" || name == "" || strings.Contains(name, "/") {
|
||||
return "", fmt.Errorf("meshdeliveryclient: the repository %q is not <owner>/<name>, with exactly one slash", part)
|
||||
}
|
||||
o, err := keys.UnescapeName(owner)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
n, err := keys.UnescapeName(name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return o + "/" + n, nil
|
||||
}
|
||||
|
||||
// OwedKey is the key, in the state owed, of an act the gate owes the forge on a pull request at a head:
|
||||
// `<repository>.<number>.<head>.<act>`. The number is 0 for a commit no pull request names, and never negative.
|
||||
func OwedKey(repository string, number int, head, act string) (string, error) {
|
||||
repo, err := escapeRepository(repository)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if number < 0 {
|
||||
return "", fmt.Errorf("meshdeliveryclient: an owed key's pull request number is 0 (none) or more, not %d", number)
|
||||
}
|
||||
if err := keys.CheckName("head", head); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if _, _, err := ParseOwedAct(act); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return repo + "." + strconv.Itoa(number) + "." + head + "." + act, nil
|
||||
}
|
||||
|
||||
// ParseOwedKey is the inverse of OwedKey; act is whole, as `status=<context>` for a status.
|
||||
func ParseOwedKey(key string) (repository string, number int, head, act string, err error) {
|
||||
parts := strings.SplitN(key, ".", 4) // a comment's act holds a dot
|
||||
if len(parts) != 4 {
|
||||
return "", 0, "", "", fmt.Errorf("meshdeliveryclient: %q is not an owed key, <repository>.<number>.<head>.<act>", key)
|
||||
}
|
||||
number, convErr := strconv.Atoi(parts[1])
|
||||
if convErr != nil {
|
||||
return "", 0, "", "", fmt.Errorf("meshdeliveryclient: %q is not an owed key: %q is not a pull request number", key, parts[1])
|
||||
}
|
||||
if repository, err = unescapeRepository(parts[0]); err != nil {
|
||||
return "", 0, "", "", fmt.Errorf("meshdeliveryclient: %q is not an owed key: %w", key, err)
|
||||
}
|
||||
if _, err := OwedKey(repository, number, parts[2], parts[3]); err != nil {
|
||||
return "", 0, "", "", fmt.Errorf("meshdeliveryclient: %q is not an owed key: %w", key, err)
|
||||
}
|
||||
return repository, number, parts[2], parts[3], nil
|
||||
}
|
||||
|
||||
// CheckOwed refuses an owed value the forge bridge could not perform: a status needs its context (one the mesh owes), a
|
||||
// state of the list and a target; a view and a comment need text; a note needs text and a ref.
|
||||
func CheckOwed(o seat.OwedByRepositoryNumberHeadActValue) error {
|
||||
const who = "meshdeliveryclient: "
|
||||
switch o.Act {
|
||||
case OwedStatus:
|
||||
if o.Context == "" {
|
||||
return fmt.Errorf(who + "an owed status has no context")
|
||||
}
|
||||
if err := checkStatusContext(o.Context); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.Target == "" {
|
||||
return fmt.Errorf(who + "an owed status has no target")
|
||||
}
|
||||
for _, s := range statusStates {
|
||||
if o.State == s {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf(who+"the owed status state %q is not %s", o.State, strings.Join(statusStates, ", "))
|
||||
case OwedView, OwedComment:
|
||||
if o.Text == "" {
|
||||
return fmt.Errorf(who+"an owed %s has no text", o.Act)
|
||||
}
|
||||
case OwedNote:
|
||||
if o.Text == "" {
|
||||
return fmt.Errorf(who + "an owed note has no text")
|
||||
}
|
||||
if o.Ref == "" {
|
||||
return fmt.Errorf(who + "an owed note has no ref")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf(who+"the owed act %q is not status, view, note or comment", o.Act)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package meshdeliveryclient
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery"
|
||||
)
|
||||
|
||||
// The keys, ids and acts equal what the gate and the teller have always written (the expected strings are the trunk's own
|
||||
// output for the same input), so a value written before is read after.
|
||||
func TestTheAsksAndOwedActsKeepTheirFormsAndRules(t *testing.T) {
|
||||
heads := []Head{{Repository: "novox/a", Number: 3, Head: "abc"}, {Repository: "novox/b", Number: 1, Head: "def"}}
|
||||
key, err := MergeAskKey("fix/1.2", heads)
|
||||
if err != nil || key != "merge.fix/1=2e2.d106c7950d28" {
|
||||
t.Fatalf("MergeAskKey = %q, %v", key, err)
|
||||
}
|
||||
if rev, _ := MergeAskKey("fix/1.2", []Head{heads[1], heads[0]}); rev != key {
|
||||
t.Errorf("the heads' order changes the key: %q", rev)
|
||||
}
|
||||
if kind, group, hash, err := ParseAskKey(key); err != nil || kind != "merge" || group != "fix/1.2" || hash != "d106c7950d28" {
|
||||
t.Errorf("ParseAskKey = %q %q %q %v", kind, group, hash, err)
|
||||
}
|
||||
for _, bad := range []string{"merge.g", "settle.g.d106c7950d28", "merge..d106c7950d28", "merge.g.D106C7950D28", "merge.g.d106"} {
|
||||
if _, _, _, err := ParseAskKey(bad); err == nil {
|
||||
t.Errorf("ParseAskKey(%q) reads a wrong key", bad)
|
||||
}
|
||||
}
|
||||
if _, err := MergeAskKey("", heads); err == nil {
|
||||
t.Error("an empty group keys")
|
||||
}
|
||||
if _, err := MergeAskKey("g", nil); err == nil {
|
||||
t.Error("no heads keys")
|
||||
}
|
||||
if id := AskID(key); id != "merge-fix_1_2e2-d106c7950d28-400030402c88" || AskingID(key, 1) != id || AskingID(key, 0) != id {
|
||||
t.Errorf("AskID = %q", id)
|
||||
}
|
||||
if id := AskingID(key, 3); id != "merge-fix_1_2e2-d106c7950d28-3-ea06879e48d8" || len(id) > 64 {
|
||||
t.Errorf("AskingID(3) = %q", id)
|
||||
}
|
||||
if AskVerb("fix/1") != "mesh-delivery.merge" {
|
||||
t.Error("AskVerb binds the wrong act")
|
||||
}
|
||||
|
||||
for act, want := range map[string]string{"status=mesh/check": "novox/a.3.abc.status=mesh/check", "view": "novox/a.3.abc.view", "comment.2": "novox/a.3.abc.comment.2"} {
|
||||
k, err := OwedKey("novox/a", 3, "abc", act)
|
||||
if err != nil || k != want {
|
||||
t.Errorf("OwedKey(%q) = %q, %v", act, k, err)
|
||||
}
|
||||
if repo, n, head, a, err := ParseOwedKey(k); err != nil || repo != "novox/a" || n != 3 || head != "abc" || a != act {
|
||||
t.Errorf("ParseOwedKey(%q) = %q %d %q %q %v", k, repo, n, head, a, err)
|
||||
}
|
||||
}
|
||||
for _, act := range []string{"status", "status=mesh/other", "view=x", "comment", "comment.0", "comment.01", "other"} {
|
||||
if _, err := OwedKey("novox/a", 3, "abc", act); err == nil {
|
||||
t.Errorf("OwedKey takes the act %q", act)
|
||||
}
|
||||
}
|
||||
if _, err := OwedKey("novox", 0, "abc", "view"); err == nil {
|
||||
t.Error("a repository with no slash keys")
|
||||
}
|
||||
if _, err := OwedKey("novox/a", -1, "abc", "view"); err == nil {
|
||||
t.Error("a negative number keys")
|
||||
}
|
||||
if act, err := OwedCommentAct(2); err != nil || act != "comment.2" {
|
||||
t.Errorf("OwedCommentAct = %q, %v", act, err)
|
||||
}
|
||||
|
||||
type owed = seat.OwedByRepositoryNumberHeadActValue
|
||||
for name, c := range map[string]struct {
|
||||
v owed
|
||||
says string
|
||||
}{
|
||||
"a good status": {owed{Act: "status", Context: StatusContextCheck, Target: "http://x", State: "success"}, ""},
|
||||
"a good note": {owed{Act: "note", Text: "t", Ref: "mesh-plan"}, ""},
|
||||
"a status no target": {owed{Act: "status", Context: StatusContextCheck, State: "success"}, "no target"},
|
||||
"a status wrong state": {owed{Act: "status", Context: StatusContextCheck, Target: "x", State: "done"}, "state"},
|
||||
"a status no context": {owed{Act: "status", Target: "x", State: "success"}, "no context"},
|
||||
"a view no text": {owed{Act: "view"}, "no text"},
|
||||
"a note no ref": {owed{Act: "note", Text: "t"}, "no ref"},
|
||||
"an unknown act": {owed{Act: "merge"}, "not status"},
|
||||
} {
|
||||
err := CheckOwed(c.v)
|
||||
if (c.says == "") != (err == nil) || (err != nil && !strings.Contains(err.Error(), c.says)) {
|
||||
t.Errorf("%s: CheckOwed = %v, want %q", name, err, c.says)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,408 +0,0 @@
|
||||
package meshdeliveryclient
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// The values of the seat's states `source`, `merges`, `asks`, `owed` and `turns`, in the seat's types: each is stamped
|
||||
// with Version when encoded, read strictly (an unknown field refused) and its version checked when decoded, and its rules
|
||||
// held on both sides, so the gate that writes them and the readers (the forge bridge, the teller, the assigner, the view)
|
||||
// agree. What the schema cannot say is written here once (ADR 0625 §4).
|
||||
|
||||
// Version is the layout version of the seat's values.
|
||||
const Version = 1
|
||||
|
||||
// MergeState is the state of a pull request in a merge.
|
||||
type MergeState string
|
||||
|
||||
// The states a merge's pull request is in.
|
||||
const (
|
||||
MergeMerging MergeState = "merging"
|
||||
MergeMerged MergeState = "merged"
|
||||
MergeRefused MergeState = "refused"
|
||||
)
|
||||
|
||||
// SourceKey is the key of the state source for a watched branch (design 47 *Watched branches and the catalog graph per
|
||||
// branch*: source.<branch> in place of source.main).
|
||||
func SourceKey(branch string) string { return seat.SourceByBranchKey(branch) }
|
||||
|
||||
func encodeValue(v any, check error, stamp func()) ([]byte, error) {
|
||||
if check != nil {
|
||||
return nil, check
|
||||
}
|
||||
stamp()
|
||||
return json.Marshal(v)
|
||||
}
|
||||
|
||||
// ApprovedKey is the key, in a merge's approved heads, of a pull request: `<repository>@<number>`.
|
||||
func ApprovedKey(repository string, number int) string {
|
||||
return repository + "@" + strconv.Itoa(number)
|
||||
}
|
||||
|
||||
// TurnsKey is the key, in the state turns, of a repository: `<owner>.<name>`, lower-case and escaped.
|
||||
func TurnsKey(repository string) (string, error) {
|
||||
repository = strings.ToLower(repository)
|
||||
part, err := escapeRepository(repository)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.Replace(part, "/", ".", 1), nil
|
||||
}
|
||||
|
||||
// ParseTurnsKey is the inverse of TurnsKey; a key that does not name a lower-case <owner>/<name> is refused.
|
||||
func ParseTurnsKey(key string) (string, error) {
|
||||
owner, name, ok := strings.Cut(key, ".")
|
||||
if !ok || owner == "" || name == "" || strings.Contains(name, ".") {
|
||||
return "", fmt.Errorf("meshdeliveryclient: %q is not a turns key, <owner>.<name>", key)
|
||||
}
|
||||
repository, err := unescapeRepository(owner + "/" + name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("meshdeliveryclient: %q is not a turns key: %w", key, err)
|
||||
}
|
||||
if again, err := TurnsKey(repository); err != nil || again != key {
|
||||
return "", fmt.Errorf("meshdeliveryclient: %q is not a turns key: it does not name a lowercase <owner>/<name>", key)
|
||||
}
|
||||
return repository, nil
|
||||
}
|
||||
|
||||
// ----- source
|
||||
|
||||
// CheckSource refuses a source naming no repository, a repository with no name or an empty head.
|
||||
func CheckSource(s seat.SourceByBranchValue) error {
|
||||
if len(s.Heads) == 0 {
|
||||
return fmt.Errorf("meshdeliveryclient: a source names no repository")
|
||||
}
|
||||
for repository, head := range s.Heads {
|
||||
if repository == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: a source names a repository with no name")
|
||||
}
|
||||
if head == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: the source's head of %s is empty", repository)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeSource is s as the value of the key main.
|
||||
func EncodeSource(s seat.SourceByBranchValue) ([]byte, error) {
|
||||
return encodeValue(&s, CheckSource(s), func() { s.V = Version })
|
||||
}
|
||||
|
||||
// DecodeSource reads the value of the key main.
|
||||
func DecodeSource(data []byte) (seat.SourceByBranchValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.SourceByBranchValue{}, err
|
||||
}
|
||||
s, err := seat.DecodeSourceByBranchValue(data)
|
||||
if err != nil {
|
||||
return s, fmt.Errorf("meshdeliveryclient: a source does not fit its shape: %w", err)
|
||||
}
|
||||
return s, CheckSource(s)
|
||||
}
|
||||
|
||||
// SameSource says whether two sources are the same.
|
||||
func SameSource(a, b seat.SourceByBranchValue) bool { return reflect.DeepEqual(a, b) }
|
||||
|
||||
// ----- merge
|
||||
|
||||
// CheckMerge refuses a merge naming no group, ask or pull request, a pull request outside the approved heads or at
|
||||
// another head than the Approve was for, and a state that lacks what it needs: merged its commit, refused the forge's words.
|
||||
func CheckMerge(m seat.MergesByGroupValue) error {
|
||||
if m.Group == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: a merge names no group")
|
||||
}
|
||||
if m.Ask == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: a merge names no ask")
|
||||
}
|
||||
if len(m.Pulls) == 0 {
|
||||
return fmt.Errorf("meshdeliveryclient: a merge names no pull request")
|
||||
}
|
||||
for key, sha := range m.Approved {
|
||||
if sha == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: the approved head of %s is empty", key)
|
||||
}
|
||||
}
|
||||
for _, p := range m.Pulls {
|
||||
who := fmt.Sprintf("%s#%d", p.Repository, p.Number)
|
||||
if len(m.Approved) > 0 {
|
||||
sha, ok := m.Approved[ApprovedKey(p.Repository, int(p.Number))]
|
||||
if !ok {
|
||||
return fmt.Errorf("meshdeliveryclient: the pull request %s is handed to the merge but is not among the approved heads", who)
|
||||
}
|
||||
if sha != p.Head {
|
||||
return fmt.Errorf("meshdeliveryclient: the pull request %s is handed at head %q but the Approve was for %q", who, p.Head, sha)
|
||||
}
|
||||
}
|
||||
switch MergeState(p.State) {
|
||||
case MergeMerging:
|
||||
case MergeMerged:
|
||||
if p.Commit == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: the merged pull request %s has no merge commit", who)
|
||||
}
|
||||
case MergeRefused:
|
||||
if p.Words == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: the refused pull request %s has no words of the forge", who)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("meshdeliveryclient: the state %q of %s is not merging, merged or refused", p.State, who)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeMerge is m as the value of a group's key.
|
||||
func EncodeMerge(m seat.MergesByGroupValue) ([]byte, error) {
|
||||
return encodeValue(&m, CheckMerge(m), func() { m.V = Version })
|
||||
}
|
||||
|
||||
// DecodeMerge reads the value of a group's key.
|
||||
func DecodeMerge(data []byte) (seat.MergesByGroupValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.MergesByGroupValue{}, err
|
||||
}
|
||||
m, err := seat.DecodeMergesByGroupValue(data)
|
||||
if err != nil {
|
||||
return m, fmt.Errorf("meshdeliveryclient: a merge does not fit its shape: %w", err)
|
||||
}
|
||||
return m, CheckMerge(m)
|
||||
}
|
||||
|
||||
// SameMerge says whether two merges are the same.
|
||||
func SameMerge(a, b seat.MergesByGroupValue) bool { return reflect.DeepEqual(a, b) }
|
||||
|
||||
// ----- ask
|
||||
|
||||
// HeadsOf are an ask's heads as Heads (for HeadsHash and MergeAskKey).
|
||||
func HeadsOf(items []seat.AsksByMergeGroupHeadsValueHeadsItem) []Head {
|
||||
out := make([]Head, len(items))
|
||||
for i, h := range items {
|
||||
out[i] = Head{Repository: h.Repository, Number: int(h.Number), Head: h.Head}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// CheckAsk refuses an ask with no group or heads, a negative count, or an ask that is no object.
|
||||
func CheckAsk(a seat.AsksByMergeGroupHeadsValue) error {
|
||||
if a.Asking < 0 {
|
||||
return fmt.Errorf("meshdeliveryclient: the ask's asking %d is negative", a.Asking)
|
||||
}
|
||||
if _, err := MergeAskKey(a.Group, HeadsOf(a.Heads)); err != nil {
|
||||
return fmt.Errorf("meshdeliveryclient: an ask needs its group and at least one pull request's head: %w", err)
|
||||
}
|
||||
raw, err := json.Marshal(a.Ask)
|
||||
var fields map[string]json.RawMessage
|
||||
if err != nil || len(bytes.TrimSpace(raw)) == 0 || json.Unmarshal(raw, &fields) != nil || fields == nil {
|
||||
return fmt.Errorf("meshdeliveryclient: the value carries no router's ask")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeAsk is a as the value of a merge ask's key; a.Ask may be a json.RawMessage.
|
||||
func EncodeAsk(a seat.AsksByMergeGroupHeadsValue) ([]byte, error) {
|
||||
return encodeValue(&a, CheckAsk(a), func() { a.V = Version })
|
||||
}
|
||||
|
||||
// DecodeAsk reads the value of a merge ask's key; its Ask is the router's ask as a decoded object.
|
||||
func DecodeAsk(data []byte) (seat.AsksByMergeGroupHeadsValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.AsksByMergeGroupHeadsValue{}, err
|
||||
}
|
||||
a, err := seat.DecodeAsksByMergeGroupHeadsValue(data)
|
||||
if err != nil {
|
||||
return a, fmt.Errorf("meshdeliveryclient: an ask does not fit its shape: %w", err)
|
||||
}
|
||||
return a, CheckAsk(a)
|
||||
}
|
||||
|
||||
// SameAsk says whether two asks are the same (the router's ask by its content).
|
||||
func SameAsk(a, b seat.AsksByMergeGroupHeadsValue) bool { return reflect.DeepEqual(a, b) }
|
||||
|
||||
// ----- owed
|
||||
|
||||
// EncodeOwed is o as the value of an owed key, after CheckOwed.
|
||||
func EncodeOwed(o seat.OwedByRepositoryNumberHeadActValue) ([]byte, error) {
|
||||
return encodeValue(&o, CheckOwed(o), func() { o.V = Version })
|
||||
}
|
||||
|
||||
// DecodeOwed reads the value of an owed key.
|
||||
func DecodeOwed(data []byte) (seat.OwedByRepositoryNumberHeadActValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.OwedByRepositoryNumberHeadActValue{}, err
|
||||
}
|
||||
o, err := seat.DecodeOwedByRepositoryNumberHeadActValue(data)
|
||||
if err != nil {
|
||||
return o, fmt.Errorf("meshdeliveryclient: an owed value does not fit its shape: %w", err)
|
||||
}
|
||||
return o, CheckOwed(o)
|
||||
}
|
||||
|
||||
// SameOwed says whether two owed values are the same.
|
||||
func SameOwed(a, b seat.OwedByRepositoryNumberHeadActValue) bool { return a == b }
|
||||
|
||||
// ----- turns
|
||||
|
||||
// CheckTurn refuses a turn whose repository is not lower-case, that names no delivery, or whose deliveries repeat a heads
|
||||
// hash, lack their times, are out of the order of the Approve, or name a wait without a verdict key.
|
||||
func CheckTurn(t seat.TurnsByRepositoryValue) error {
|
||||
repository := strings.ToLower(t.Repository)
|
||||
if repository != t.Repository {
|
||||
return fmt.Errorf("meshdeliveryclient: the turn's repository %q is not lowercase", t.Repository)
|
||||
}
|
||||
if _, err := escapeRepository(repository); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(t.Waiting) == 0 {
|
||||
return fmt.Errorf("meshdeliveryclient: the turn of %s names no delivery: its key is deleted instead", t.Repository)
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for i, w := range t.Waiting {
|
||||
if w.Group == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: a delivery in the turn of %s names no group", t.Repository)
|
||||
}
|
||||
if !hashOK.MatchString(w.Heads) {
|
||||
return fmt.Errorf("meshdeliveryclient: the heads hash %q in the turn of %s is not 12 lowercase hex digits", w.Heads, t.Repository)
|
||||
}
|
||||
if seen[w.Heads] {
|
||||
return fmt.Errorf("meshdeliveryclient: the turn of %s names the heads %s twice", t.Repository, w.Heads)
|
||||
}
|
||||
seen[w.Heads] = true
|
||||
if w.Approved.IsZero() || w.Since.IsZero() {
|
||||
return fmt.Errorf("meshdeliveryclient: the delivery %s in the turn of %s says no time of its Approve or of its wait", w.Group, t.Repository)
|
||||
}
|
||||
if i > 0 && w.Approved.Before(t.Waiting[i-1].Approved) {
|
||||
return fmt.Errorf("meshdeliveryclient: the turn of %s is not in the order of the Approve: %s was approved before %s", t.Repository, w.Group, t.Waiting[i-1].Group)
|
||||
}
|
||||
if w.WaitsFor != "" {
|
||||
if _, _, err := parseVerdictKey(w.WaitsFor); err != nil {
|
||||
return fmt.Errorf("meshdeliveryclient: the delivery %s in the turn of %s waits for what is not a verdict key: %w", w.Group, t.Repository, err)
|
||||
}
|
||||
} else if (w.WaitsSince != nil && !w.WaitsSince.IsZero()) || w.Step != "" {
|
||||
return fmt.Errorf("meshdeliveryclient: the delivery %s in the turn of %s says when and where a check runs, and names no check", w.Group, t.Repository)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseVerdictKey is the checker's verdict key `<group>.<heads hash>` (the checker's client has the same rule over its
|
||||
// own seat; a client uses its own seat's contract alone).
|
||||
func parseVerdictKey(key string) (group, heads string, err error) {
|
||||
i := strings.LastIndex(key, ".")
|
||||
if i < 0 || !hashOK.MatchString(key[i+1:]) || i == 0 || strings.Contains(key[:i], ".") {
|
||||
return "", "", fmt.Errorf("%q is not a verdict key, <group>.<heads hash>", key)
|
||||
}
|
||||
if group, err = keys.UnescapeName(key[:i]); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return group, key[i+1:], nil
|
||||
}
|
||||
|
||||
// TurnHolds says whether a delivery at these heads is not in the turn while the turn names others: the delivery's
|
||||
// check or merge holds back for the one before it.
|
||||
func TurnHolds(t seat.TurnsByRepositoryValue, heads string) bool {
|
||||
if len(t.Waiting) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, w := range t.Waiting {
|
||||
if w.Heads == heads {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// EncodeTurn is t as the value of a repository's key.
|
||||
func EncodeTurn(t seat.TurnsByRepositoryValue) ([]byte, error) {
|
||||
if err := CheckTurn(t); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.V = Version
|
||||
return json.Marshal(t)
|
||||
}
|
||||
|
||||
// DecodeTurn reads the value of a repository's key.
|
||||
func DecodeTurn(data []byte) (seat.TurnsByRepositoryValue, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return seat.TurnsByRepositoryValue{}, err
|
||||
}
|
||||
t, err := seat.DecodeTurnsByRepositoryValue(data)
|
||||
if err != nil {
|
||||
return t, fmt.Errorf("meshdeliveryclient: a turn does not fit its shape: %w", err)
|
||||
}
|
||||
return t, CheckTurn(t)
|
||||
}
|
||||
|
||||
// SameTurn says whether two turns are the same, a time by the instant it names.
|
||||
func SameTurn(a, b seat.TurnsByRepositoryValue) bool {
|
||||
if len(a.Waiting) != len(b.Waiting) || a.Repository != b.Repository || a.V != b.V {
|
||||
return false
|
||||
}
|
||||
for i := range a.Waiting {
|
||||
x, y := a.Waiting[i], b.Waiting[i]
|
||||
if !x.Approved.Equal(y.Approved) || !x.Since.Equal(y.Since) || !sameTime(x.WaitsSince, y.WaitsSince) {
|
||||
return false
|
||||
}
|
||||
x.Approved, y.Approved, x.Since, y.Since, x.WaitsSince, y.WaitsSince = time.Time{}, time.Time{}, time.Time{}, time.Time{}, nil, nil
|
||||
if !reflect.DeepEqual(x, y) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func sameTime(a, b *time.Time) bool {
|
||||
if a == nil || a.IsZero() {
|
||||
return b == nil || b.IsZero()
|
||||
}
|
||||
return b != nil && a.Equal(*b)
|
||||
}
|
||||
|
||||
// Answer is the operator's answer to a merge ask as the gate acts on it: the option chosen, the warrant that proves who
|
||||
// answered, and the words said. It is the teller's state `answers` under the ask's key (the teller's own record; this is
|
||||
// its layout for the gate that reads it).
|
||||
type Answer struct {
|
||||
V int `json:"v"`
|
||||
Option string `json:"option"`
|
||||
Warrant string `json:"warrant"`
|
||||
Words string `json:"words"`
|
||||
}
|
||||
|
||||
// CheckAnswer refuses an answer lacking its option, warrant or words.
|
||||
func CheckAnswer(a Answer) error {
|
||||
for _, f := range []struct{ name, value string }{{"option", a.Option}, {"warrant", a.Warrant}, {"words", a.Words}} {
|
||||
if f.value == "" {
|
||||
return fmt.Errorf("meshdeliveryclient: an answer has no %s", f.name)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeAnswer is a as the value of an answer's key.
|
||||
func EncodeAnswer(a Answer) ([]byte, error) {
|
||||
return encodeValue(&a, CheckAnswer(a), func() { a.V = Version })
|
||||
}
|
||||
|
||||
// DecodeAnswer reads the value of an answer's key.
|
||||
func DecodeAnswer(data []byte) (Answer, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return Answer{}, err
|
||||
}
|
||||
var a Answer
|
||||
dec := json.NewDecoder(bytes.NewReader(data))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&a); err != nil {
|
||||
return Answer{}, fmt.Errorf("meshdeliveryclient: an answer does not fit its shape: %w", err)
|
||||
}
|
||||
return a, CheckAnswer(a)
|
||||
}
|
||||
|
||||
// SameAnswer says whether two answers are the same.
|
||||
func SameAnswer(a, b Answer) bool { return a == b }
|
||||
@@ -1,248 +0,0 @@
|
||||
package meshdeliveryclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// sameJSON says whether two documents hold the same values (the generated types write their fields in alphabetical
|
||||
// order, the old package's in declaration order: the bytes differ, the documents do not).
|
||||
func sameJSON(t *testing.T, got []byte, want string) {
|
||||
t.Helper()
|
||||
var g, w any
|
||||
if err := json.Unmarshal(got, &g); err != nil {
|
||||
t.Fatalf("%s: %v", got, err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(want), &w); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("got %s\nwant %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// The goldens are the output of go/delivery's Encode* before it was deleted; each value must encode to the same
|
||||
// document and decode back to what it was.
|
||||
func TestGateValuesEncodeAsGoDeliveryDid(t *testing.T) {
|
||||
ap := time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC)
|
||||
wait := ap.Add(2 * time.Minute)
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
encode func() ([]byte, error)
|
||||
decode func([]byte) (any, error)
|
||||
value any
|
||||
golden string
|
||||
}{
|
||||
{"source", func() ([]byte, error) {
|
||||
return EncodeSource(seat.SourceByBranchValue{Group: "fix/1.2", Heads: map[string]string{"novox/a": "aaaa", "novox/b": "bbbb"}})
|
||||
}, func(b []byte) (any, error) { return DecodeSource(b) },
|
||||
seat.SourceByBranchValue{V: 1, Group: "fix/1.2", Heads: map[string]string{"novox/a": "aaaa", "novox/b": "bbbb"}},
|
||||
`{"v":1,"group":"fix/1.2","heads":{"novox/a":"aaaa","novox/b":"bbbb"}}`},
|
||||
{"merge", func() ([]byte, error) {
|
||||
return EncodeMerge(seat.MergesByGroupValue{Group: "g", Ask: "merge.g.0123456789ab", Approved: map[string]string{"novox/a@7": "h1"},
|
||||
Pulls: []seat.MergesByGroupValuePullsItem{{Repository: "novox/a", Number: 7, Head: "h1", State: "merged", Commit: "c1"}}})
|
||||
}, func(b []byte) (any, error) { return DecodeMerge(b) },
|
||||
seat.MergesByGroupValue{V: 1, Group: "g", Ask: "merge.g.0123456789ab", Approved: map[string]string{"novox/a@7": "h1"},
|
||||
Pulls: []seat.MergesByGroupValuePullsItem{{Repository: "novox/a", Number: 7, Head: "h1", State: "merged", Commit: "c1"}}},
|
||||
`{"v":1,"group":"g","ask":"merge.g.0123456789ab","approved":{"novox/a@7":"h1"},"pulls":[{"repository":"novox/a","number":7,"head":"h1","state":"merged","commit":"c1"}]}`},
|
||||
{"ask", func() ([]byte, error) {
|
||||
return EncodeAsk(seat.AsksByMergeGroupHeadsValue{Group: "g", Asking: 2, Ask: json.RawMessage(`{"headline":"x"}`),
|
||||
Heads: []seat.AsksByMergeGroupHeadsValueHeadsItem{{Repository: "novox/a", Number: 7, Head: "h1"}}})
|
||||
}, func(b []byte) (any, error) { return DecodeAsk(b) },
|
||||
seat.AsksByMergeGroupHeadsValue{V: 1, Group: "g", Asking: 2, Ask: map[string]any{"headline": "x"},
|
||||
Heads: []seat.AsksByMergeGroupHeadsValueHeadsItem{{Repository: "novox/a", Number: 7, Head: "h1"}}},
|
||||
`{"v":1,"group":"g","heads":[{"repository":"novox/a","number":7,"head":"h1"}],"ask":{"headline":"x"},"asking":2}`},
|
||||
{"owed", func() ([]byte, error) {
|
||||
return EncodeOwed(seat.OwedByRepositoryNumberHeadActValue{Act: OwedStatus, Context: StatusContextCheck, Target: "t", State: "pending"})
|
||||
}, func(b []byte) (any, error) { return DecodeOwed(b) },
|
||||
seat.OwedByRepositoryNumberHeadActValue{V: 1, Act: OwedStatus, Context: StatusContextCheck, Target: "t", State: "pending"},
|
||||
`{"v":1,"act":"status","context":"mesh/check","target":"t","state":"pending"}`},
|
||||
{"turn", func() ([]byte, error) {
|
||||
return EncodeTurn(seat.TurnsByRepositoryValue{Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{
|
||||
Group: "g", Heads: "0123456789ab", Ask: "k", Approved: ap, Since: ap.Add(time.Minute), WaitsFor: "g.0123456789ab", WaitsSince: &wait, Step: "s"}}})
|
||||
}, func(b []byte) (any, error) { return DecodeTurn(b) },
|
||||
seat.TurnsByRepositoryValue{V: 1, Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{
|
||||
Group: "g", Heads: "0123456789ab", Ask: "k", Approved: ap, Since: ap.Add(time.Minute), WaitsFor: "g.0123456789ab", WaitsSince: &wait, Step: "s"}}},
|
||||
`{"v":1,"repository":"novox/a","waiting":[{"group":"g","heads":"0123456789ab","ask":"k","approved":"2026-11-05T10:00:00Z","since":"2026-11-05T10:01:00Z","waits-for":"g.0123456789ab","waits-since":"2026-11-05T10:02:00Z","step":"s"}]}`},
|
||||
{"answer", func() ([]byte, error) { return EncodeAnswer(Answer{Option: "merge", Warrant: "w", Words: "ok"}) },
|
||||
func(b []byte) (any, error) { return DecodeAnswer(b) }, Answer{V: 1, Option: "merge", Warrant: "w", Words: "ok"},
|
||||
`{"v":1,"option":"merge","warrant":"w","words":"ok"}`},
|
||||
} {
|
||||
raw, err := c.encode()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", c.name, err)
|
||||
}
|
||||
sameJSON(t, raw, c.golden)
|
||||
back, err := c.decode([]byte(c.golden))
|
||||
if err != nil || !reflect.DeepEqual(back, c.value) {
|
||||
t.Errorf("%s decoded %+v, %v; want %+v", c.name, back, err, c.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGateKeysAsGoDeliveryHadThem(t *testing.T) {
|
||||
for in, want := range map[string]string{"novox/Mesh-sdk": "novox.mesh-sdk", "novox/mesh-sdk": "novox.mesh-sdk", "novox/mesh.x": "novox.mesh=2ex"} {
|
||||
got, err := TurnsKey(in)
|
||||
if err != nil || got != want {
|
||||
t.Errorf("TurnsKey(%q) = %q, %v; want %q", in, got, err, want)
|
||||
}
|
||||
}
|
||||
if r, err := ParseTurnsKey("novox.mesh=2ex"); err != nil || r != "novox/mesh.x" {
|
||||
t.Errorf("%q %v", r, err)
|
||||
}
|
||||
for _, bad := range []string{"novox", "novox.Mesh", "a.b.c", ".x", "novox.mesh-sdk."} {
|
||||
if _, err := ParseTurnsKey(bad); err == nil {
|
||||
t.Errorf("%q parses as a turns key", bad)
|
||||
}
|
||||
}
|
||||
if _, err := TurnsKey("novox"); err == nil {
|
||||
t.Error("a repository with no slash keys")
|
||||
}
|
||||
if k := ApprovedKey("novox/a", 7); k != "novox/a@7" {
|
||||
t.Error(k)
|
||||
}
|
||||
if SourceKey("beta") != seat.SourceByBranchKey("beta") || SourceKey("beta") != "beta" {
|
||||
t.Error("the source's key is the seat's, one per watched branch")
|
||||
}
|
||||
// A switched act's id carries its state, key and revision, and reads back; any other id is not one.
|
||||
for _, c := range []struct {
|
||||
state, key string
|
||||
rev uint64
|
||||
id string
|
||||
}{
|
||||
{SwitchedOwed, "novox.app.7.0123abcd.status=mesh/delivery", 4, "switched.owed.4.novox.app.7.0123abcd.status=mesh/delivery"},
|
||||
{SwitchedMerges, "release-g", 12, "switched.merges.12.release-g"},
|
||||
} {
|
||||
id, err := SwitchedActID(c.state, c.key, c.rev)
|
||||
if err != nil || id != c.id {
|
||||
t.Errorf("SwitchedActID(%q, %q, %d) = %q, %v; want %q", c.state, c.key, c.rev, id, err, c.id)
|
||||
}
|
||||
if s, k, r, ok := ParseSwitchedActID(id); !ok || s != c.state || k != c.key || r != c.rev {
|
||||
t.Errorf("ParseSwitchedActID(%q) = %q %q %d %v", id, s, k, r, ok)
|
||||
}
|
||||
}
|
||||
for _, bad := range []struct {
|
||||
state, key string
|
||||
rev uint64
|
||||
}{{"turns", "k", 1}, {SwitchedOwed, "", 1}, {SwitchedOwed, "a@b", 1}, {SwitchedMerges, "k", 0}} {
|
||||
if id, err := SwitchedActID(bad.state, bad.key, bad.rev); err == nil {
|
||||
t.Errorf("SwitchedActID(%+v) = %q, no error", bad, id)
|
||||
}
|
||||
}
|
||||
for _, other := range []string{"novox.app.7.0123abcd.view@1700000000", "switched.turns.1.k", "switched.owed.x.k",
|
||||
"switched.owed.0.k", "switched.owed.3", "switched.owed.3.k@1"} {
|
||||
if _, _, _, ok := ParseSwitchedActID(other); ok {
|
||||
t.Errorf("%q reads as a switched act's id", other)
|
||||
}
|
||||
}
|
||||
// A switched act's id carries its state, key and revision, and reads back; any other id is not one.
|
||||
for _, c := range []struct {
|
||||
state, key string
|
||||
rev uint64
|
||||
id string
|
||||
}{
|
||||
{SwitchedOwed, "novox.app.7.0123abcd.status=mesh/delivery", 4, "switched.owed.4.novox.app.7.0123abcd.status=mesh/delivery"},
|
||||
{SwitchedMerges, "release-g", 12, "switched.merges.12.release-g"},
|
||||
} {
|
||||
id, err := SwitchedActID(c.state, c.key, c.rev)
|
||||
if err != nil || id != c.id {
|
||||
t.Errorf("SwitchedActID(%q, %q, %d) = %q, %v; want %q", c.state, c.key, c.rev, id, err, c.id)
|
||||
}
|
||||
if s, k, r, ok := ParseSwitchedActID(id); !ok || s != c.state || k != c.key || r != c.rev {
|
||||
t.Errorf("ParseSwitchedActID(%q) = %q %q %d %v", id, s, k, r, ok)
|
||||
}
|
||||
}
|
||||
for _, bad := range []struct {
|
||||
state, key string
|
||||
rev uint64
|
||||
}{{"turns", "k", 1}, {SwitchedOwed, "", 1}, {SwitchedOwed, "a@b", 1}, {SwitchedMerges, "k", 0}} {
|
||||
if id, err := SwitchedActID(bad.state, bad.key, bad.rev); err == nil {
|
||||
t.Errorf("SwitchedActID(%+v) = %q, no error", bad, id)
|
||||
}
|
||||
}
|
||||
for _, other := range []string{"novox.app.7.0123abcd.view@1700000000", "switched.turns.1.k", "switched.owed.x.k",
|
||||
"switched.owed.0.k", "switched.owed.3", "switched.owed.3.k@1"} {
|
||||
if _, _, _, ok := ParseSwitchedActID(other); ok {
|
||||
t.Errorf("%q reads as a switched act's id", other)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGateValuesRefuseWhatTheirRulesRefuse(t *testing.T) {
|
||||
ap := time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC)
|
||||
pull := seat.MergesByGroupValuePullsItem{Repository: "novox/a", Number: 7, Head: "h1", State: "merging"}
|
||||
merge := func(edit func(*seat.MergesByGroupValue)) error {
|
||||
m := seat.MergesByGroupValue{Group: "g", Ask: "k", Pulls: []seat.MergesByGroupValuePullsItem{pull}}
|
||||
edit(&m)
|
||||
_, err := EncodeMerge(m)
|
||||
return err
|
||||
}
|
||||
turn := func(edit func(*seat.TurnsByRepositoryValue)) error {
|
||||
tv := seat.TurnsByRepositoryValue{Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{Group: "g", Heads: "0123456789ab", Approved: ap, Since: ap}}}
|
||||
edit(&tv)
|
||||
_, err := EncodeTurn(tv)
|
||||
return err
|
||||
}
|
||||
for name, c := range map[string]struct {
|
||||
err error
|
||||
want string
|
||||
}{
|
||||
"merge: no group": {merge(func(m *seat.MergesByGroupValue) { m.Group = "" }), "no group"},
|
||||
"merge: no pull": {merge(func(m *seat.MergesByGroupValue) { m.Pulls = nil }), "no pull request"},
|
||||
"merge: not approved": {merge(func(m *seat.MergesByGroupValue) { m.Approved = map[string]string{"novox/b@1": "x"} }), "not among the approved"},
|
||||
"merge: other head": {merge(func(m *seat.MergesByGroupValue) { m.Approved = map[string]string{"novox/a@7": "x"} }), "Approve was for"},
|
||||
"merge: merged no commit": {merge(func(m *seat.MergesByGroupValue) { m.Pulls[0].State = "merged" }), "no merge commit"},
|
||||
"merge: refused no words": {merge(func(m *seat.MergesByGroupValue) { m.Pulls[0].State = "refused" }), "no words"},
|
||||
"merge: unknown state": {merge(func(m *seat.MergesByGroupValue) { m.Pulls[0].State = "lost" }), "not merging, merged or refused"},
|
||||
"turn: upper case": {turn(func(v *seat.TurnsByRepositoryValue) { v.Repository = "Novox/a" }), "not lowercase"},
|
||||
"turn: empty": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting = nil }), "names no delivery"},
|
||||
"turn: bad hash": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].Heads = "xyz" }), "12 lowercase hex"},
|
||||
"turn: no time": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].Since = time.Time{} }), "no time"},
|
||||
"turn: step with no wait": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].Step = "s" }), "names no check"},
|
||||
"turn: not a verdict key": {turn(func(v *seat.TurnsByRepositoryValue) { v.Waiting[0].WaitsFor = "nope" }), "not a verdict key"},
|
||||
} {
|
||||
if c.err == nil || !strings.Contains(c.err.Error(), c.want) {
|
||||
t.Errorf("%s: %v, want %q", name, c.err, c.want)
|
||||
}
|
||||
}
|
||||
if _, err := EncodeSource(seat.SourceByBranchValue{Group: "g"}); err == nil {
|
||||
t.Error("an empty source encodes")
|
||||
}
|
||||
if _, err := EncodeAsk(seat.AsksByMergeGroupHeadsValue{Group: "g", Ask: "text", Heads: []seat.AsksByMergeGroupHeadsValueHeadsItem{{Repository: "novox/a", Number: 1, Head: "h"}}}); err == nil {
|
||||
t.Error("an ask that is no object encodes")
|
||||
}
|
||||
if _, err := EncodeAnswer(Answer{Option: "merge"}); err == nil {
|
||||
t.Error("an answer with no warrant encodes")
|
||||
}
|
||||
if _, err := DecodeSource([]byte(`{"v":2,"group":"g","heads":{"a":"b"}}`)); !errors.Is(err, keys.ErrUnknownVersion) {
|
||||
t.Errorf("another version: %v", err)
|
||||
}
|
||||
if _, err := DecodeMerge([]byte(`{"v":1,"group":"g","ask":"k","pulls":[],"extra":1}`)); err == nil {
|
||||
t.Error("an unknown field decodes")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTurnHoldsAndSameTurn(t *testing.T) {
|
||||
ap := time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC)
|
||||
tv := seat.TurnsByRepositoryValue{V: 1, Repository: "novox/a", Waiting: []seat.TurnsByRepositoryValueWaitingItem{{Group: "g", Heads: "0123456789ab", Approved: ap, Since: ap}}}
|
||||
if TurnHolds(tv, "0123456789ab") || !TurnHolds(tv, "ba9876543210") || TurnHolds(seat.TurnsByRepositoryValue{}, "x") {
|
||||
t.Error("a turn holds a delivery that is not in it while others wait")
|
||||
}
|
||||
other := tv
|
||||
other.Waiting = []seat.TurnsByRepositoryValueWaitingItem{tv.Waiting[0]}
|
||||
other.Waiting[0].Approved = ap.In(time.FixedZone("x", 3600))
|
||||
if !SameTurn(tv, other) {
|
||||
t.Error("the same instant in another zone is another turn")
|
||||
}
|
||||
other.Waiting[0].Since = ap.Add(time.Second)
|
||||
if SameTurn(tv, other) {
|
||||
t.Error("another instant is the same turn")
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshdeliveryclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
@@ -1,51 +0,0 @@
|
||||
package meshdeliveryclient
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// A switched act is an act the gate owed before its switch to the delivery record (design 47 *The switch carries what is
|
||||
// owed*): a key of the gate's state owed or merges that the old forge bridge had not performed. The gate says it as the
|
||||
// event owed under an id made of the state, the key and its revision, so the new forge bridge counts it as performed when
|
||||
// the old bridge's own bookkeeping names that key at that revision, and nothing is done twice. The form is
|
||||
// `switched.<state>.<revision>.<key>`, the key last because it holds dots; it holds no `@`, which the gate's own ids hold,
|
||||
// so the two never meet.
|
||||
|
||||
// The states a switched act comes from.
|
||||
const (
|
||||
SwitchedOwed = "owed"
|
||||
SwitchedMerges = "merges"
|
||||
)
|
||||
|
||||
const switchedPrefix = "switched."
|
||||
|
||||
// SwitchedActID is the id of the act the key of the state held at the revision.
|
||||
func SwitchedActID(state, key string, revision uint64) (string, error) {
|
||||
if state != SwitchedOwed && state != SwitchedMerges {
|
||||
return "", fmt.Errorf("meshdeliveryclient: a switched act comes from the state owed or merges, not %q", state)
|
||||
}
|
||||
if key == "" || strings.Contains(key, "@") {
|
||||
return "", fmt.Errorf("meshdeliveryclient: a switched act's key %q is empty or holds an @", key)
|
||||
}
|
||||
if revision == 0 {
|
||||
return "", fmt.Errorf("meshdeliveryclient: a switched act's revision is 1 or more")
|
||||
}
|
||||
return switchedPrefix + state + "." + strconv.FormatUint(revision, 10) + "." + key, nil
|
||||
}
|
||||
|
||||
// ParseSwitchedActID reads the state, the key and the revision out of a switched act's id; ok is false for any other id.
|
||||
func ParseSwitchedActID(id string) (state, key string, revision uint64, ok bool) {
|
||||
rest, found := strings.CutPrefix(id, switchedPrefix)
|
||||
if !found || strings.Contains(id, "@") {
|
||||
return "", "", 0, false
|
||||
}
|
||||
state, rest, _ = strings.Cut(rest, ".")
|
||||
rev, key, _ := strings.Cut(rest, ".")
|
||||
revision, err := strconv.ParseUint(rev, 10, 64)
|
||||
if err != nil || revision == 0 || key == "" || (state != SwitchedOwed && state != SwitchedMerges) {
|
||||
return "", "", 0, false
|
||||
}
|
||||
return state, key, revision, true
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// Package meshpipelinerunnerclient is the logic the callers of the seat mesh-pipeline-runner share (ADR 0634 §1): the
|
||||
// subjects of the runner's events, built and parsed, and their bodies decoded (design 47 G §73, §332). It names no
|
||||
// module, repository or branch: every name is the caller's.
|
||||
package meshpipelinerunnerclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshpipelinerunner"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// eventPrefix starts every event subject of the seat.
|
||||
const eventPrefix = "mesh.seat." + seat.Seat + ".event."
|
||||
|
||||
// Subject is where the runner says event of a pipeline: mesh.seat.mesh-pipeline-runner.event.<event>.<module>.<branch>.
|
||||
// <commit or group>, each name escaped as a key's name is (design 47 *Health and going back*), so a branch or a group
|
||||
// holding a dot is one token.
|
||||
func Subject(event, module, branch, commitOrGroup string) string {
|
||||
return eventPrefix + event + "." + keys.EscapeName(module) + "." + keys.EscapeName(branch) + "." + keys.EscapeName(commitOrGroup)
|
||||
}
|
||||
|
||||
// GroupEndedSubject is where the runner says a group's end: mesh.seat.mesh-pipeline-runner.event.group-ended.<branch>.
|
||||
// <group>, with no module part, since a group spans modules (design 47 G §332).
|
||||
func GroupEndedSubject(branch, group string) string {
|
||||
return eventPrefix + seat.EventGroupEnded + "." + keys.EscapeName(branch) + "." + keys.EscapeName(group)
|
||||
}
|
||||
|
||||
// Of is what an event's subject names. A group-ended names no module.
|
||||
type Of struct {
|
||||
Event, Module, Branch, CommitOrGroup string
|
||||
}
|
||||
|
||||
// Parse reads a subject Subject or GroupEndedSubject built: an event of the seat's, and its names unescaped.
|
||||
func Parse(subject string) (Of, error) {
|
||||
rest, ok := strings.CutPrefix(subject, eventPrefix)
|
||||
toks := strings.Split(rest, ".")
|
||||
want := 4
|
||||
if len(toks) > 0 && toks[0] == seat.EventGroupEnded {
|
||||
want = 3
|
||||
}
|
||||
if !ok || len(toks) != want || !slices.Contains(seat.Events(), toks[0]) {
|
||||
return Of{}, fmt.Errorf("meshpipelinerunnerclient: %q is no event subject of the seat %s", subject, seat.Seat)
|
||||
}
|
||||
names := make([]string, 0, 3)
|
||||
for i, t := range toks[1:] {
|
||||
n, err := keys.UnescapeName(t)
|
||||
if err != nil || n == "" {
|
||||
return Of{}, fmt.Errorf("meshpipelinerunnerclient: %q: part %d: %v", subject, i+1, err)
|
||||
}
|
||||
names = append(names, n)
|
||||
}
|
||||
if want == 3 {
|
||||
return Of{Event: toks[0], Branch: names[0], CommitOrGroup: names[1]}, nil
|
||||
}
|
||||
return Of{Event: toks[0], Module: names[0], Branch: names[1], CommitOrGroup: names[2]}, nil
|
||||
}
|
||||
|
||||
// PipelineEnded decodes a pipeline-ended body, refusing one that names no pipeline, module, branch or commit.
|
||||
func PipelineEnded(data []byte) (seat.PipelineEndedEvent, error) {
|
||||
var e seat.PipelineEndedEvent
|
||||
if err := json.Unmarshal(data, &e); err != nil {
|
||||
return e, fmt.Errorf("meshpipelinerunnerclient: pipeline-ended: %w", err)
|
||||
}
|
||||
if e.Pipeline == "" || e.Module == "" || e.Branch == "" || e.Commit == "" {
|
||||
return e, fmt.Errorf("meshpipelinerunnerclient: pipeline-ended names no pipeline, module, branch or commit")
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// GroupEnded decodes a group-ended body, refusing one that names no group or branch, and each of its pipelines as
|
||||
// PipelineEnded does.
|
||||
func GroupEnded(data []byte) (seat.GroupEndedEvent, error) {
|
||||
var g seat.GroupEndedEvent
|
||||
if err := json.Unmarshal(data, &g); err != nil {
|
||||
return g, fmt.Errorf("meshpipelinerunnerclient: group-ended: %w", err)
|
||||
}
|
||||
if g.Group == "" || g.Branch == "" {
|
||||
return g, fmt.Errorf("meshpipelinerunnerclient: group-ended names no group or branch")
|
||||
}
|
||||
for _, p := range g.Pipelines {
|
||||
if p.Pipeline == "" || p.Module == "" || p.Branch == "" || p.Commit == "" {
|
||||
return g, fmt.Errorf("meshpipelinerunnerclient: group-ended %s: a pipeline names no pipeline, module, branch or commit", g.Group)
|
||||
}
|
||||
}
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// StepEnded decodes a step-ended (or step-started) body, refusing one that names no pipeline, module or step.
|
||||
func StepEnded(data []byte) (seat.StepEndedEvent, error) {
|
||||
var e seat.StepEndedEvent
|
||||
if err := json.Unmarshal(data, &e); err != nil {
|
||||
return e, fmt.Errorf("meshpipelinerunnerclient: step event: %w", err)
|
||||
}
|
||||
if e.Pipeline == "" || e.Module == "" || e.Result.Step == "" {
|
||||
return e, fmt.Errorf("meshpipelinerunnerclient: step event names no pipeline, module or step")
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package meshpipelinerunnerclient
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshpipelinerunner"
|
||||
)
|
||||
|
||||
// A-D7: the subject carries the module, the branch and the commit or group, each escaped as a key's name is, and is
|
||||
// read back (design 47 *Health and going back*); a body naming nothing is refused.
|
||||
func TestSubjectsAndBodies(t *testing.T) {
|
||||
s := Subject(seat.EventPipelineEnded, "nats", "release.1", "feat/47-G")
|
||||
if s != "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.release=2e1.feat/47-G" {
|
||||
t.Errorf("subject %s", s)
|
||||
}
|
||||
if of, err := Parse(s); err != nil || of != (Of{seat.EventPipelineEnded, "nats", "release.1", "feat/47-G"}) {
|
||||
t.Errorf("parse %s: %+v, %v", s, of, err)
|
||||
}
|
||||
for _, bad := range []string{"not.an.event.subject", "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main",
|
||||
"mesh.seat.mesh-pipeline-runner.event.no-such.nats.main.c1", "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.ma=zz.c1"} {
|
||||
if _, err := Parse(bad); err == nil {
|
||||
t.Errorf("%s parsed", bad)
|
||||
}
|
||||
}
|
||||
// design 47 G §332: a group's end is said under the branch and the group, with no module.
|
||||
gs := GroupEndedSubject("main", "registry.1966")
|
||||
if gs != "mesh.seat.mesh-pipeline-runner.event.group-ended.main.registry=2e1966" {
|
||||
t.Errorf("group-ended subject %s", gs)
|
||||
}
|
||||
if of, err := Parse(gs); err != nil || of != (Of{Event: seat.EventGroupEnded, Branch: "main", CommitOrGroup: "registry.1966"}) {
|
||||
t.Errorf("parse %s: %+v, %v", gs, of, err)
|
||||
}
|
||||
if _, err := Parse("mesh.seat.mesh-pipeline-runner.event.group-ended.nats.main.g1"); err == nil {
|
||||
t.Error("a group-ended with a module part parsed")
|
||||
}
|
||||
if _, err := PipelineEnded([]byte(`{"v":1,"pipeline":"main.12.nats","module":"nats","branch":"main","commit":"c1","outcome":"passed","steps":[]}`)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err := PipelineEnded([]byte(`{"v":1,"module":"nats"}`)); err == nil {
|
||||
t.Error("a pipeline-ended naming no pipeline was taken")
|
||||
}
|
||||
if _, err := GroupEnded([]byte(`{"v":1,"group":"g","branch":"main","outcome":"passed","pipelines":[{"module":"nats"}]}`)); err == nil {
|
||||
t.Error("a group-ended with a pipeline naming nothing was taken")
|
||||
}
|
||||
if e, err := StepEnded([]byte(`{"v":1,"pipeline":"p","module":"nats","branch":"main","commit":"c1","result":{"step":"unit","status":"required","outcome":"passed","rerun":true,"by":"operator@shanks"}}`)); err != nil || !e.Result.Rerun {
|
||||
t.Errorf("step-ended: %+v, %v", e, err)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshpipelinerunnerclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/meshpipelinerunner v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op h1:Z/MZK75wC/NSrkgqeNIa7jexam9uWzhLmFTSCPI/kn0=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
|
||||
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
|
||||
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/nats-io/jwt/v2 v2.8.1 h1:V0xpGuD/N8Mi+fQNDynXohVvp7ZztevW5io8CUWlPmU=
|
||||
github.com/nats-io/jwt/v2 v2.8.1/go.mod h1:nWnOEEiVMiKHQpnAy4eXlizVEtSfzacZ1Q43LIRavZg=
|
||||
github.com/nats-io/nats-server/v2 v2.11.17 h1:GKEghcFK6A+aFx11Yf1LjgLC3txAwvyhnYzhBIQZA8I=
|
||||
github.com/nats-io/nats-server/v2 v2.11.17/go.mod h1:B1sFVz4StNosQ903ak4N1G01Fl/9f8e06mXpFIE2K24=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
@@ -1,176 +0,0 @@
|
||||
package meshwantsclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
// RevisionVerb is the seat verb a part takes its first view of the assignment half by, as its manifest's invokes names
|
||||
// it.
|
||||
const RevisionVerb = "seat:" + seat.Seat + "." + seat.VerbRevision
|
||||
|
||||
// kindTrunk is the kind of an assignment graph revision a running part acts on; a candidate's moves nothing.
|
||||
const kindTrunk = "trunk"
|
||||
|
||||
// Call asks one seat verb over the bus and answers what the holder said, whatever wraps it (process.Conn.Call, or
|
||||
// stdio.Ask through the tool runner).
|
||||
type Call func(key string, body any) (json.RawMessage, error)
|
||||
|
||||
// assignmentCreated stands for the view's Created in its follower: a revision view is never made again, so one fixed
|
||||
// time, never zero, lets the follower tell a revision heard from one it holds.
|
||||
var assignmentCreated = time.Unix(0, 0).UTC()
|
||||
|
||||
// assignmentViewName is how an assignment half's revision is named in a part's first-view status (views.Status.View,
|
||||
// WaitsFor).
|
||||
func assignmentViewName(revision int64) string { return strconv.FormatInt(revision, 10) }
|
||||
|
||||
// Assignment is a part's view of the assignment half (design 47 G §245): a first view of the newest trunk revision asked
|
||||
// of the seat mesh-wants' verb `revision`, then kept from its event `assignment-revision`, built on go/views' Follower,
|
||||
// so the runtime's tools `<module>_first_views` and `<module>_first_view_again` read and steer it as every first view.
|
||||
// Its picture is keyed `<node>.<module>`, each value that entry's reference. With no view the part acts on nothing:
|
||||
// Revision says false, and a revision heard and not held yet is waited for, said in the status, and past
|
||||
// views.WaitsBound raised as view-waits.
|
||||
type Assignment struct {
|
||||
Follower *views.Follower
|
||||
// Held, when set, is told of each revision once the view holds it, on the ask's goroutine and outside any lock.
|
||||
Held func(seat.AssignmentRevision)
|
||||
|
||||
call Call
|
||||
mu sync.Mutex
|
||||
held *seat.AssignmentRevision
|
||||
waits int64
|
||||
}
|
||||
|
||||
// NewAssignment is an Assignment asking the seat through call. Nothing is asked before Start.
|
||||
func NewAssignment(call Call) *Assignment {
|
||||
a := &Assignment{call: call}
|
||||
a.Follower = &views.Follower{Owner: seat.Seat, Tool: RevisionVerb, State: seat.StateAssignmentRevisions, Ask: a.ask}
|
||||
return a
|
||||
}
|
||||
|
||||
// WireAssignment is an Assignment adopted by a stdio part's views.Reader: the reader writes its conditions and its
|
||||
// view-waits finding, reads it as `mesh-wants.assignment-revisions`, lists and asks it again in its first-view tools, and
|
||||
// at its Start subscribes the seat's event assignment-revision (the part's manifest consumes it) into Hear and asks the
|
||||
// first view. held, when not nil, is the Assignment's Held. The part declares the seat's verb revision in invokes.
|
||||
func WireAssignment(r *views.Reader, call Call, held func(seat.AssignmentRevision)) (*Assignment, error) {
|
||||
a := NewAssignment(call)
|
||||
a.Held = held
|
||||
if err := r.Adopt(a.Follower, seat.Seat, seat.EventAssignmentRevision, a.Hear); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// WireAssignmentProcess is WireAssignment for a process's views.ProcessReader: its picture
|
||||
// (`mesh-wants_assignment-revisions`) reads the half as a read-only bucket, and the seat's event assignment-revision on
|
||||
// the module's durable consumer goes to Hear.
|
||||
func WireAssignmentProcess(r *views.ProcessReader, call Call, held func(seat.AssignmentRevision)) (*Assignment, *views.Picture, error) {
|
||||
a := NewAssignment(call)
|
||||
a.Held = held
|
||||
p, err := r.Adopt(a.Follower, seat.Seat, seat.EventAssignmentRevision, a.Hear)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return a, p, nil
|
||||
}
|
||||
|
||||
// Start asks the first view, the newest trunk revision, until it is answered or ctx ends.
|
||||
func (a *Assignment) Start(ctx context.Context) error { return a.Follower.Start(ctx) }
|
||||
|
||||
// Revision is the assignment graph revision the view holds; false while it has none, when the part acts on nothing new.
|
||||
func (a *Assignment) Revision() (seat.AssignmentRevision, bool) {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.held == nil {
|
||||
return seat.AssignmentRevision{}, false
|
||||
}
|
||||
return *a.held, true
|
||||
}
|
||||
|
||||
// Hear takes one `assignment-revision` event, as the part's durable consumer of the seat's events hands it. A
|
||||
// candidate's revision moves nothing; a trunk revision the view holds, or one older, is passed over; a newer one is
|
||||
// waited for and asked on its own goroutine, so the consumer is never held while the holder is away. Data that is no
|
||||
// such event is an error.
|
||||
func (a *Assignment) Hear(ctx context.Context, data []byte) error {
|
||||
var ev seat.AssignmentRevisionEvent
|
||||
if err := json.Unmarshal(data, &ev); err != nil || ev.Revision <= 0 {
|
||||
return fmt.Errorf("meshwantsclient: not a %s event: %s", seat.EventAssignmentRevision, clipBytes(data))
|
||||
}
|
||||
if ev.Kind != kindTrunk {
|
||||
return nil
|
||||
}
|
||||
a.mu.Lock()
|
||||
held := int64(0)
|
||||
if a.held != nil {
|
||||
held = a.held.Revision
|
||||
}
|
||||
if ev.Revision > a.waits {
|
||||
a.waits = ev.Revision
|
||||
}
|
||||
a.mu.Unlock()
|
||||
if ev.Revision <= held {
|
||||
return nil
|
||||
}
|
||||
// The follower keeps the newest revision heard, so an ask that was running when it was heard is asked once more.
|
||||
a.Follower.Apply(views.Event{Owner: seat.Seat, State: seat.StateAssignmentRevisions, Revision: uint64(ev.Revision), Created: assignmentCreated, Gap: true})
|
||||
a.Follower.WaitFor(ctx, assignmentViewName(ev.Revision))
|
||||
go func() {
|
||||
_ = a.Follower.Gap(ctx, fmt.Sprintf("assignment revision %d said, the view holds %d", ev.Revision, held))
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
// ask is the Follower's Ask: the newest trunk revision, whole in one answer (its entries are named by digest).
|
||||
func (a *Assignment) ask(_ context.Context, _ string) (views.Answer, error) {
|
||||
raw, err := a.call(RevisionVerb, seat.RevisionInput{})
|
||||
if err != nil {
|
||||
return views.Answer{}, err
|
||||
}
|
||||
answer, said, ok := buscalls.Unwrap(raw)
|
||||
if !ok {
|
||||
return views.Answer{}, fmt.Errorf("%s answered: %s", RevisionVerb, said)
|
||||
}
|
||||
var ans seat.RevisionAnswer
|
||||
if err := json.Unmarshal(answer, &ans); err != nil {
|
||||
return views.Answer{}, fmt.Errorf("%s answered what is not its answer: %s", RevisionVerb, clipBytes(answer))
|
||||
}
|
||||
r := ans.Revision
|
||||
if r.Revision <= 0 || r.Kind != kindTrunk {
|
||||
return views.Answer{}, fmt.Errorf("%s answered a %q revision %d for the trunk", RevisionVerb, r.Kind, r.Revision)
|
||||
}
|
||||
values := make(map[string]json.RawMessage, len(r.Entries))
|
||||
for _, e := range r.Entries {
|
||||
v, _ := json.Marshal(e)
|
||||
values[e.Node+"."+e.Module] = v
|
||||
}
|
||||
a.mu.Lock()
|
||||
moved := a.held == nil || a.held.Revision != r.Revision
|
||||
a.held = &r
|
||||
holds := a.waits <= r.Revision
|
||||
if holds {
|
||||
a.waits = 0
|
||||
}
|
||||
a.mu.Unlock()
|
||||
if holds {
|
||||
a.Follower.Holds(assignmentViewName(r.Revision))
|
||||
}
|
||||
if moved && a.Held != nil {
|
||||
a.Held(r)
|
||||
}
|
||||
return views.Answer{V: 1, Owner: seat.Seat, State: seat.StateAssignmentRevisions, Revision: uint64(r.Revision), Created: assignmentCreated, Values: values, At: time.Now()}, nil
|
||||
}
|
||||
|
||||
func clipBytes(b []byte) string {
|
||||
if len(b) > 200 {
|
||||
return string(b[:200]) + "…"
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package meshwantsclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
||||
)
|
||||
|
||||
// fakeWants answers the verb revision with its newest trunk revision, and counts each ask.
|
||||
type fakeWants struct {
|
||||
mu sync.Mutex
|
||||
newest int64
|
||||
asks int
|
||||
}
|
||||
|
||||
func (f *fakeWants) call(key string, body any) (json.RawMessage, error) {
|
||||
if key != RevisionVerb {
|
||||
return nil, fmt.Errorf("asked %s", key)
|
||||
}
|
||||
if in := body.(seat.RevisionInput); in != (seat.RevisionInput{}) {
|
||||
return nil, fmt.Errorf("asked %+v", in)
|
||||
}
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.asks++
|
||||
r := seat.AssignmentRevision{Revision: f.newest, Kind: kindTrunk, Placements: "p",
|
||||
Catalogs: []seat.CatalogOf{{Branch: "main", Revision: 10 + f.newest}},
|
||||
Entries: []seat.NodeEntryRef{{Node: "anchor", Module: "nats", Digest: fmt.Sprintf("d%d", f.newest)}}}
|
||||
return json.Marshal(seat.RevisionAnswer{Revision: r})
|
||||
}
|
||||
|
||||
func (f *fakeWants) set(newest int64) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.newest = newest
|
||||
}
|
||||
|
||||
func (f *fakeWants) asked() int {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.asks
|
||||
}
|
||||
|
||||
func revisionEvent(rev int64, kind string) []byte {
|
||||
b, _ := json.Marshal(seat.AssignmentRevisionEvent{V: 1, Revision: rev, Kind: kind})
|
||||
return b
|
||||
}
|
||||
|
||||
// CT10 (design 47 G §245): a part takes a first view of the assignment half by the verb revision, then follows its
|
||||
// event assignment-revision: a newer trunk revision is waited for, said in the status, and held; a candidate's, or one
|
||||
// held, asks nothing; what is no such event is refused.
|
||||
func TestTheAssignmentHalfIsAFirstViewThenItsEvents(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
held := make(chan seat.AssignmentRevision, 8)
|
||||
next := func() seat.AssignmentRevision {
|
||||
t.Helper()
|
||||
select {
|
||||
case r := <-held:
|
||||
return r
|
||||
case <-ctx.Done():
|
||||
t.Fatal("no revision held")
|
||||
return seat.AssignmentRevision{}
|
||||
}
|
||||
}
|
||||
f := &fakeWants{newest: 3}
|
||||
a := NewAssignment(f.call)
|
||||
a.Follower.Wait = time.Nanosecond
|
||||
a.Held = func(r seat.AssignmentRevision) { held <- r }
|
||||
if _, ok := a.Revision(); ok {
|
||||
t.Fatal("a revision before its first view")
|
||||
}
|
||||
if err := a.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r := next(); r.Revision != 3 || len(r.Catalogs) != 1 || r.Catalogs[0].Revision != 13 {
|
||||
t.Fatalf("first view holds %+v", r)
|
||||
}
|
||||
if v, ok := a.Follower.Get("anchor.nats"); !ok || string(v) == "" {
|
||||
t.Errorf("the picture lacks anchor.nats: %s", v)
|
||||
}
|
||||
|
||||
for _, ev := range [][]byte{revisionEvent(3, kindTrunk), revisionEvent(2, kindTrunk), revisionEvent(9, "candidate")} {
|
||||
if err := a.Hear(ctx, ev); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if n := f.asked(); n != 1 {
|
||||
t.Errorf("a revision held, an older one or a candidate's asked again: %d asks", n)
|
||||
}
|
||||
|
||||
f.set(4)
|
||||
if err := a.Hear(ctx, revisionEvent(4, kindTrunk)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r := next(); r.Revision != 4 {
|
||||
t.Fatalf("after assignment-revision 4 the view holds %d", r.Revision)
|
||||
}
|
||||
if s := a.Follower.Status(); s.View != "4" || s.WaitsFor != "" {
|
||||
t.Errorf("status view %q, waits for %q", s.View, s.WaitsFor)
|
||||
}
|
||||
if r, ok := a.Revision(); !ok || r.Revision != 4 {
|
||||
t.Errorf("Revision = %d, %v", r.Revision, ok)
|
||||
}
|
||||
|
||||
for _, data := range []string{`{}`, `not json`, `{"kind":"trunk"}`} {
|
||||
if err := a.Hear(ctx, []byte(data)); err == nil {
|
||||
t.Errorf("Hear(%s) took it", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshwantsclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/klauspost/compress v1.20.0 // indirect
|
||||
github.com/nats-io/nats.go v1.54.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op h1:Z/MZK75wC/NSrkgqeNIa7jexam9uWzhLmFTSCPI/kn0=
|
||||
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
|
||||
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
|
||||
github.com/nats-io/jwt/v2 v2.8.1/go.mod h1:nWnOEEiVMiKHQpnAy4eXlizVEtSfzacZ1Q43LIRavZg=
|
||||
github.com/nats-io/jwt/v2 v2.8.1 h1:V0xpGuD/N8Mi+fQNDynXohVvp7ZztevW5io8CUWlPmU=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats-server/v2 v2.11.17/go.mod h1:B1sFVz4StNosQ903ak4N1G01Fl/9f8e06mXpFIE2K24=
|
||||
github.com/nats-io/nats-server/v2 v2.11.17 h1:GKEghcFK6A+aFx11Yf1LjgLC3txAwvyhnYzhBIQZA8I=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||
@@ -1,109 +0,0 @@
|
||||
package meshwantsclient
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
||||
)
|
||||
|
||||
// Placed is where the assignment half (the seat mesh-wants' assignment graph revisions; design 47 *The revision view*)
|
||||
// places each module, and since when: the one reading of "does module stand on node" for every part that takes its view
|
||||
// of the assignment half (the builder's, the indexer's and the checker's toolchain gate), so no part reads the assigner's
|
||||
// state for it (design 47 *Each part acts on its own entries*; ADR 0596). Its input is the revisions a part's view holds,
|
||||
// in the order it holds them (assignmentview's Held): Take takes each whole, from its entries' nodes and modules alone, so
|
||||
// no entry is asked. A pair stands since the revision that first named it in an unbroken run: in the first revision taken
|
||||
// since the zero time (the module may have run there before), in a later one since that revision's time (its `at`; the
|
||||
// zero time when it carries none). A revision not newer than the one taken moves nothing.
|
||||
//
|
||||
// Safe for use from a view's goroutine and a reader at once.
|
||||
type Placed struct {
|
||||
mu sync.Mutex
|
||||
since map[string]map[string]time.Time // node -> module -> since when it stands
|
||||
revision int64 // the revision taken last, 0 before the first
|
||||
}
|
||||
|
||||
// NewPlaced is a Placed that holds no revision yet.
|
||||
func NewPlaced() *Placed { return &Placed{since: map[string]map[string]time.Time{}} }
|
||||
|
||||
// Take takes one assignment graph revision in and answers, by node, the modules whose standing on it changed (placed or
|
||||
// removed), each in name order; nothing for a revision not newer than the one taken.
|
||||
func (p *Placed) Take(r seat.AssignmentRevision) map[string][]string {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
if r.Revision <= p.revision {
|
||||
return nil
|
||||
}
|
||||
at := time.Time{}
|
||||
if p.revision > 0 && r.At != nil {
|
||||
at = *r.At
|
||||
}
|
||||
p.revision = r.Revision
|
||||
now := map[string]map[string]bool{}
|
||||
for _, e := range r.Entries {
|
||||
if now[e.Node] == nil {
|
||||
now[e.Node] = map[string]bool{}
|
||||
}
|
||||
now[e.Node][e.Module] = true
|
||||
}
|
||||
changed := map[string][]string{}
|
||||
next := map[string]map[string]time.Time{}
|
||||
for node, modules := range now {
|
||||
next[node] = map[string]time.Time{}
|
||||
for m := range modules {
|
||||
if s, ok := p.since[node][m]; ok {
|
||||
next[node][m] = s
|
||||
continue
|
||||
}
|
||||
next[node][m] = at
|
||||
changed[node] = append(changed[node], m)
|
||||
}
|
||||
}
|
||||
for node, modules := range p.since {
|
||||
for m := range modules {
|
||||
if !now[node][m] {
|
||||
changed[node] = append(changed[node], m)
|
||||
}
|
||||
}
|
||||
}
|
||||
for node := range changed {
|
||||
slices.Sort(changed[node])
|
||||
}
|
||||
p.since = next
|
||||
return changed
|
||||
}
|
||||
|
||||
// Revision is the assignment graph revision taken last; 0 before the first.
|
||||
func (p *Placed) Revision() int64 {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
return p.revision
|
||||
}
|
||||
|
||||
// Seeded says the revision taken places some module somewhere.
|
||||
func (p *Placed) Seeded() bool {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
return len(p.since) > 0
|
||||
}
|
||||
|
||||
// Since says whether module stands on node, and since when (the zero time: since before the first revision taken).
|
||||
func (p *Placed) Since(node, module string) (time.Time, bool) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
s, ok := p.since[node][module]
|
||||
return s, ok
|
||||
}
|
||||
|
||||
// ByNode is, by node, the modules placed on it in name order.
|
||||
func (p *Placed) ByNode() map[string][]string {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
out := make(map[string][]string, len(p.since))
|
||||
for node, mods := range p.since {
|
||||
out[node] = slices.Sorted(maps.Keys(mods))
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -1,327 +0,0 @@
|
||||
// Package meshwantsclient is the client of the seat mesh-wants: the keys of its state wants, and the check and the codec
|
||||
// of a want, a node's own want and a hold, which every module that reads or writes wants shares (the assigner that writes
|
||||
// them, the node-engine, the provisioner and the artifact store that read them). The layouts are the seat's contract; this
|
||||
// file writes the version and refuses what the earlier codec refused (novox/hq ADR 0528, ADR 0539, ADR 0546, ADR 0634 §4).
|
||||
package meshwantsclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
// The three values of the state wants, in the seat's types.
|
||||
type (
|
||||
// Want is a node's want for a module: the fingerprint it should run and the digest of the one composition it allows,
|
||||
// or Removed, or Self when the node composes it itself; Newest and Rule name what holds the node back.
|
||||
Want = seat.WantsByWantNodeModuleValue
|
||||
// NodeWant is a node's own want: the digest of the node's own composition it may apply.
|
||||
NodeWant = seat.WantsByWantNodeNodeValue
|
||||
// Held is a fingerprint the assigner holds: the node whose health check failed on it, and the check's words.
|
||||
Held = seat.WantsByHeldModuleFingerprintValue
|
||||
)
|
||||
|
||||
// The rules of ADR 0429 §6 and ADR 0539 clause 6, by number, as a want or a difference names the one that holds a node back.
|
||||
const (
|
||||
RuleBuildDone = 1 // the build of F is done
|
||||
RuleNotHeld = 2 // F is not held
|
||||
RuleCanary = 3 // the node is the module's canary, or the canary runs F healthy
|
||||
RuleStep = 4 // at most step other nodes are ahead (step 0: no limit, ADR 0528 §3)
|
||||
RuleProviders = 5 // every provider the module requires runs healthy on that node, or at its canary
|
||||
RuleGrant = 6 // the module's credential for F exists (grants.<module>.<fp>)
|
||||
RuleComposed = 7 // the module's composition for that node at F exists (ADR 0539 §6)
|
||||
// RuleProvisions: every provision the module requires on that node is provided (novox/hq ADR 0570 §4).
|
||||
RuleProvisions = 8
|
||||
)
|
||||
|
||||
// ruleRead is the highest rule a reader takes (novox/hq ADR 0614 §2, §4): 9 and 10 are kept for the verb wait and the
|
||||
// capability hold of a later release.
|
||||
const ruleRead = 10
|
||||
|
||||
// The answers a want carries to a failed backup before an apply (ADR 0539 clause 16).
|
||||
const (
|
||||
// BackupAgain is the answer to back the module up again before the apply.
|
||||
BackupAgain = seat.WantsByWantNodeModuleValueBackupAgain
|
||||
// BackupSkip is the answer to go on without a backup.
|
||||
BackupSkip = seat.WantsByWantNodeModuleValueBackupSkip
|
||||
)
|
||||
|
||||
// NodeWord is the last part of a node's own key.
|
||||
const NodeWord = "node"
|
||||
|
||||
const (
|
||||
wantWord = "want"
|
||||
heldWord = "held"
|
||||
srcWord = "src2:"
|
||||
)
|
||||
|
||||
var (
|
||||
moduleNameOK = regexp.MustCompile(`^[-/_a-zA-Z0-9]+(\.[-/_a-zA-Z0-9]+)*$`)
|
||||
digestForm = regexp.MustCompile(`^sha256:[0-9a-f]{64}$`)
|
||||
)
|
||||
|
||||
func moduleKeyPart(module string) (string, error) {
|
||||
if module == "" {
|
||||
return "", fmt.Errorf("wants: the module name is empty")
|
||||
}
|
||||
if !moduleNameOK.MatchString(module) {
|
||||
return "", fmt.Errorf("wants: the module name %q holds a wildcard, whitespace, '=', an empty part between dots or a character a key refuses", module)
|
||||
}
|
||||
return keys.EscapeName(module), nil
|
||||
}
|
||||
|
||||
func parseModuleKeyPart(part string) (string, error) {
|
||||
if err := keys.CheckName("module", part); err != nil {
|
||||
return "", err
|
||||
}
|
||||
module, err := keys.UnescapeName(part)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if back, err := moduleKeyPart(module); err != nil || back != part {
|
||||
return "", fmt.Errorf("wants: the module part %q is not a module name as a key writes it", part)
|
||||
}
|
||||
return module, nil
|
||||
}
|
||||
|
||||
func checkFingerprint(fp, of string) error {
|
||||
if part, ok := strings.CutPrefix(fp, srcWord); !ok || !keys.IsHex64(part) {
|
||||
return fmt.Errorf("wants: %s: %q is not a fingerprint of the new form, %s and 64 lowercase hex digits", of, fp, srcWord)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkDigest(digest, of string) error {
|
||||
if !digestForm.MatchString(digest) {
|
||||
return fmt.Errorf("wants: %s %q is not sha256:<64 lowercase hex digits>", of, digest)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkRule(rule int64, of string) error {
|
||||
if rule < RuleBuildDone || rule > ruleRead {
|
||||
return fmt.Errorf("wants: %s names the rule %d, which is not one of 1 to %d", of, rule, ruleRead)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WantKey is the key, in the state wants, of a node's want for a module: `want.<node>.<module>`. A module named `node` is
|
||||
// refused, since `want.<node>.node` is the node's own key.
|
||||
func WantKey(node, module string) (string, error) {
|
||||
if err := keys.CheckName("node", node); err != nil {
|
||||
return "", err
|
||||
}
|
||||
part, err := moduleKeyPart(module)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if module == NodeWord {
|
||||
return "", fmt.Errorf(`wants: the module name "node" is refused: want.%s.node is the node's own key`, node)
|
||||
}
|
||||
return seat.WantsByWantNodeModuleKey(node, part), nil
|
||||
}
|
||||
|
||||
// WantNodeKey is the key of a node's own want: `want.<node>.node`.
|
||||
func WantNodeKey(node string) (string, error) {
|
||||
if err := keys.CheckName("node", node); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return seat.WantsByWantNodeNodeKey(node), nil
|
||||
}
|
||||
|
||||
// ParseWantNodeKey is the inverse of WantNodeKey; it refuses a module's want key and any key of another form.
|
||||
func ParseWantNodeKey(key string) (node string, err error) {
|
||||
node, ok := seat.ParseWantsByWantNodeNodeKey(key)
|
||||
if !ok || keys.CheckName("node", node) != nil {
|
||||
return "", fmt.Errorf("wants: %q is not a node's own want key, want.<node>.node", key)
|
||||
}
|
||||
return node, nil
|
||||
}
|
||||
|
||||
// ParseWantKey is the inverse of WantKey; it refuses a held key, the node's own want key and any key of another form.
|
||||
func ParseWantKey(key string) (node, module string, err error) {
|
||||
refused := fmt.Errorf("wants: %q is not a want key, want.<node>.<module>", key)
|
||||
node, part, ok := seat.ParseWantsByWantNodeModuleKey(key)
|
||||
if !ok || part == NodeWord || keys.CheckName("node", node) != nil {
|
||||
return "", "", refused
|
||||
}
|
||||
if module, err = parseModuleKeyPart(part); err != nil {
|
||||
return "", "", refused
|
||||
}
|
||||
return node, module, nil
|
||||
}
|
||||
|
||||
// HeldKey is the key of a module's fingerprint the assigner holds: `held.<module>.<hex>`, the hex being the
|
||||
// fingerprint's key part.
|
||||
func HeldKey(module, fingerprint string) (string, error) {
|
||||
if err := keys.CheckName("module", module); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := checkFingerprint(fingerprint, "a held key's fingerprint"); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return seat.WantsByHeldModuleFingerprintKey(module, strings.TrimPrefix(fingerprint, srcWord)), nil
|
||||
}
|
||||
|
||||
// ParseHeldKey is the inverse of HeldKey: the module and the fingerprint (`src2:` and the hex).
|
||||
func ParseHeldKey(key string) (module, fingerprint string, err error) {
|
||||
module, part, ok := seat.ParseWantsByHeldModuleFingerprintKey(key)
|
||||
if !ok || keys.CheckName("module", module) != nil || !keys.IsHex64(part) {
|
||||
return "", "", fmt.Errorf("wants: %q is not a held key, held.<module>.<fingerprint hex>", key)
|
||||
}
|
||||
return module, srcWord + part, nil
|
||||
}
|
||||
|
||||
func checkWant(w Want) error {
|
||||
if w.Removed {
|
||||
if w.Fp != "" || w.Composed != "" || w.Newest != "" || w.Rule != 0 || w.Backup != "" || w.Put || w.Hold || w.Self || w.Yes != "" || w.Release != "" {
|
||||
return fmt.Errorf("wants: a removed want names no fingerprint, composition, rule, backup answer or put")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if w.Hold && !w.Put {
|
||||
return fmt.Errorf("wants: only a put holds a want")
|
||||
}
|
||||
if w.Put && (w.Newest != "" || w.Rule != 0) {
|
||||
return fmt.Errorf("wants: a put's want is held back by no rule")
|
||||
}
|
||||
if err := checkFingerprint(w.Fp, "a want's fingerprint"); err != nil {
|
||||
return err
|
||||
}
|
||||
// A node the catalogue places composes its own modules (ADR 0547 §2): its want is Self and names the build alone. Any
|
||||
// other want names the one composition it allows (ADR 0539 clause 1).
|
||||
switch {
|
||||
case w.Self && w.Composed != "":
|
||||
return fmt.Errorf("wants: the want of %s says the node composes it, and names a composition", w.Fp)
|
||||
case !w.Self && w.Composed == "":
|
||||
return fmt.Errorf("wants: the want of %s names no composition: a want names the digest of the one composition it allows (ADR 0539 clause 1), unless the node composes it itself", w.Fp)
|
||||
case w.Composed != "":
|
||||
if err := checkDigest(w.Composed, "a want's composition digest"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if w.Yes != "" {
|
||||
if err := checkDigest(w.Yes, "the digest a want's yes allows"); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if w.Release != "" {
|
||||
return fmt.Errorf("wants: the want of %s names the release %s and no yes it gave", w.Fp, w.Release)
|
||||
}
|
||||
switch w.Backup {
|
||||
case "", BackupAgain, BackupSkip:
|
||||
default:
|
||||
return fmt.Errorf("wants: the backup answer %q is not %s or %s", w.Backup, BackupAgain, BackupSkip)
|
||||
}
|
||||
if w.Newest == "" && w.Rule == 0 {
|
||||
return nil
|
||||
}
|
||||
if err := checkFingerprint(w.Newest, "a want's newest fingerprint"); err != nil {
|
||||
return err
|
||||
}
|
||||
if w.Newest == w.Fp {
|
||||
return fmt.Errorf("wants: a want at its newest fingerprint names no rule holding it back")
|
||||
}
|
||||
return checkRule(w.Rule, "a want held back")
|
||||
}
|
||||
|
||||
// CheckWant refuses a want the codec refuses.
|
||||
func CheckWant(w Want) error { return checkWant(w) }
|
||||
|
||||
// EncodeWant is w as JSON at the kept values' version; it refuses a fingerprint not of the new form, a removed want naming
|
||||
// one, and a want that names no composition unless the node composes it itself.
|
||||
func EncodeWant(w Want) ([]byte, error) {
|
||||
if err := checkWant(w); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w.V = keys.Version
|
||||
return json.Marshal(w)
|
||||
}
|
||||
|
||||
// DecodeWant reads a want; it refuses an unknown version (keys.ErrUnknownVersion), a field the contract does not know and
|
||||
// what EncodeWant refuses.
|
||||
func DecodeWant(data []byte) (Want, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return Want{}, err
|
||||
}
|
||||
w, err := seat.DecodeWantsByWantNodeModuleValue(data)
|
||||
if err != nil {
|
||||
return Want{}, fmt.Errorf("wants: value does not fit its shape: %w", err)
|
||||
}
|
||||
if err := checkWant(w); err != nil {
|
||||
return Want{}, err
|
||||
}
|
||||
return w, nil
|
||||
}
|
||||
|
||||
// SameWant says whether two wants are the same value, so the assigner writes only when they differ.
|
||||
func SameWant(a, b Want) bool { return reflect.DeepEqual(a, b) }
|
||||
|
||||
func checkNodeWant(w NodeWant) error {
|
||||
switch {
|
||||
case w.Self && w.Composed != "":
|
||||
return fmt.Errorf("wants: the node's own want says the node composes it, and names a composition")
|
||||
case w.Self:
|
||||
return nil
|
||||
}
|
||||
return checkDigest(w.Composed, "the node's own want's composition digest")
|
||||
}
|
||||
|
||||
// EncodeNodeWant is w as JSON; it refuses a digest not of the sha256 form, and a want that names no composition unless it
|
||||
// says the node composes its own (Self, ADR 0547 §2).
|
||||
func EncodeNodeWant(w NodeWant) ([]byte, error) {
|
||||
if err := checkNodeWant(w); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w.V = keys.Version
|
||||
return json.Marshal(w)
|
||||
}
|
||||
|
||||
// DecodeNodeWant reads a node's own want; it refuses an unknown version, a field a node's own want does not have (a
|
||||
// fingerprint among them), and what EncodeNodeWant refuses.
|
||||
func DecodeNodeWant(data []byte) (NodeWant, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return NodeWant{}, err
|
||||
}
|
||||
w, err := seat.DecodeWantsByWantNodeNodeValue(data)
|
||||
if err != nil {
|
||||
return NodeWant{}, fmt.Errorf("wants: a node's own want does not fit its shape: %w", err)
|
||||
}
|
||||
if err := checkNodeWant(w); err != nil {
|
||||
return NodeWant{}, err
|
||||
}
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func checkHeld(h Held) error { return keys.CheckName("node", h.Node) }
|
||||
|
||||
// EncodeHeld is h as JSON; it refuses a node name a key refuses.
|
||||
func EncodeHeld(h Held) ([]byte, error) {
|
||||
if err := checkHeld(h); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
h.V = keys.Version
|
||||
return json.Marshal(h)
|
||||
}
|
||||
|
||||
// DecodeHeld reads a hold; it refuses an unknown version and what EncodeHeld refuses.
|
||||
func DecodeHeld(data []byte) (Held, error) {
|
||||
if err := keys.CheckVersion(data); err != nil {
|
||||
return Held{}, err
|
||||
}
|
||||
h, err := seat.DecodeWantsByHeldModuleFingerprintValue(data)
|
||||
if err != nil {
|
||||
return Held{}, fmt.Errorf("wants: value does not fit its shape: %w", err)
|
||||
}
|
||||
if err := checkHeld(h); err != nil {
|
||||
return Held{}, err
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// SameHeld says whether two holds are the same value.
|
||||
func SameHeld(a, b Held) bool { return a == b }
|
||||
@@ -1,212 +0,0 @@
|
||||
package meshwantsclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
func rep(c string) string { return strings.Repeat(c, 64) }
|
||||
|
||||
// TestWantsAreWhatTheEarlierCodecWrote holds the values and keys equal to what go/delivery's codec wrote for the same
|
||||
// values (the golden texts are its output; the field order is the contract's now, so values are compared decoded), and the
|
||||
// refusals it made.
|
||||
func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) {
|
||||
a, b, c, d := "src2:"+rep("a"), "src2:"+rep("b"), "sha256:"+rep("c"), "sha256:"+rep("d")
|
||||
sameJSON := func(t *testing.T, got []byte, want string) {
|
||||
t.Helper()
|
||||
var g, w any
|
||||
if err := json.Unmarshal(got, &g); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(want), &w); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(g, w) {
|
||||
t.Fatalf("wrote %s, the earlier codec wrote %s", got, want)
|
||||
}
|
||||
}
|
||||
t.Run("wants", func(t *testing.T) {
|
||||
for name, row := range map[string]struct {
|
||||
w Want
|
||||
golden string
|
||||
}{
|
||||
"composed": {Want{Fp: a, Composed: c, Words: "w"}, `{"v":1,"fp":"` + a + `","composed":"` + c + `","words":"w"}`},
|
||||
"held back": {Want{Fp: a, Self: true, Newest: b, Rule: RuleGrant, Backup: BackupAgain, Words: "held"}, `{"v":1,"fp":"` + a + `","newest":"` + b + `","rule":6,"backup":"again","words":"held","self":true}`},
|
||||
"put": {Want{Fp: a, Self: true, Put: true, Hold: true, Yes: d, Release: "r1"}, `{"v":1,"fp":"` + a + `","put":true,"hold":true,"yes":"` + d + `","release":"r1","self":true}`},
|
||||
"removed": {Want{Removed: true, Words: "gone"}, `{"v":1,"removed":true,"words":"gone"}`},
|
||||
"released": {Want{Fp: a, Composed: c, Version: "0.1.15", Parts: map[string]string{"mesh-sdk:go": d}}, `{"v":1,"fp":"` + a + `","composed":"` + c + `","version":"0.1.15","parts":{"mesh-sdk:go":"` + d + `"}}`},
|
||||
"kept": {Want{Fp: a, Composed: c, Parts: map[string]string{"x:image": d}, KeptOn: "n1"}, `{"v":1,"fp":"` + a + `","composed":"` + c + `","parts":{"x:image":"` + d + `"},"kept-on":"n1"}`},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
raw, err := EncodeWant(row.w)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sameJSON(t, raw, row.golden)
|
||||
back, err := DecodeWant(raw)
|
||||
if err != nil || !SameWant(back, func() Want { w := row.w; w.V = keys.Version; return w }()) {
|
||||
t.Fatalf("read back %+v, %v", back, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
t.Run("refused", func(t *testing.T) {
|
||||
for name, w := range map[string]Want{
|
||||
"old fingerprint": {Fp: "src1:abc", Composed: c},
|
||||
"no composition": {Fp: a},
|
||||
"self and composition": {Fp: a, Self: true, Composed: c},
|
||||
"hold without put": {Fp: a, Self: true, Hold: true},
|
||||
"put held back": {Fp: a, Self: true, Put: true, Newest: b, Rule: RuleStep},
|
||||
"removed names a rule": {Removed: true, Rule: 1},
|
||||
"release without yes": {Fp: a, Self: true, Release: "r"},
|
||||
"backup answer unknown": {Fp: a, Self: true, Backup: "later"},
|
||||
"newest equals fp": {Fp: a, Self: true, Newest: a, Rule: RuleStep},
|
||||
"rule 11": {Fp: a, Self: true, Newest: b, Rule: 11},
|
||||
"newest without a rule": {Fp: a, Self: true, Newest: b},
|
||||
"composition not sha256": {Fp: a, Composed: "sha256:xyz"},
|
||||
} {
|
||||
if _, err := EncodeWant(w); err == nil {
|
||||
t.Errorf("%s: written", name)
|
||||
}
|
||||
}
|
||||
if _, err := EncodeWant(Want{Fp: a, Self: true, Newest: b, Rule: 10}); err != nil {
|
||||
t.Errorf("rule 10 is read: %v", err)
|
||||
}
|
||||
if _, err := DecodeWant([]byte(`{"fp":"` + a + `","self":true}`)); !errors.Is(err, keys.ErrUnknownVersion) {
|
||||
t.Errorf("no version: %v", err)
|
||||
}
|
||||
if _, err := DecodeWant([]byte(`{"v":1,"fp":"` + a + `","self":true,"extra":1}`)); err == nil {
|
||||
t.Error("an unknown field is read")
|
||||
}
|
||||
})
|
||||
t.Run("node want and hold", func(t *testing.T) {
|
||||
raw, err := EncodeNodeWant(NodeWant{Composed: c, Words: "n"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sameJSON(t, raw, `{"v":1,"composed":"`+c+`","words":"n"}`)
|
||||
raw, err = EncodeNodeWant(NodeWant{Self: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sameJSON(t, raw, `{"v":1,"composed":"","self":true}`)
|
||||
if back, err := DecodeNodeWant(raw); err != nil || !back.Self {
|
||||
t.Fatalf("%+v %v", back, err)
|
||||
}
|
||||
for name, w := range map[string]NodeWant{"none": {}, "both": {Self: true, Composed: c}, "bad": {Composed: "x"}} {
|
||||
if _, err := EncodeNodeWant(w); err == nil {
|
||||
t.Errorf("%s: written", name)
|
||||
}
|
||||
}
|
||||
if _, err := DecodeNodeWant([]byte(`{"v":1,"composed":"` + c + `","fp":"` + a + `"}`)); err == nil {
|
||||
t.Error("a fingerprint in a node's own want is read")
|
||||
}
|
||||
raw, err = EncodeHeld(Held{Node: "ace", Words: "unhealthy"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sameJSON(t, raw, `{"v":1,"node":"ace","words":"unhealthy"}`)
|
||||
if h, err := DecodeHeld(raw); err != nil || !SameHeld(h, Held{V: 1, Node: "ace", Words: "unhealthy"}) {
|
||||
t.Fatalf("%+v %v", h, err)
|
||||
}
|
||||
if _, err := EncodeHeld(Held{Node: "a.b"}); err == nil {
|
||||
t.Error("a node with a dot is held")
|
||||
}
|
||||
})
|
||||
t.Run("keys", func(t *testing.T) {
|
||||
for _, row := range []struct{ module, want string }{
|
||||
{"mesh-delivery-assigner", "want.ace.mesh-delivery-assigner"},
|
||||
{"novox.be", "want.ace.novox=2ebe"},
|
||||
} {
|
||||
k, err := WantKey("ace", row.module)
|
||||
if err != nil || k != row.want {
|
||||
t.Fatalf("WantKey %s = %q, %v", row.module, k, err)
|
||||
}
|
||||
if n, m, err := ParseWantKey(k); err != nil || n != "ace" || m != row.module {
|
||||
t.Fatalf("ParseWantKey %q = %q %q %v", k, n, m, err)
|
||||
}
|
||||
}
|
||||
if k, err := HeldKey("mesh-delivery-assigner", a); err != nil || k != "held.mesh-delivery-assigner."+rep("a") {
|
||||
t.Fatalf("HeldKey = %q %v", k, err)
|
||||
}
|
||||
if m, fp, err := ParseHeldKey("held.mesh-delivery-assigner." + rep("a")); err != nil || m != "mesh-delivery-assigner" || fp != a {
|
||||
t.Fatalf("ParseHeldKey = %q %q %v", m, fp, err)
|
||||
}
|
||||
if k, err := WantNodeKey("ace"); err != nil || k != "want.ace.node" {
|
||||
t.Fatalf("WantNodeKey = %q %v", k, err)
|
||||
}
|
||||
if n, err := ParseWantNodeKey("want.ace.node"); err != nil || n != "ace" {
|
||||
t.Fatalf("ParseWantNodeKey = %q %v", n, err)
|
||||
}
|
||||
if _, err := WantKey("ace", "node"); err == nil {
|
||||
t.Error("a module named node has a want key")
|
||||
}
|
||||
if _, err := HeldKey("novox.be", a); err == nil {
|
||||
t.Error("a module with a dot has a held key")
|
||||
}
|
||||
for _, key := range []string{"want.ace.node", "held.m." + rep("a"), "ace.m", "want.ace", "want..m"} {
|
||||
if _, _, err := ParseWantKey(key); err == nil {
|
||||
t.Errorf("%q is a want key", key)
|
||||
}
|
||||
}
|
||||
if _, err := ParseWantNodeKey("want.ace.m"); err == nil {
|
||||
t.Error("a module's want is a node's own")
|
||||
}
|
||||
if _, _, err := ParseHeldKey("want.ace.m"); err == nil {
|
||||
t.Error("a want key is a held key")
|
||||
}
|
||||
})
|
||||
|
||||
// Design 47 *Each part acts on its own entries*: the placements a part's toolchain gate counts come from the assignment
|
||||
// half's revisions, never the assigner's state; a pair stands since the zero time in the first revision taken, since its
|
||||
// revision's time in a later one, and an older or the same revision moves nothing.
|
||||
t.Run("placed from the assignment half", func(t *testing.T) {
|
||||
later := time.Date(2026, 11, 10, 18, 0, 0, 0, time.UTC)
|
||||
rev := func(n int64, at *time.Time, pairs ...string) seat.AssignmentRevision {
|
||||
r := seat.AssignmentRevision{Revision: n, Kind: "trunk", At: at}
|
||||
for _, p := range pairs {
|
||||
node, module, _ := strings.Cut(p, "/")
|
||||
r.Entries = append(r.Entries, seat.NodeEntryRef{Node: node, Module: module, Digest: "d-" + p})
|
||||
}
|
||||
return r
|
||||
}
|
||||
p := NewPlaced()
|
||||
if p.Seeded() {
|
||||
t.Fatal("no revision taken, yet seeded")
|
||||
}
|
||||
first := later.Add(-time.Hour)
|
||||
if got := p.Take(rev(3, &first, "ace/mesh-build-go", "g14/mesh-build-go", "g14/mesh-build-node")); !reflect.DeepEqual(got,
|
||||
map[string][]string{"ace": {"mesh-build-go"}, "g14": {"mesh-build-go", "mesh-build-node"}}) {
|
||||
t.Fatalf("first revision changed %v", got)
|
||||
}
|
||||
if s, ok := p.Since("ace", "mesh-build-go"); !ok || !s.IsZero() {
|
||||
t.Fatalf("a pair of the first revision stands since %v (%v), want the zero time", s, ok)
|
||||
}
|
||||
if got := p.Take(rev(4, &later, "ace/mesh-build-go", "ace/mesh-build-node", "g14/mesh-build-go")); !reflect.DeepEqual(got,
|
||||
map[string][]string{"ace": {"mesh-build-node"}, "g14": {"mesh-build-node"}}) {
|
||||
t.Fatalf("revision 4 changed %v, want mesh-build-node placed on ace and taken off g14", got)
|
||||
}
|
||||
if s, ok := p.Since("ace", "mesh-build-node"); !ok || !s.Equal(later) {
|
||||
t.Fatalf("a pair new in revision 4 stands since %v (%v), want its time %v", s, ok, later)
|
||||
}
|
||||
if s, _ := p.Since("ace", "mesh-build-go"); !s.IsZero() {
|
||||
t.Fatalf("a pair named again keeps its time, got %v", s)
|
||||
}
|
||||
if _, ok := p.Since("g14", "mesh-build-node"); ok {
|
||||
t.Fatal("a pair revision 4 does not name still stands")
|
||||
}
|
||||
if got := p.Take(rev(4, &later)); got != nil || !p.Seeded() || p.Revision() != 4 {
|
||||
t.Fatalf("the same revision again moved %v", got)
|
||||
}
|
||||
if got := p.ByNode(); !reflect.DeepEqual(got, map[string][]string{"ace": {"mesh-build-go", "mesh-build-node"}, "g14": {"mesh-build-go"}}) {
|
||||
t.Fatalf("by node %v", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Package npmpackageregistryclient is the npm-package-registry seat's client (novox/hq ADR 0627 §1, §2; ADR 0611, design 51
|
||||
// *Publishing*): it publishes a file in parts to the seat's holder. `publish` opens the transfer naming every part,
|
||||
// the holder answers the parts it lacks, and only those travel by `publish-part`, in chunks a bus message carries; a
|
||||
// cut transfer goes on from what the holder answers when the same transfer is opened again. The sending in parts is
|
||||
// mesh-sdk's seat-neutral runtime (parts); this client binds it to this seat's verbs and types alone. The call is the
|
||||
// caller's own (a bundle's stdio.Ask, a process's call of a seat verb), so it holds no transport.
|
||||
package npmpackageregistryclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/npmpackageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// Call asks one verb of the seat, `seat:<seat>.<verb>`, with a body, and answers its JSON.
|
||||
type Call func(key string, body any) (json.RawMessage, error)
|
||||
|
||||
// Sent is what a Publish did: the transfer, whether the holder held its digest already, the parts it lacked and were
|
||||
// sent, and the chunks they took.
|
||||
type Sent struct {
|
||||
Transfer string
|
||||
parts.Sent
|
||||
}
|
||||
|
||||
// Publish opens (or opens again) the transfer in on the seat and sends the parts the holder answers it lacks, each in
|
||||
// chunks of at most parts.MaxChunk, in sequence, the last marked. in.Parts is written from parts. A part whose bytes
|
||||
// do not hash to its digest is refused before anything of it is sent; a part the holder does not name is never read.
|
||||
// Its outcome, published or refused, is the holder's event, which the caller waits for.
|
||||
func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Part) (Sent, error) {
|
||||
open := func(_ context.Context, ps []parts.Part) (parts.Opened, error) {
|
||||
in.Parts = make([]seat.Part, 0, len(ps))
|
||||
for _, p := range ps {
|
||||
in.Parts = append(in.Parts, seat.Part{Digest: p.Digest, Size: p.Size})
|
||||
}
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublish, in)
|
||||
if err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's publish of %s: %w", seat.Seat, in.Name, err)
|
||||
}
|
||||
var a seat.PublishAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err)
|
||||
}
|
||||
return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil
|
||||
}
|
||||
chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error {
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part,
|
||||
Sequence: int64(sequence), Last: last, Data: base64.StdEncoding.EncodeToString(data)})
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s's publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
var a seat.PublishPartAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return fmt.Errorf("%s's answer to publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
sent, err := parts.Send(ctx, open, chunk, ps)
|
||||
return Sent{Transfer: in.Transfer, Sent: sent}, err
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package npmpackageregistryclient
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/npmpackageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// The client publishes over its own seat's verbs alone (ADR 0627 §1): publish names every part, and only the part the
|
||||
// holder lacks travels by publish-part, its bytes whole, the last chunk marked.
|
||||
func TestPublishTalksToItsOwnSeat(t *testing.T) {
|
||||
held, lacked := []byte("held"), []byte("lacked")
|
||||
part := func(b []byte) parts.Part {
|
||||
sum := sha256.Sum256(b)
|
||||
return parts.Part{Digest: "sha256:" + hex.EncodeToString(sum[:]), Size: int64(len(b)),
|
||||
Open: func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(b)), nil }}
|
||||
}
|
||||
ps := []parts.Part{part(held), part(lacked)}
|
||||
var asked []string
|
||||
var got []byte
|
||||
call := func(key string, body any) (json.RawMessage, error) {
|
||||
asked = append(asked, key)
|
||||
raw, _ := json.Marshal(body)
|
||||
switch key {
|
||||
case "seat:npm-package-registry.publish":
|
||||
var in seat.PublishInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
if len(in.Parts) != 2 {
|
||||
t.Errorf("publish names %d parts, want 2", len(in.Parts))
|
||||
}
|
||||
return json.Marshal(seat.PublishAnswer{Transfer: in.Transfer, Lacks: []string{ps[1].Digest}})
|
||||
case "seat:npm-package-registry.publish-part":
|
||||
var in seat.PublishPartInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
data, _ := base64.StdEncoding.DecodeString(in.Data)
|
||||
if in.Part != ps[1].Digest || !in.Last || in.Transfer != "t1" {
|
||||
t.Errorf("publish-part %+v", in)
|
||||
}
|
||||
got = append(got, data...)
|
||||
return json.Marshal(seat.PublishPartAnswer{Transfer: in.Transfer, Part: in.Part})
|
||||
}
|
||||
t.Fatalf("asked %s", key)
|
||||
return nil, nil
|
||||
}
|
||||
sent, err := Publish(context.Background(), call, seat.PublishInput{Transfer: "t1", Name: "x"}, ps)
|
||||
if err != nil || sent.Transfer != "t1" || sent.Chunks != 1 || len(sent.Parts) != 1 || !bytes.Equal(got, lacked) || len(asked) != 2 {
|
||||
t.Errorf("sent %+v, %q arrived, asked %v, %v", sent, got, asked, err)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/npmpackageregistryclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/npmpackageregistry v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-delivery/sdk v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/klauspost/compress v1.20.1 // indirect
|
||||
github.com/nats-io/nats.go v1.54.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
@@ -1,63 +0,0 @@
|
||||
// Package ociartifactregistryclient is the oci-artifact-registry seat's client (novox/hq ADR 0627 §1, §2; ADR 0611, design 51
|
||||
// *Publishing*): it publishes a file in parts to the seat's holder. `publish` opens the transfer naming every part,
|
||||
// the holder answers the parts it lacks, and only those travel by `publish-part`, in chunks a bus message carries; a
|
||||
// cut transfer goes on from what the holder answers when the same transfer is opened again. The sending in parts is
|
||||
// mesh-sdk's seat-neutral runtime (parts); this client binds it to this seat's verbs and types alone. The call is the
|
||||
// caller's own (a bundle's stdio.Ask, a process's call of a seat verb), so it holds no transport.
|
||||
package ociartifactregistryclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/ociartifactregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// Call asks one verb of the seat, `seat:<seat>.<verb>`, with a body, and answers its JSON.
|
||||
type Call func(key string, body any) (json.RawMessage, error)
|
||||
|
||||
// Sent is what a Publish did: the transfer, whether the holder held its digest already, the parts it lacked and were
|
||||
// sent, and the chunks they took.
|
||||
type Sent struct {
|
||||
Transfer string
|
||||
parts.Sent
|
||||
}
|
||||
|
||||
// Publish opens (or opens again) the transfer in on the seat and sends the parts the holder answers it lacks, each in
|
||||
// chunks of at most parts.MaxChunk, in sequence, the last marked. in.Parts is written from parts. A part whose bytes
|
||||
// do not hash to its digest is refused before anything of it is sent; a part the holder does not name is never read.
|
||||
// Its outcome, published or refused, is the holder's event, which the caller waits for.
|
||||
func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Part) (Sent, error) {
|
||||
open := func(_ context.Context, ps []parts.Part) (parts.Opened, error) {
|
||||
in.Parts = make([]seat.Part, 0, len(ps))
|
||||
for _, p := range ps {
|
||||
in.Parts = append(in.Parts, seat.Part{Digest: p.Digest, Size: p.Size})
|
||||
}
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublish, in)
|
||||
if err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's publish of %s: %w", seat.Seat, in.Name, err)
|
||||
}
|
||||
var a seat.PublishAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err)
|
||||
}
|
||||
return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil
|
||||
}
|
||||
chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error {
|
||||
raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part,
|
||||
Sequence: int64(sequence), Last: last, Data: base64.StdEncoding.EncodeToString(data)})
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s's publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
var a seat.PublishPartAnswer
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return fmt.Errorf("%s's answer to publish-part: %w", seat.Seat, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
sent, err := parts.Send(ctx, open, chunk, ps)
|
||||
return Sent{Transfer: in.Transfer, Sent: sent}, err
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package ociartifactregistryclient
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/ociartifactregistry"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/parts"
|
||||
)
|
||||
|
||||
// The client publishes over its own seat's verbs alone (ADR 0627 §1): publish names every part, and only the part the
|
||||
// holder lacks travels by publish-part, its bytes whole, the last chunk marked.
|
||||
func TestPublishTalksToItsOwnSeat(t *testing.T) {
|
||||
held, lacked := []byte("held"), []byte("lacked")
|
||||
part := func(b []byte) parts.Part {
|
||||
sum := sha256.Sum256(b)
|
||||
return parts.Part{Digest: "sha256:" + hex.EncodeToString(sum[:]), Size: int64(len(b)),
|
||||
Open: func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(b)), nil }}
|
||||
}
|
||||
ps := []parts.Part{part(held), part(lacked)}
|
||||
var asked []string
|
||||
var got []byte
|
||||
call := func(key string, body any) (json.RawMessage, error) {
|
||||
asked = append(asked, key)
|
||||
raw, _ := json.Marshal(body)
|
||||
switch key {
|
||||
case "seat:oci-artifact-registry.publish":
|
||||
var in seat.PublishInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
if len(in.Parts) != 2 {
|
||||
t.Errorf("publish names %d parts, want 2", len(in.Parts))
|
||||
}
|
||||
return json.Marshal(seat.PublishAnswer{Transfer: in.Transfer, Lacks: []string{ps[1].Digest}})
|
||||
case "seat:oci-artifact-registry.publish-part":
|
||||
var in seat.PublishPartInput
|
||||
_ = json.Unmarshal(raw, &in)
|
||||
data, _ := base64.StdEncoding.DecodeString(in.Data)
|
||||
if in.Part != ps[1].Digest || !in.Last || in.Transfer != "t1" {
|
||||
t.Errorf("publish-part %+v", in)
|
||||
}
|
||||
got = append(got, data...)
|
||||
return json.Marshal(seat.PublishPartAnswer{Transfer: in.Transfer, Part: in.Part})
|
||||
}
|
||||
t.Fatalf("asked %s", key)
|
||||
return nil, nil
|
||||
}
|
||||
sent, err := Publish(context.Background(), call, seat.PublishInput{Transfer: "t1", Name: "x"}, ps)
|
||||
if err != nil || sent.Transfer != "t1" || sent.Chunks != 1 || len(sent.Parts) != 1 || !bytes.Equal(got, lacked) || len(asked) != 2 {
|
||||
t.Errorf("sent %+v, %q arrived, asked %v, %v", sent, got, asked, err)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/clients/ociartifactregistryclient
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-delivery/contracts/go/seats/ociartifactregistry v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-delivery/sdk v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
require (
|
||||
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/klauspost/compress v1.20.1 // indirect
|
||||
github.com/nats-io/nats.go v1.54.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ=
|
||||
github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/nats-io/nats.go v1.54.0 h1:vsXoOxjHp/GmPUN+EcI7uOf/uB+iAP+kEsAFNQN0yzA=
|
||||
github.com/nats-io/nats.go v1.54.0/go.mod h1:y+DZoD1oBOYfZTU681eTUiUjI0vbqYGixNVFHcjHJ0k=
|
||||
github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg=
|
||||
github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
@@ -1,528 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package containerimageregistry is the contract of the seat "container-image-registry", defined whole (seats/container-image-registry/seat.json): The mesh's container images, in the one artifact store: the OCI distribution protocol's read side, an image's tags and mirroring an outside image.
|
||||
package containerimageregistry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "container-image-registry"
|
||||
|
||||
const (
|
||||
VerbPublish = "publish"
|
||||
VerbPublishPart = "publish-part"
|
||||
VerbVersions = "versions"
|
||||
VerbRemove = "remove"
|
||||
VerbMirror = "mirror"
|
||||
VerbTags = "tags"
|
||||
VerbHold = "hold"
|
||||
VerbRelease = "release"
|
||||
VerbList = "list"
|
||||
)
|
||||
|
||||
const (
|
||||
EventPublished = "published"
|
||||
EventRefused = "refused"
|
||||
EventRemoved = "removed"
|
||||
EventKept = "kept"
|
||||
EventHeld = "held"
|
||||
EventReleased = "released"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbPublish, VerbPublishPart, VerbVersions, VerbRemove, VerbMirror, VerbTags, VerbHold, VerbRelease, VerbList}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventPublished, EventRefused, EventRemoved, EventKept, EventHeld, EventReleased}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "container-image-registry.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// SubjectPublished is where published is published.
|
||||
const SubjectPublished = "mesh.seat.container-image-registry.event.published"
|
||||
|
||||
// SubjectRefused is where refused is published.
|
||||
const SubjectRefused = "mesh.seat.container-image-registry.event.refused"
|
||||
|
||||
// SubjectRemoved is where removed is published.
|
||||
const SubjectRemoved = "mesh.seat.container-image-registry.event.removed"
|
||||
|
||||
// SubjectKept is where kept is published.
|
||||
const SubjectKept = "mesh.seat.container-image-registry.event.kept"
|
||||
|
||||
// SubjectHeld is where held is published.
|
||||
const SubjectHeld = "mesh.seat.container-image-registry.event.held"
|
||||
|
||||
// SubjectReleased is where released is published.
|
||||
const SubjectReleased = "mesh.seat.container-image-registry.event.released"
|
||||
|
||||
const (
|
||||
StateHolds = "holds"
|
||||
StateWindows = "windows"
|
||||
)
|
||||
|
||||
// HoldsBySeatNameDigestKey is the key of one value of the state holds under the form "<seat>.<name>.<digest>".
|
||||
func HoldsBySeatNameDigestKey(seat, name, digest string) string {
|
||||
return seat + "." + name + "." + digest
|
||||
}
|
||||
|
||||
// ParseHoldsBySeatNameDigestKey reads the parts of a key of the form "<seat>.<name>.<digest>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseHoldsBySeatNameDigestKey(key string) (string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
if rest == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
v4 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, true
|
||||
}
|
||||
|
||||
// DecodeHoldsBySeatNameDigestValue reads one value of the state holds under the form "<seat>.<name>.<digest>", refusing a field HoldsBySeatNameDigestValue does not know and any text after the value.
|
||||
func DecodeHoldsBySeatNameDigestValue(raw []byte) (HoldsBySeatNameDigestValue, error) {
|
||||
var v HoldsBySeatNameDigestValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// WindowsByCallerKey is the key of one value of the state windows under the form "<caller>".
|
||||
func WindowsByCallerKey(caller string) string { return caller }
|
||||
|
||||
// ParseWindowsByCallerKey reads the parts of a key of the form "<caller>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseWindowsByCallerKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodeWindowsByCallerValue reads one value of the state windows under the form "<caller>", refusing a field WindowsByCallerValue does not know and any text after the value.
|
||||
func DecodeWindowsByCallerValue(raw []byte) (WindowsByCallerValue, error) {
|
||||
var v WindowsByCallerValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Artifact is one published thing, as every registry event and answer names it.
|
||||
type Artifact struct {
|
||||
// the source commit it was built from
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// its digest, sha256:<hex> (a Go package's h1: hash beside it in the version's record)
|
||||
Digest string `json:"digest"`
|
||||
// the build's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// what it is
|
||||
Kind string `json:"kind"`
|
||||
// the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk)
|
||||
Name string `json:"name"`
|
||||
// the tag it carries, for a tagged version
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Artifact's kind.
|
||||
const (
|
||||
ArtifactKindPackage = "package"
|
||||
ArtifactKindImage = "image"
|
||||
ArtifactKindBundle = "bundle"
|
||||
ArtifactKindArchive = "archive"
|
||||
ArtifactKindUpstream = "upstream"
|
||||
)
|
||||
|
||||
// Hold is the body of held and released.
|
||||
type Hold struct {
|
||||
// when, RFC 3339
|
||||
At string `json:"at,omitempty"`
|
||||
// the caller the holder proved
|
||||
By string `json:"by,omitempty"`
|
||||
// the digest
|
||||
Digest string `json:"digest"`
|
||||
// the module holding the seat
|
||||
Holder string `json:"holder"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// why
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Listed is a type of the contract.
|
||||
type Listed struct {
|
||||
// for a manifest keeping one bundle or archive, the digest of that blob: what a reference names it by
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
// the manifest's digest, sha256:<hex>
|
||||
Digest string `json:"digest"`
|
||||
// a hold keeps it from retention
|
||||
Held bool `json:"held"`
|
||||
// it is an index, naming a manifest per platform
|
||||
Index bool `json:"index"`
|
||||
// for an index, the digests of the manifests it names
|
||||
Platforms []string `json:"platforms,omitempty"`
|
||||
// its bytes: its own content and every blob it names
|
||||
Size int64 `json:"size"`
|
||||
// the tags naming it, none for an untagged one
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// Outcome is the body of published, refused and removed.
|
||||
type Outcome struct {
|
||||
// the source commit it was built from
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// its digest, sha256:<hex> (a Go package's h1: hash beside it in the version's record)
|
||||
Digest string `json:"digest"`
|
||||
// the build's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the module holding the seat that said it
|
||||
Holder string `json:"holder"`
|
||||
// what it is
|
||||
Kind string `json:"kind"`
|
||||
// the Go module path a Go package is fetched under, equal to name for a Go package (go-package-registry's published); empty for every other kind of artifact
|
||||
Module string `json:"module,omitempty"`
|
||||
// the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk)
|
||||
Name string `json:"name"`
|
||||
// why: a refusal's cause, a removal's (retention, tag-gone, by-hand), or why a removal was kept (shared-digest)
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// the reference the seat answers: <registry>/<module>/<artifact>@sha256:<digest>, or <name>@<version> for a package (ADR 0605 §9)
|
||||
Reference string `json:"reference,omitempty"`
|
||||
// the tag it carries, for a tagged version
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// for kept: the other tags still naming its digest
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
// the transfer it ends, when it ended one
|
||||
Transfer string `json:"transfer,omitempty"`
|
||||
// the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Outcome's kind.
|
||||
const (
|
||||
OutcomeKindPackage = "package"
|
||||
OutcomeKindImage = "image"
|
||||
OutcomeKindBundle = "bundle"
|
||||
OutcomeKindArchive = "archive"
|
||||
OutcomeKindUpstream = "upstream"
|
||||
)
|
||||
|
||||
// Part is one part of a transfer.
|
||||
type Part struct {
|
||||
// the part's digest, sha256:<hex>: an image's layer or config, a package's file, a bundle's blob
|
||||
Digest string `json:"digest"`
|
||||
// its size in bytes
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
// Repository is a type of the contract.
|
||||
type Repository struct {
|
||||
// each manifest it holds, by digest
|
||||
Manifests []Listed `json:"manifests"`
|
||||
// the repository
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// PublishInput is what publish takes.
|
||||
type PublishInput struct {
|
||||
// the source commit it was built from
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// its digest, sha256:<hex> (a Go package's h1: hash beside it in the version's record)
|
||||
Digest string `json:"digest"`
|
||||
// the build's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// what it is
|
||||
Kind string `json:"kind"`
|
||||
// the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk)
|
||||
Name string `json:"name"`
|
||||
// every part's digest and size; none when the digest is already held
|
||||
Parts []Part `json:"parts,omitempty"`
|
||||
// the tag it carries, for a tagged version
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// the transfer's name, the caller's own; the same name opens the same transfer again
|
||||
Transfer string `json:"transfer"`
|
||||
// the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of PublishInput's kind.
|
||||
const (
|
||||
PublishInputKindPackage = "package"
|
||||
PublishInputKindImage = "image"
|
||||
PublishInputKindBundle = "bundle"
|
||||
PublishInputKindArchive = "archive"
|
||||
PublishInputKindUpstream = "upstream"
|
||||
)
|
||||
|
||||
// PublishAnswer is what publish answers.
|
||||
type PublishAnswer struct {
|
||||
// the digest is held already: nothing to send; the outcome follows as an event
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the digests of the parts the holder lacks, to send by publish-part
|
||||
Lacks []string `json:"lacks,omitempty"`
|
||||
// the transfer
|
||||
Transfer string `json:"transfer"`
|
||||
}
|
||||
|
||||
// PublishPartInput is what publish-part takes.
|
||||
type PublishPartInput struct {
|
||||
// the chunk's bytes, base64 (at most 760 KiB before encoding)
|
||||
Data string `json:"data"`
|
||||
// this chunk is the part's last
|
||||
Last bool `json:"last"`
|
||||
// the part's digest
|
||||
Part string `json:"part"`
|
||||
// the chunk's place in its part, from 0
|
||||
Sequence int64 `json:"sequence"`
|
||||
// the transfer
|
||||
Transfer string `json:"transfer"`
|
||||
}
|
||||
|
||||
// PublishPartAnswer is what publish-part answers.
|
||||
type PublishPartAnswer struct {
|
||||
// the part is whole and its bytes match its digest
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
// the part
|
||||
Part string `json:"part"`
|
||||
// the chunks of the part held so far
|
||||
Received int64 `json:"received,omitempty"`
|
||||
// the transfer
|
||||
Transfer string `json:"transfer"`
|
||||
}
|
||||
|
||||
// VersionsInput is what versions takes.
|
||||
type VersionsInput struct {
|
||||
// narrowed to one kind (optional)
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// VersionsAnswer is what versions answers.
|
||||
type VersionsAnswer struct {
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// newest first
|
||||
Versions []Artifact `json:"versions"`
|
||||
}
|
||||
|
||||
// RemoveInput is what remove takes.
|
||||
type RemoveInput struct {
|
||||
// the digest (for a bundle, archive or copied base)
|
||||
Digest string `json:"digest,omitempty"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// why it goes
|
||||
Reason string `json:"reason"`
|
||||
// the tag (for a tagged version)
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// the version
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of RemoveInput's reason.
|
||||
const (
|
||||
RemoveInputReasonTagGone = "tag-gone"
|
||||
RemoveInputReasonRetention = "retention"
|
||||
)
|
||||
|
||||
// RemoveAnswer is what remove answers.
|
||||
type RemoveAnswer struct {
|
||||
Artifact *Artifact `json:"artifact,omitempty"`
|
||||
// it stays whole, its tag and its bytes: the store cannot remove the tag alone while another tag names its digest (reason, tags)
|
||||
Kept bool `json:"kept,omitempty"`
|
||||
// why it was kept: shared-digest, another tag names its digest
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// it is gone
|
||||
Removed bool `json:"removed"`
|
||||
// the other tags still naming its digest, when kept
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// The values of RemoveAnswer's reason.
|
||||
const (
|
||||
RemoveAnswerReasonSharedDigest = "shared-digest"
|
||||
)
|
||||
|
||||
// MirrorInput is what mirror takes.
|
||||
type MirrorInput struct {
|
||||
// its pinned digest, sha256:<hex>
|
||||
Digest string `json:"digest"`
|
||||
// the name it is kept under
|
||||
Name string `json:"name"`
|
||||
// the outside image's reference
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
// MirrorAnswer is what mirror answers.
|
||||
type MirrorAnswer struct {
|
||||
// the digest stored
|
||||
Digest string `json:"digest"`
|
||||
// the reference the seat answers
|
||||
Reference string `json:"reference"`
|
||||
}
|
||||
|
||||
// TagsInput is what tags takes.
|
||||
type TagsInput struct {
|
||||
// the image
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// TagsAnswerTagsItem is a type of the contract.
|
||||
type TagsAnswerTagsItem struct {
|
||||
// its digest
|
||||
Digest string `json:"digest"`
|
||||
// the tag
|
||||
Tag string `json:"tag"`
|
||||
}
|
||||
|
||||
// TagsAnswer is what tags answers.
|
||||
type TagsAnswer struct {
|
||||
// the image
|
||||
Name string `json:"name"`
|
||||
// every tag
|
||||
Tags []TagsAnswerTagsItem `json:"tags"`
|
||||
}
|
||||
|
||||
// HoldInput is what hold takes.
|
||||
type HoldInput struct {
|
||||
// the digest
|
||||
Digest string `json:"digest"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// which of the sweep's rules keeps it
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// HoldAnswer is what hold answers.
|
||||
type HoldAnswer struct {
|
||||
// it is held
|
||||
Held bool `json:"held"`
|
||||
// when the hold began, RFC 3339
|
||||
Since string `json:"since,omitempty"`
|
||||
}
|
||||
|
||||
// ReleaseInput is what release takes.
|
||||
type ReleaseInput struct {
|
||||
// the digest
|
||||
Digest string `json:"digest"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// why it is let go
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// ReleaseAnswer is what release answers.
|
||||
type ReleaseAnswer struct {
|
||||
// a hold was let go; false when there was none
|
||||
Released bool `json:"released"`
|
||||
}
|
||||
|
||||
// ListInput is what list takes.
|
||||
type ListInput struct {
|
||||
// the repository, <module>/<artifact>; every repository of the seat when not given
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// ListAnswer is what list answers.
|
||||
type ListAnswer struct {
|
||||
// each repository named, in order of its name
|
||||
Repositories []Repository `json:"repositories"`
|
||||
}
|
||||
|
||||
// PublishedEvent is the body of the event published.
|
||||
type PublishedEvent = Outcome
|
||||
|
||||
// RefusedEvent is the body of the event refused.
|
||||
type RefusedEvent = Outcome
|
||||
|
||||
// RemovedEvent is the body of the event removed.
|
||||
type RemovedEvent = Outcome
|
||||
|
||||
// KeptEvent is the body of the event kept.
|
||||
type KeptEvent = Outcome
|
||||
|
||||
// HeldEvent is the body of the event held.
|
||||
type HeldEvent = Hold
|
||||
|
||||
// ReleasedEvent is the body of the event released.
|
||||
type ReleasedEvent = Hold
|
||||
|
||||
// HoldsBySeatNameDigestValue is one value of the state holds under the key <seat>.<name>.<digest>.
|
||||
type HoldsBySeatNameDigestValue struct {
|
||||
By string `json:"by"`
|
||||
Digest string `json:"digest"`
|
||||
Kind string `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
Seat string `json:"seat"`
|
||||
// when (RFC 3339 time)
|
||||
Since string `json:"since"`
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// WindowsByCallerValueDroppedItem is a type of the contract.
|
||||
type WindowsByCallerValueDroppedItem struct {
|
||||
// when (RFC 3339 time)
|
||||
At string `json:"at,omitempty"`
|
||||
By string `json:"by,omitempty"`
|
||||
Node string `json:"node"`
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// WindowsByCallerValue is one value of the state windows under the key <caller>.
|
||||
type WindowsByCallerValue struct {
|
||||
// when it last closed (RFC 3339 time)
|
||||
Closed string `json:"closed,omitempty"`
|
||||
// retired nodes dropped by hand
|
||||
Dropped []WindowsByCallerValueDroppedItem `json:"dropped,omitempty"`
|
||||
// the nodes holding it open
|
||||
Holding []string `json:"holding,omitempty"`
|
||||
LastHolding []string `json:"last_holding,omitempty"`
|
||||
// the caller whose window it is
|
||||
Name string `json:"name"`
|
||||
Open bool `json:"open,omitempty"`
|
||||
// node to when it began to hold
|
||||
Since map[string]string `json:"since,omitempty"`
|
||||
// of each node holding the window, why it holds it
|
||||
Why map[string]string `json:"why,omitempty"`
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package containerimageregistry
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/container-image-registry/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "published on the seat's subject", subject: "mesh.seat.container-image-registry.event.published", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.container-image-registry\\.event\\.published$")},
|
||||
{name: "refused on the seat's subject", subject: "mesh.seat.container-image-registry.event.refused", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reason\":\"retention\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reason\":\"retention\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v RefusedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.container-image-registry\\.event\\.refused$")},
|
||||
{name: "removed on the seat's subject", subject: "mesh.seat.container-image-registry.event.removed", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reason\":\"retention\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reason\":\"retention\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v RemovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.container-image-registry\\.event\\.removed$")},
|
||||
{name: "kept on the seat's subject: a tagged version sharing its digest stays, naming the tags on it", subject: "mesh.seat.container-image-registry.event.kept", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reason\":\"shared-digest\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"tag\":\"0.1.19-feat-x.2\",\"tags\":[\"0.1.19\"],\"version\":\"0.1.19-feat-x.2\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"distribution\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"reason\":\"shared-digest\",\"reference\":\"container-image-registry/mesh-sdk/lib@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"tag\":\"0.1.19-feat-x.2\",\"tags\":[\"0.1.19\"],\"version\":\"0.1.19-feat-x.2\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.container-image-registry\\.event\\.kept$")},
|
||||
{name: "held on the seat's subject", subject: "mesh.seat.container-image-registry.event.held", given: "{\"at\":\"2026-11-04T12:00:00Z\",\"by\":\"mesh-artifact-sweep\",\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"holder\":\"distribution\",\"name\":\"mesh-sdk\",\"reason\":\"kept by the sweep's rule\"}", wire: "{\"at\":\"2026-11-04T12:00:00Z\",\"by\":\"mesh-artifact-sweep\",\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"holder\":\"distribution\",\"name\":\"mesh-sdk\",\"reason\":\"kept by the sweep's rule\"}",
|
||||
decode: func(b []byte) (any, error) { var v HeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.container-image-registry\\.event\\.held$")},
|
||||
{name: "released on the seat's subject", subject: "mesh.seat.container-image-registry.event.released", given: "{\"at\":\"2026-11-04T12:00:00Z\",\"by\":\"mesh-artifact-sweep\",\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"holder\":\"distribution\",\"name\":\"mesh-sdk\",\"reason\":\"kept by the sweep's rule\"}", wire: "{\"at\":\"2026-11-04T12:00:00Z\",\"by\":\"mesh-artifact-sweep\",\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"holder\":\"distribution\",\"name\":\"mesh-sdk\",\"reason\":\"kept by the sweep's rule\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReleasedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.container-image-registry\\.event\\.released$")},
|
||||
{name: "a hold", subject: "", given: "{\"by\":\"operator@shanks\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"kind\":\"base\",\"name\":\"base\",\"seat\":\"container-image-registry\",\"since\":\"2026-11-05T10:00:00Z\"}", wire: "{\"by\":\"operator@shanks\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"kind\":\"base\",\"name\":\"base\",\"seat\":\"container-image-registry\",\"since\":\"2026-11-05T10:00:00Z\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v HoldsBySeatNameDigestValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "an open window", subject: "", given: "{\"holding\":[\"ace\"],\"name\":\"mesh-delivery-builder\",\"open\":true,\"since\":{\"ace\":\"2026-11-05T10:00:00Z\"}}", wire: "{\"holding\":[\"ace\"],\"name\":\"mesh-delivery-builder\",\"open\":true,\"since\":{\"ace\":\"2026-11-05T10:00:00Z\"}}",
|
||||
decode: func(b []byte) (any, error) { var v WindowsByCallerValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "publish opens a transfer", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a field the reader does not know is dropped", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"image\",\"later\":{\"x\":1},\"name\":\"mesh-sdk\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"image\",\"name\":\"mesh-sdk\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "publish answers what it lacks", subject: "", given: "{\"lacks\":[\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"transfer\":\"t1\"}", wire: "{\"lacks\":[\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"transfer\":\"t1\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a chunk of a part", subject: "", given: "{\"data\":\"aGVsbG8=\",\"last\":true,\"part\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sequence\":0,\"transfer\":\"t1\"}", wire: "{\"data\":\"aGVsbG8=\",\"last\":true,\"part\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sequence\":0,\"transfer\":\"t1\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishPartInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the versions held", subject: "", given: "{\"name\":\"mesh-sdk\",\"versions\":[{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"mesh-sdk\",\"version\":\"0.1.19\"}]}", wire: "{\"name\":\"mesh-sdk\",\"versions\":[{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"mesh-sdk\",\"version\":\"0.1.19\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a release of what is not held answers released false", subject: "", given: "{\"released\":false}", wire: "{\"released\":false}",
|
||||
decode: func(b []byte) (any, error) { var v ReleaseAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a tagged version sharing its digest with another tag is kept, not removed", subject: "", given: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", wire: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}",
|
||||
decode: func(b []byte) (any, error) { var v RemoveAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "list answers an index with its platforms, its tag and its hold", subject: "", given: "{\"repositories\":[{\"manifests\":[{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"held\":false,\"index\":true,\"platforms\":[\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"size\":2048,\"tags\":[\"3\"]},{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"held\":false,\"index\":false,\"size\":1024}],\"name\":\"mail/server\"}]}", wire: "{\"repositories\":[{\"manifests\":[{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"held\":false,\"index\":true,\"platforms\":[\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"size\":2048,\"tags\":[\"3\"]},{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"held\":false,\"index\":false,\"size\":1024}],\"name\":\"mail/server\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v ListAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/containerimageregistry
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,752 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package git is the contract of the seat "git", defined whole (seats/git/seat.json): The forge: every read and act a delivery part makes of the mesh's git repositories, and what the forge says happened (design 47 *The seat git*, ADR 0596 §1, §2). A failed read answers an error, never an empty answer. The act verbs are the forge bridge's alone.
|
||||
package git
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "git"
|
||||
|
||||
const (
|
||||
VerbPull = "pull"
|
||||
VerbBranch = "branch"
|
||||
VerbOpenPulls = "open-pulls"
|
||||
VerbTags = "tags"
|
||||
VerbTrees = "trees"
|
||||
VerbFile = "file"
|
||||
VerbContains = "contains"
|
||||
VerbStatuses = "statuses"
|
||||
VerbStatus = "status"
|
||||
VerbComment = "comment"
|
||||
VerbView = "view"
|
||||
VerbNote = "note"
|
||||
VerbMergePull = "merge-pull"
|
||||
VerbTag = "tag"
|
||||
)
|
||||
|
||||
const (
|
||||
EventPullUpdated = "pull-updated"
|
||||
EventPullMerged = "pull-merged"
|
||||
EventPullClosed = "pull-closed"
|
||||
EventForgePull = "forge-pull"
|
||||
EventForgeStatus = "forge-status"
|
||||
EventForgeDelete = "forge-delete"
|
||||
EventRepoWritable = "repo-writable"
|
||||
EventBranchMoved = "branch-moved"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbPull, VerbBranch, VerbOpenPulls, VerbTags, VerbTrees, VerbFile, VerbContains, VerbStatuses, VerbStatus, VerbComment, VerbView, VerbNote, VerbMergePull, VerbTag}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventPullUpdated, EventPullMerged, EventPullClosed, EventForgePull, EventForgeStatus, EventForgeDelete, EventRepoWritable, EventBranchMoved}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "git.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// SubjectPullUpdated is where pull-updated is published.
|
||||
const SubjectPullUpdated = "mesh.seat.git.event.pull-updated"
|
||||
|
||||
// SubjectPullMerged is where pull-merged is published.
|
||||
const SubjectPullMerged = "mesh.seat.git.event.pull-merged"
|
||||
|
||||
// SubjectPullClosed is where pull-closed is published.
|
||||
const SubjectPullClosed = "mesh.seat.git.event.pull-closed"
|
||||
|
||||
// SubjectForgePull is where forge-pull is published.
|
||||
const SubjectForgePull = "mesh.seat.git.event.forge-pull"
|
||||
|
||||
// SubjectForgeStatus is where forge-status is published.
|
||||
const SubjectForgeStatus = "mesh.seat.git.event.forge-status"
|
||||
|
||||
// SubjectForgeDelete is where forge-delete is published.
|
||||
const SubjectForgeDelete = "mesh.seat.git.event.forge-delete"
|
||||
|
||||
// SubjectRepoWritable is where repo-writable is published.
|
||||
const SubjectRepoWritable = "mesh.seat.git.event.repo-writable"
|
||||
|
||||
// StreamBranchMoved is the stream branch-moved is kept in.
|
||||
const StreamBranchMoved = "SEAT_git_branch-moved"
|
||||
|
||||
// SubjectBranchMoved is where branch-moved is published.
|
||||
const SubjectBranchMoved = "mesh.seat.git.event.branch-moved"
|
||||
|
||||
const (
|
||||
StateFailedSteps = "failed-steps"
|
||||
)
|
||||
|
||||
// FailedStepsByModuleFingerprintStepKey is the key of one value of the state failed-steps under the form "<module>.<fingerprint>.<step>".
|
||||
func FailedStepsByModuleFingerprintStepKey(module, fingerprint, step string) string {
|
||||
return module + "." + fingerprint + "." + step
|
||||
}
|
||||
|
||||
// ParseFailedStepsByModuleFingerprintStepKey reads the parts of a key of the form "<module>.<fingerprint>.<step>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseFailedStepsByModuleFingerprintStepKey(key string) (string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
if rest == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
v4 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, true
|
||||
}
|
||||
|
||||
// DecodeFailedStepsByModuleFingerprintStepValue reads one value of the state failed-steps under the form "<module>.<fingerprint>.<step>", refusing a field FailedStepsByModuleFingerprintStepValue does not know and any text after the value.
|
||||
func DecodeFailedStepsByModuleFingerprintStepValue(raw []byte) (FailedStepsByModuleFingerprintStepValue, error) {
|
||||
var v FailedStepsByModuleFingerprintStepValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Change is what a pull request changed.
|
||||
type Change struct {
|
||||
// the changed directories that hold a module at its head; absent when they could not be read
|
||||
ModuleDirs []string `json:"module-dirs,omitempty"`
|
||||
// the paths it changed
|
||||
Paths []string `json:"paths"`
|
||||
// the forge cut the list
|
||||
PathsTruncated bool `json:"paths-truncated,omitempty"`
|
||||
// which of them it deleted
|
||||
Removed []string `json:"removed,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorKind is which kind of error, set with error alone: refused, the forge or the holder refused and error says why in the forge's own words; not-found, the forge said that what was asked about (a repository, a commit, a pull request, a branch or a tag) does not exist, so a caller never reads it out of error's words; failed, the forge failed or could not be reached, so the act or read could not be performed.
|
||||
type ErrorKind = string
|
||||
|
||||
// The values of ErrorKind.
|
||||
const (
|
||||
ErrorKindRefused = "refused"
|
||||
ErrorKindNotFound = "not-found"
|
||||
ErrorKindFailed = "failed"
|
||||
)
|
||||
|
||||
// FailedStep is a failed required step at a build-input fingerprint, with the commits it was seen at and the run that failed it (design 47 *Judged from its own state, never by a call*); cleared by a later passing rerun of that step whose proved caller is the operator or a healer.
|
||||
type FailedStep struct {
|
||||
// the artifact reference, <module>:<artifact>
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// every commit it was seen at
|
||||
Commits []string `json:"commits"`
|
||||
// the build-input fingerprint the step failed at
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
Module string `json:"module"`
|
||||
// the run that failed it: the runner's pipeline key
|
||||
Run string `json:"run"`
|
||||
// why it failed, as the runner's step-ended said
|
||||
Said string `json:"said,omitempty"`
|
||||
Step string `json:"step"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// Merging is what the forge would merge now, for an open pull request (issues 1275, 1945; ADR 0441 §1): answered whole or not at all, and a read the forge could not make answers the verb's error, never a guess; absent for a merged or closed one.
|
||||
type Merging struct {
|
||||
// the forge's own word on whether it merges into its base now: false while it is in conflict with its base, or while the forge works that out after the base moved
|
||||
Mergeable bool `json:"mergeable"`
|
||||
// whether a protection rule guards its base branch
|
||||
Protected bool `json:"protected"`
|
||||
// the status contexts the base branch's protection requires; none when it requires none
|
||||
Required []string `json:"required"`
|
||||
// whether the forge's merging account may write the repository: false, its statuses and its merge are refused
|
||||
Writes bool `json:"writes"`
|
||||
}
|
||||
|
||||
// OpenPull is an open pull request, with the statuses its base requires and those its head has.
|
||||
type OpenPull struct {
|
||||
// the head's statuses by context, the newest of each
|
||||
Checks map[string]Status `json:"checks"`
|
||||
Pull Pull `json:"pull"`
|
||||
// the contexts the base branch's protection requires; none when it requires none
|
||||
Required []string `json:"required"`
|
||||
}
|
||||
|
||||
// Pull is one pull request as the forge holds it; never its description (ADR 0659 §1).
|
||||
type Pull struct {
|
||||
// who opened it, the forge's login
|
||||
Author string `json:"author,omitempty"`
|
||||
// the branch it merges into
|
||||
Base string `json:"base"`
|
||||
// its head branch: what a delivery group is named by
|
||||
Branch string `json:"branch"`
|
||||
// a commit, its full 40-hex sha
|
||||
Head string `json:"head"`
|
||||
// the merge commit, once merged
|
||||
MergeCommit string `json:"merge-commit,omitempty"`
|
||||
// when it merged
|
||||
MergedAt *time.Time `json:"merged-at,omitempty"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// open, merged or closed
|
||||
State string `json:"state"`
|
||||
// its title
|
||||
Title string `json:"title,omitempty"`
|
||||
// its page on the forge
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Pull's state.
|
||||
const (
|
||||
PullStateOpen = "open"
|
||||
PullStateMerged = "merged"
|
||||
PullStateClosed = "closed"
|
||||
)
|
||||
|
||||
// Status is the newest status of one context on a commit.
|
||||
type Status struct {
|
||||
// when it was set
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// who set it
|
||||
By string `json:"by,omitempty"`
|
||||
// the status's context, such as mesh/check
|
||||
Context string `json:"context"`
|
||||
// what it says
|
||||
Description string `json:"description,omitempty"`
|
||||
// pending, success, failure, error or warning
|
||||
State string `json:"state"`
|
||||
// the page it links to
|
||||
Target string `json:"target,omitempty"`
|
||||
}
|
||||
|
||||
// PullInput is what pull takes.
|
||||
type PullInput struct {
|
||||
// instead of the number: the merge commit it made
|
||||
MergeCommit string `json:"merge-commit,omitempty"`
|
||||
// its number
|
||||
Number int64 `json:"number,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// PullAnswer is what pull answers.
|
||||
type PullAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
Merging *Merging `json:"merging,omitempty"`
|
||||
Pull *Pull `json:"pull,omitempty"`
|
||||
}
|
||||
|
||||
// BranchInput is what branch takes.
|
||||
type BranchInput struct {
|
||||
Branch string `json:"branch"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// BranchAnswer is what branch answers.
|
||||
type BranchAnswer struct {
|
||||
Branch string `json:"branch,omitempty"`
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// a commit, its full 40-hex sha
|
||||
Head string `json:"head,omitempty"`
|
||||
// a protection rule refuses a direct push and admits only merges
|
||||
Protected bool `json:"protected,omitempty"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// OpenPullsInput is what open-pulls takes.
|
||||
type OpenPullsInput struct {
|
||||
}
|
||||
|
||||
// OpenPullsAnswer is what open-pulls answers.
|
||||
type OpenPullsAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// every open pull request; said empty when none is open, so an answer that lacks it is never read as none
|
||||
Pulls []OpenPull `json:"pulls"`
|
||||
}
|
||||
|
||||
// TagsInput is what tags takes.
|
||||
type TagsInput struct {
|
||||
// the page, from 1
|
||||
Page int64 `json:"page,omitempty"`
|
||||
// only tags starting with it
|
||||
Prefix string `json:"prefix,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// TagsAnswer is what tags answers.
|
||||
type TagsAnswer struct {
|
||||
// how many tags a page holds
|
||||
Bound int64 `json:"bound,omitempty"`
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// another page exists
|
||||
More bool `json:"more,omitempty"`
|
||||
// the page
|
||||
Page int64 `json:"page,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository,omitempty"`
|
||||
// the tags of this page
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// TreesInput is what trees takes.
|
||||
type TreesInput struct {
|
||||
// a commit, its full 40-hex sha
|
||||
Commit string `json:"commit"`
|
||||
// directories whose every blob is answered; the root is the empty name
|
||||
Files []string `json:"files,omitempty"`
|
||||
// {directory: [path relative to it]}; the root is the empty name
|
||||
Paths map[string][]string `json:"paths,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// TreesAnswer is what trees answers.
|
||||
type TreesAnswer struct {
|
||||
// a commit, its full 40-hex sha
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// directory to {path: blob id}
|
||||
Files map[string]map[string]string `json:"files,omitempty"`
|
||||
// directory to {path: object id}
|
||||
Paths map[string]map[string]string `json:"paths,omitempty"`
|
||||
// the root tree's hash
|
||||
Root string `json:"root,omitempty"`
|
||||
// directory to its tree's hash, the root as the empty name
|
||||
Trees map[string]string `json:"trees,omitempty"`
|
||||
}
|
||||
|
||||
// FileInput is what file takes.
|
||||
type FileInput struct {
|
||||
// the file's path from the repository's root
|
||||
Path string `json:"path"`
|
||||
// a commit, branch or tag; the default branch when absent
|
||||
Ref string `json:"ref,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// FileAnswer is what file answers.
|
||||
type FileAnswer struct {
|
||||
// the forge holds no such file there
|
||||
Absent bool `json:"absent,omitempty"`
|
||||
// the file's git blob id
|
||||
Blob string `json:"blob,omitempty"`
|
||||
// its content
|
||||
Content string `json:"content,omitempty"`
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the path
|
||||
Path string `json:"path,omitempty"`
|
||||
// what was read
|
||||
Ref string `json:"ref,omitempty"`
|
||||
// its size in bytes
|
||||
Size int64 `json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ContainsInput is what contains takes.
|
||||
type ContainsInput struct {
|
||||
// the commit asked about
|
||||
Commit string `json:"commit"`
|
||||
// the commit it may be contained in
|
||||
In string `json:"in"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// ContainsAnswer is what contains answers.
|
||||
type ContainsAnswer struct {
|
||||
// how many commits commit is ahead of in
|
||||
Ahead int64 `json:"ahead,omitempty"`
|
||||
// the commit
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// in contains commit
|
||||
Contains bool `json:"contains,omitempty"`
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the other
|
||||
In string `json:"in,omitempty"`
|
||||
}
|
||||
|
||||
// StatusesInput is what statuses takes.
|
||||
type StatusesInput struct {
|
||||
// a commit, its full 40-hex sha
|
||||
Commit string `json:"commit"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// StatusesAnswer is what statuses answers.
|
||||
type StatusesAnswer struct {
|
||||
// the forge's combined state
|
||||
Combined string `json:"combined,omitempty"`
|
||||
// a commit, its full 40-hex sha
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the newest of each context
|
||||
Statuses []Status `json:"statuses,omitempty"`
|
||||
}
|
||||
|
||||
// StatusInput is what status takes.
|
||||
type StatusInput struct {
|
||||
// a commit, its full 40-hex sha
|
||||
Commit string `json:"commit"`
|
||||
// the context, such as mesh/check
|
||||
Context string `json:"context"`
|
||||
// what it says
|
||||
Description string `json:"description,omitempty"`
|
||||
// the act's id
|
||||
ID string `json:"id"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// the state
|
||||
State string `json:"state"`
|
||||
// the page it links to
|
||||
Target string `json:"target,omitempty"`
|
||||
}
|
||||
|
||||
// The values of StatusInput's state.
|
||||
const (
|
||||
StatusInputStatePending = "pending"
|
||||
StatusInputStateSuccess = "success"
|
||||
StatusInputStateFailure = "failure"
|
||||
StatusInputStateError = "error"
|
||||
StatusInputStateWarning = "warning"
|
||||
)
|
||||
|
||||
// StatusAnswer is what status answers.
|
||||
type StatusAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the id was already held on the pull request or the note, so nothing was done again
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the act's id, as the caller gave it
|
||||
ID string `json:"id,omitempty"`
|
||||
// the forge holds the act now
|
||||
Performed bool `json:"performed,omitempty"`
|
||||
}
|
||||
|
||||
// CommentInput is what comment takes.
|
||||
type CommentInput struct {
|
||||
// the act's id
|
||||
ID string `json:"id"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// the comment, markdown
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// CommentAnswer is what comment answers.
|
||||
type CommentAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the id was already held on the pull request or the note, so nothing was done again
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the act's id, as the caller gave it
|
||||
ID string `json:"id,omitempty"`
|
||||
// the forge holds the act now
|
||||
Performed bool `json:"performed,omitempty"`
|
||||
}
|
||||
|
||||
// ViewInput is what view takes.
|
||||
type ViewInput struct {
|
||||
// the act's id
|
||||
ID string `json:"id"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// the view, markdown
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// ViewAnswer is what view answers.
|
||||
type ViewAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the id was already held on the pull request or the note, so nothing was done again
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the act's id, as the caller gave it
|
||||
ID string `json:"id,omitempty"`
|
||||
// the forge holds the act now
|
||||
Performed bool `json:"performed,omitempty"`
|
||||
}
|
||||
|
||||
// NoteInput is what note takes.
|
||||
type NoteInput struct {
|
||||
// a commit, its full 40-hex sha
|
||||
Commit string `json:"commit"`
|
||||
// the act's id
|
||||
ID string `json:"id"`
|
||||
// the line, one line
|
||||
Line string `json:"line"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// NoteAnswer is what note answers.
|
||||
type NoteAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the id was already held on the pull request or the note, so nothing was done again
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the act's id, as the caller gave it
|
||||
ID string `json:"id,omitempty"`
|
||||
// the forge holds the act now
|
||||
Performed bool `json:"performed,omitempty"`
|
||||
}
|
||||
|
||||
// MergePullInput is what merge-pull takes.
|
||||
type MergePullInput struct {
|
||||
// the head the caller names
|
||||
Head string `json:"head"`
|
||||
// the act's id
|
||||
ID string `json:"id"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// MergePullAnswer is what merge-pull answers.
|
||||
type MergePullAnswer struct {
|
||||
// why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the id was already held on the pull request or the note, so nothing was done again
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the act's id, as the caller gave it
|
||||
ID string `json:"id,omitempty"`
|
||||
// the merge commit
|
||||
MergeCommit string `json:"merge-commit,omitempty"`
|
||||
// for policy-failed, the module
|
||||
Module string `json:"module,omitempty"`
|
||||
// the forge holds the act now
|
||||
Performed bool `json:"performed,omitempty"`
|
||||
// why the forge or the holder refused the merge; the act is not performed
|
||||
Refused string `json:"refused,omitempty"`
|
||||
// which refusal, set with refused: head-moved, the pull request's head is not the one named; unprotected, the base branch's protection does not refuse a direct push; policy-failed, a run at the head's fingerprint failed a required step (run, module and step name it); no-registrations, no registration-changed heard yet (ADR 0667 section 10); git-refused, git refused the merge
|
||||
RefusedKind string `json:"refused-kind,omitempty"`
|
||||
// for policy-failed, the run that failed the step: the runner's pipeline key
|
||||
Run string `json:"run,omitempty"`
|
||||
// for policy-failed, the step
|
||||
Step string `json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// The values of MergePullAnswer's refused-kind.
|
||||
const (
|
||||
MergePullAnswerRefusedKindHeadMoved = "head-moved"
|
||||
MergePullAnswerRefusedKindUnprotected = "unprotected"
|
||||
MergePullAnswerRefusedKindPolicyFailed = "policy-failed"
|
||||
MergePullAnswerRefusedKindNoRegistrations = "no-registrations"
|
||||
MergePullAnswerRefusedKindGitRefused = "git-refused"
|
||||
)
|
||||
|
||||
// TagInput is what tag takes.
|
||||
type TagInput struct {
|
||||
// the commit it is written at
|
||||
Commit string `json:"commit"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// the tag
|
||||
Tag string `json:"tag"`
|
||||
}
|
||||
|
||||
// TagAnswer is what tag answers.
|
||||
type TagAnswer struct {
|
||||
// why the forge could not write it: set alone with error-kind
|
||||
Error string `json:"error,omitempty"`
|
||||
ErrorKind ErrorKind `json:"error-kind,omitempty"`
|
||||
// the forge holds the tag at that commit now
|
||||
Performed bool `json:"performed,omitempty"`
|
||||
// the tag, as asked
|
||||
Tag string `json:"tag,omitempty"`
|
||||
}
|
||||
|
||||
// PullUpdatedEvent is the body of the event pull-updated.
|
||||
type PullUpdatedEvent struct {
|
||||
// who opened it
|
||||
Author string `json:"author,omitempty"`
|
||||
// the branch it merges into
|
||||
Base string `json:"base"`
|
||||
// the base branch's head as the head was announced; absent when it could not be read
|
||||
BaseHead string `json:"base-head,omitempty"`
|
||||
// its head branch
|
||||
Branch string `json:"branch"`
|
||||
Change *Change `json:"change,omitempty"`
|
||||
// a commit, its full 40-hex sha
|
||||
Head string `json:"head"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// its title
|
||||
Title string `json:"title,omitempty"`
|
||||
// its page
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// PullMergedEvent is the body of the event pull-merged.
|
||||
type PullMergedEvent struct {
|
||||
// who opened it
|
||||
Author string `json:"author,omitempty"`
|
||||
// the branch it merges into
|
||||
Base string `json:"base"`
|
||||
// its head branch
|
||||
Branch string `json:"branch"`
|
||||
Change *Change `json:"change,omitempty"`
|
||||
// a commit, its full 40-hex sha
|
||||
Head string `json:"head"`
|
||||
// the head's statuses by context, their states; absent when they could not be read
|
||||
HeadChecks map[string]string `json:"head-checks,omitempty"`
|
||||
// a commit, its full 40-hex sha
|
||||
MergeCommit string `json:"merge-commit"`
|
||||
// when
|
||||
MergedAt *time.Time `json:"merged-at,omitempty"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// its title
|
||||
Title string `json:"title,omitempty"`
|
||||
// its page
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// PullClosedEvent is the body of the event pull-closed.
|
||||
type PullClosedEvent struct {
|
||||
// who opened it
|
||||
Author string `json:"author,omitempty"`
|
||||
// the branch it merges into
|
||||
Base string `json:"base"`
|
||||
// its head branch
|
||||
Branch string `json:"branch"`
|
||||
// a commit, its full 40-hex sha
|
||||
Head string `json:"head"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// its title
|
||||
Title string `json:"title,omitempty"`
|
||||
// its page
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// ForgePullEvent is the body of the event forge-pull.
|
||||
type ForgePullEvent struct {
|
||||
// what the forge said: opened, reopened, synchronized, edited, closed, merged
|
||||
Action string `json:"action"`
|
||||
// who opened it
|
||||
Author string `json:"author,omitempty"`
|
||||
// its base branch
|
||||
Base string `json:"base,omitempty"`
|
||||
// its head branch
|
||||
Branch string `json:"branch,omitempty"`
|
||||
// its head commit
|
||||
Head string `json:"head,omitempty"`
|
||||
// the merge commit
|
||||
MergeCommit string `json:"merge-commit,omitempty"`
|
||||
// merged
|
||||
Merged bool `json:"merged,omitempty"`
|
||||
// its number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// who acted
|
||||
Sender string `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// ForgeStatusEvent is the body of the event forge-status.
|
||||
type ForgeStatusEvent struct {
|
||||
// the commit
|
||||
Commit string `json:"commit"`
|
||||
// the context
|
||||
Context string `json:"context"`
|
||||
// what it says
|
||||
Description string `json:"description,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// who set it
|
||||
Sender string `json:"sender,omitempty"`
|
||||
// the state
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
// ForgeDeleteEvent is the body of the event forge-delete.
|
||||
type ForgeDeleteEvent struct {
|
||||
// the deleted branch or tag
|
||||
Ref string `json:"ref"`
|
||||
// branch or tag
|
||||
RefType string `json:"ref-type,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// who deleted it
|
||||
Sender string `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
// RepoWritableEvent is the body of the event repo-writable.
|
||||
type RepoWritableEvent struct {
|
||||
// the account that writes it now
|
||||
Account string `json:"account"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// BranchMovedEvent is the body of the event branch-moved.
|
||||
type BranchMovedEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Branch string `json:"branch"`
|
||||
// the head the webhook said, a commit's full 40-hex sha; read again by branch
|
||||
Head string `json:"head,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// FailedStepsByModuleFingerprintStepValue is one value of the state failed-steps under the key <module>.<fingerprint>.<step>.
|
||||
type FailedStepsByModuleFingerprintStepValue = FailedStep
|
||||
@@ -1,164 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package git
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/git/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "pull.updated is said", subject: "mesh.seat.git.event.pull-updated", given: "{\"author\":\"jochen\",\"base\":\"main\",\"base-head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"branch\":\"feat/47-G\",\"change\":{\"module-dirs\":[\"go\"],\"paths\":[\"go/seatlist/seatlist.go\"]},\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"title\":\"One wiring\",\"url\":\"https://forge.test/p/178\"}", wire: "{\"author\":\"jochen\",\"base\":\"main\",\"base-head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"branch\":\"feat/47-G\",\"change\":{\"module-dirs\":[\"go\"],\"paths\":[\"go/seatlist/seatlist.go\"]},\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"title\":\"One wiring\",\"url\":\"https://forge.test/p/178\"}",
|
||||
decode: func(b []byte) (any, error) { var v PullUpdatedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.pull-updated$")},
|
||||
{name: "pull.merged is said", subject: "mesh.seat.git.event.pull-merged", given: "{\"base\":\"main\",\"branch\":\"feat/47-G\",\"change\":{\"module-dirs\":[\"go\"],\"paths\":[\"go/seatlist/seatlist.go\"]},\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"head-checks\":{\"mesh/check\":\"success\"},\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"merged-at\":\"2026-11-09T19:40:00Z\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"base\":\"main\",\"branch\":\"feat/47-G\",\"change\":{\"module-dirs\":[\"go\"],\"paths\":[\"go/seatlist/seatlist.go\"]},\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"head-checks\":{\"mesh/check\":\"success\"},\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"merged-at\":\"2026-11-09T19:40:00Z\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v PullMergedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.pull-merged$")},
|
||||
{name: "pull.closed is said", subject: "mesh.seat.git.event.pull-closed", given: "{\"base\":\"main\",\"branch\":\"fix/x\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":179,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"base\":\"main\",\"branch\":\"fix/x\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":179,\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v PullClosedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.pull-closed$")},
|
||||
{name: "forge.pull is said", subject: "mesh.seat.git.event.forge-pull", given: "{\"action\":\"synchronized\",\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"sender\":\"jochen\"}", wire: "{\"action\":\"synchronized\",\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"sender\":\"jochen\"}",
|
||||
decode: func(b []byte) (any, error) { var v ForgePullEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.forge-pull$")},
|
||||
{name: "forge.status is said", subject: "mesh.seat.git.event.forge-status", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"context\":\"mesh/check\",\"description\":\"failed\",\"repository\":\"novox/mesh-sdk\",\"sender\":\"mesh-delivery-checker\",\"state\":\"failure\"}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"context\":\"mesh/check\",\"description\":\"failed\",\"repository\":\"novox/mesh-sdk\",\"sender\":\"mesh-delivery-checker\",\"state\":\"failure\"}",
|
||||
decode: func(b []byte) (any, error) { var v ForgeStatusEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.forge-status$")},
|
||||
{name: "forge.delete is said", subject: "mesh.seat.git.event.forge-delete", given: "{\"ref\":\"feat/47-G\",\"ref-type\":\"branch\",\"repository\":\"novox/mesh-sdk\",\"sender\":\"jochen\"}", wire: "{\"ref\":\"feat/47-G\",\"ref-type\":\"branch\",\"repository\":\"novox/mesh-sdk\",\"sender\":\"jochen\"}",
|
||||
decode: func(b []byte) (any, error) { var v ForgeDeleteEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.forge-delete$")},
|
||||
{name: "repo.writable is said", subject: "mesh.seat.git.event.repo-writable", given: "{\"account\":\"mesh-delivery\",\"repository\":\"jochen/notes\"}", wire: "{\"account\":\"mesh-delivery\",\"repository\":\"jochen/notes\"}",
|
||||
decode: func(b []byte) (any, error) { var v RepoWritableEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.repo-writable$")},
|
||||
{name: "a branch moved by a merge", subject: "mesh.seat.git.event.branch-moved", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-catalog\"}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-catalog\"}",
|
||||
decode: func(b []byte) (any, error) { var v BranchMovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.git\\.event\\.branch-moved$")},
|
||||
{name: "a failed required step kept", subject: "", given: "{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"commits\":[\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"run\":\"main.12.nats\",\"said\":\"TestTheBusWhole failed\",\"step\":\"unit\",\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"commits\":[\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"run\":\"main.12.nats\",\"said\":\"TestTheBusWhole failed\",\"step\":\"unit\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v FailedStepsByModuleFingerprintStepValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "pull asks", subject: "", given: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v PullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "pull answers", subject: "", given: "{\"pull\":{\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"merged-at\":\"2026-11-09T19:40:00Z\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/178\"}}", wire: "{\"pull\":{\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"merged-at\":\"2026-11-09T19:40:00Z\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/178\"}}",
|
||||
decode: func(b []byte) (any, error) { var v PullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "pull answers an open one with what the forge would merge now", subject: "", given: "{\"merging\":{\"mergeable\":false,\"protected\":true,\"required\":[\"mesh/check\"],\"writes\":true},\"pull\":{\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":179,\"repository\":\"novox/mesh-sdk\",\"state\":\"open\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/179\"}}", wire: "{\"merging\":{\"mergeable\":false,\"protected\":true,\"required\":[\"mesh/check\"],\"writes\":true},\"pull\":{\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":179,\"repository\":\"novox/mesh-sdk\",\"state\":\"open\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/179\"}}",
|
||||
decode: func(b []byte) (any, error) { var v PullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "pull answers an error, never none", subject: "", given: "{\"error\":\"the forge holds no pull request novox/mesh-sdk#999\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge holds no pull request novox/mesh-sdk#999\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v PullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "open-pulls asks", subject: "", given: "{}", wire: "{}",
|
||||
decode: func(b []byte) (any, error) { var v OpenPullsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "open-pulls answers", subject: "", given: "{\"pulls\":[{\"checks\":{\"mesh/check\":{\"at\":\"2026-11-09T19:00:00Z\",\"by\":\"mesh-delivery-checker\",\"context\":\"mesh/check\",\"description\":\"passed\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}},\"pull\":{\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"open\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/178\"},\"required\":[\"mesh/check\"]}]}", wire: "{\"pulls\":[{\"checks\":{\"mesh/check\":{\"at\":\"2026-11-09T19:00:00Z\",\"by\":\"mesh-delivery-checker\",\"context\":\"mesh/check\",\"description\":\"passed\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}},\"pull\":{\"author\":\"jochen\",\"base\":\"main\",\"branch\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"open\",\"title\":\"One wiring of the seat list\",\"url\":\"https://forge.test/novox/mesh-sdk/pulls/178\"},\"required\":[\"mesh/check\"]}]}",
|
||||
decode: func(b []byte) (any, error) { var v OpenPullsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "open-pulls answers none open as an empty list", subject: "", given: "{\"pulls\":[]}", wire: "{\"pulls\":[]}",
|
||||
decode: func(b []byte) (any, error) { var v OpenPullsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "open-pulls answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\",\"pulls\":[]}", wire: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\",\"pulls\":[]}",
|
||||
decode: func(b []byte) (any, error) { var v OpenPullsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "tags asks", subject: "", given: "{\"page\":1,\"prefix\":\"go/v\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"page\":1,\"prefix\":\"go/v\",\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v TagsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "tags answers", subject: "", given: "{\"bound\":50,\"more\":true,\"page\":1,\"repository\":\"novox/mesh-sdk\",\"tags\":[\"go/v0.1.15\",\"go/v0.1.14\"]}", wire: "{\"bound\":50,\"more\":true,\"page\":1,\"repository\":\"novox/mesh-sdk\",\"tags\":[\"go/v0.1.15\",\"go/v0.1.14\"]}",
|
||||
decode: func(b []byte) (any, error) { var v TagsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "tags answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 404 for novox/nothing\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge answered 404 for novox/nothing\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v TagsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "trees asks", subject: "", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"files\":[\"contracts\"],\"paths\":{\"\":[\"go.work\"]},\"repository\":\"novox/mesh-delivery\"}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"files\":[\"contracts\"],\"paths\":{\"\":[\"go.work\"]},\"repository\":\"novox/mesh-delivery\"}",
|
||||
decode: func(b []byte) (any, error) { var v TreesInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "trees answers", subject: "", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"files\":{\"contracts\":{\"module.json\":\"ffffffffffffffffffffffffffffffffffffffff\"}},\"paths\":{\"\":{\"go.work\":\"1111111111111111111111111111111111111111\"}},\"root\":\"dddddddddddddddddddddddddddddddddddddddd\",\"trees\":{\"\":\"dddddddddddddddddddddddddddddddddddddddd\",\"contracts\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"files\":{\"contracts\":{\"module.json\":\"ffffffffffffffffffffffffffffffffffffffff\"}},\"paths\":{\"\":{\"go.work\":\"1111111111111111111111111111111111111111\"}},\"root\":\"dddddddddddddddddddddddddddddddddddddddd\",\"trees\":{\"\":\"dddddddddddddddddddddddddddddddddddddddd\",\"contracts\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}}",
|
||||
decode: func(b []byte) (any, error) { var v TreesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "trees answers an error, never none", subject: "", given: "{\"error\":\"the forge's tree listing of novox/mesh-delivery at aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa was cut; no trees are answered from a part\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge's tree listing of novox/mesh-delivery at aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa was cut; no trees are answered from a part\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v TreesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "file asks", subject: "", given: "{\"path\":\"seats/index.json\",\"ref\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-contracts\"}", wire: "{\"path\":\"seats/index.json\",\"ref\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-contracts\"}",
|
||||
decode: func(b []byte) (any, error) { var v FileInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "file answers", subject: "", given: "{\"blob\":\"2222222222222222222222222222222222222222\",\"content\":\"{\\\"format\\\":1,\\\"seats\\\":[\\\"mesh-broker\\\"]}\",\"path\":\"seats/index.json\",\"ref\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"size\":31}", wire: "{\"blob\":\"2222222222222222222222222222222222222222\",\"content\":\"{\\\"format\\\":1,\\\"seats\\\":[\\\"mesh-broker\\\"]}\",\"path\":\"seats/index.json\",\"ref\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"size\":31}",
|
||||
decode: func(b []byte) (any, error) { var v FileAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "file answers", subject: "", given: "{\"absent\":true,\"path\":\"seats/gone.json\",\"ref\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}", wire: "{\"absent\":true,\"path\":\"seats/gone.json\",\"ref\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}",
|
||||
decode: func(b []byte) (any, error) { var v FileAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "file answers an error, never none", subject: "", given: "{\"error\":\"seats/big.json is over 512 KiB\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"seats/big.json is over 512 KiB\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v FileAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "contains asks", subject: "", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"in\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"in\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v ContainsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "contains answers", subject: "", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"contains\":true,\"in\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"contains\":true,\"in\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}",
|
||||
decode: func(b []byte) (any, error) { var v ContainsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "contains answers an error, never none", subject: "", given: "{\"error\":\"the forge cannot compare bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge cannot compare bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v ContainsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "contains answers a commit the forge does not have as not-found", subject: "", given: "{\"error\":\"the forge has no commit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"error-kind\":\"not-found\"}", wire: "{\"error\":\"the forge has no commit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"error-kind\":\"not-found\"}",
|
||||
decode: func(b []byte) (any, error) { var v ContainsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "statuses asks", subject: "", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v StatusesInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "statuses answers", subject: "", given: "{\"combined\":\"success\",\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"statuses\":[{\"at\":\"2026-11-09T19:00:00Z\",\"by\":\"mesh-delivery-checker\",\"context\":\"mesh/check\",\"description\":\"passed\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}]}", wire: "{\"combined\":\"success\",\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"statuses\":[{\"at\":\"2026-11-09T19:00:00Z\",\"by\":\"mesh-delivery-checker\",\"context\":\"mesh/check\",\"description\":\"passed\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v StatusesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "statuses answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 500\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the forge answered 500\",\"error-kind\":\"failed\"}",
|
||||
decode: func(b []byte) (any, error) { var v StatusesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "status asks", subject: "", given: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"context\":\"mesh/check\",\"description\":\"checking\",\"id\":\"owed-1\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\"}", wire: "{\"commit\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"context\":\"mesh/check\",\"description\":\"checking\",\"id\":\"owed-1\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\"}",
|
||||
decode: func(b []byte) (any, error) { var v StatusInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "status answers", subject: "", given: "{\"id\":\"owed-1\",\"performed\":true}", wire: "{\"id\":\"owed-1\",\"performed\":true}",
|
||||
decode: func(b []byte) (any, error) { var v StatusAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "status answers an error, never none", subject: "", given: "{\"error\":\"the forge account cannot write novox/mesh-sdk\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge account cannot write novox/mesh-sdk\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v StatusAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "comment asks", subject: "", given: "{\"id\":\"owed-2\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"text\":\"the delivery reached every node\"}", wire: "{\"id\":\"owed-2\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"text\":\"the delivery reached every node\"}",
|
||||
decode: func(b []byte) (any, error) { var v CommentInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "comment answers", subject: "", given: "{\"held\":true,\"id\":\"owed-2\"}", wire: "{\"held\":true,\"id\":\"owed-2\"}",
|
||||
decode: func(b []byte) (any, error) { var v CommentAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "comment answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 403\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge answered 403\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v CommentAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "view asks", subject: "", given: "{\"id\":\"owed-3\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"text\":\"## Delivery\"}", wire: "{\"id\":\"owed-3\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"text\":\"## Delivery\"}",
|
||||
decode: func(b []byte) (any, error) { var v ViewInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "view answers", subject: "", given: "{\"id\":\"owed-3\",\"performed\":true}", wire: "{\"id\":\"owed-3\",\"performed\":true}",
|
||||
decode: func(b []byte) (any, error) { var v ViewAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "view answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}",
|
||||
decode: func(b []byte) (any, error) { var v ViewAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "note asks", subject: "", given: "{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"id\":\"owed-4\",\"line\":\"owed-4 delivered to ace\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"id\":\"owed-4\",\"line\":\"owed-4 delivered to ace\",\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v NoteInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "note answers", subject: "", given: "{\"id\":\"owed-4\",\"performed\":true}", wire: "{\"id\":\"owed-4\",\"performed\":true}",
|
||||
decode: func(b []byte) (any, error) { var v NoteAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "note answers an error, never none", subject: "", given: "{\"error\":\"the note ref could not be pushed\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the note ref could not be pushed\",\"error-kind\":\"failed\"}",
|
||||
decode: func(b []byte) (any, error) { var v NoteAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "merge-pull asks", subject: "", given: "{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"owed-5\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"owed-5\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v MergePullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "merge-pull answers", subject: "", given: "{\"id\":\"owed-5\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"performed\":true}", wire: "{\"id\":\"owed-5\",\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"performed\":true}",
|
||||
decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "merge-pull answers", subject: "", given: "{\"id\":\"owed-5\",\"refused\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"refused-kind\":\"head-moved\"}", wire: "{\"id\":\"owed-5\",\"refused\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"refused-kind\":\"head-moved\"}",
|
||||
decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "merge-pull answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}", wire: "{\"error\":\"the forge answered 502\",\"error-kind\":\"failed\"}",
|
||||
decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "merge-pull refuses a failed required step, naming the run, the module and the step", subject: "", given: "{\"id\":\"merge-7\",\"module\":\"nats\",\"refused\":\"unit of nats:program failed at fp-0123 in main.12.nats\",\"refused-kind\":\"policy-failed\",\"run\":\"main.12.nats\",\"step\":\"unit\"}", wire: "{\"id\":\"merge-7\",\"module\":\"nats\",\"refused\":\"unit of nats:program failed at fp-0123 in main.12.nats\",\"refused-kind\":\"policy-failed\",\"run\":\"main.12.nats\",\"step\":\"unit\"}",
|
||||
decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "branch asks a branch", subject: "", given: "{\"branch\":\"main\",\"repository\":\"novox/mesh-catalog\"}", wire: "{\"branch\":\"main\",\"repository\":\"novox/mesh-catalog\"}",
|
||||
decode: func(b []byte) (any, error) { var v BranchInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "branch answers its head and protection", subject: "", given: "{\"branch\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"protected\":true,\"repository\":\"novox/mesh-catalog\"}", wire: "{\"branch\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"protected\":true,\"repository\":\"novox/mesh-catalog\"}",
|
||||
decode: func(b []byte) (any, error) { var v BranchAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "branch answers a branch the forge does not hold", subject: "", given: "{\"error\":\"no branch beta in novox/mesh-catalog\",\"error-kind\":\"not-found\"}", wire: "{\"error\":\"no branch beta in novox/mesh-catalog\",\"error-kind\":\"not-found\"}",
|
||||
decode: func(b []byte) (any, error) { var v BranchAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "tag asks", subject: "", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\",\"tag\":\"go/v0.1.15\"}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\",\"tag\":\"go/v0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v TagInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "tag answers performed", subject: "", given: "{\"performed\":true,\"tag\":\"go/v0.1.15\"}", wire: "{\"performed\":true,\"tag\":\"go/v0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v TagAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "tag answers an error, never none", subject: "", given: "{\"error\":\"the forge answered 403\",\"error-kind\":\"refused\"}", wire: "{\"error\":\"the forge answered 403\",\"error-kind\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v TagAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/git
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,262 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package gopackageregistry is the contract of the seat "go-package-registry", defined whole (seats/go-package-registry/seat.json): The mesh's Go modules: Go's module proxy protocol's read side, and publishing over the bus.
|
||||
package gopackageregistry
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "go-package-registry"
|
||||
|
||||
const (
|
||||
VerbPublish = "publish"
|
||||
VerbPublishPart = "publish-part"
|
||||
VerbVersions = "versions"
|
||||
VerbRemove = "remove"
|
||||
)
|
||||
|
||||
const (
|
||||
EventPublished = "published"
|
||||
EventRefused = "refused"
|
||||
EventRemoved = "removed"
|
||||
EventKept = "kept"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbPublish, VerbPublishPart, VerbVersions, VerbRemove}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventPublished, EventRefused, EventRemoved, EventKept}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "go-package-registry.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// SubjectPublished is where published is published.
|
||||
const SubjectPublished = "mesh.seat.go-package-registry.event.published"
|
||||
|
||||
// SubjectRefused is where refused is published.
|
||||
const SubjectRefused = "mesh.seat.go-package-registry.event.refused"
|
||||
|
||||
// SubjectRemoved is where removed is published.
|
||||
const SubjectRemoved = "mesh.seat.go-package-registry.event.removed"
|
||||
|
||||
// SubjectKept is where kept is published.
|
||||
const SubjectKept = "mesh.seat.go-package-registry.event.kept"
|
||||
|
||||
// Artifact is one published thing, as every registry event and answer names it.
|
||||
type Artifact struct {
|
||||
// the source commit it was built from
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// its digest, sha256:<hex> (a Go package's h1: hash beside it in the version's record)
|
||||
Digest string `json:"digest"`
|
||||
// the build's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// what it is
|
||||
Kind string `json:"kind"`
|
||||
// the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk)
|
||||
Name string `json:"name"`
|
||||
// the tag it carries, for a tagged version
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Artifact's kind.
|
||||
const (
|
||||
ArtifactKindPackage = "package"
|
||||
ArtifactKindImage = "image"
|
||||
ArtifactKindBundle = "bundle"
|
||||
ArtifactKindArchive = "archive"
|
||||
ArtifactKindUpstream = "upstream"
|
||||
)
|
||||
|
||||
// Outcome is the body of published, refused and removed.
|
||||
type Outcome struct {
|
||||
// the source commit it was built from
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// its digest, sha256:<hex> (a Go package's h1: hash beside it in the version's record)
|
||||
Digest string `json:"digest"`
|
||||
// the build's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the module holding the seat that said it
|
||||
Holder string `json:"holder"`
|
||||
// what it is
|
||||
Kind string `json:"kind"`
|
||||
// the Go module path a Go package is fetched under, equal to name for a Go package (go-package-registry's published); empty for every other kind of artifact
|
||||
Module string `json:"module,omitempty"`
|
||||
// the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk)
|
||||
Name string `json:"name"`
|
||||
// why: a refusal's cause, a removal's (retention, tag-gone, by-hand), or why a removal was kept (shared-digest)
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// the reference the seat answers: <registry>/<module>/<artifact>@sha256:<digest>, or <name>@<version> for a package (ADR 0605 §9)
|
||||
Reference string `json:"reference,omitempty"`
|
||||
// the tag it carries, for a tagged version
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// for kept: the other tags still naming its digest
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
// the transfer it ends, when it ended one
|
||||
Transfer string `json:"transfer,omitempty"`
|
||||
// the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Outcome's kind.
|
||||
const (
|
||||
OutcomeKindPackage = "package"
|
||||
OutcomeKindImage = "image"
|
||||
OutcomeKindBundle = "bundle"
|
||||
OutcomeKindArchive = "archive"
|
||||
OutcomeKindUpstream = "upstream"
|
||||
)
|
||||
|
||||
// Part is one part of a transfer.
|
||||
type Part struct {
|
||||
// the part's digest, sha256:<hex>: an image's layer or config, a package's file, a bundle's blob
|
||||
Digest string `json:"digest"`
|
||||
// its size in bytes
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
// PublishInput is what publish takes.
|
||||
type PublishInput struct {
|
||||
// the source commit it was built from
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// its digest, sha256:<hex> (a Go package's h1: hash beside it in the version's record)
|
||||
Digest string `json:"digest"`
|
||||
// the build's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// what it is
|
||||
Kind string `json:"kind"`
|
||||
// the package's, image's, bundle's or archive's name; a package's is its name in its own language (design 32): a Go package's the go.mod module path (git.novox.be/novox/mesh-sdk/go), an npm package's package.json's name (@novox/mesh-sdk)
|
||||
Name string `json:"name"`
|
||||
// every part's digest and size; none when the digest is already held
|
||||
Parts []Part `json:"parts,omitempty"`
|
||||
// the tag it carries, for a tagged version
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// the transfer's name, the caller's own; the same name opens the same transfer again
|
||||
Transfer string `json:"transfer"`
|
||||
// the version the builder gave it (design 51 *The versions*); empty for a bundle or archive published by its digest alone
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of PublishInput's kind.
|
||||
const (
|
||||
PublishInputKindPackage = "package"
|
||||
PublishInputKindImage = "image"
|
||||
PublishInputKindBundle = "bundle"
|
||||
PublishInputKindArchive = "archive"
|
||||
PublishInputKindUpstream = "upstream"
|
||||
)
|
||||
|
||||
// PublishAnswer is what publish answers.
|
||||
type PublishAnswer struct {
|
||||
// the digest is held already: nothing to send; the outcome follows as an event
|
||||
Held bool `json:"held,omitempty"`
|
||||
// the digests of the parts the holder lacks, to send by publish-part
|
||||
Lacks []string `json:"lacks,omitempty"`
|
||||
// the transfer
|
||||
Transfer string `json:"transfer"`
|
||||
}
|
||||
|
||||
// PublishPartInput is what publish-part takes.
|
||||
type PublishPartInput struct {
|
||||
// the chunk's bytes, base64 (at most 760 KiB before encoding)
|
||||
Data string `json:"data"`
|
||||
// this chunk is the part's last
|
||||
Last bool `json:"last"`
|
||||
// the part's digest
|
||||
Part string `json:"part"`
|
||||
// the chunk's place in its part, from 0
|
||||
Sequence int64 `json:"sequence"`
|
||||
// the transfer
|
||||
Transfer string `json:"transfer"`
|
||||
}
|
||||
|
||||
// PublishPartAnswer is what publish-part answers.
|
||||
type PublishPartAnswer struct {
|
||||
// the part is whole and its bytes match its digest
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
// the part
|
||||
Part string `json:"part"`
|
||||
// the chunks of the part held so far
|
||||
Received int64 `json:"received,omitempty"`
|
||||
// the transfer
|
||||
Transfer string `json:"transfer"`
|
||||
}
|
||||
|
||||
// VersionsInput is what versions takes.
|
||||
type VersionsInput struct {
|
||||
// narrowed to one kind (optional)
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// VersionsAnswer is what versions answers.
|
||||
type VersionsAnswer struct {
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// newest first
|
||||
Versions []Artifact `json:"versions"`
|
||||
}
|
||||
|
||||
// RemoveInput is what remove takes.
|
||||
type RemoveInput struct {
|
||||
// the digest (for a bundle, archive or copied base)
|
||||
Digest string `json:"digest,omitempty"`
|
||||
// the name
|
||||
Name string `json:"name"`
|
||||
// why it goes
|
||||
Reason string `json:"reason"`
|
||||
// the tag (for a tagged version)
|
||||
Tag string `json:"tag,omitempty"`
|
||||
// the version
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of RemoveInput's reason.
|
||||
const (
|
||||
RemoveInputReasonTagGone = "tag-gone"
|
||||
RemoveInputReasonRetention = "retention"
|
||||
)
|
||||
|
||||
// RemoveAnswer is what remove answers.
|
||||
type RemoveAnswer struct {
|
||||
Artifact *Artifact `json:"artifact,omitempty"`
|
||||
// it stays whole, its tag and its bytes: the store cannot remove the tag alone while another tag names its digest (reason, tags)
|
||||
Kept bool `json:"kept,omitempty"`
|
||||
// why it was kept: shared-digest, another tag names its digest
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// it is gone
|
||||
Removed bool `json:"removed"`
|
||||
// the other tags still naming its digest, when kept
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// The values of RemoveAnswer's reason.
|
||||
const (
|
||||
RemoveAnswerReasonSharedDigest = "shared-digest"
|
||||
)
|
||||
|
||||
// PublishedEvent is the body of the event published.
|
||||
type PublishedEvent = Outcome
|
||||
|
||||
// RefusedEvent is the body of the event refused.
|
||||
type RefusedEvent = Outcome
|
||||
|
||||
// RemovedEvent is the body of the event removed.
|
||||
type RemovedEvent = Outcome
|
||||
|
||||
// KeptEvent is the body of the event kept.
|
||||
type KeptEvent = Outcome
|
||||
|
||||
// GoPackageRegistryForm is the form of the provision go-package-registry.
|
||||
type GoPackageRegistryForm struct {
|
||||
// the read side's address
|
||||
URL string `json:"url"`
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package gopackageregistry
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/go-package-registry/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "published on the seat's subject", subject: "mesh.seat.go-package-registry.event.published", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.go-package-registry\\.event\\.published$")},
|
||||
{name: "refused on the seat's subject", subject: "mesh.seat.go-package-registry.event.refused", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reason\":\"retention\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reason\":\"retention\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v RefusedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.go-package-registry\\.event\\.refused$")},
|
||||
{name: "removed on the seat's subject", subject: "mesh.seat.go-package-registry.event.removed", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reason\":\"retention\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reason\":\"retention\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v RemovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.go-package-registry\\.event\\.removed$")},
|
||||
{name: "kept on the seat's subject: a tagged version sharing its digest stays, naming the tags on it", subject: "mesh.seat.go-package-registry.event.kept", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reason\":\"shared-digest\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"tag\":\"0.1.19-feat-x.2\",\"tags\":[\"0.1.19\"],\"version\":\"0.1.19-feat-x.2\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"holder\":\"gitea\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"reason\":\"shared-digest\",\"reference\":\"git.novox.be/novox/mesh-sdk/go@0.1.19\",\"tag\":\"0.1.19-feat-x.2\",\"tags\":[\"0.1.19\"],\"version\":\"0.1.19-feat-x.2\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.go-package-registry\\.event\\.kept$")},
|
||||
{name: "publish opens a transfer", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a field the reader does not know is dropped", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"later\":{\"x\":1},\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"parts\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"size\":1048576}],\"transfer\":\"t1\",\"version\":\"0.1.19\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "publish answers what it lacks", subject: "", given: "{\"lacks\":[\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"transfer\":\"t1\"}", wire: "{\"lacks\":[\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"transfer\":\"t1\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a chunk of a part", subject: "", given: "{\"data\":\"aGVsbG8=\",\"last\":true,\"part\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sequence\":0,\"transfer\":\"t1\"}", wire: "{\"data\":\"aGVsbG8=\",\"last\":true,\"part\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sequence\":0,\"transfer\":\"t1\"}",
|
||||
decode: func(b []byte) (any, error) { var v PublishPartInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the versions held", subject: "", given: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"versions\":[{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.19\"}]}", wire: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"versions\":[{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fingerprint\":\"f1\",\"kind\":\"package\",\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.19\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a tagged version sharing its digest with another tag is kept, not removed", subject: "", given: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", wire: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}",
|
||||
decode: func(b []byte) (any, error) { var v RemoveAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/gopackageregistry
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,129 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package meshartifactsweep is the contract of the seat "mesh-artifact-sweep", defined whole (seats/mesh-artifact-sweep/seat.json): no description.
|
||||
package meshartifactsweep
|
||||
|
||||
import "time"
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "mesh-artifact-sweep"
|
||||
|
||||
const (
|
||||
VerbArtifacts = "artifacts"
|
||||
VerbHeld = "held"
|
||||
VerbCollect = "collect"
|
||||
VerbMirrors = "mirrors"
|
||||
VerbImages = "images"
|
||||
)
|
||||
|
||||
const (
|
||||
EventArtifactsGone = "artifacts-gone"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbArtifacts, VerbHeld, VerbCollect, VerbMirrors, VerbImages}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventArtifactsGone}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "mesh-artifact-sweep.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// SubjectArtifactsGone is where artifacts-gone is published.
|
||||
const SubjectArtifactsGone = "mesh.seat.mesh-artifact-sweep.event.artifacts-gone"
|
||||
|
||||
// ArtifactsGone is the body of artifacts-gone.
|
||||
type ArtifactsGone struct {
|
||||
// when the sweep found it
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// artifacts-gone
|
||||
Event string `json:"event"`
|
||||
// the key's fingerprint
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
// every reference of the key the store does not hold, sorted
|
||||
Gone []string `json:"gone"`
|
||||
// the builder's done key
|
||||
Key string `json:"key,omitempty"`
|
||||
// the module whose builder's key names a gone artifact
|
||||
Module string `json:"module"`
|
||||
}
|
||||
|
||||
// ArtifactsInput is what artifacts takes.
|
||||
type ArtifactsInput struct {
|
||||
// "true": list the collected references too (counted always)
|
||||
Collected string `json:"collected,omitempty"`
|
||||
// only this repository's references, as <module>/<artifact> (the counts stay whole)
|
||||
Repository string `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// The values of ArtifactsInput's collected.
|
||||
const (
|
||||
ArtifactsInputCollectedTrue = "true"
|
||||
ArtifactsInputCollectedFalse = "false"
|
||||
)
|
||||
|
||||
// ArtifactsAnswer is what artifacts answers.
|
||||
type ArtifactsAnswer = map[string]any
|
||||
|
||||
// HeldInput is what held takes.
|
||||
type HeldInput struct {
|
||||
// the artifacts' references, artifact-store://<module>/<artifact>/blobs/sha256:<hex>: a list, or one text separated by commas
|
||||
References []string `json:"references"`
|
||||
}
|
||||
|
||||
// HeldAnswer is what held answers.
|
||||
type HeldAnswer struct {
|
||||
// the references the store answered 404 for
|
||||
Gone []string `json:"gone"`
|
||||
// the references the store holds
|
||||
Held []string `json:"held"`
|
||||
// the store asked, host and port
|
||||
Store string `json:"store,omitempty"`
|
||||
// a reference the store could not be asked about, to why
|
||||
Unknown map[string]string `json:"unknown,omitempty"`
|
||||
}
|
||||
|
||||
// CollectInput is what collect takes.
|
||||
type CollectInput struct {
|
||||
// "true": let go of what is eligible (needs why); without it nothing is done
|
||||
Confirm string `json:"confirm,omitempty"`
|
||||
// let go of at most this many (500 by default, at most 5000)
|
||||
Most string `json:"most,omitempty"`
|
||||
// with confirm: why, required and recorded
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// The values of CollectInput's confirm.
|
||||
const (
|
||||
CollectInputConfirmTrue = "true"
|
||||
CollectInputConfirmFalse = "false"
|
||||
)
|
||||
|
||||
// CollectAnswer is what collect answers.
|
||||
type CollectAnswer = map[string]any
|
||||
|
||||
// MirrorsInput is what mirrors takes.
|
||||
type MirrorsInput struct {
|
||||
}
|
||||
|
||||
// MirrorsAnswer is what mirrors answers.
|
||||
type MirrorsAnswer = map[string]any
|
||||
|
||||
// ImagesInput is what images takes.
|
||||
type ImagesInput struct {
|
||||
// the machine's name
|
||||
Node string `json:"node"`
|
||||
}
|
||||
|
||||
// ImagesAnswer is what images answers.
|
||||
type ImagesAnswer = map[string]any
|
||||
|
||||
// ArtifactsGoneEvent is the body of the event artifacts-gone.
|
||||
type ArtifactsGoneEvent = ArtifactsGone
|
||||
@@ -1,54 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshartifactsweep
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-artifact-sweep/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "artifacts-gone on the seat's subject", subject: "mesh.seat.mesh-artifact-sweep.event.artifacts-gone", given: "{\"at\":\"2026-11-05T15:04:05Z\",\"event\":\"artifacts-gone\",\"fingerprint\":\"f1\",\"gone\":[\"artifact-store://ca-trust/archive/blobs/sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"artifact-store://ca-trust/archive/blobs/sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"key\":\"ca-trust.archive.f1\",\"module\":\"ca-trust\"}", wire: "{\"at\":\"2026-11-05T15:04:05Z\",\"event\":\"artifacts-gone\",\"fingerprint\":\"f1\",\"gone\":[\"artifact-store://ca-trust/archive/blobs/sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"artifact-store://ca-trust/archive/blobs/sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"key\":\"ca-trust.archive.f1\",\"module\":\"ca-trust\"}",
|
||||
decode: func(b []byte) (any, error) { var v ArtifactsGoneEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-artifact-sweep\\.event\\.artifacts-gone$")},
|
||||
{name: "held asks the references", subject: "", given: "{\"references\":[\"artifact-store://ca-trust/archive/blobs/sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"artifact-store://ca-trust/archive/blobs/sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"artifact-store://ca-trust/archive/blobs/sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"]}", wire: "{\"references\":[\"artifact-store://ca-trust/archive/blobs/sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"artifact-store://ca-trust/archive/blobs/sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"artifact-store://ca-trust/archive/blobs/sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"]}",
|
||||
decode: func(b []byte) (any, error) { var v HeldInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "held answers held, gone and unknown", subject: "", given: "{\"gone\":[\"artifact-store://ca-trust/archive/blobs/sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"held\":[\"artifact-store://ca-trust/archive/blobs/sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"store\":\"store.test:5100\",\"unknown\":{\"artifact-store://ca-trust/archive/blobs/sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\":\"the store answered 503\"}}", wire: "{\"gone\":[\"artifact-store://ca-trust/archive/blobs/sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"],\"held\":[\"artifact-store://ca-trust/archive/blobs/sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"],\"store\":\"store.test:5100\",\"unknown\":{\"artifact-store://ca-trust/archive/blobs/sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\":\"the store answered 503\"}}",
|
||||
decode: func(b []byte) (any, error) { var v HeldAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "held answers with nothing unknown", subject: "", given: "{\"gone\":[],\"held\":[],\"store\":\"store.test:5100\"}", wire: "{\"gone\":[],\"held\":[],\"store\":\"store.test:5100\"}",
|
||||
decode: func(b []byte) (any, error) { var v HeldAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshartifactsweep
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,226 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package meshbuilds is the contract of the seat "mesh-builds", defined whole (seats/mesh-builds/seat.json): The builder's seat: it says each artifact it published and each agreed toolchain, and answers a module's reserved version. Held once for the mesh (design 47 G section 52, section 307).
|
||||
package meshbuilds
|
||||
|
||||
import "time"
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "mesh-builds"
|
||||
|
||||
const (
|
||||
VerbReserved = "reserved"
|
||||
)
|
||||
|
||||
const (
|
||||
AcceptStep = "step"
|
||||
)
|
||||
|
||||
const (
|
||||
EventPackagePublished = "package-published"
|
||||
EventToolchainAgreed = "toolchain-agreed"
|
||||
EventStepEnded = "step-ended"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbReserved}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventPackagePublished, EventToolchainAgreed, EventStepEnded}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "mesh-builds.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// StreamPackagePublished is the stream package-published is kept in.
|
||||
const StreamPackagePublished = "SEAT_mesh-builds_package-published"
|
||||
|
||||
// SubjectPackagePublished is where package-published is published.
|
||||
const SubjectPackagePublished = "mesh.seat.mesh-builds.event.package-published"
|
||||
|
||||
// StreamToolchainAgreed is the stream toolchain-agreed is kept in.
|
||||
const StreamToolchainAgreed = "SEAT_mesh-builds_toolchain-agreed"
|
||||
|
||||
// SubjectToolchainAgreed is where toolchain-agreed is published.
|
||||
const SubjectToolchainAgreed = "mesh.seat.mesh-builds.event.toolchain-agreed"
|
||||
|
||||
// StreamStepEnded is the stream step-ended is kept in.
|
||||
const StreamStepEnded = "SEAT_mesh-builds_step-ended"
|
||||
|
||||
// SubjectStepEnded is where step-ended is published, on mesh.seat.mesh-builds.event.step-ended.<node>.
|
||||
func SubjectStepEnded(node string) string { return "mesh.seat.mesh-builds.event.step-ended." + node }
|
||||
|
||||
// SubjectStepEndedAll hears every step-ended.
|
||||
const SubjectStepEndedAll = "mesh.seat.mesh-builds.event.step-ended.*"
|
||||
|
||||
// AcceptSubjectStep is where step is sent.
|
||||
const AcceptSubjectStep = "mesh.seat.mesh-builds.accept.step"
|
||||
|
||||
// BuildEntry is one entry a candidate's build builds: a module at the fingerprint of its build inputs, and the commit that fingerprint was read at.
|
||||
type BuildEntry struct {
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
Module string `json:"module"`
|
||||
}
|
||||
|
||||
// Dependency is a dependency the build resolved: one item of kind 1 for each resolved package and one of kind 3 for the toolchain, named by the build module in its step key and carried by the builder (design 47 G 374, 673).
|
||||
type Dependency struct {
|
||||
// the digest of the part, as the build used it
|
||||
Digest string `json:"digest"`
|
||||
// 1 an imported package, 3 the build toolchain (design 47 G section 374)
|
||||
Kind int64 `json:"kind"`
|
||||
// the dependency's part: for kind 1 the package's artifact reference, <module>:<artifact>; for kind 3 the agreed toolchain's part (design 47 G 466, 673)
|
||||
Part string `json:"part"`
|
||||
// the version of the dependency the build resolved
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// PackagePublished is one artifact published at the module's reserved version (design 47 G section 52, section 334).
|
||||
type PackagePublished struct {
|
||||
// the package's artifact reference, <module>:<artifact>, from the catalog entry
|
||||
Artifact string `json:"artifact"`
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the watched branch the build was made from
|
||||
Branch string `json:"branch"`
|
||||
// each dependency the build resolved, with its version and digest
|
||||
Dependencies []Dependency `json:"dependencies,omitempty"`
|
||||
// the published artifact's digest
|
||||
Digest string `json:"digest"`
|
||||
// the module
|
||||
Module string `json:"module"`
|
||||
// the source revision of that branch the build was made from
|
||||
Source int64 `json:"source"`
|
||||
V int64 `json:"v"`
|
||||
// the version the build reserved, MAJOR.MINOR.PATCH
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// StepEnded is the build step's end, said by the builder on the node it runs on (design 47 G A-97; ADR 0666 section 21): the runner takes it only from that holder's account, naming the ask and each entry's fingerprint it was asked at.
|
||||
type StepEnded struct {
|
||||
// for a rerun, the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
Ended *time.Time `json:"ended,omitempty"`
|
||||
// each entry the step built, by module and fingerprint
|
||||
Entries []BuildEntry `json:"entries"`
|
||||
// the ask's id
|
||||
ID string `json:"id"`
|
||||
// the node the builder ran it on, as in the subject
|
||||
Node string `json:"node"`
|
||||
// never passed for a build that built nothing
|
||||
Outcome string `json:"outcome"`
|
||||
Pipeline string `json:"pipeline"`
|
||||
Rerun bool `json:"rerun,omitempty"`
|
||||
// why it failed or could not run: the entry not built, the part not heard
|
||||
Said string `json:"said,omitempty"`
|
||||
Started *time.Time `json:"started,omitempty"`
|
||||
Step string `json:"step"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// The values of StepEnded's outcome.
|
||||
const (
|
||||
StepEndedOutcomePassed = "passed"
|
||||
StepEndedOutcomeFailed = "failed"
|
||||
StepEndedOutcomeNothingToRun = "nothing to run"
|
||||
StepEndedOutcomeCouldNotRun = "could not run"
|
||||
)
|
||||
|
||||
// The values of StepEnded's step.
|
||||
const (
|
||||
StepEndedStepBuild = "build"
|
||||
)
|
||||
|
||||
// StepRun is the build step of one module's pipeline (design 47 G section 230, A-97): the runner asks the seat mesh-builds to build a candidate's entries, each named by its fingerprint, and the builder, the one entry point for a candidate, takes the ask and answers the step's end.
|
||||
type StepRun struct {
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// for a rerun, the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
// each entry the candidate's build builds, by module and fingerprint
|
||||
Entries []BuildEntry `json:"entries"`
|
||||
// the runner's pipeline key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline"`
|
||||
// the step is asked again by the runner's rerun
|
||||
Rerun bool `json:"rerun,omitempty"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the source revision of the watched branch; absent for a run on request
|
||||
Source int64 `json:"source,omitempty"`
|
||||
Step string `json:"step"`
|
||||
}
|
||||
|
||||
// The values of StepRun's step.
|
||||
const (
|
||||
StepRunStepBuild = "build"
|
||||
)
|
||||
|
||||
// ToolchainAgreedDigestsItem is a type of the contract.
|
||||
type ToolchainAgreedDigestsItem struct {
|
||||
// the toolchain part's digest
|
||||
Digest string `json:"digest"`
|
||||
// the nodes reporting that digest
|
||||
Nodes []string `json:"nodes"`
|
||||
}
|
||||
|
||||
// ToolchainAgreed is the agreed toolchain of a language changed (design 47 G section 376, ADR 0584 section 1).
|
||||
type ToolchainAgreed struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// each digest the nodes reporting the agreed version report, as it stood when the version was agreed, with those nodes (design 47 G section 472, section 495)
|
||||
Digests []ToolchainAgreedDigestsItem `json:"digests"`
|
||||
// the language whose agreed toolchain changed
|
||||
Language string `json:"language"`
|
||||
V int64 `json:"v"`
|
||||
// the agreed toolchain's version
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// ReservedInput is what reserved takes.
|
||||
type ReservedInput struct {
|
||||
// the module; give this or name
|
||||
Module string `json:"module,omitempty"`
|
||||
// a package's or an image's name in its ecosystem (the Go module path, the npm name, the image name), in place of module; a name no entry carries, or more than one entry carries, is answered error naming it (design 47 G section 478, section 491)
|
||||
Name string `json:"name,omitempty"`
|
||||
// the version, when asked for a particular one
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// ReservedAnswerArtifactsItem is a type of the contract.
|
||||
type ReservedAnswerArtifactsItem struct {
|
||||
// the artifact reference, <module>:<artifact>
|
||||
Artifact string `json:"artifact"`
|
||||
// its digest once built; empty before
|
||||
Digest string `json:"digest,omitempty"`
|
||||
}
|
||||
|
||||
// ReservedAnswer is what reserved answers.
|
||||
type ReservedAnswer struct {
|
||||
Artifacts []ReservedAnswerArtifactsItem `json:"artifacts,omitempty"`
|
||||
// a name no entry carries, or a version neither reserved nor released, naming which; set alone (design 47 G 582, 679)
|
||||
Error string `json:"error,omitempty"`
|
||||
// the module
|
||||
Module string `json:"module,omitempty"`
|
||||
// true when the version is released: the catalog holds it, and artifacts are the ones its release recorded with their digests; false when it is reserved (design 47 G 582, 679)
|
||||
Released bool `json:"released,omitempty"`
|
||||
// the reserved version, MAJOR.MINOR.PATCH
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// StepAccept is the body of step.
|
||||
type StepAccept = StepRun
|
||||
|
||||
// PackagePublishedEvent is the body of the event package-published.
|
||||
type PackagePublishedEvent = PackagePublished
|
||||
|
||||
// ToolchainAgreedEvent is the body of the event toolchain-agreed.
|
||||
type ToolchainAgreedEvent = ToolchainAgreed
|
||||
|
||||
// StepEndedEvent is the body of the event step-ended.
|
||||
type StepEndedEvent = StepEnded
|
||||
@@ -1,64 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshbuilds
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-builds/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a package published with the dependencies the build resolved", subject: "mesh.seat.mesh-builds.event.package-published", given: "{\"artifact\":\"mesh-sdk:go\",\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"dependencies\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"version\":\"0.1.4\"},{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":3,\"part\":\"mesh-build-go:toolchain\",\"version\":\"1.26.0\"}],\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"artifact\":\"mesh-sdk:go\",\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"dependencies\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"version\":\"0.1.4\"},{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":3,\"part\":\"mesh-build-go:toolchain\",\"version\":\"1.26.0\"}],\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v PackagePublishedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.package-published$")},
|
||||
{name: "a toolchain agreed", subject: "mesh.seat.mesh-builds.event.toolchain-agreed", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"digests\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"nodes\":[\"ace\",\"g14\"]},{\"digest\":\"sha256:fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210\",\"nodes\":[\"novox\"]}],\"language\":\"go\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"digests\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"nodes\":[\"ace\",\"g14\"]},{\"digest\":\"sha256:fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210\",\"nodes\":[\"novox\"]}],\"language\":\"go\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) { var v ToolchainAgreedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.toolchain-agreed$")},
|
||||
{name: "the build step ended passed on the builder's node, each entry named by its fingerprint (A-97)", subject: "mesh.seat.mesh-builds.event.step-ended.novox", given: "{\"ended\":\"2026-11-10T10:01:00Z\",\"entries\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"novox\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"build\",\"v\":1}", wire: "{\"ended\":\"2026-11-10T10:01:00Z\",\"entries\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"novox\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "the build step failed on its entry", subject: "mesh.seat.mesh-builds.event.step-ended.novox", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"novox\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"novox\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "reserved asks a module", subject: "", given: "{\"module\":\"mesh-sdk\"}", wire: "{\"module\":\"mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReservedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "reserved asks a package by its name", subject: "", given: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.15\"}", wire: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReservedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "reserved answers the version and each artifact's digest", subject: "", given: "{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},{\"artifact\":\"mesh-sdk:ts\"}],\"module\":\"mesh-sdk\",\"version\":\"0.1.15\"}", wire: "{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},{\"artifact\":\"mesh-sdk:ts\"}],\"module\":\"mesh-sdk\",\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReservedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "reserved answers a released version with the digests the release recorded", subject: "", given: "{\"artifacts\":[{\"artifact\":\"mesh-tools:go-meshtools\",\"digest\":\"sha256:aa\"}],\"module\":\"mesh-tools\",\"released\":true,\"version\":\"0.1.4\"}", wire: "{\"artifacts\":[{\"artifact\":\"mesh-tools:go-meshtools\",\"digest\":\"sha256:aa\"}],\"module\":\"mesh-tools\",\"released\":true,\"version\":\"0.1.4\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReservedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "reserved answers an error alone, naming the name or the version", subject: "", given: "{\"error\":\"no entry carries the name example.org/none\"}", wire: "{\"error\":\"no entry carries the name example.org/none\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReservedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshbuilds
|
||||
|
||||
go 1.26.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,206 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshcatalog
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-catalog/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a trunk revision kept, on the seat's subject", subject: "mesh.seat.mesh-catalog.event.catalog-revision.main", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"changed\":[\"xclip\"],\"entries\":2,\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"changed\":[\"xclip\"],\"entries\":2,\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CatalogRevisionEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.catalog-revision\\.[^.*> ]+$")},
|
||||
{name: "a candidate's revision kept", subject: "mesh.seat.mesh-catalog.event.catalog-revision.main", given: "{\"branch\":\"main\",\"entries\":2,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"revision\":13,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"entries\":2,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"revision\":13,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CatalogRevisionEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.catalog-revision\\.[^.*> ]+$")},
|
||||
{name: "the store past 80 % of its cap", subject: "mesh.seat.mesh-catalog.event.filling", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":450000000,\"cap\":536870912,\"store\":\"catalog-revisions\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":450000000,\"cap\":536870912,\"store\":\"catalog-revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v FillingEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.filling$")},
|
||||
{name: "the store full, naming what it refuses", subject: "mesh.seat.mesh-catalog.event.full", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":536870912,\"cap\":536870912,\"refused\":\"the next revision; source revision 3590 held pending with the reason objects full\",\"store\":\"catalog-revisions\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":536870912,\"cap\":536870912,\"refused\":\"the next revision; source revision 3590 held pending with the reason objects full\",\"store\":\"catalog-revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v FullEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.full$")},
|
||||
{name: "the store back below its cap", subject: "mesh.seat.mesh-catalog.event.room", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":300000000,\"cap\":536870912,\"store\":\"catalog-revisions\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":300000000,\"cap\":536870912,\"store\":\"catalog-revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v RoomEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.room$")},
|
||||
{name: "a registration changed on its warrant", subject: "mesh.seat.mesh-catalog.event.registration-changed", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"operator@shanks\",\"module\":\"nats\",\"moved\":[\"nats:program unit: required -\\u003e bypass\"],\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"operator@shanks\",\"module\":\"nats\",\"moved\":[\"nats:program unit: required -\\u003e bypass\"],\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v RegistrationChangedEvent
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.registration-changed$")},
|
||||
{name: "a version released", subject: "mesh.seat.mesh-catalog.event.version-released", given: "{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}],\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}],\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v VersionReleasedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.version-released$")},
|
||||
{name: "the versions filled", subject: "mesh.seat.mesh-catalog.event.versions-filled", given: "{\"at\":\"2026-11-11T10:00:00Z\",\"modules\":120,\"v\":1}", wire: "{\"at\":\"2026-11-11T10:00:00Z\",\"modules\":120,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v VersionsFilledEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.versions-filled$")},
|
||||
{name: "a manifest (xclip, read through mesh-catalog.module)", subject: "", given: "{\"manifest\":\"{\\\"build\\\":{\\\"artifacts\\\":[{\\\"binary\\\":\\\"xclip-tools\\\",\\\"from\\\":\\\"cmd/xclip-tools\\\",\\\"kind\\\":\\\"bundle\\\",\\\"language\\\":\\\"go\\\",\\\"loads\\\":[\\\"xclip-tools\\\"],\\\"name\\\":\\\"tools\\\",\\\"system\\\":\\\"arch\\\"}]},\\\"capabilities\\\":[\\\"package-manager\\\"],\\\"module\\\":\\\"xclip\\\",\\\"resources\\\":[{\\\"id\\\":\\\"package\\\",\\\"package\\\":\\\"xclip\\\",\\\"type\\\":\\\"package\\\"}],\\\"tools\\\":[\\\"xclip_copy\\\",\\\"xclip_paste\\\",\\\"xclip_targets\\\",\\\"xclip_session\\\"],\\\"version\\\":\\\"1\\\"}\",\"module\":\"xclip\",\"v\":1}", wire: "{\"manifest\":\"{\\\"build\\\":{\\\"artifacts\\\":[{\\\"binary\\\":\\\"xclip-tools\\\",\\\"from\\\":\\\"cmd/xclip-tools\\\",\\\"kind\\\":\\\"bundle\\\",\\\"language\\\":\\\"go\\\",\\\"loads\\\":[\\\"xclip-tools\\\"],\\\"name\\\":\\\"tools\\\",\\\"system\\\":\\\"arch\\\"}]},\\\"capabilities\\\":[\\\"package-manager\\\"],\\\"module\\\":\\\"xclip\\\",\\\"resources\\\":[{\\\"id\\\":\\\"package\\\",\\\"package\\\":\\\"xclip\\\",\\\"type\\\":\\\"package\\\"}],\\\"tools\\\":[\\\"xclip_copy\\\",\\\"xclip_paste\\\",\\\"xclip_targets\\\",\\\"xclip_session\\\"],\\\"version\\\":\\\"1\\\"}\",\"module\":\"xclip\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v ManifestsByDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a module (xclip, read through mesh-catalog.modules; the inputs and toolchains no tool reads are not here)", subject: "", given: "{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp2\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"v\":1}", wire: "{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp2\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v ModulesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a candidate", subject: "", given: "{\"base\":3,\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"modules\":[\"nats\"],\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}", wire: "{\"base\":3,\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"modules\":[\"nats\"],\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CandidatesByGroupValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a refused verdict (nats, read through the indexer's verdicts tool)", subject: "", given: "{\"at\":\"2026-11-04T18:51:12.614583047+01:00\",\"judge\":\"exe:661e6fb424d7ffea\",\"module\":\"nats\",\"problems\":[\"this is not a module manifest: a state is either a name or {name, history, ttl-seconds, per-machine, key-ttl}: json: unknown field \\\"read-only\\\" (read without state[2].read-only)\"],\"state\":\"refused\"}", wire: "{\"at\":\"2026-11-04T18:51:12.614583047+01:00\",\"judge\":\"exe:661e6fb424d7ffea\",\"module\":\"nats\",\"problems\":[\"this is not a module manifest: a state is either a name or {name, history, ttl-seconds, per-machine, key-ttl}: json: unknown field \\\"read-only\\\" (read without state[2].read-only)\"],\"state\":\"refused\"}",
|
||||
decode: func(b []byte) (any, error) { var v VerdictsByDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the predefined list", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"list\":{\"streams\":[]},\"v\":1}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"list\":{\"streams\":[]},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v PredefinedByListValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a pull request's configuration", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ConfigCandidatesByPullValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a pull request's configuration state whose bounds are declared 0 (a zero is a bound, not none)", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ConfigCandidatesByPullValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a published Go module", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"packages\":[{\"digest\":\"ab\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"repository\":\"novox/mesh-sdk\",\"v\":1}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"packages\":[{\"digest\":\"ab\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"repository\":\"novox/mesh-sdk\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v PackagesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a package series", subject: "", given: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}", wire: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PackagesByPackageSeriesValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a module with its toolchain", subject: "", given: "{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp2\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1}", wire: "{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp2\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v ModulesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the modules verb (captured: the first three modules)", subject: "", given: "{\"modules\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:5e4a1b4ad4ea6175c05e4655ce58aeb957547149d4c9805eb27636efd50c1c87\",\"module\":\"adwaita\",\"path\":\"modules/adwaita\",\"repository\":\"novox/mesh-catalog\"},{\"commit\":\"b112adcecc41d18f54190cbd2fc864199b70c518\",\"fp\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\",\"module\":\"amqp-email-forwarder\",\"path\":\".\",\"repository\":\"jschoubben/amqp-email-forwarder\"},{\"commit\":\"dd458cb155f5f5fa3ed824a23728e444be5b156a\",\"fp\":\"src2:a98f8152f0a837dd5ba883a15efaf110ba88100193157e4bdb1a93ba55209371\",\"module\":\"artifact-store-tools\",\"path\":\"modules/artifact-store-tools\",\"repository\":\"novox/mesh-catalog\"}]}", wire: "{\"modules\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:5e4a1b4ad4ea6175c05e4655ce58aeb957547149d4c9805eb27636efd50c1c87\",\"module\":\"adwaita\",\"path\":\"modules/adwaita\",\"repository\":\"novox/mesh-catalog\"},{\"commit\":\"b112adcecc41d18f54190cbd2fc864199b70c518\",\"fp\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\",\"module\":\"amqp-email-forwarder\",\"path\":\".\",\"repository\":\"jschoubben/amqp-email-forwarder\"},{\"commit\":\"dd458cb155f5f5fa3ed824a23728e444be5b156a\",\"fp\":\"src2:a98f8152f0a837dd5ba883a15efaf110ba88100193157e4bdb1a93ba55209371\",\"module\":\"artifact-store-tools\",\"path\":\"modules/artifact-store-tools\",\"repository\":\"novox/mesh-catalog\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v ModulesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the module verb (captured: xclip)", subject: "", given: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}", wire: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}",
|
||||
decode: func(b []byte) (any, error) { var v ModuleAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByBranchRevisionValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a candidate's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"revision\":13,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"revision\":13,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByCandidateGroupHeadsValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a catalog graph entry (xclip)", subject: "", given: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByEntryDigestValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "an acting part's entry carries the rule of the seat it claims", subject: "", given: "{\"acts\":[{\"bound\":\"60m\",\"on\":\"go\",\"seat\":\"node-build-go\",\"step\":\"build\"}],\"awaits\":[\"database\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"left-out\":[\"mesh-catalog.revision\"],\"main\":\"cmd/mesh-build-go\",\"manifest\":{\"module\":\"mesh-build-go\",\"version\":\"1\"},\"module\":\"mesh-build-go\",\"needs\":[\"form:setting\",\"word:claims\"],\"path\":\"modules/mesh-build-go\",\"repository\":\"novox/mesh-catalog\",\"serves\":[\"node-build-go.run\"],\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"acts\":[{\"bound\":\"60m\",\"on\":\"go\",\"seat\":\"node-build-go\",\"step\":\"build\"}],\"awaits\":[\"database\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"left-out\":[\"mesh-catalog.revision\"],\"main\":\"cmd/mesh-build-go\",\"manifest\":{\"module\":\"mesh-build-go\",\"version\":\"1\"},\"module\":\"mesh-build-go\",\"needs\":[\"form:setting\",\"word:claims\"],\"path\":\"modules/mesh-build-go\",\"repository\":\"novox/mesh-catalog\",\"serves\":[\"node-build-go.run\"],\"v\":1,\"verdict\":\"accepted\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByEntryDigestValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a module's registration", subject: "", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v RegistrationsByModuleValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "one version kept in the history", subject: "", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v RegistrationHistoryByModuleVersionValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "an entry with its artifacts and the edges into them, per artifact", subject: "", given: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"fp-src\":41,\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"src\":41,\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByEntryDigestValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a released version", subject: "", given: "{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}],\"edges\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"stale\":true,\"version\":\"0.1.4\",\"word\":\"imports\"}],\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}],\"edges\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"stale\":true,\"version\":\"0.1.4\",\"word\":\"imports\"}],\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v VersionsByModuleVersionValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a build of another branch", subject: "", given: "{\"edges\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"stale\":true,\"version\":\"0.1.4\",\"word\":\"imports\"}],\"fp\":\"src2:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"source\":3589,\"v\":1}", wire: "{\"edges\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"stale\":true,\"version\":\"0.1.4\",\"word\":\"imports\"}],\"fp\":\"src2:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v BuildEdgesByModuleBranchValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "an input", subject: "", given: "\"eyJ2IjoxfQ==\"", wire: "\"eyJ2IjoxfQ==\"",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v InputsByTimeDigestValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "revision asks the trunk's newest", subject: "", given: "{}", wire: "{}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "revision asks a candidate's, from a page on", subject: "", given: "{\"after\":\"mesh-build-go\",\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\"}", wire: "{\"after\":\"mesh-build-go\",\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\"}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "revision answers a page and the next", subject: "", given: "{\"entries\":[{\"acts\":[{\"bound\":\"60m\",\"on\":\"go\",\"seat\":\"node-build-go\",\"step\":\"build\"}],\"awaits\":[\"database\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"left-out\":[\"mesh-catalog.revision\"],\"main\":\"cmd/mesh-build-go\",\"manifest\":{\"module\":\"mesh-build-go\",\"version\":\"1\"},\"module\":\"mesh-build-go\",\"needs\":[\"form:setting\",\"word:claims\"],\"path\":\"modules/mesh-build-go\",\"repository\":\"novox/mesh-catalog\",\"serves\":[\"node-build-go.run\"],\"v\":1,\"verdict\":\"accepted\"}],\"next\":\"mesh-build-go\",\"revision\":{\"at\":\"2026-11-09T19:00:00Z\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}}", wire: "{\"entries\":[{\"acts\":[{\"bound\":\"60m\",\"on\":\"go\",\"seat\":\"node-build-go\",\"step\":\"build\"}],\"awaits\":[\"database\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"left-out\":[\"mesh-catalog.revision\"],\"main\":\"cmd/mesh-build-go\",\"manifest\":{\"module\":\"mesh-build-go\",\"version\":\"1\"},\"module\":\"mesh-build-go\",\"needs\":[\"form:setting\",\"word:claims\"],\"path\":\"modules/mesh-build-go\",\"repository\":\"novox/mesh-catalog\",\"serves\":[\"node-build-go.run\"],\"v\":1,\"verdict\":\"accepted\"}],\"next\":\"mesh-build-go\",\"revision\":{\"at\":\"2026-11-09T19:00:00Z\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "revision answers its last page", subject: "", given: "{\"entries\":[{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}],\"revision\":{\"at\":\"2026-11-09T19:00:00Z\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}}", wire: "{\"entries\":[{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}],\"revision\":{\"at\":\"2026-11-09T19:00:00Z\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "revision answers none yet for a branch with no revision", subject: "", given: "{\"none-yet\":true}", wire: "{\"none-yet\":true}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "registrations of one module with its history", subject: "", given: "{\"history\":true,\"module\":\"nats\"}", wire: "{\"history\":true,\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v RegistrationsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "registrations answers one with its versions", subject: "", given: "{\"history\":[{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":1,\"warrant\":\"ask-m2kx9a1b3c4d5e\"},{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}],\"registrations\":[{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}]}", wire: "{\"history\":[{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":1,\"warrant\":\"ask-m2kx9a1b3c4d5e\"},{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}],\"registrations\":[{\"at\":\"2026-11-10T10:00:00Z\",\"branches\":[\"main\"],\"by\":\"operator@shanks\",\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":2,\"warrant\":\"ask-m2kx9a1b3c4d5e\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v RegistrationsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "register a module whole", subject: "", given: "{\"registration\":{\"branches\":[\"main\"],\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1},\"why\":\"the first registration\"}", wire: "{\"registration\":{\"branches\":[\"main\"],\"module\":\"nats\",\"origin\":\"novox/mesh-catalog\",\"path\":\"modules/nats/module.json\",\"policy\":{\"artifacts\":{\"program\":{\"unit\":\"bypass\"}},\"steps\":{\"approval\":\"bypass\",\"composition\":\"required\",\"integration\":\"required\",\"lint\":\"required\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1},\"why\":\"the first registration\"}",
|
||||
decode: func(b []byte) (any, error) { var v RegisterInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "register refused for an unprotected branch", subject: "", given: "{\"module\":\"nats\",\"refused\":\"unprotected branch\",\"words\":\"the branch beta of novox/mesh-catalog admits a direct push\"}", wire: "{\"module\":\"nats\",\"refused\":\"unprotected branch\",\"words\":\"the branch beta of novox/mesh-catalog admits a direct push\"}",
|
||||
decode: func(b []byte) (any, error) { var v RegisterAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "unwatch refused for a branch a placement names", subject: "", given: "{\"module\":\"nats\",\"refused\":\"placed\",\"words\":\"the branch beta of nats is placed: n1 and n2 run it from that branch\"}", wire: "{\"module\":\"nats\",\"refused\":\"placed\",\"words\":\"the branch beta of nats is placed: n1 and n2 run it from that branch\"}",
|
||||
decode: func(b []byte) (any, error) { var v UnwatchAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "register refused for a reserved branch name", subject: "", given: "{\"module\":\"nats\",\"refused\":\"reserved branch name\",\"words\":\"the branch candidate of novox/mesh-catalog is a name the catalog keeps for its own revisions\"}", wire: "{\"module\":\"nats\",\"refused\":\"reserved branch name\",\"words\":\"the branch candidate of novox/mesh-catalog is a name the catalog keeps for its own revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v RegisterAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "policy moves one artifact's unit step", subject: "", given: "{\"artifact\":\"program\",\"module\":\"nats\",\"steps\":{\"unit\":\"bypass\"},\"why\":\"its tests need hardware\"}", wire: "{\"artifact\":\"program\",\"module\":\"nats\",\"steps\":{\"unit\":\"bypass\"},\"why\":\"its tests need hardware\"}",
|
||||
decode: func(b []byte) (any, error) { var v PolicyInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "policy asked, naming the moved status", subject: "", given: "{\"ask\":\"ask-m2kx9a1b3c4d5e\",\"lines\":[\"nats:program unit: required -\\u003e bypass\"],\"module\":\"nats\"}", wire: "{\"ask\":\"ask-m2kx9a1b3c4d5e\",\"lines\":[\"nats:program unit: required -\\u003e bypass\"],\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v PolicyAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "watch a second branch", subject: "", given: "{\"branch\":\"beta\",\"module\":\"nats\"}", wire: "{\"branch\":\"beta\",\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v WatchInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "unwatch it", subject: "", given: "{\"branch\":\"beta\",\"module\":\"nats\"}", wire: "{\"branch\":\"beta\",\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v UnwatchInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "versions asks a module", subject: "", given: "{\"module\":\"mesh-sdk\"}", wire: "{\"module\":\"mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v VersionsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "versions answers the released versions with their edges", subject: "", given: "{\"module\":\"mesh-sdk\",\"versions\":[{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}],\"edges\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"stale\":true,\"version\":\"0.1.4\",\"word\":\"imports\"}],\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}]}", wire: "{\"module\":\"mesh-sdk\",\"versions\":[{\"artifacts\":[{\"artifact\":\"mesh-sdk:go\",\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}],\"edges\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"stale\":true,\"version\":\"0.1.4\",\"word\":\"imports\"}],\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "outdated asks for one dependency", subject: "", given: "{\"branch\":\"main\",\"dependency\":\"mesh-sdk:go\"}", wire: "{\"branch\":\"main\",\"dependency\":\"mesh-sdk:go\"}",
|
||||
decode: func(b []byte) (any, error) { var v OutdatedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "outdated answers an entry behind", subject: "", given: "{\"behind\":[{\"act\":\"rebuild\",\"dependency\":{\"artifact\":\"mesh-sdk:go\",\"branch\":\"main\",\"source\":3589},\"kind\":1,\"module\":\"nats\",\"newest\":\"0.1.15 sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"recorded\":\"0.1.14 sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"version\":\"1.2.3\"}]}", wire: "{\"behind\":[{\"act\":\"rebuild\",\"dependency\":{\"artifact\":\"mesh-sdk:go\",\"branch\":\"main\",\"source\":3589},\"kind\":1,\"module\":\"nats\",\"newest\":\"0.1.15 sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"recorded\":\"0.1.14 sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"version\":\"1.2.3\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v OutdatedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "input asks a step's input by digest", subject: "", given: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", wire: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}",
|
||||
decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "input answers the exact bytes", subject: "", given: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"input\":\"eyJ2IjoxfQ==\"}", wire: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"input\":\"eyJ2IjoxfQ==\"}",
|
||||
decode: func(b []byte) (any, error) { var v InputAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "entry asks by fingerprint", subject: "", given: "{\"fingerprint\":\"src2:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", wire: "{\"fingerprint\":\"src2:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}",
|
||||
decode: func(b []byte) (any, error) { var v EntryInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,764 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package meshdelivery is the contract of the seat "mesh-delivery", defined whole (seats/mesh-delivery/seat.json): The delivery gate: reads and steers deliveries, merges and the checks that decide them; the merge is made on the operator's Approve once both checks passed.
|
||||
package meshdelivery
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "mesh-delivery"
|
||||
|
||||
const (
|
||||
VerbDeliveries = "deliveries"
|
||||
VerbShow = "show"
|
||||
VerbGroups = "groups"
|
||||
VerbSource = "source"
|
||||
VerbStalled = "stalled"
|
||||
VerbRecovery = "recovery"
|
||||
)
|
||||
|
||||
const (
|
||||
EventOwed = "owed"
|
||||
EventPinned = "pinned"
|
||||
EventFreed = "freed"
|
||||
EventHeadsReplaced = "heads-replaced"
|
||||
EventRecordOpened = "record-opened"
|
||||
EventRecordEnded = "record-ended"
|
||||
EventFilling = "filling"
|
||||
EventFull = "full"
|
||||
EventRoom = "room"
|
||||
EventSourceMoved = "source-moved"
|
||||
EventRecoveryMerged = "recovery-merged"
|
||||
EventApprovalCarried = "approval-carried"
|
||||
EventPinsStated = "pins-stated"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbDeliveries, VerbShow, VerbGroups, VerbSource, VerbStalled, VerbRecovery}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventOwed, EventPinned, EventFreed, EventHeadsReplaced, EventRecordOpened, EventRecordEnded, EventFilling, EventFull, EventRoom, EventSourceMoved, EventRecoveryMerged, EventApprovalCarried, EventPinsStated}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "mesh-delivery.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// StreamOwed is the stream owed is kept in.
|
||||
const StreamOwed = "SEAT_mesh-delivery_owed"
|
||||
|
||||
// SubjectOwed is where owed is published, on mesh.seat.mesh-delivery.event.owed.<repository>.<number>.
|
||||
func SubjectOwed(repository, number string) string {
|
||||
return "mesh.seat.mesh-delivery.event.owed." + repository + "." + number
|
||||
}
|
||||
|
||||
// SubjectOwedAll hears every owed.
|
||||
const SubjectOwedAll = "mesh.seat.mesh-delivery.event.owed.*.*"
|
||||
|
||||
// SubjectPinned is where pinned is published.
|
||||
const SubjectPinned = "mesh.seat.mesh-delivery.event.pinned"
|
||||
|
||||
// SubjectFreed is where freed is published.
|
||||
const SubjectFreed = "mesh.seat.mesh-delivery.event.freed"
|
||||
|
||||
// SubjectHeadsReplaced is where heads-replaced is published.
|
||||
const SubjectHeadsReplaced = "mesh.seat.mesh-delivery.event.heads-replaced"
|
||||
|
||||
// SubjectRecordOpened is where record-opened is published.
|
||||
const SubjectRecordOpened = "mesh.seat.mesh-delivery.event.record-opened"
|
||||
|
||||
// SubjectRecordEnded is where record-ended is published.
|
||||
const SubjectRecordEnded = "mesh.seat.mesh-delivery.event.record-ended"
|
||||
|
||||
// SubjectFilling is where filling is published.
|
||||
const SubjectFilling = "mesh.seat.mesh-delivery.event.filling"
|
||||
|
||||
// SubjectFull is where full is published.
|
||||
const SubjectFull = "mesh.seat.mesh-delivery.event.full"
|
||||
|
||||
// SubjectRoom is where room is published.
|
||||
const SubjectRoom = "mesh.seat.mesh-delivery.event.room"
|
||||
|
||||
// SubjectSourceMoved is where source-moved is published, on mesh.seat.mesh-delivery.event.source-moved.<branch>.
|
||||
func SubjectSourceMoved(branch string) string {
|
||||
return "mesh.seat.mesh-delivery.event.source-moved." + branch
|
||||
}
|
||||
|
||||
// SubjectSourceMovedAll hears every source-moved.
|
||||
const SubjectSourceMovedAll = "mesh.seat.mesh-delivery.event.source-moved.*"
|
||||
|
||||
// SubjectRecoveryMerged is where recovery-merged is published.
|
||||
const SubjectRecoveryMerged = "mesh.seat.mesh-delivery.event.recovery-merged"
|
||||
|
||||
// StreamApprovalCarried is the stream approval-carried is kept in.
|
||||
const StreamApprovalCarried = "SEAT_mesh-delivery_approval-carried"
|
||||
|
||||
// SubjectApprovalCarried is where approval-carried is published, on mesh.seat.mesh-delivery.event.approval-carried.<repository>.<pull>.
|
||||
func SubjectApprovalCarried(repository, pull string) string {
|
||||
return "mesh.seat.mesh-delivery.event.approval-carried." + repository + "." + pull
|
||||
}
|
||||
|
||||
// SubjectApprovalCarriedAll hears every approval-carried.
|
||||
const SubjectApprovalCarriedAll = "mesh.seat.mesh-delivery.event.approval-carried.*.*"
|
||||
|
||||
// SubjectPinsStated is where pins-stated is published.
|
||||
const SubjectPinsStated = "mesh.seat.mesh-delivery.event.pins-stated"
|
||||
|
||||
const (
|
||||
StateSource = "source"
|
||||
StateMerges = "merges"
|
||||
StateAsks = "asks"
|
||||
StateOwed = "owed"
|
||||
StateTurns = "turns"
|
||||
)
|
||||
|
||||
// SourceByBranchKey is the key of one value of the state source under the form "<branch>".
|
||||
func SourceByBranchKey(branch string) string { return branch }
|
||||
|
||||
// ParseSourceByBranchKey reads the parts of a key of the form "<branch>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseSourceByBranchKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodeSourceByBranchValue reads one value of the state source under the form "<branch>", refusing a field SourceByBranchValue does not know and any text after the value.
|
||||
func DecodeSourceByBranchValue(raw []byte) (SourceByBranchValue, error) {
|
||||
var v SourceByBranchValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// MergesByGroupKey is the key of one value of the state merges under the form "<group>".
|
||||
func MergesByGroupKey(group string) string { return group }
|
||||
|
||||
// ParseMergesByGroupKey reads the parts of a key of the form "<group>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseMergesByGroupKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodeMergesByGroupValue reads one value of the state merges under the form "<group>", refusing a field MergesByGroupValue does not know and any text after the value.
|
||||
func DecodeMergesByGroupValue(raw []byte) (MergesByGroupValue, error) {
|
||||
var v MergesByGroupValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// AsksByMergeGroupHeadsKey is the key of one value of the state asks under the form "merge.<group>.<heads>".
|
||||
func AsksByMergeGroupHeadsKey(group, heads string) string { return "merge." + group + "." + heads }
|
||||
|
||||
// ParseAsksByMergeGroupHeadsKey reads the parts of a key of the form "merge.<group>.<heads>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseAsksByMergeGroupHeadsKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "merge.") {
|
||||
return "", "", false
|
||||
}
|
||||
rest = rest[6:]
|
||||
v1, after1, found1 := strings.Cut(rest, ".")
|
||||
if !found1 || v1 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after1
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v3 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v1, v3, true
|
||||
}
|
||||
|
||||
// DecodeAsksByMergeGroupHeadsValue reads one value of the state asks under the form "merge.<group>.<heads>", refusing a field AsksByMergeGroupHeadsValue does not know and any text after the value.
|
||||
func DecodeAsksByMergeGroupHeadsValue(raw []byte) (AsksByMergeGroupHeadsValue, error) {
|
||||
var v AsksByMergeGroupHeadsValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// OwedByRepositoryNumberHeadActKey is the key of one value of the state owed under the form "<repository>.<number>.<head>.<act>".
|
||||
func OwedByRepositoryNumberHeadActKey(repository, number, head, act string) string {
|
||||
return repository + "." + number + "." + head + "." + act
|
||||
}
|
||||
|
||||
// ParseOwedByRepositoryNumberHeadActKey reads the parts of a key of the form "<repository>.<number>.<head>.<act>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseOwedByRepositoryNumberHeadActKey(key string) (string, string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
v4, after4, found4 := strings.Cut(rest, ".")
|
||||
if !found4 || v4 == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
rest = after4
|
||||
if rest == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
v6 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, v6, true
|
||||
}
|
||||
|
||||
// DecodeOwedByRepositoryNumberHeadActValue reads one value of the state owed under the form "<repository>.<number>.<head>.<act>", refusing a field OwedByRepositoryNumberHeadActValue does not know and any text after the value.
|
||||
func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumberHeadActValue, error) {
|
||||
var v OwedByRepositoryNumberHeadActValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// TurnsByRepositoryKey is the key of one value of the state turns under the form "<repository>".
|
||||
func TurnsByRepositoryKey(repository string) string { return repository }
|
||||
|
||||
// ParseTurnsByRepositoryKey reads the parts of a key of the form "<repository>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseTurnsByRepositoryKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodeTurnsByRepositoryValue reads one value of the state turns under the form "<repository>", refusing a field TurnsByRepositoryValue does not know and any text after the value.
|
||||
func DecodeTurnsByRepositoryValue(raw []byte) (TurnsByRepositoryValue, error) {
|
||||
var v TurnsByRepositoryValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Act is an act the gate said for a group, with its recorded outcome once the forge bridge said one.
|
||||
type Act struct {
|
||||
// when the outcome was recorded
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the outcome the forge bridge said as owed.ended and the gate recorded; absent while unanswered
|
||||
Outcome string `json:"outcome,omitempty"`
|
||||
Owed Owed `json:"owed"`
|
||||
// the forge's own words for a refusal, the error for an act that could not be performed, why one is undecodable or dropped
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Act's outcome.
|
||||
const (
|
||||
ActOutcomePerformed = "performed"
|
||||
ActOutcomeRefused = "refused"
|
||||
ActOutcomeCouldNotBePerformed = "could not be performed"
|
||||
ActOutcomeUndecodable = "undecodable"
|
||||
ActOutcomeDropped = "dropped"
|
||||
)
|
||||
|
||||
// Ask is the one Approve ask of a milestone (ADR 0493 §9), said apart from each delivery's transition.
|
||||
type Ask struct {
|
||||
// on answered: approve or decline
|
||||
Answer string `json:"answer,omitempty"`
|
||||
// the ask's id
|
||||
Ask string `json:"ask"`
|
||||
// when
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// on answered: who answered
|
||||
By string `json:"by,omitempty"`
|
||||
// its delivery group
|
||||
Group string `json:"group"`
|
||||
// repository to the head asked
|
||||
Heads map[string]string `json:"heads,omitempty"`
|
||||
// the milestone
|
||||
Milestone string `json:"milestone"`
|
||||
// on withdrawn: why, such as a new head of a member
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// Fill is the delivery records' ledger's fill against its cap.
|
||||
type Fill struct {
|
||||
// when
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
// bytes
|
||||
Cap int64 `json:"cap"`
|
||||
// what full refuses, such as the next record
|
||||
Refused string `json:"refused,omitempty"`
|
||||
// the kept data, by its name in the holder's manifest
|
||||
Store string `json:"store"`
|
||||
}
|
||||
|
||||
// Group is one delivery group: its members, its derived state and the acts the gate said for it.
|
||||
type Group struct {
|
||||
// the acts the gate said for it, each with its id and its recorded outcome; an id said and not answered is the forge bridge's to perform
|
||||
Acts []Act `json:"acts"`
|
||||
// the group's check: its verdict, or asked as <id>
|
||||
Check string `json:"check,omitempty"`
|
||||
// the group's id, its branch
|
||||
ID string `json:"id"`
|
||||
// its members in merge order
|
||||
Members []Member `json:"members"`
|
||||
// its state, derived from its members
|
||||
State string `json:"state"`
|
||||
// why it is in that state
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// Member is one member of a group: a pull request.
|
||||
type Member struct {
|
||||
// the branch it merges into
|
||||
Base string `json:"base,omitempty"`
|
||||
// its head
|
||||
Head string `json:"head"`
|
||||
// the member's delivery id
|
||||
ID string `json:"id"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the pull request is open: not merged, closed or final
|
||||
Open bool `json:"open,omitempty"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// the member's delivery state
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
// Owed is one act the gate owes the forge, said once under its id and safe to repeat at the forge (design 47 *What the gate owes the forge*); the forge bridge performs it through the seat git's verb of the same act.
|
||||
type Owed struct {
|
||||
// the act: merge (the seat git's merge-pull), status, view, comment or note
|
||||
Act string `json:"act"`
|
||||
// the operator's ask that approved the heads, for a merge
|
||||
Ask string `json:"ask,omitempty"`
|
||||
// the commit a status or a note line is on; the head when absent
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// a status: its context, such as mesh/merge-gate
|
||||
Context string `json:"context,omitempty"`
|
||||
// a status: what it says
|
||||
Description string `json:"description,omitempty"`
|
||||
// the delivery group the pull request is a member of, for a merge
|
||||
Group string `json:"group,omitempty"`
|
||||
// the pull request's head the act is for
|
||||
Head string `json:"head"`
|
||||
// the act's id, the same each time it is said again; a comment and a note line carry it, so the forge holds it once
|
||||
ID string `json:"id"`
|
||||
// a note line: the one line
|
||||
Line string `json:"line,omitempty"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// when the gate first said it
|
||||
Said *time.Time `json:"said,omitempty"`
|
||||
// a status: its state, pending, success, failure or error
|
||||
State string `json:"state,omitempty"`
|
||||
// a status: the page it links to
|
||||
Target string `json:"target,omitempty"`
|
||||
// a comment or the view: the text, markdown
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Owed's act.
|
||||
const (
|
||||
OwedActMerge = "merge"
|
||||
OwedActStatus = "status"
|
||||
OwedActView = "view"
|
||||
OwedActComment = "comment"
|
||||
OwedActNote = "note"
|
||||
)
|
||||
|
||||
// Pins is the graph revisions a delivery record starts or stops pointing at.
|
||||
type Pins struct {
|
||||
// assignment graph revisions, by their number on the seat mesh-wants
|
||||
Assignment []int64 `json:"assignment,omitempty"`
|
||||
// catalog graph revisions, by their number on the seat mesh-catalog
|
||||
Catalog []int64 `json:"catalog,omitempty"`
|
||||
// the record's milestone
|
||||
Milestone string `json:"milestone"`
|
||||
// the record's id
|
||||
Record string `json:"record"`
|
||||
// on freed: the record ended past its retention, or was removed by hand
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// SourceHead is one repository of the source revision: its trunk branch and that trunk's head.
|
||||
type SourceHead struct {
|
||||
// the trunk's head the source revision names
|
||||
Head string `json:"head"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// its trunk branch, such as main
|
||||
Trunk string `json:"trunk"`
|
||||
}
|
||||
|
||||
// DeliveriesInput is what deliveries takes.
|
||||
type DeliveriesInput struct {
|
||||
// "true": the final ones of the last thirty days too
|
||||
All string `json:"all,omitempty"`
|
||||
// a group's id (its branch name)
|
||||
Group string `json:"group,omitempty"`
|
||||
// owner/repository
|
||||
Repository string `json:"repository,omitempty"`
|
||||
// one state, e.g. delivering or held
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
// The values of DeliveriesInput's all.
|
||||
const (
|
||||
DeliveriesInputAllTrue = "true"
|
||||
DeliveriesInputAllFalse = "false"
|
||||
)
|
||||
|
||||
// DeliveriesAnswer is what deliveries answers.
|
||||
type DeliveriesAnswer = map[string]any
|
||||
|
||||
// ShowInput is what show takes.
|
||||
type ShowInput struct {
|
||||
// a delivery's id, or a group's
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// ShowAnswer is what show answers.
|
||||
type ShowAnswer = map[string]any
|
||||
|
||||
// GroupsInput is what groups takes.
|
||||
type GroupsInput struct {
|
||||
// "true": the groups that ended too
|
||||
All string `json:"all,omitempty"`
|
||||
// one group's id: that group alone, ended or not
|
||||
Group string `json:"group,omitempty"`
|
||||
}
|
||||
|
||||
// The values of GroupsInput's all.
|
||||
const (
|
||||
GroupsInputAllTrue = "true"
|
||||
GroupsInputAllFalse = "false"
|
||||
)
|
||||
|
||||
// GroupsAnswer is what groups answers.
|
||||
type GroupsAnswer struct {
|
||||
// why it could not answer at all; a group it does not know is answered with no groups, never an error
|
||||
Error string `json:"error,omitempty"`
|
||||
Groups []Group `json:"groups,omitempty"`
|
||||
}
|
||||
|
||||
// SourceInput is what source takes.
|
||||
type SourceInput struct {
|
||||
// the watched branch, escaped as a key name is; absent: the answer is the list of the branches the gate keeps a source revision of (design 47 G section 690)
|
||||
Branch string `json:"branch,omitempty"`
|
||||
}
|
||||
|
||||
// SourceAnswer is what source answers.
|
||||
type SourceAnswer struct {
|
||||
// the watched branch the source revision is of
|
||||
Branch string `json:"branch,omitempty"`
|
||||
// given no branch: the branch name of each source.<branch> key the gate keeps, which every reader of the catalog half follows before the first registrations (design 47 G section 614, section 690)
|
||||
Branches []string `json:"branches,omitempty"`
|
||||
// why it could not be read
|
||||
Error string `json:"error,omitempty"`
|
||||
// the group that moved the source revision last; absent before the first
|
||||
Group string `json:"group,omitempty"`
|
||||
// every repository the source revision names, by name
|
||||
Repositories []SourceHead `json:"repositories,omitempty"`
|
||||
// the source revision's number on the bus; 0 before the first
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
}
|
||||
|
||||
// StalledInput is what stalled takes.
|
||||
type StalledInput struct {
|
||||
}
|
||||
|
||||
// StalledAnswer is what stalled answers.
|
||||
type StalledAnswer = map[string]any
|
||||
|
||||
// RecoveryInput is what recovery takes.
|
||||
type RecoveryInput struct {
|
||||
// the merge commit
|
||||
Commit string `json:"commit"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// why the merge is a recovery
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// RecoveryAnswer is what recovery answers.
|
||||
type RecoveryAnswer struct {
|
||||
// the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
// the merge commit
|
||||
Commit string `json:"commit"`
|
||||
Recovery bool `json:"recovery"`
|
||||
// the repository
|
||||
Repository string `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// OwedEvent is the body of the event owed.
|
||||
type OwedEvent = Owed
|
||||
|
||||
// PinnedEvent is the body of the event pinned.
|
||||
type PinnedEvent = Pins
|
||||
|
||||
// FreedEvent is the body of the event freed.
|
||||
type FreedEvent = Pins
|
||||
|
||||
// HeadsReplacedEvent is the body of the event heads-replaced.
|
||||
type HeadsReplacedEvent struct {
|
||||
// when
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the pull request closed
|
||||
Closed bool `json:"closed,omitempty"`
|
||||
// the group
|
||||
Group string `json:"group"`
|
||||
// its new head; absent when it closed
|
||||
Head string `json:"head,omitempty"`
|
||||
// the candidate's heads, 12 hex digits, as its revisions are keyed
|
||||
Heads string `json:"heads"`
|
||||
// its pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the member whose head moved or which closed
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// RecordOpenedEvent is the body of the event record-opened.
|
||||
type RecordOpenedEvent struct {
|
||||
// when
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// a merge made at the forge, with no Approve
|
||||
ForgeMade bool `json:"forge-made,omitempty"`
|
||||
// its milestone
|
||||
Milestone string `json:"milestone"`
|
||||
// the record's id
|
||||
Record string `json:"record"`
|
||||
}
|
||||
|
||||
// RecordEndedEventAwayItem is a type of the contract.
|
||||
type RecordEndedEventAwayItem struct {
|
||||
// a node away
|
||||
Node string `json:"node"`
|
||||
// since when
|
||||
Since *time.Time `json:"since,omitempty"`
|
||||
}
|
||||
|
||||
// RecordEndedEvent is the body of the event record-ended.
|
||||
type RecordEndedEvent struct {
|
||||
// when
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the nodes away, each with since when; it ends without them
|
||||
Away []RecordEndedEventAwayItem `json:"away,omitempty"`
|
||||
// a merge made at the forge, with no Approve
|
||||
ForgeMade bool `json:"forge-made,omitempty"`
|
||||
// its milestone
|
||||
Milestone string `json:"milestone"`
|
||||
// the record's id
|
||||
Record string `json:"record"`
|
||||
}
|
||||
|
||||
// FillingEvent is the body of the event filling.
|
||||
type FillingEvent = Fill
|
||||
|
||||
// FullEvent is the body of the event full.
|
||||
type FullEvent = Fill
|
||||
|
||||
// RoomEvent is the body of the event room.
|
||||
type RoomEvent = Fill
|
||||
|
||||
// SourceMovedEvent is the body of the event source-moved.
|
||||
type SourceMovedEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Branch string `json:"branch"`
|
||||
// the group that moved it, when one did
|
||||
Group string `json:"group,omitempty"`
|
||||
Revision int64 `json:"revision"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// RecoveryMergedEvent is the body of the event recovery-merged.
|
||||
type RecoveryMergedEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
// the merge commit
|
||||
Commit string `json:"commit"`
|
||||
// the repository
|
||||
Repository string `json:"repository"`
|
||||
V int64 `json:"v"`
|
||||
// why
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// ApprovalCarriedEvent is the body of the event approval-carried.
|
||||
type ApprovalCarriedEvent struct {
|
||||
// who approved: the operator
|
||||
Approver string `json:"approver"`
|
||||
// when it was said, RFC 3339
|
||||
At time.Time `json:"at"`
|
||||
// the head the Approve named
|
||||
Commit string `json:"commit"`
|
||||
// the pull request's number
|
||||
Pull int64 `json:"pull"`
|
||||
// the repository
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// PinsStatedEvent is the body of the event pins-stated.
|
||||
type PinsStatedEvent struct {
|
||||
// when it was said, RFC 3339
|
||||
At time.Time `json:"at"`
|
||||
}
|
||||
|
||||
// SourceByBranchValue is one value of the state source under the key <branch>.
|
||||
type SourceByBranchValue struct {
|
||||
// the group that moved it
|
||||
Group string `json:"group"`
|
||||
// repository to the merged head, a full commit
|
||||
Heads map[string]string `json:"heads"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// MergesByGroupValuePullsItem is a type of the contract.
|
||||
type MergesByGroupValuePullsItem struct {
|
||||
Commit string `json:"commit,omitempty"`
|
||||
Head string `json:"head"`
|
||||
Number int64 `json:"number"`
|
||||
Repository string `json:"repository"`
|
||||
// merging, merged or refused
|
||||
State string `json:"state"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// MergesByGroupValue is one value of the state merges under the key <group>.
|
||||
type MergesByGroupValue struct {
|
||||
// <repository>@<number> to the approved head
|
||||
Approved map[string]string `json:"approved,omitempty"`
|
||||
// the ask key
|
||||
Ask string `json:"ask"`
|
||||
Group string `json:"group"`
|
||||
Pulls []MergesByGroupValuePullsItem `json:"pulls"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// AsksByMergeGroupHeadsValueHeadsItem is a type of the contract.
|
||||
type AsksByMergeGroupHeadsValueHeadsItem struct {
|
||||
// the full commit
|
||||
Head string `json:"head"`
|
||||
Number int64 `json:"number"`
|
||||
// <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// AsksByMergeGroupHeadsValue is one value of the state asks under the key merge.<group>.<heads>.
|
||||
type AsksByMergeGroupHeadsValue struct {
|
||||
// the operator-channel ask as raised
|
||||
Ask any `json:"ask"`
|
||||
// the number of times it was asked
|
||||
Asking int64 `json:"asking,omitempty"`
|
||||
Group string `json:"group"`
|
||||
Heads []AsksByMergeGroupHeadsValueHeadsItem `json:"heads"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// OwedByRepositoryNumberHeadActValue is one value of the state owed under the key <repository>.<number>.<head>.<act>.
|
||||
type OwedByRepositoryNumberHeadActValue struct {
|
||||
// status=<context>, view, note or comment.<seq>
|
||||
Act string `json:"act"`
|
||||
Context string `json:"context,omitempty"`
|
||||
Ref string `json:"ref,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Target string `json:"target,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// TurnsByRepositoryValueWaitingItem is a type of the contract.
|
||||
type TurnsByRepositoryValueWaitingItem struct {
|
||||
// when (RFC 3339 time)
|
||||
Approved time.Time `json:"approved"`
|
||||
Ask string `json:"ask,omitempty"`
|
||||
Group string `json:"group"`
|
||||
Heads string `json:"heads"`
|
||||
// when (RFC 3339 time)
|
||||
Since time.Time `json:"since"`
|
||||
Step string `json:"step,omitempty"`
|
||||
WaitsFor string `json:"waits-for,omitempty"`
|
||||
// when (RFC 3339 time)
|
||||
WaitsSince *time.Time `json:"waits-since,omitempty"`
|
||||
}
|
||||
|
||||
// TurnsByRepositoryValue is one value of the state turns under the key <repository>.
|
||||
type TurnsByRepositoryValue struct {
|
||||
Repository string `json:"repository"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
Waiting []TurnsByRepositoryValueWaitingItem `json:"waiting"`
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshdelivery
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-delivery/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "owed is said, a merge", subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}", wire: "{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}",
|
||||
decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "owed is said, a status", subject: "mesh.seat.mesh-delivery.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}", wire: "{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}",
|
||||
decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "pinned is said", subject: "mesh.seat.mesh-delivery.event.pinned", given: "{\"assignment\":[1204],\"catalog\":[3610],\"milestone\":\"47/G\",\"record\":\"47-G\"}", wire: "{\"assignment\":[1204],\"catalog\":[3610],\"milestone\":\"47/G\",\"record\":\"47-G\"}",
|
||||
decode: func(b []byte) (any, error) { var v PinnedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.pinned$")},
|
||||
{name: "freed is said", subject: "mesh.seat.mesh-delivery.event.freed", given: "{\"assignment\":[1204],\"catalog\":[3610],\"milestone\":\"47/G\",\"record\":\"47-G\",\"why\":\"past its retention of 90 days\"}", wire: "{\"assignment\":[1204],\"catalog\":[3610],\"milestone\":\"47/G\",\"record\":\"47-G\",\"why\":\"past its retention of 90 days\"}",
|
||||
decode: func(b []byte) (any, error) { var v FreedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.freed$")},
|
||||
{name: "heads-replaced is said", subject: "mesh.seat.mesh-delivery.event.heads-replaced", given: "{\"at\":\"2026-11-09T20:05:00Z\",\"group\":\"feat/47-G\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"at\":\"2026-11-09T20:05:00Z\",\"group\":\"feat/47-G\",\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v HeadsReplacedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.heads-replaced$")},
|
||||
{name: "heads-replaced is said for a closed pull request", subject: "mesh.seat.mesh-delivery.event.heads-replaced", given: "{\"closed\":true,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"closed\":true,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"number\":178,\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v HeadsReplacedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.heads-replaced$")},
|
||||
{name: "record-opened is said", subject: "mesh.seat.mesh-delivery.event.record-opened", given: "{\"at\":\"2026-11-09T18:00:00Z\",\"milestone\":\"47/G\",\"record\":\"47-G\"}", wire: "{\"at\":\"2026-11-09T18:00:00Z\",\"milestone\":\"47/G\",\"record\":\"47-G\"}",
|
||||
decode: func(b []byte) (any, error) { var v RecordOpenedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-opened$")},
|
||||
{name: "record-ended is said", subject: "mesh.seat.mesh-delivery.event.record-ended", given: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"milestone\":\"47/G\",\"record\":\"47-G\"}", wire: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"milestone\":\"47/G\",\"record\":\"47-G\"}",
|
||||
decode: func(b []byte) (any, error) { var v RecordEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-ended$")},
|
||||
{name: "filling is said", subject: "mesh.seat.mesh-delivery.event.filling", given: "{\"bytes\":650000000,\"cap\":805306368,\"store\":\"records\"}", wire: "{\"bytes\":650000000,\"cap\":805306368,\"store\":\"records\"}",
|
||||
decode: func(b []byte) (any, error) { var v FillingEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.filling$")},
|
||||
{name: "full is said", subject: "mesh.seat.mesh-delivery.event.full", given: "{\"bytes\":805306368,\"cap\":805306368,\"refused\":\"the next record\",\"store\":\"records\"}", wire: "{\"bytes\":805306368,\"cap\":805306368,\"refused\":\"the next record\",\"store\":\"records\"}",
|
||||
decode: func(b []byte) (any, error) { var v FullEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.full$")},
|
||||
{name: "room is said", subject: "mesh.seat.mesh-delivery.event.room", given: "{\"bytes\":400000000,\"cap\":805306368,\"store\":\"records\"}", wire: "{\"bytes\":400000000,\"cap\":805306368,\"store\":\"records\"}",
|
||||
decode: func(b []byte) (any, error) { var v RoomEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.room$")},
|
||||
{name: "main moved to its next source revision", subject: "mesh.seat.mesh-delivery.event.source-moved.main", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"revision\":3590,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"revision\":3590,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v SourceMovedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.source-moved\\.[^.*> ]+$")},
|
||||
{name: "a recovery merged", subject: "mesh.seat.mesh-delivery.event.recovery-merged", given: "{\"at\":\"2026-11-11T10:00:00Z\",\"by\":\"jochen\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\",\"v\":1,\"why\":\"the live delivery was broken\"}", wire: "{\"at\":\"2026-11-11T10:00:00Z\",\"by\":\"jochen\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\",\"v\":1,\"why\":\"the live delivery was broken\"}",
|
||||
decode: func(b []byte) (any, error) { var v RecoveryMergedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.recovery-merged$")},
|
||||
{name: "approval-carried is said for a pull request approved before G", subject: "mesh.seat.mesh-delivery.event.approval-carried.mesh-tools.35", given: "{\"approver\":\"operator\",\"at\":\"2026-11-11T10:00:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"pull\":35,\"repository\":\"mesh-tools\"}", wire: "{\"approver\":\"operator\",\"at\":\"2026-11-11T10:00:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"pull\":35,\"repository\":\"mesh-tools\"}",
|
||||
decode: func(b []byte) (any, error) { var v ApprovalCarriedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.approval-carried\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "pins-stated is said once the pins are", subject: "mesh.seat.mesh-delivery.event.pins-stated", given: "{\"at\":\"2026-11-11T10:00:00Z\"}", wire: "{\"at\":\"2026-11-11T10:00:00Z\"}",
|
||||
decode: func(b []byte) (any, error) { var v PinsStatedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.pins-stated$")},
|
||||
{name: "the source revision", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":{\"novox/mesh-sdk\":\"cccccccccccccccccccccccccccccccccccccccc\"},\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":{\"novox/mesh-sdk\":\"cccccccccccccccccccccccccccccccccccccccc\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v SourceByBranchValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a merge", subject: "", given: "{\"ask\":\"merge.feat=registry.0123456789ab\",\"group\":\"feat/registry\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"v\":1}", wire: "{\"ask\":\"merge.feat=registry.0123456789ab\",\"group\":\"feat/registry\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v MergesByGroupValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an act owed", subject: "", given: "{\"act\":\"view\",\"v\":1}", wire: "{\"act\":\"view\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v OwedByRepositoryNumberHeadActValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a turn", subject: "", given: "{\"repository\":\"novox/mesh-sdk\",\"v\":1,\"waiting\":[{\"approved\":\"2026-11-05T10:00:00Z\",\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"since\":\"2026-11-05T10:01:00Z\"}]}", wire: "{\"repository\":\"novox/mesh-sdk\",\"v\":1,\"waiting\":[{\"approved\":\"2026-11-05T10:00:00Z\",\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"since\":\"2026-11-05T10:01:00Z\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v TurnsByRepositoryValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an ask", subject: "", given: "{\"ask\":{\"headline\":\"merge\"},\"group\":\"feat/registry\",\"heads\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}", wire: "{\"ask\":{\"headline\":\"merge\"},\"group\":\"feat/registry\",\"heads\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v AsksByMergeGroupHeadsValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "groups asks for one group", subject: "", given: "{\"group\":\"feat/47-G\"}", wire: "{\"group\":\"feat/47-G\"}",
|
||||
decode: func(b []byte) (any, error) { var v GroupsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "groups answers a group with its members and acts", subject: "", given: "{\"groups\":[{\"acts\":[{\"at\":\"2026-11-09T20:01:00Z\",\"outcome\":\"performed\",\"owed\":{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}},{\"owed\":{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}}],\"check\":\"pass\",\"id\":\"feat/47-G\",\"members\":[{\"base\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"novox/mesh-sdk#178\",\"number\":178,\"open\":true,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"state\":\"merging\",\"why\":\"novox/mesh-sdk#178 merges first\"}]}", wire: "{\"groups\":[{\"acts\":[{\"at\":\"2026-11-09T20:01:00Z\",\"outcome\":\"performed\",\"owed\":{\"act\":\"merge\",\"ask\":\"merge.feat=47-G.0123456789ab\",\"group\":\"feat/47-G\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"merge.feat=47-G.0123456789ab.novox/mesh-sdk#178\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:00:00Z\"}},{\"owed\":{\"act\":\"status\",\"context\":\"mesh/merge-gate\",\"description\":\"waits for the operator's Approve\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/merge-gate\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"pending\",\"target\":\"https://forge.test/x\"}}],\"check\":\"pass\",\"id\":\"feat/47-G\",\"members\":[{\"base\":\"main\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"novox/mesh-sdk#178\",\"number\":178,\"open\":true,\"repository\":\"novox/mesh-sdk\",\"state\":\"merging\"}],\"state\":\"merging\",\"why\":\"novox/mesh-sdk#178 merges first\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v GroupsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "groups answers a group it does not know with no groups", subject: "", given: "{}", wire: "{}",
|
||||
decode: func(b []byte) (any, error) { var v GroupsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "source is asked for one branch", subject: "", given: "{\"branch\":\"main\"}", wire: "{\"branch\":\"main\"}",
|
||||
decode: func(b []byte) (any, error) { var v SourceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "source is asked with no branch", subject: "", given: "{}", wire: "{}",
|
||||
decode: func(b []byte) (any, error) { var v SourceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "source answers each repository's trunk and head", subject: "", given: "{\"branch\":\"main\",\"group\":\"feat/47-G\",\"repositories\":[{\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"main\"}],\"revision\":42}", wire: "{\"branch\":\"main\",\"group\":\"feat/47-G\",\"repositories\":[{\"head\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"main\"}],\"revision\":42}",
|
||||
decode: func(b []byte) (any, error) { var v SourceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "source answers the branches it keeps", subject: "", given: "{\"branches\":[\"main\",\"beta\"]}", wire: "{\"branches\":[\"main\",\"beta\"]}",
|
||||
decode: func(b []byte) (any, error) { var v SourceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "source answers an error when it cannot be read", subject: "", given: "{\"error\":\"source.main is not readable\"}", wire: "{\"error\":\"source.main is not readable\"}",
|
||||
decode: func(b []byte) (any, error) { var v SourceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "recovery names a merge and why", subject: "", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\",\"why\":\"the live delivery was broken\"}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\",\"why\":\"the live delivery was broken\"}",
|
||||
decode: func(b []byte) (any, error) { var v RecoveryInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "recovery answers the caller the runtime proved", subject: "", given: "{\"by\":\"jochen\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"recovery\":true,\"repository\":\"novox/mesh-sdk\"}", wire: "{\"by\":\"jochen\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"recovery\":true,\"repository\":\"novox/mesh-sdk\"}",
|
||||
decode: func(b []byte) (any, error) { var v RecoveryAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,566 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package meshdeliverychecker is the contract of the seat "mesh-delivery-checker", defined whole (seats/mesh-delivery-checker/seat.json): The merge check's tries: start one, read one, end one. The seat says each check's end as checked and what the checker owes the forge as owed; the checker's other events stay under its own subjects (ADR 0620 §2).
|
||||
package meshdeliverychecker
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "mesh-delivery-checker"
|
||||
|
||||
const (
|
||||
VerbTry = "try"
|
||||
VerbTryRead = "try-read"
|
||||
VerbTryEnd = "try-end"
|
||||
VerbInput = "input"
|
||||
)
|
||||
|
||||
const (
|
||||
EventChecked = "checked"
|
||||
EventOwed = "owed"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbTry, VerbTryRead, VerbTryEnd, VerbInput}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventChecked, EventOwed}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "mesh-delivery-checker.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// SubjectChecked is where checked is published.
|
||||
const SubjectChecked = "mesh.seat.mesh-delivery-checker.event.checked"
|
||||
|
||||
// StreamOwed is the stream owed is kept in.
|
||||
const StreamOwed = "SEAT_mesh-delivery-checker_owed"
|
||||
|
||||
// SubjectOwed is where owed is published, on mesh.seat.mesh-delivery-checker.event.owed.<repository>.<number>.
|
||||
func SubjectOwed(repository, number string) string {
|
||||
return "mesh.seat.mesh-delivery-checker.event.owed." + repository + "." + number
|
||||
}
|
||||
|
||||
// SubjectOwedAll hears every owed.
|
||||
const SubjectOwedAll = "mesh.seat.mesh-delivery-checker.event.owed.*.*"
|
||||
|
||||
// The holder's own events, listed beside the seat and published under the holder's subjects (ADR 0620 §2).
|
||||
const (
|
||||
HolderEventVerdict = "verdict"
|
||||
HolderEventPreviewWritten = "preview.written"
|
||||
)
|
||||
|
||||
// HolderSubjectVerdict is where the holder publishes verdict, kept in checker.asks.
|
||||
func HolderSubjectVerdict(holder string) string { return "mesh.stream." + holder + ".event.verdict" }
|
||||
|
||||
// HolderSubjectPreviewWritten is where the holder publishes preview.written, kept in checks.
|
||||
func HolderSubjectPreviewWritten(holder string) string {
|
||||
return "mesh.stream." + holder + ".event.preview.written"
|
||||
}
|
||||
|
||||
const (
|
||||
StateVerdicts = "verdicts"
|
||||
StateKept = "kept"
|
||||
StateOwed = "owed"
|
||||
StatePreviews = "previews"
|
||||
)
|
||||
|
||||
// VerdictsByGroupHeadsKey is the key of one value of the state verdicts under the form "<group>.<heads>".
|
||||
func VerdictsByGroupHeadsKey(group, heads string) string { return group + "." + heads }
|
||||
|
||||
// ParseVerdictsByGroupHeadsKey reads the parts of a key of the form "<group>.<heads>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseVerdictsByGroupHeadsKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after0
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v2 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v0, v2, true
|
||||
}
|
||||
|
||||
// DecodeVerdictsByGroupHeadsValue reads one value of the state verdicts under the form "<group>.<heads>", refusing a field VerdictsByGroupHeadsValue does not know and any text after the value.
|
||||
func DecodeVerdictsByGroupHeadsValue(raw []byte) (VerdictsByGroupHeadsValue, error) {
|
||||
var v VerdictsByGroupHeadsValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// KeptByLevelDigestKey is the key of one value of the state kept under the form "<level>.<digest>".
|
||||
func KeptByLevelDigestKey(level, digest string) string { return level + "." + digest }
|
||||
|
||||
// ParseKeptByLevelDigestKey reads the parts of a key of the form "<level>.<digest>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseKeptByLevelDigestKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after0
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v2 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v0, v2, true
|
||||
}
|
||||
|
||||
// DecodeKeptByLevelDigestValue reads one value of the state kept under the form "<level>.<digest>", refusing a field KeptByLevelDigestValue does not know and any text after the value.
|
||||
func DecodeKeptByLevelDigestValue(raw []byte) (KeptByLevelDigestValue, error) {
|
||||
var v KeptByLevelDigestValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// OwedByRepositoryNumberHeadActKey is the key of one value of the state owed under the form "<repository>.<number>.<head>.<act>".
|
||||
func OwedByRepositoryNumberHeadActKey(repository, number, head, act string) string {
|
||||
return repository + "." + number + "." + head + "." + act
|
||||
}
|
||||
|
||||
// ParseOwedByRepositoryNumberHeadActKey reads the parts of a key of the form "<repository>.<number>.<head>.<act>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseOwedByRepositoryNumberHeadActKey(key string) (string, string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
v4, after4, found4 := strings.Cut(rest, ".")
|
||||
if !found4 || v4 == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
rest = after4
|
||||
if rest == "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
v6 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, v6, true
|
||||
}
|
||||
|
||||
// DecodeOwedByRepositoryNumberHeadActValue reads one value of the state owed under the form "<repository>.<number>.<head>.<act>", refusing a field OwedByRepositoryNumberHeadActValue does not know and any text after the value.
|
||||
func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumberHeadActValue, error) {
|
||||
var v OwedByRepositoryNumberHeadActValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// PreviewsByRepositoryHeadTrunkKey is the key of one value of the state previews under the form "<repository>.<head>.<trunk>".
|
||||
func PreviewsByRepositoryHeadTrunkKey(repository, head, trunk string) string {
|
||||
return repository + "." + head + "." + trunk
|
||||
}
|
||||
|
||||
// ParsePreviewsByRepositoryHeadTrunkKey reads the parts of a key of the form "<repository>.<head>.<trunk>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParsePreviewsByRepositoryHeadTrunkKey(key string) (string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
if rest == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
v4 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, true
|
||||
}
|
||||
|
||||
// DecodePreviewsByRepositoryHeadTrunkValue reads one value of the state previews under the form "<repository>.<head>.<trunk>", refusing a field PreviewsByRepositoryHeadTrunkValue does not know and any text after the value.
|
||||
func DecodePreviewsByRepositoryHeadTrunkValue(raw []byte) (PreviewsByRepositoryHeadTrunkValue, error) {
|
||||
var v PreviewsByRepositoryHeadTrunkValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// CheckedEntry is one entry of the candidate checked: a module at its fingerprint.
|
||||
type CheckedEntry struct {
|
||||
// the entry's fingerprint
|
||||
Fp string `json:"fp"`
|
||||
// the module
|
||||
Module string `json:"module"`
|
||||
// the node it was composed for, when the check composed it on one
|
||||
Node string `json:"node,omitempty"`
|
||||
}
|
||||
|
||||
// Owed is the status the checker owes the forge for a head, said under its id and safe to repeat (a status replaces what stands); the forge bridge performs it through the seat git's verb status (design 47 *What the gate owes the forge*).
|
||||
type Owed struct {
|
||||
// the act: always status
|
||||
Act string `json:"act"`
|
||||
// its context, mesh/check
|
||||
Context string `json:"context"`
|
||||
// what it says
|
||||
Description string `json:"description,omitempty"`
|
||||
// the pull request's head the status is on
|
||||
Head string `json:"head"`
|
||||
// the act's id, the same each time it is said again
|
||||
ID string `json:"id"`
|
||||
// the pull request's number
|
||||
Number int64 `json:"number"`
|
||||
// the repository, <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// when the checker first said it
|
||||
Said *time.Time `json:"said,omitempty"`
|
||||
// pending, success, failure or error
|
||||
State string `json:"state"`
|
||||
// the page it links to
|
||||
Target string `json:"target,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Owed's act.
|
||||
const (
|
||||
OwedActStatus = "status"
|
||||
)
|
||||
|
||||
// TryInputMembersItem is a type of the contract.
|
||||
type TryInputMembersItem struct {
|
||||
// the full commit to try, 40 or 64 hex digits
|
||||
Head string `json:"head"`
|
||||
// <owner>/<name>
|
||||
Repository string `json:"repository"`
|
||||
// the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent
|
||||
Trunk string `json:"trunk,omitempty"`
|
||||
}
|
||||
|
||||
// TryInput is what try takes.
|
||||
type TryInput struct {
|
||||
// the full commit to try, 40 or 64 hex digits, for a try of one member (instead of members)
|
||||
Head string `json:"head,omitempty"`
|
||||
// unit or integration: only this level; both when absent
|
||||
Level string `json:"level,omitempty"`
|
||||
// the group: one repository at most once, each at the exact commit asked and the trunk commit it is merged onto; instead of repository and head
|
||||
Members []TryInputMembersItem `json:"members,omitempty"`
|
||||
// <owner>/<name>, for a try of one member (instead of members)
|
||||
Repository string `json:"repository,omitempty"`
|
||||
// a go test -run pattern: only those tests run, and nothing is kept
|
||||
Tests string `json:"tests,omitempty"`
|
||||
// the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent
|
||||
Trunk string `json:"trunk,omitempty"`
|
||||
}
|
||||
|
||||
// TryAnswer is what try answers.
|
||||
type TryAnswer struct {
|
||||
// the try's id
|
||||
ID string `json:"id"`
|
||||
// its state
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
// TryReadInput is what try-read takes.
|
||||
type TryReadInput struct {
|
||||
// the try's id, try-<digits>
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// TryReadAnswer is what try-read answers.
|
||||
type TryReadAnswer = map[string]any
|
||||
|
||||
// TryEndInput is what try-end takes.
|
||||
type TryEndInput struct {
|
||||
// the try's id, try-<digits>
|
||||
ID string `json:"id"`
|
||||
// why it is ended, in words
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// TryEndAnswer is what try-end answers.
|
||||
type TryEndAnswer struct {
|
||||
// it is ended
|
||||
Ended bool `json:"ended"`
|
||||
// the try
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// InputInput is what input takes.
|
||||
type InputInput struct {
|
||||
// the input's sha256, 64 lowercase hex digits, as the run ask names it
|
||||
Digest string `json:"digest"`
|
||||
}
|
||||
|
||||
// InputAnswer is what input answers.
|
||||
type InputAnswer struct {
|
||||
// the digest asked
|
||||
Digest string `json:"digest"`
|
||||
// the input's exact bytes, base64, so no encoding on the way changes a byte the digest covers
|
||||
Input string `json:"input"`
|
||||
}
|
||||
|
||||
// CheckedEvent is the body of the event checked.
|
||||
type CheckedEvent struct {
|
||||
// when
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the candidate's catalog graph revision judged, by its number on the seat mesh-catalog
|
||||
Catalog int64 `json:"catalog,omitempty"`
|
||||
// the entries checked
|
||||
Entries []CheckedEntry `json:"entries,omitempty"`
|
||||
// the group, its branch
|
||||
Group string `json:"group"`
|
||||
// the heads checked, 12 hex digits, as the candidate's revisions are keyed
|
||||
Heads string `json:"heads"`
|
||||
// the source revision the heads are merged onto
|
||||
Source int64 `json:"source,omitempty"`
|
||||
// pass, fail, or could not run when a part the check needs did not answer
|
||||
Verdict string `json:"verdict"`
|
||||
// what failed first, or the part not heard
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// The values of CheckedEvent's verdict.
|
||||
const (
|
||||
CheckedEventVerdictPass = "pass"
|
||||
CheckedEventVerdictFail = "fail"
|
||||
CheckedEventVerdictCouldNotRun = "could not run"
|
||||
)
|
||||
|
||||
// OwedEvent is the body of the event owed.
|
||||
type OwedEvent = Owed
|
||||
|
||||
// VerdictHolderEventSeriesItem is a type of the contract.
|
||||
type VerdictHolderEventSeriesItem struct {
|
||||
// its artifact, or the package's ecosystem name as the module's packages name it
|
||||
Artifact string `json:"artifact"`
|
||||
// the series on trunk
|
||||
From string `json:"from"`
|
||||
// the module whose artifact's series changes
|
||||
Module string `json:"module"`
|
||||
// the series the checked head gives it
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
// VerdictHolderEvent is the body of the holder's event verdict.
|
||||
type VerdictHolderEvent struct {
|
||||
// the commit checked
|
||||
Head string `json:"head"`
|
||||
// the generated files out of step with their seat definitions, each path (design 26)
|
||||
OutOfStep []string `json:"out-of-step,omitempty"`
|
||||
// the pull request's number, for a pull request's check
|
||||
Pull int64 `json:"pull,omitempty"`
|
||||
// owner/repo
|
||||
Repository string `json:"repository"`
|
||||
// each change of an artifact's series the checked head makes against trunk's manifests, once each (design 32); absent when it changes none
|
||||
Series []VerdictHolderEventSeriesItem `json:"series,omitempty"`
|
||||
// pass or fail
|
||||
Verdict string `json:"verdict"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueComposition is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueComposition struct {
|
||||
Fpset string `json:"fpset,omitempty"`
|
||||
Machines []string `json:"machines,omitempty"`
|
||||
Sdk string `json:"sdk,omitempty"`
|
||||
// not-run, pass or fail
|
||||
State string `json:"state"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueFailed is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueFailed struct {
|
||||
Machine string `json:"machine,omitempty"`
|
||||
Test string `json:"test,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueFailuresItem is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueFailuresItem struct {
|
||||
Machine string `json:"machine,omitempty"`
|
||||
Test string `json:"test,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueJudgedByHeadsItem is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueJudgedByHeadsItem struct {
|
||||
Commit string `json:"commit"`
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueJudgedByProgram is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueJudgedByProgram struct {
|
||||
Commit string `json:"commit"`
|
||||
Dir string `json:"dir"`
|
||||
Package string `json:"package"`
|
||||
Repository string `json:"repository"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueJudgedBy is the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it.
|
||||
type VerdictsByGroupHeadsValueJudgedBy struct {
|
||||
Built bool `json:"built,omitempty"`
|
||||
Heads []VerdictsByGroupHeadsValueJudgedByHeadsItem `json:"heads"`
|
||||
// program- and 16 hex digits
|
||||
Key string `json:"key"`
|
||||
Program VerdictsByGroupHeadsValueJudgedByProgram `json:"program"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueLevelsValue is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueLevelsValue struct {
|
||||
Kept int64 `json:"kept"`
|
||||
Run int64 `json:"run"`
|
||||
Skipped int64 `json:"skipped,omitempty"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueSeriesItem is a type of the contract.
|
||||
type VerdictsByGroupHeadsValueSeriesItem struct {
|
||||
Artifact string `json:"artifact"`
|
||||
From string `json:"from"`
|
||||
Module string `json:"module"`
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValueTook is milliseconds.
|
||||
type VerdictsByGroupHeadsValueTook struct {
|
||||
Clone int64 `json:"clone,omitempty"`
|
||||
Composition int64 `json:"composition,omitempty"`
|
||||
IntegrationRun int64 `json:"integration-run,omitempty"`
|
||||
IntegrationSetup int64 `json:"integration-setup,omitempty"`
|
||||
Lint int64 `json:"lint,omitempty"`
|
||||
Queue int64 `json:"queue,omitempty"`
|
||||
Unit int64 `json:"unit,omitempty"`
|
||||
}
|
||||
|
||||
// VerdictsByGroupHeadsValue is one value of the state verdicts under the key <group>.<heads>.
|
||||
type VerdictsByGroupHeadsValue struct {
|
||||
Beside map[string]string `json:"beside,omitempty"`
|
||||
CarriedFrom map[string]string `json:"carried-from,omitempty"`
|
||||
Composition *VerdictsByGroupHeadsValueComposition `json:"composition,omitempty"`
|
||||
Failed *VerdictsByGroupHeadsValueFailed `json:"failed,omitempty"`
|
||||
Failures []VerdictsByGroupHeadsValueFailuresItem `json:"failures,omitempty"`
|
||||
Group string `json:"group"`
|
||||
// 12 hex digits
|
||||
Heads string `json:"heads"`
|
||||
// the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it
|
||||
JudgedBy *VerdictsByGroupHeadsValueJudgedBy `json:"judged-by,omitempty"`
|
||||
// by level, unit or integration
|
||||
Levels map[string]VerdictsByGroupHeadsValueLevelsValue `json:"levels,omitempty"`
|
||||
Machines []string `json:"machines,omitempty"`
|
||||
OverBound []string `json:"over-bound,omitempty"`
|
||||
Sdk string `json:"sdk,omitempty"`
|
||||
Series []VerdictsByGroupHeadsValueSeriesItem `json:"series,omitempty"`
|
||||
// running, pass or fail
|
||||
State string `json:"state"`
|
||||
// milliseconds
|
||||
Took *VerdictsByGroupHeadsValueTook `json:"took,omitempty"`
|
||||
// repository to the trunk head merged onto
|
||||
Trunk map[string]string `json:"trunk,omitempty"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// KeptByLevelDigestValue is one value of the state kept under the key <level>.<digest>.
|
||||
type KeptByLevelDigestValue struct {
|
||||
// when (RFC 3339 time)
|
||||
At string `json:"at,omitempty"`
|
||||
Level string `json:"level"`
|
||||
Package string `json:"package"`
|
||||
Repository string `json:"repository"`
|
||||
// pass: a failure is never kept
|
||||
State string `json:"state"`
|
||||
Tests int64 `json:"tests,omitempty"`
|
||||
Took int64 `json:"took,omitempty"`
|
||||
Toolchain string `json:"toolchain,omitempty"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// OwedByRepositoryNumberHeadActValue is one value of the state owed under the key <repository>.<number>.<head>.<act>.
|
||||
type OwedByRepositoryNumberHeadActValue struct {
|
||||
// status=<context>, view, note or comment.<seq>
|
||||
Act string `json:"act"`
|
||||
Context string `json:"context,omitempty"`
|
||||
Ref string `json:"ref,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Target string `json:"target,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// PreviewsByRepositoryHeadTrunkValueModulesValue is a type of the contract.
|
||||
type PreviewsByRepositoryHeadTrunkValueModulesValue struct {
|
||||
Locks map[string]string `json:"locks,omitempty"`
|
||||
// manifest digest
|
||||
Manifest string `json:"manifest"`
|
||||
Packages []string `json:"packages,omitempty"`
|
||||
Paths map[string]string `json:"paths,omitempty"`
|
||||
Tree string `json:"tree"`
|
||||
}
|
||||
|
||||
// PreviewsByRepositoryHeadTrunkValue is one value of the state previews under the key <repository>.<head>.<trunk>.
|
||||
type PreviewsByRepositoryHeadTrunkValue struct {
|
||||
// files in conflict
|
||||
Conflicts []string `json:"conflicts,omitempty"`
|
||||
Head string `json:"head"`
|
||||
// the merge commit
|
||||
Merge string `json:"merge,omitempty"`
|
||||
// by directory
|
||||
Modules map[string]PreviewsByRepositoryHeadTrunkValueModulesValue `json:"modules,omitempty"`
|
||||
Repository string `json:"repository"`
|
||||
Trunk string `json:"trunk"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshdeliverychecker
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-delivery-checker/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "verdict on the checker's own family", subject: "mesh.stream.mesh-delivery-checker.event.verdict", given: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"out-of-step\":[\"go/seats/meshbroker/contract.go\"],\"pull\":3,\"repository\":\"novox/mesh-contracts\",\"series\":[{\"artifact\":\"go\",\"from\":\"0.1\",\"module\":\"mesh-contracts\",\"to\":\"0.2\"}],\"verdict\":\"fail\"}", wire: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"out-of-step\":[\"go/seats/meshbroker/contract.go\"],\"pull\":3,\"repository\":\"novox/mesh-contracts\",\"series\":[{\"artifact\":\"go\",\"from\":\"0.1\",\"module\":\"mesh-contracts\",\"to\":\"0.2\"}],\"verdict\":\"fail\"}",
|
||||
decode: func(b []byte) (any, error) { var v VerdictHolderEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.verdict$")},
|
||||
{name: "preview.written on the checker's stream", subject: "mesh.stream.mesh-delivery-checker.event.preview.written", given: "{}", wire: "{}",
|
||||
decode: func(b []byte) (any, error) { var v map[string]any; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.preview\\.written$")},
|
||||
{name: "checked is said", subject: "mesh.seat.mesh-delivery-checker.event.checked", given: "{\"at\":\"2026-11-09T20:30:00Z\",\"catalog\":3612,\"entries\":[{\"fp\":\"src2:1480985e\",\"module\":\"mesh-delivery-gate\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"source\":3611,\"verdict\":\"pass\"}", wire: "{\"at\":\"2026-11-09T20:30:00Z\",\"catalog\":3612,\"entries\":[{\"fp\":\"src2:1480985e\",\"module\":\"mesh-delivery-gate\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"source\":3611,\"verdict\":\"pass\"}",
|
||||
decode: func(b []byte) (any, error) { var v CheckedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery-checker\\.event\\.checked$")},
|
||||
{name: "checked is said when it could not run", subject: "mesh.seat.mesh-delivery-checker.event.checked", given: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"verdict\":\"could not run\",\"words\":\"the seat git's holder did not answer\"}", wire: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"verdict\":\"could not run\",\"words\":\"the seat git's holder did not answer\"}",
|
||||
decode: func(b []byte) (any, error) { var v CheckedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery-checker\\.event\\.checked$")},
|
||||
{name: "owed is said", subject: "mesh.seat.mesh-delivery-checker.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"status\",\"context\":\"mesh/check\",\"description\":\"passed\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/check\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:30:00Z\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}", wire: "{\"act\":\"status\",\"context\":\"mesh/check\",\"description\":\"passed\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/check\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:30:00Z\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}",
|
||||
decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery-checker\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a running verdict", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"state\":\"running\",\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"state\":\"running\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v VerdictsByGroupHeadsValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a pass judged by the checking program built at a mesh-delivery head", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"judged-by\":{\"built\":true,\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"}],\"key\":\"program-0123456789abcdef\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"}},\"levels\":{\"integration\":{\"kept\":0,\"run\":3},\"unit\":{\"kept\":0,\"run\":12}},\"state\":\"pass\",\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"judged-by\":{\"built\":true,\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"}],\"key\":\"program-0123456789abcdef\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"}},\"levels\":{\"integration\":{\"kept\":0,\"run\":3},\"unit\":{\"kept\":0,\"run\":12}},\"state\":\"pass\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v VerdictsByGroupHeadsValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a kept pass", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"level\":\"unit\",\"package\":\"go/keys\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pass\",\"tests\":4,\"took\":120,\"toolchain\":\"go1.26\",\"v\":1}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"level\":\"unit\",\"package\":\"go/keys\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pass\",\"tests\":4,\"took\":120,\"toolchain\":\"go1.26\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v KeptByLevelDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the status owed for a head", subject: "", given: "{\"act\":\"status=mesh/check\",\"context\":\"mesh/check\",\"state\":\"success\",\"v\":1}", wire: "{\"act\":\"status=mesh/check\",\"context\":\"mesh/check\",\"state\":\"success\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v OwedByRepositoryNumberHeadActValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a preview", subject: "", given: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"merge\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"dddddddddddddddddddddddddddddddddddddddd\",\"v\":1}", wire: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"merge\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"dddddddddddddddddddddddddddddddddddddddd\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PreviewsByRepositoryHeadTrunkValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a checking program asks its input by its digest", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"}",
|
||||
decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the input answered as its exact bytes, base64", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"input\":\"eyJ2IjoxfQ==\"}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"input\":\"eyJ2IjoxfQ==\"}",
|
||||
decode: func(b []byte) (any, error) { var v InputAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,987 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package meshpipelinerunner is the contract of the seat "mesh-pipeline-runner", defined whole (seats/mesh-pipeline-runner/seat.json): The pipeline runner: it runs each module's pipeline on each of its watched branches, asking each step of the seat that serves it and hearing its end, and says each pipeline's and each step's start and end (design 47 *Pipelines per module*). Held once for the mesh; a foundation part.
|
||||
package meshpipelinerunner
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "mesh-pipeline-runner"
|
||||
|
||||
const (
|
||||
VerbRun = "run"
|
||||
VerbStart = "start"
|
||||
VerbShow = "show"
|
||||
VerbList = "list"
|
||||
VerbStands = "stands"
|
||||
VerbWhyCarried = "why-carried"
|
||||
VerbKept = "kept"
|
||||
VerbReview = "review"
|
||||
VerbRerun = "rerun"
|
||||
VerbAccept = "accept"
|
||||
VerbCancel = "cancel"
|
||||
VerbAskAgain = "ask-again"
|
||||
)
|
||||
|
||||
const (
|
||||
EventPipelineStarted = "pipeline-started"
|
||||
EventPipelineEnded = "pipeline-ended"
|
||||
EventGroupEnded = "group-ended"
|
||||
EventRunStarted = "run-started"
|
||||
EventStepStarted = "step-started"
|
||||
EventStepEnded = "step-ended"
|
||||
EventWaitHeld = "wait-held"
|
||||
EventWaitEnded = "wait-ended"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbAskAgain}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventPipelineStarted, EventPipelineEnded, EventGroupEnded, EventRunStarted, EventStepStarted, EventStepEnded, EventWaitHeld, EventWaitEnded}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "mesh-pipeline-runner.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// StreamPipelineStarted is the stream pipeline-started is kept in.
|
||||
const StreamPipelineStarted = "SEAT_mesh-pipeline-runner_pipeline-started"
|
||||
|
||||
// SubjectPipelineStarted is where pipeline-started is published, on mesh.seat.mesh-pipeline-runner.event.pipeline-started.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectPipelineStarted(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.pipeline-started." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectPipelineStartedAll hears every pipeline-started.
|
||||
const SubjectPipelineStartedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*.*"
|
||||
|
||||
// StreamPipelineEnded is the stream pipeline-ended is kept in.
|
||||
const StreamPipelineEnded = "SEAT_mesh-pipeline-runner_pipeline-ended"
|
||||
|
||||
// SubjectPipelineEnded is where pipeline-ended is published, on mesh.seat.mesh-pipeline-runner.event.pipeline-ended.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectPipelineEnded(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.pipeline-ended." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectPipelineEndedAll hears every pipeline-ended.
|
||||
const SubjectPipelineEndedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.*.*.*"
|
||||
|
||||
// StreamGroupEnded is the stream group-ended is kept in.
|
||||
const StreamGroupEnded = "SEAT_mesh-pipeline-runner_group-ended"
|
||||
|
||||
// SubjectGroupEnded is where group-ended is published, on mesh.seat.mesh-pipeline-runner.event.group-ended.<branch>.<group>.
|
||||
func SubjectGroupEnded(branch, group string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.group-ended." + branch + "." + group
|
||||
}
|
||||
|
||||
// SubjectGroupEndedAll hears every group-ended.
|
||||
const SubjectGroupEndedAll = "mesh.seat.mesh-pipeline-runner.event.group-ended.*.*"
|
||||
|
||||
// StreamRunStarted is the stream run-started is kept in.
|
||||
const StreamRunStarted = "SEAT_mesh-pipeline-runner_run-started"
|
||||
|
||||
// SubjectRunStarted is where run-started is published, on mesh.seat.mesh-pipeline-runner.event.run-started.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectRunStarted(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.run-started." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectRunStartedAll hears every run-started.
|
||||
const SubjectRunStartedAll = "mesh.seat.mesh-pipeline-runner.event.run-started.*.*.*"
|
||||
|
||||
// StreamStepStarted is the stream step-started is kept in.
|
||||
const StreamStepStarted = "SEAT_mesh-pipeline-runner_step-started"
|
||||
|
||||
// SubjectStepStarted is where step-started is published, on mesh.seat.mesh-pipeline-runner.event.step-started.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectStepStarted(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.step-started." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectStepStartedAll hears every step-started.
|
||||
const SubjectStepStartedAll = "mesh.seat.mesh-pipeline-runner.event.step-started.*.*.*"
|
||||
|
||||
// StreamStepEnded is the stream step-ended is kept in.
|
||||
const StreamStepEnded = "SEAT_mesh-pipeline-runner_step-ended"
|
||||
|
||||
// SubjectStepEnded is where step-ended is published, on mesh.seat.mesh-pipeline-runner.event.step-ended.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectStepEnded(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.step-ended." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectStepEndedAll hears every step-ended.
|
||||
const SubjectStepEndedAll = "mesh.seat.mesh-pipeline-runner.event.step-ended.*.*.*"
|
||||
|
||||
// StreamWaitHeld is the stream wait-held is kept in.
|
||||
const StreamWaitHeld = "SEAT_mesh-pipeline-runner_wait-held"
|
||||
|
||||
// SubjectWaitHeld is where wait-held is published, on mesh.seat.mesh-pipeline-runner.event.wait-held.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectWaitHeld(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.wait-held." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectWaitHeldAll hears every wait-held.
|
||||
const SubjectWaitHeldAll = "mesh.seat.mesh-pipeline-runner.event.wait-held.*.*.*"
|
||||
|
||||
// StreamWaitEnded is the stream wait-ended is kept in.
|
||||
const StreamWaitEnded = "SEAT_mesh-pipeline-runner_wait-ended"
|
||||
|
||||
// SubjectWaitEnded is where wait-ended is published, on mesh.seat.mesh-pipeline-runner.event.wait-ended.<module>.<branch>.<commit-or-group>.
|
||||
func SubjectWaitEnded(module, branch, commitOrGroup string) string {
|
||||
return "mesh.seat.mesh-pipeline-runner.event.wait-ended." + module + "." + branch + "." + commitOrGroup
|
||||
}
|
||||
|
||||
// SubjectWaitEndedAll hears every wait-ended.
|
||||
const SubjectWaitEndedAll = "mesh.seat.mesh-pipeline-runner.event.wait-ended.*.*.*"
|
||||
|
||||
const (
|
||||
StatePipelines = "pipelines"
|
||||
StateKept = "kept"
|
||||
StateStepLog = "step-log"
|
||||
StateStepOutputs = "step-outputs"
|
||||
)
|
||||
|
||||
// PipelinesByBranchRevisionModuleKey is the key of one value of the state pipelines under the form "<branch>.<revision>.<module>".
|
||||
func PipelinesByBranchRevisionModuleKey(branch, revision, module string) string {
|
||||
return branch + "." + revision + "." + module
|
||||
}
|
||||
|
||||
// ParsePipelinesByBranchRevisionModuleKey reads the parts of a key of the form "<branch>.<revision>.<module>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParsePipelinesByBranchRevisionModuleKey(key string) (string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
if rest == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
v4 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, true
|
||||
}
|
||||
|
||||
// DecodePipelinesByBranchRevisionModuleValue reads one value of the state pipelines under the form "<branch>.<revision>.<module>", refusing a field PipelinesByBranchRevisionModuleValue does not know and any text after the value.
|
||||
func DecodePipelinesByBranchRevisionModuleValue(raw []byte) (PipelinesByBranchRevisionModuleValue, error) {
|
||||
var v PipelinesByBranchRevisionModuleValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// KeptByLevelDigestKey is the key of one value of the state kept under the form "<level>.<digest>".
|
||||
func KeptByLevelDigestKey(level, digest string) string { return level + "." + digest }
|
||||
|
||||
// ParseKeptByLevelDigestKey reads the parts of a key of the form "<level>.<digest>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseKeptByLevelDigestKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after0
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v2 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v0, v2, true
|
||||
}
|
||||
|
||||
// DecodeKeptByLevelDigestValue reads one value of the state kept under the form "<level>.<digest>", refusing a field KeptByLevelDigestValue does not know and any text after the value.
|
||||
func DecodeKeptByLevelDigestValue(raw []byte) (KeptByLevelDigestValue, error) {
|
||||
var v KeptByLevelDigestValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StepLogByPipelineKey is the key of one value of the state step-log under the form "<pipeline>".
|
||||
func StepLogByPipelineKey(pipeline string) string { return pipeline }
|
||||
|
||||
// ParseStepLogByPipelineKey reads the parts of a key of the form "<pipeline>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseStepLogByPipelineKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodeStepLogByPipelineValue reads one value of the state step-log under the form "<pipeline>", refusing a field StepLogByPipelineValue does not know and any text after the value.
|
||||
func DecodeStepLogByPipelineValue(raw []byte) (StepLogByPipelineValue, error) {
|
||||
var v StepLogByPipelineValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StepOutputsByPipelineStepArtifactKey is the key of one value of the state step-outputs under the form "<pipeline>.<step>.<artifact>".
|
||||
func StepOutputsByPipelineStepArtifactKey(pipeline, step, artifact string) string {
|
||||
return pipeline + "." + step + "." + artifact
|
||||
}
|
||||
|
||||
// ParseStepOutputsByPipelineStepArtifactKey reads the parts of a key of the form "<pipeline>.<step>.<artifact>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseStepOutputsByPipelineStepArtifactKey(key string) (string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
if rest == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
v4 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, true
|
||||
}
|
||||
|
||||
// DecodeStepOutputsByPipelineStepArtifactValue reads one value of the state step-outputs under the form "<pipeline>.<step>.<artifact>", refusing a field StepOutputsByPipelineStepArtifactValue does not know and any text after the value.
|
||||
func DecodeStepOutputsByPipelineStepArtifactValue(raw []byte) (StepOutputsByPipelineStepArtifactValue, error) {
|
||||
var v StepOutputsByPipelineStepArtifactValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Accepted is a failed optional step a person accepted, recorded in the hand-act log.
|
||||
type Accepted struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// who accepted it, as the runtime proved the caller
|
||||
By string `json:"by"`
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// Fill is a store's fill against its cap.
|
||||
type Fill struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
// bytes
|
||||
Cap int64 `json:"cap"`
|
||||
// the kept data, by its name in the holder's manifest
|
||||
Store string `json:"store"`
|
||||
}
|
||||
|
||||
// GroupEnded is a group's one pipeline's end on a watched branch, said once every member's modules have ended; a group's wants are written on it alone (ADR 0666 section 9).
|
||||
type GroupEnded struct {
|
||||
Branch string `json:"branch"`
|
||||
Ended *time.Time `json:"ended,omitempty"`
|
||||
Group string `json:"group"`
|
||||
Outcome string `json:"outcome"`
|
||||
// every member module's pipeline, each ended
|
||||
Pipelines []PipelineEnded `json:"pipelines"`
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the group's one source revision of the watched branch
|
||||
Source int64 `json:"source,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// The values of GroupEnded's outcome.
|
||||
const (
|
||||
GroupEndedOutcomeRunning = "running"
|
||||
GroupEndedOutcomePassed = "passed"
|
||||
GroupEndedOutcomeFailed = "failed"
|
||||
GroupEndedOutcomeRefused = "refused"
|
||||
GroupEndedOutcomeSuperseded = "superseded"
|
||||
GroupEndedOutcomeCancelled = "cancelled"
|
||||
)
|
||||
|
||||
// KeptResult is a package's passing result the runner keeps, by the digest of what its tests read (ADR 0666 section 8).
|
||||
type KeptResult struct {
|
||||
// sha256:<hex> of what the package's tests read
|
||||
Digest string `json:"digest"`
|
||||
// unit or integration
|
||||
Level string `json:"level"`
|
||||
Package string `json:"package"`
|
||||
// the pipeline whose step kept it
|
||||
Pipeline string `json:"pipeline,omitempty"`
|
||||
Toolchain *ToolchainUsed `json:"toolchain,omitempty"`
|
||||
}
|
||||
|
||||
// LogEntry is one entry of the step log.
|
||||
type LogEntry struct {
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
At time.Time `json:"at"`
|
||||
Outcome string `json:"outcome,omitempty"`
|
||||
// the output's name in step-outputs
|
||||
Output string `json:"output,omitempty"`
|
||||
Pipeline string `json:"pipeline"`
|
||||
Step string `json:"step"`
|
||||
What string `json:"what"`
|
||||
}
|
||||
|
||||
// The values of LogEntry's outcome.
|
||||
const (
|
||||
LogEntryOutcomeRunning = "running"
|
||||
LogEntryOutcomeWaiting = "waiting"
|
||||
LogEntryOutcomePassed = "passed"
|
||||
LogEntryOutcomeFailed = "failed"
|
||||
LogEntryOutcomeNothingToRun = "nothing to run"
|
||||
LogEntryOutcomeBypassed = "bypassed"
|
||||
LogEntryOutcomeCarried = "carried"
|
||||
LogEntryOutcomeCouldNotRun = "could not run"
|
||||
LogEntryOutcomeWaitingForABuildNode = "waiting for a build node"
|
||||
LogEntryOutcomeDidNotBuild = "did not build"
|
||||
LogEntryOutcomeAccepted = "accepted"
|
||||
LogEntryOutcomeDeclined = "declined"
|
||||
LogEntryOutcomeSuperseded = "superseded"
|
||||
LogEntryOutcomeCancelled = "cancelled"
|
||||
)
|
||||
|
||||
// The values of LogEntry's step.
|
||||
const (
|
||||
LogEntryStepBuild = "build"
|
||||
LogEntryStepLint = "lint"
|
||||
LogEntryStepUnit = "unit"
|
||||
LogEntryStepIntegration = "integration"
|
||||
LogEntryStepComposition = "composition"
|
||||
LogEntryStepReview = "review"
|
||||
LogEntryStepApproval = "approval"
|
||||
)
|
||||
|
||||
// The values of LogEntry's what.
|
||||
const (
|
||||
LogEntryWhatStarted = "started"
|
||||
LogEntryWhatEnded = "ended"
|
||||
)
|
||||
|
||||
// Member is a module at a named commit.
|
||||
type Member struct {
|
||||
// the branch the commit is on
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Commit string `json:"commit"`
|
||||
Module string `json:"module"`
|
||||
}
|
||||
|
||||
// Pipeline is one pipeline as the runner keeps it in its state pipelines, by compare-and-set (design 47 *The runner's kept data*).
|
||||
type Pipeline struct {
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// the commit the module's entry was last changed at
|
||||
Commit string `json:"commit"`
|
||||
// how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)
|
||||
EndCount int64 `json:"end-count,omitempty"`
|
||||
Ended *time.Time `json:"ended,omitempty"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the gathered group, when the pipeline is its
|
||||
Group string `json:"group,omitempty"`
|
||||
Module string `json:"module"`
|
||||
Outcome string `json:"outcome"`
|
||||
// yes when the module is over its test budget (design 47 G section 419)
|
||||
OverBudget bool `json:"over-budget,omitempty"`
|
||||
// the pipeline's key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline,omitempty"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||
Run string `json:"run,omitempty"`
|
||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||
Source int64 `json:"source,omitempty"`
|
||||
Started *time.Time `json:"started,omitempty"`
|
||||
// every step, approval last
|
||||
Steps []StepResult `json:"steps"`
|
||||
Tests *TestCounts `json:"tests,omitempty"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
// the version package-published names, for a pipeline the runner started from a publication or from outdated; none for any other (design 47 G 550)
|
||||
Version string `json:"version,omitempty"`
|
||||
// for a pipeline that did not pass, the steps that held it
|
||||
Why string `json:"why,omitempty"`
|
||||
Widens []Widening `json:"widens,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Pipeline's outcome.
|
||||
const (
|
||||
PipelineOutcomeRunning = "running"
|
||||
PipelineOutcomePassed = "passed"
|
||||
PipelineOutcomeFailed = "failed"
|
||||
PipelineOutcomeRefused = "refused"
|
||||
PipelineOutcomeSuperseded = "superseded"
|
||||
PipelineOutcomeCancelled = "cancelled"
|
||||
)
|
||||
|
||||
// PipelineEnded is a pipeline's end with every step's result, its test counts, the source revision and widens (design 47 *Health and going back*); the assigner writes a want only from one whose every required step passed.
|
||||
type PipelineEnded struct {
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// the commit the module's entry was last changed at
|
||||
Commit string `json:"commit"`
|
||||
// how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)
|
||||
EndCount int64 `json:"end-count,omitempty"`
|
||||
Ended *time.Time `json:"ended,omitempty"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the gathered group, when the pipeline is its
|
||||
Group string `json:"group,omitempty"`
|
||||
Module string `json:"module"`
|
||||
Outcome string `json:"outcome"`
|
||||
// yes when the module is over its test budget (500 unit or 50 integration tests; design 47 G section 419)
|
||||
OverBudget bool `json:"over-budget,omitempty"`
|
||||
// the pipeline's key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||
Run string `json:"run,omitempty"`
|
||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||
Source int64 `json:"source,omitempty"`
|
||||
Started *time.Time `json:"started,omitempty"`
|
||||
Steps []StepResult `json:"steps"`
|
||||
Tests *TestCounts `json:"tests,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
Why string `json:"why,omitempty"`
|
||||
Widens []Widening `json:"widens,omitempty"`
|
||||
}
|
||||
|
||||
// The values of PipelineEnded's outcome.
|
||||
const (
|
||||
PipelineEndedOutcomeRunning = "running"
|
||||
PipelineEndedOutcomePassed = "passed"
|
||||
PipelineEndedOutcomeFailed = "failed"
|
||||
PipelineEndedOutcomeRefused = "refused"
|
||||
PipelineEndedOutcomeSuperseded = "superseded"
|
||||
PipelineEndedOutcomeCancelled = "cancelled"
|
||||
)
|
||||
|
||||
// PipelineStartedStepsItem is a type of the contract.
|
||||
type PipelineStartedStepsItem struct {
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Step string `json:"step"`
|
||||
}
|
||||
|
||||
// The values of PipelineStartedStepsItem's status.
|
||||
const (
|
||||
PipelineStartedStepsItemStatusRequired = "required"
|
||||
PipelineStartedStepsItemStatusOptional = "optional"
|
||||
PipelineStartedStepsItemStatusBypass = "bypass"
|
||||
)
|
||||
|
||||
// The values of PipelineStartedStepsItem's step.
|
||||
const (
|
||||
PipelineStartedStepsItemStepBuild = "build"
|
||||
PipelineStartedStepsItemStepLint = "lint"
|
||||
PipelineStartedStepsItemStepUnit = "unit"
|
||||
PipelineStartedStepsItemStepIntegration = "integration"
|
||||
PipelineStartedStepsItemStepComposition = "composition"
|
||||
PipelineStartedStepsItemStepReview = "review"
|
||||
PipelineStartedStepsItemStepApproval = "approval"
|
||||
)
|
||||
|
||||
// PipelineStarted is a pipeline's start.
|
||||
type PipelineStarted struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// the commit the module's entry was last changed at
|
||||
Commit string `json:"commit"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the gathered group, when the pipeline is its
|
||||
Group string `json:"group,omitempty"`
|
||||
Module string `json:"module"`
|
||||
// the pipeline's key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||
Run string `json:"run,omitempty"`
|
||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||
Source int64 `json:"source,omitempty"`
|
||||
// the steps the policy gives it
|
||||
Steps []PipelineStartedStepsItem `json:"steps,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// RunStarted is a run on request's start, with its members at their commits (ADR 0666 section 18).
|
||||
type RunStarted struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the caller the runtime proved
|
||||
By string `json:"by"`
|
||||
Members []Member `json:"members"`
|
||||
Run string `json:"run"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// StepEvent is a step's start or end: the step, its status, its outcome, its fingerprint, its test counts, what a carried result was carried from, and for a rerun that it is one and its proved caller; a bypassed step too.
|
||||
type StepEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// the commit the module's entry was last changed at
|
||||
Commit string `json:"commit"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the gathered group, when the pipeline is its
|
||||
Group string `json:"group,omitempty"`
|
||||
Module string `json:"module"`
|
||||
// the pipeline's key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline"`
|
||||
Result StepResult `json:"result"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||
Run string `json:"run,omitempty"`
|
||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||
Source int64 `json:"source,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// StepResult is one step of a pipeline: its status in the policy and its outcome (design 47 *Pipeline steps and the policy*).
|
||||
type StepResult struct {
|
||||
Accepted *Accepted `json:"accepted,omitempty"`
|
||||
// the artifact reference, <module>:<artifact>; absent for a step of the whole module (review, approval)
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
// the step's ask on the serving seat's work queue
|
||||
Ask string `json:"ask,omitempty"`
|
||||
// for a rerun, the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
// for a carried result, the pipeline it was carried from
|
||||
CarriedFrom string `json:"carried-from,omitempty"`
|
||||
Ended *time.Time `json:"ended,omitempty"`
|
||||
// the artifact's build-input fingerprint the step ran at
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the node whose holder ended it
|
||||
Node string `json:"node,omitempty"`
|
||||
// for a waiting step, who or what it waits on: a person, a build node, the revision view
|
||||
On string `json:"on,omitempty"`
|
||||
// never passed for a step that ran nothing (design 47 *Pipeline steps and the policy*)
|
||||
Outcome string `json:"outcome"`
|
||||
// the step's output, by its name in the runner's objects step-outputs
|
||||
Output string `json:"output,omitempty"`
|
||||
// the step was asked again by the runner's rerun
|
||||
Rerun bool `json:"rerun,omitempty"`
|
||||
// the seat that serves the step, whose holder alone may end it (ADR 0666 section 21)
|
||||
Seat string `json:"seat,omitempty"`
|
||||
Started *time.Time `json:"started,omitempty"`
|
||||
// the step's status in the module's policy
|
||||
Status string `json:"status"`
|
||||
Step string `json:"step"`
|
||||
Tests *TestCounts `json:"tests,omitempty"`
|
||||
// what the outcome rests on: the part not heard, the seat with no holder, what a waiting step waits on
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// The values of StepResult's outcome.
|
||||
const (
|
||||
StepResultOutcomeRunning = "running"
|
||||
StepResultOutcomeWaiting = "waiting"
|
||||
StepResultOutcomePassed = "passed"
|
||||
StepResultOutcomeFailed = "failed"
|
||||
StepResultOutcomeNothingToRun = "nothing to run"
|
||||
StepResultOutcomeBypassed = "bypassed"
|
||||
StepResultOutcomeCarried = "carried"
|
||||
StepResultOutcomeCouldNotRun = "could not run"
|
||||
StepResultOutcomeWaitingForABuildNode = "waiting for a build node"
|
||||
StepResultOutcomeDidNotBuild = "did not build"
|
||||
StepResultOutcomeAccepted = "accepted"
|
||||
StepResultOutcomeNotAsked = "not asked"
|
||||
StepResultOutcomeDeclined = "declined"
|
||||
StepResultOutcomeSuperseded = "superseded"
|
||||
StepResultOutcomeCancelled = "cancelled"
|
||||
)
|
||||
|
||||
// The values of StepResult's status.
|
||||
const (
|
||||
StepResultStatusRequired = "required"
|
||||
StepResultStatusOptional = "optional"
|
||||
StepResultStatusBypass = "bypass"
|
||||
)
|
||||
|
||||
// The values of StepResult's step.
|
||||
const (
|
||||
StepResultStepBuild = "build"
|
||||
StepResultStepLint = "lint"
|
||||
StepResultStepUnit = "unit"
|
||||
StepResultStepIntegration = "integration"
|
||||
StepResultStepComposition = "composition"
|
||||
StepResultStepReview = "review"
|
||||
StepResultStepApproval = "approval"
|
||||
)
|
||||
|
||||
// TestCounts is how many tests a step ran and carried, per level (ADR 0666 section 8).
|
||||
type TestCounts struct {
|
||||
Integration int64 `json:"integration,omitempty"`
|
||||
Unit int64 `json:"unit,omitempty"`
|
||||
}
|
||||
|
||||
// ToolchainUsed is the toolchain a build was made with: the language, the installed version and the build module's recipe.
|
||||
type ToolchainUsed struct {
|
||||
Language string `json:"language"`
|
||||
Recipe string `json:"recipe"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// Wait is a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283).
|
||||
type Wait struct {
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// the time the bound counts from (design 47 G section 266, section 269, section 498)
|
||||
ClockFrom *time.Time `json:"clock-from,omitempty"`
|
||||
// the commit the module's entry was last changed at
|
||||
Commit string `json:"commit,omitempty"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// the gathered group, when the pipeline is its
|
||||
Group string `json:"group,omitempty"`
|
||||
// for its end, how it ended: answered, ran, released, superseded
|
||||
How string `json:"how,omitempty"`
|
||||
Module string `json:"module"`
|
||||
// what the step waits on (design 47 *Health and going back*)
|
||||
On string `json:"on"`
|
||||
// the pipeline's key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||
Run string `json:"run,omitempty"`
|
||||
Since time.Time `json:"since"`
|
||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||
Source int64 `json:"source,omitempty"`
|
||||
// a pipeline step a wait inside a pipeline is in; pipeline is the acting step of design 47 G 203, for a wait of the entries the runner holds for its new version (design 47 G 534)
|
||||
Step string `json:"step"`
|
||||
V int64 `json:"v"`
|
||||
// for a wait on a person, who: the operator, a reviewer
|
||||
Who string `json:"who,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Wait's on.
|
||||
const (
|
||||
WaitOnPerson = "person"
|
||||
WaitOnBuildNode = "build node"
|
||||
WaitOnRevisionView = "revision view"
|
||||
)
|
||||
|
||||
// The values of Wait's step.
|
||||
const (
|
||||
WaitStepBuild = "build"
|
||||
WaitStepLint = "lint"
|
||||
WaitStepUnit = "unit"
|
||||
WaitStepIntegration = "integration"
|
||||
WaitStepComposition = "composition"
|
||||
WaitStepReview = "review"
|
||||
WaitStepApproval = "approval"
|
||||
WaitStepPipeline = "pipeline"
|
||||
)
|
||||
|
||||
// Widening is a part serving a step the change alters, or an acting rule, a grant or a credential it widens, computed by the running runner (ADR 0666 section 23).
|
||||
type Widening struct {
|
||||
// the part, rule, grant or credential
|
||||
Name string `json:"name"`
|
||||
// what the change alters in it; for "could not run" the grants part did not answer grants-for (design 47 G section 441)
|
||||
Said string `json:"said,omitempty"`
|
||||
What string `json:"what"`
|
||||
}
|
||||
|
||||
// The values of Widening's what.
|
||||
const (
|
||||
WideningWhatServingPart = "serving part"
|
||||
WideningWhatActingRule = "acting rule"
|
||||
WideningWhatGrant = "grant"
|
||||
WideningWhatCredential = "credential"
|
||||
WideningWhatCouldNotRun = "could not run"
|
||||
)
|
||||
|
||||
// RunInput is what run takes.
|
||||
type RunInput struct {
|
||||
Members []Member `json:"members"`
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// RunAnswer is what run answers.
|
||||
type RunAnswer struct {
|
||||
// the pipelines' keys
|
||||
Pipelines []string `json:"pipelines,omitempty"`
|
||||
Run string `json:"run"`
|
||||
}
|
||||
|
||||
// StartInput is what start takes.
|
||||
type StartInput struct {
|
||||
Branch string `json:"branch"`
|
||||
Module string `json:"module"`
|
||||
// why, written with the caller the runtime proves in the hand-act log
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// StartAnswer is what start answers.
|
||||
type StartAnswer struct {
|
||||
Pipeline string `json:"pipeline"`
|
||||
}
|
||||
|
||||
// ShowInput is what show takes.
|
||||
type ShowInput struct {
|
||||
// the pipeline's key
|
||||
Pipeline string `json:"pipeline"`
|
||||
}
|
||||
|
||||
// ShowAnswer is what show answers.
|
||||
type ShowAnswer struct {
|
||||
Fill []Fill `json:"fill,omitempty"`
|
||||
Log []LogEntry `json:"log,omitempty"`
|
||||
// the outputs' names in step-outputs
|
||||
Outputs []string `json:"outputs,omitempty"`
|
||||
Pipeline Pipeline `json:"pipeline"`
|
||||
}
|
||||
|
||||
// ListInput is what list takes.
|
||||
type ListInput struct {
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Commit string `json:"commit,omitempty"`
|
||||
Limit int64 `json:"limit,omitempty"`
|
||||
Module string `json:"module,omitempty"`
|
||||
Run string `json:"run,omitempty"`
|
||||
}
|
||||
|
||||
// ListAnswer is what list answers.
|
||||
type ListAnswer struct {
|
||||
Fill *Fill `json:"fill,omitempty"`
|
||||
Pipelines []Pipeline `json:"pipelines"`
|
||||
}
|
||||
|
||||
// StandsInput is what stands takes.
|
||||
type StandsInput struct {
|
||||
}
|
||||
|
||||
// StandsAnswer is what stands answers.
|
||||
type StandsAnswer struct {
|
||||
Stands []Wait `json:"stands"`
|
||||
}
|
||||
|
||||
// WhyCarriedInput is what why-carried takes.
|
||||
type WhyCarriedInput struct {
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
// the pipeline's key
|
||||
Pipeline string `json:"pipeline"`
|
||||
Step string `json:"step"`
|
||||
}
|
||||
|
||||
// The values of WhyCarriedInput's step.
|
||||
const (
|
||||
WhyCarriedInputStepBuild = "build"
|
||||
WhyCarriedInputStepLint = "lint"
|
||||
WhyCarriedInputStepUnit = "unit"
|
||||
WhyCarriedInputStepIntegration = "integration"
|
||||
WhyCarriedInputStepComposition = "composition"
|
||||
WhyCarriedInputStepReview = "review"
|
||||
WhyCarriedInputStepApproval = "approval"
|
||||
)
|
||||
|
||||
// WhyCarriedAnswer is what why-carried answers.
|
||||
type WhyCarriedAnswer struct {
|
||||
CarriedFrom string `json:"carried-from,omitempty"`
|
||||
Kept []KeptResult `json:"kept,omitempty"`
|
||||
}
|
||||
|
||||
// KeptInput is what kept takes.
|
||||
type KeptInput struct {
|
||||
Digest string `json:"digest,omitempty"`
|
||||
Level string `json:"level,omitempty"`
|
||||
Package string `json:"package,omitempty"`
|
||||
}
|
||||
|
||||
// KeptAnswer is what kept answers.
|
||||
type KeptAnswer struct {
|
||||
Fill *Fill `json:"fill,omitempty"`
|
||||
Kept []KeptResult `json:"kept"`
|
||||
}
|
||||
|
||||
// ReviewInput is what review takes.
|
||||
type ReviewInput struct {
|
||||
Commit string `json:"commit"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
Module string `json:"module"`
|
||||
Outcome string `json:"outcome"`
|
||||
// what the review found
|
||||
Said string `json:"said,omitempty"`
|
||||
}
|
||||
|
||||
// The values of ReviewInput's outcome.
|
||||
const (
|
||||
ReviewInputOutcomePassed = "passed"
|
||||
ReviewInputOutcomeFailed = "failed"
|
||||
)
|
||||
|
||||
// ReviewAnswer is what review answers.
|
||||
type ReviewAnswer struct {
|
||||
Pipeline string `json:"pipeline,omitempty"`
|
||||
Result StepResult `json:"result"`
|
||||
}
|
||||
|
||||
// RerunInput is what rerun takes.
|
||||
type RerunInput struct {
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
// the pipeline's key
|
||||
Pipeline string `json:"pipeline"`
|
||||
Step string `json:"step"`
|
||||
// why, written with the caller the runtime proves in the hand-act log
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// The values of RerunInput's step.
|
||||
const (
|
||||
RerunInputStepBuild = "build"
|
||||
RerunInputStepLint = "lint"
|
||||
RerunInputStepUnit = "unit"
|
||||
RerunInputStepIntegration = "integration"
|
||||
RerunInputStepComposition = "composition"
|
||||
RerunInputStepReview = "review"
|
||||
RerunInputStepApproval = "approval"
|
||||
)
|
||||
|
||||
// RerunAnswer is what rerun answers.
|
||||
type RerunAnswer struct {
|
||||
Pipeline string `json:"pipeline"`
|
||||
Result *StepResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
// AcceptInput is what accept takes.
|
||||
type AcceptInput struct {
|
||||
Artifact string `json:"artifact,omitempty"`
|
||||
// the pipeline's key
|
||||
Pipeline string `json:"pipeline"`
|
||||
Step string `json:"step"`
|
||||
// why, written with the caller the runtime proves in the hand-act log
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// The values of AcceptInput's step.
|
||||
const (
|
||||
AcceptInputStepBuild = "build"
|
||||
AcceptInputStepLint = "lint"
|
||||
AcceptInputStepUnit = "unit"
|
||||
AcceptInputStepIntegration = "integration"
|
||||
AcceptInputStepComposition = "composition"
|
||||
AcceptInputStepReview = "review"
|
||||
AcceptInputStepApproval = "approval"
|
||||
)
|
||||
|
||||
// AcceptAnswer is what accept answers.
|
||||
type AcceptAnswer struct {
|
||||
Result StepResult `json:"result"`
|
||||
}
|
||||
|
||||
// CancelInput is what cancel takes.
|
||||
type CancelInput struct {
|
||||
// the pipeline's key
|
||||
Pipeline string `json:"pipeline"`
|
||||
// why, written with the caller the runtime proves in the hand-act log
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// CancelAnswer is what cancel answers.
|
||||
type CancelAnswer struct {
|
||||
Pipeline Pipeline `json:"pipeline"`
|
||||
}
|
||||
|
||||
// AskAgainInput is what ask-again takes.
|
||||
type AskAgainInput struct {
|
||||
// the pipeline's key
|
||||
Pipeline string `json:"pipeline"`
|
||||
// why, written with the caller the runtime proves in the hand-act log
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// AskAgainAnswer is what ask-again answers.
|
||||
type AskAgainAnswer struct {
|
||||
Result StepResult `json:"result"`
|
||||
}
|
||||
|
||||
// PipelineStartedEvent is the body of the event pipeline-started.
|
||||
type PipelineStartedEvent = PipelineStarted
|
||||
|
||||
// PipelineEndedEvent is the body of the event pipeline-ended.
|
||||
type PipelineEndedEvent = PipelineEnded
|
||||
|
||||
// GroupEndedEvent is the body of the event group-ended.
|
||||
type GroupEndedEvent = GroupEnded
|
||||
|
||||
// RunStartedEvent is the body of the event run-started.
|
||||
type RunStartedEvent = RunStarted
|
||||
|
||||
// StepStartedEvent is the body of the event step-started.
|
||||
type StepStartedEvent = StepEvent
|
||||
|
||||
// StepEndedEvent is the body of the event step-ended.
|
||||
type StepEndedEvent = StepEvent
|
||||
|
||||
// WaitHeldEvent is the body of the event wait-held.
|
||||
type WaitHeldEvent = Wait
|
||||
|
||||
// WaitEndedEvent is the body of the event wait-ended.
|
||||
type WaitEndedEvent = Wait
|
||||
|
||||
// PipelinesByBranchRevisionModuleValue is one value of the state pipelines under the key <branch>.<revision>.<module>.
|
||||
type PipelinesByBranchRevisionModuleValue = Pipeline
|
||||
|
||||
// KeptByLevelDigestValue is one value of the state kept under the key <level>.<digest>.
|
||||
type KeptByLevelDigestValue = KeptResult
|
||||
|
||||
// StepLogByPipelineValue is one value of the state step-log under the key <pipeline>.
|
||||
type StepLogByPipelineValue = LogEntry
|
||||
|
||||
// StepOutputsByPipelineStepArtifactValue is one value of the state step-outputs under the key <pipeline>.<step>.<artifact>.
|
||||
type StepOutputsByPipelineStepArtifactValue = string
|
||||
@@ -1,96 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshpipelinerunner
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-pipeline-runner/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a pipeline started with the steps its policy gives", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"status\":\"required\",\"step\":\"lint\"},{\"status\":\"bypass\",\"step\":\"review\"}],\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"status\":\"required\",\"step\":\"lint\"},{\"status\":\"bypass\",\"step\":\"review\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a pipeline ended passed, an optional step failed, over budget and widening named", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"g14\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tests\":{\"integration\":3,\"unit\":42},\"v\":1,\"widens\":[{\"name\":\"mesh-build-go:program\",\"said\":\"its test runner\",\"what\":\"serving part\"}]}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"g14\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tests\":{\"integration\":3,\"unit\":42},\"v\":1,\"widens\":[{\"name\":\"mesh-build-go:program\",\"said\":\"its test runner\",\"what\":\"serving part\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a pipeline ended failed, naming the step that held it, its approval not asked", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"v\":1,\"why\":\"unit of nats:program failed\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"over-budget\":true,\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"v\":1,\"why\":\"unit of nats:program failed\"}",
|
||||
decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a group's one pipeline ended on a watched branch", subject: "mesh.seat.mesh-pipeline-runner.event.group-ended.main.registry-1966", given: "{\"branch\":\"main\",\"ended\":\"2026-11-10T10:20:00Z\",\"group\":\"registry-1966\",\"outcome\":\"passed\",\"pipelines\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"group\":\"registry-1966\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}],\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"ended\":\"2026-11-10T10:20:00Z\",\"group\":\"registry-1966\",\"outcome\":\"passed\",\"pipelines\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"group\":\"registry-1966\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}],\"revision\":12,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v GroupEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.group-ended\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a run on request started", subject: "mesh.seat.mesh-pipeline-runner.event.run-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"fix-1965@shanks\",\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}],\"run\":\"run-m2kx9a\",\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"fix-1965@shanks\",\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}],\"run\":\"run-m2kx9a\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v RunStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.run-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a step started", subject: "mesh.seat.mesh-pipeline-runner.event.step-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"outcome\":\"running\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},\"revision\":12,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a rerun step ended passed, with its proved caller", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"by\":\"operator@shanks\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"rerun\":true,\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:05:00Z\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"artifact\":\"nats:program\",\"by\":\"operator@shanks\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"rerun\":true,\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},\"revision\":12,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a bypassed step said", subject: "mesh.seat.mesh-pipeline-runner.event.step-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},\"revision\":12,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "an approval waits on the operator", subject: "mesh.seat.mesh-pipeline-runner.event.wait-held.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-held\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "the wait ended answered", subject: "mesh.seat.mesh-pipeline-runner.event.wait-ended.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"how\":\"answered\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"how\":\"answered\",\"module\":\"nats\",\"on\":\"person\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:10:00Z\",\"source\":3589,\"step\":\"approval\",\"v\":1,\"who\":\"the operator\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a pipeline kept", subject: "", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"g14\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"g14\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PipelinesByBranchRevisionModuleValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a pipeline a publication started, with the version it names (design 47 G 550)", subject: "", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"g14\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.11.nats\",\"fingerprint\":\"fp-0123\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"node\":\"g14\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1,\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PipelinesByBranchRevisionModuleValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a kept result", subject: "", given: "{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}", wire: "{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptByLevelDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "run asks one member at a commit", subject: "", given: "{\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}]}", wire: "{\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v RunInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "run answers its id and pipelines", subject: "", given: "{\"pipelines\":[\"feature~2f1966-x.0.nats\"],\"run\":\"run-m2kx9a\"}", wire: "{\"pipelines\":[\"feature~2f1966-x.0.nats\"],\"run\":\"run-m2kx9a\"}",
|
||||
decode: func(b []byte) (any, error) { var v RunAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "review of a commit", subject: "", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"said\":\"reads well\"}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"passed\",\"said\":\"reads well\"}",
|
||||
decode: func(b []byte) (any, error) { var v ReviewInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "review answers its step", subject: "", given: "{\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"passed\",\"status\":\"optional\",\"step\":\"review\"}}", wire: "{\"pipeline\":\"main.12.nats\",\"result\":{\"outcome\":\"passed\",\"status\":\"optional\",\"step\":\"review\"}}",
|
||||
decode: func(b []byte) (any, error) { var v ReviewAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "show answers a pipeline with its log and fill", subject: "", given: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.12.nats\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}", wire: "{\"fill\":[{\"bytes\":4096,\"cap\":268435456,\"store\":\"pipelines\"}],\"log\":[{\"artifact\":\"nats:program\",\"at\":\"2026-11-10T10:00:00Z\",\"pipeline\":\"main.12.nats\",\"step\":\"lint\",\"what\":\"started\"}],\"outputs\":[\"main.12.nats.lint.nats:program\"],\"pipeline\":{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"node\":\"ace\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"}],\"v\":1}}",
|
||||
decode: func(b []byte) (any, error) { var v ShowAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "accept asks with why", subject: "", given: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}", wire: "{\"artifact\":\"nats:program\",\"pipeline\":\"main.12.nats\",\"step\":\"integration\",\"why\":\"flaky upstream, issue 1966\"}",
|
||||
decode: func(b []byte) (any, error) { var v AcceptInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "stands answers a wait on a build node", subject: "", given: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}", wire: "{\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}]}",
|
||||
decode: func(b []byte) (any, error) { var v StandsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept answers by digest", subject: "", given: "{\"fill\":{\"bytes\":300,\"cap\":134217728,\"store\":\"kept\"},\"kept\":[{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}]}", wire: "{\"fill\":{\"bytes\":300,\"cap\":134217728,\"store\":\"kept\"},\"kept\":[{\"digest\":\"sha256:aa\",\"level\":\"unit\",\"package\":\"git.novox.be/novox/nats\",\"pipeline\":\"main.12.nats\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v KeptAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshpipelinerunner
|
||||
|
||||
go 1.26.0
|
||||
@@ -1,976 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
// Package meshwants is the contract of the seat "mesh-wants", defined whole (seats/mesh-wants/seat.json): The seat that says what each node should run and whether each module's new builds wait for a person (ADR 0565, ADR 0539).
|
||||
package meshwants
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "mesh-wants"
|
||||
|
||||
const (
|
||||
VerbUpgrade = "upgrade"
|
||||
VerbBus = "bus"
|
||||
VerbRevision = "revision"
|
||||
VerbEntry = "entry"
|
||||
VerbDifference = "difference"
|
||||
VerbInput = "input"
|
||||
)
|
||||
|
||||
const (
|
||||
AcceptStep = "step"
|
||||
)
|
||||
|
||||
const (
|
||||
EventPolicyChanged = "policy-changed"
|
||||
EventAssignmentRevision = "assignment-revision"
|
||||
EventDifference = "difference"
|
||||
EventWanted = "wanted"
|
||||
EventWaitHeld = "wait-held"
|
||||
EventWaitEnded = "wait-ended"
|
||||
EventFilling = "filling"
|
||||
EventFull = "full"
|
||||
EventRoom = "room"
|
||||
EventStepEnded = "step-ended"
|
||||
EventVersionDelivered = "version-delivered"
|
||||
EventStepProgress = "step-progress"
|
||||
)
|
||||
|
||||
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
||||
func Verbs() []string {
|
||||
return []string{VerbUpgrade, VerbBus, VerbRevision, VerbEntry, VerbDifference, VerbInput}
|
||||
}
|
||||
|
||||
// Events is every event published on the seat's subject: a new copy each call.
|
||||
func Events() []string {
|
||||
return []string{EventPolicyChanged, EventAssignmentRevision, EventDifference, EventWanted, EventWaitHeld, EventWaitEnded, EventFilling, EventFull, EventRoom, EventStepEnded, EventVersionDelivered, EventStepProgress}
|
||||
}
|
||||
|
||||
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
||||
const (
|
||||
Family = "mesh-wants.events"
|
||||
FamilyMaxAgeDays = 7
|
||||
)
|
||||
|
||||
// SubjectPolicyChanged is where policy-changed is published.
|
||||
const SubjectPolicyChanged = "mesh.seat.mesh-wants.event.policy-changed"
|
||||
|
||||
// SubjectAssignmentRevision is where assignment-revision is published.
|
||||
const SubjectAssignmentRevision = "mesh.seat.mesh-wants.event.assignment-revision"
|
||||
|
||||
// SubjectDifference is where difference is published.
|
||||
const SubjectDifference = "mesh.seat.mesh-wants.event.difference"
|
||||
|
||||
// StreamWanted is the stream wanted is kept in.
|
||||
const StreamWanted = "SEAT_mesh-wants_wanted"
|
||||
|
||||
// SubjectWanted is where wanted is published, on mesh.seat.mesh-wants.event.wanted.<node>.<module>.
|
||||
func SubjectWanted(node, module string) string {
|
||||
return "mesh.seat.mesh-wants.event.wanted." + node + "." + module
|
||||
}
|
||||
|
||||
// SubjectWantedAll hears every wanted.
|
||||
const SubjectWantedAll = "mesh.seat.mesh-wants.event.wanted.*.*"
|
||||
|
||||
// SubjectWaitHeld is where wait-held is published.
|
||||
const SubjectWaitHeld = "mesh.seat.mesh-wants.event.wait-held"
|
||||
|
||||
// SubjectWaitEnded is where wait-ended is published.
|
||||
const SubjectWaitEnded = "mesh.seat.mesh-wants.event.wait-ended"
|
||||
|
||||
// SubjectFilling is where filling is published.
|
||||
const SubjectFilling = "mesh.seat.mesh-wants.event.filling"
|
||||
|
||||
// SubjectFull is where full is published.
|
||||
const SubjectFull = "mesh.seat.mesh-wants.event.full"
|
||||
|
||||
// SubjectRoom is where room is published.
|
||||
const SubjectRoom = "mesh.seat.mesh-wants.event.room"
|
||||
|
||||
// StreamStepEnded is the stream step-ended is kept in.
|
||||
const StreamStepEnded = "SEAT_mesh-wants_step-ended"
|
||||
|
||||
// SubjectStepEnded is where step-ended is published, on mesh.seat.mesh-wants.event.step-ended.<node>.
|
||||
func SubjectStepEnded(node string) string { return "mesh.seat.mesh-wants.event.step-ended." + node }
|
||||
|
||||
// SubjectStepEndedAll hears every step-ended.
|
||||
const SubjectStepEndedAll = "mesh.seat.mesh-wants.event.step-ended.*"
|
||||
|
||||
// StreamVersionDelivered is the stream version-delivered is kept in.
|
||||
const StreamVersionDelivered = "SEAT_mesh-wants_version-delivered"
|
||||
|
||||
// SubjectVersionDelivered is where version-delivered is published.
|
||||
const SubjectVersionDelivered = "mesh.seat.mesh-wants.event.version-delivered"
|
||||
|
||||
// SubjectStepProgress is where step-progress is published, on mesh.seat.mesh-wants.event.step-progress.<node>.
|
||||
func SubjectStepProgress(node string) string {
|
||||
return "mesh.seat.mesh-wants.event.step-progress." + node
|
||||
}
|
||||
|
||||
// SubjectStepProgressAll hears every step-progress.
|
||||
const SubjectStepProgressAll = "mesh.seat.mesh-wants.event.step-progress.*"
|
||||
|
||||
// AcceptSubjectStep is where step is sent.
|
||||
const AcceptSubjectStep = "mesh.seat.mesh-wants.accept.step"
|
||||
|
||||
const (
|
||||
StateWants = "wants"
|
||||
StateDifferences = "differences"
|
||||
StateCompositions = "compositions"
|
||||
StateAssignmentRevisions = "assignment-revisions"
|
||||
StateInputs = "inputs"
|
||||
)
|
||||
|
||||
// WantsByWantNodeModuleKey is the key of one value of the state wants under the form "want.<node>.<module>".
|
||||
func WantsByWantNodeModuleKey(node, module string) string { return "want." + node + "." + module }
|
||||
|
||||
// ParseWantsByWantNodeModuleKey reads the parts of a key of the form "want.<node>.<module>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseWantsByWantNodeModuleKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "want.") {
|
||||
return "", "", false
|
||||
}
|
||||
rest = rest[5:]
|
||||
v1, after1, found1 := strings.Cut(rest, ".")
|
||||
if !found1 || v1 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after1
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v3 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v1, v3, true
|
||||
}
|
||||
|
||||
// DecodeWantsByWantNodeModuleValue reads one value of the state wants under the form "want.<node>.<module>", refusing a field WantsByWantNodeModuleValue does not know and any text after the value.
|
||||
func DecodeWantsByWantNodeModuleValue(raw []byte) (WantsByWantNodeModuleValue, error) {
|
||||
var v WantsByWantNodeModuleValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// WantsByWantNodeNodeKey is the key of one value of the state wants under the form "want.<node>.node".
|
||||
func WantsByWantNodeNodeKey(node string) string { return "want." + node + ".node" }
|
||||
|
||||
// ParseWantsByWantNodeNodeKey reads the parts of a key of the form "want.<node>.node", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseWantsByWantNodeNodeKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "want.") {
|
||||
return "", false
|
||||
}
|
||||
rest = rest[5:]
|
||||
v1, after1, found1 := strings.Cut(rest, ".node")
|
||||
if !found1 || v1 == "" {
|
||||
return "", false
|
||||
}
|
||||
rest = after1
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v1, true
|
||||
}
|
||||
|
||||
// DecodeWantsByWantNodeNodeValue reads one value of the state wants under the form "want.<node>.node", refusing a field WantsByWantNodeNodeValue does not know and any text after the value.
|
||||
func DecodeWantsByWantNodeNodeValue(raw []byte) (WantsByWantNodeNodeValue, error) {
|
||||
var v WantsByWantNodeNodeValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// WantsByHeldModuleFingerprintKey is the key of one value of the state wants under the form "held.<module>.<fingerprint>".
|
||||
func WantsByHeldModuleFingerprintKey(module, fingerprint string) string {
|
||||
return "held." + module + "." + fingerprint
|
||||
}
|
||||
|
||||
// ParseWantsByHeldModuleFingerprintKey reads the parts of a key of the form "held.<module>.<fingerprint>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseWantsByHeldModuleFingerprintKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "held.") {
|
||||
return "", "", false
|
||||
}
|
||||
rest = rest[5:]
|
||||
v1, after1, found1 := strings.Cut(rest, ".")
|
||||
if !found1 || v1 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after1
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v3 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v1, v3, true
|
||||
}
|
||||
|
||||
// DecodeWantsByHeldModuleFingerprintValue reads one value of the state wants under the form "held.<module>.<fingerprint>", refusing a field WantsByHeldModuleFingerprintValue does not know and any text after the value.
|
||||
func DecodeWantsByHeldModuleFingerprintValue(raw []byte) (WantsByHeldModuleFingerprintValue, error) {
|
||||
var v WantsByHeldModuleFingerprintValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// DifferencesByNodeModuleKey is the key of one value of the state differences under the form "<node>.<module>".
|
||||
func DifferencesByNodeModuleKey(node, module string) string { return node + "." + module }
|
||||
|
||||
// ParseDifferencesByNodeModuleKey reads the parts of a key of the form "<node>.<module>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseDifferencesByNodeModuleKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after0
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v2 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v0, v2, true
|
||||
}
|
||||
|
||||
// DecodeDifferencesByNodeModuleValue reads one value of the state differences under the form "<node>.<module>", refusing a field DifferencesByNodeModuleValue does not know and any text after the value.
|
||||
func DecodeDifferencesByNodeModuleValue(raw []byte) (DifferencesByNodeModuleValue, error) {
|
||||
var v DifferencesByNodeModuleValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// CompositionsByGroupHeadsKey is the key of one value of the state compositions under the form "<group>.<heads>".
|
||||
func CompositionsByGroupHeadsKey(group, heads string) string { return group + "." + heads }
|
||||
|
||||
// ParseCompositionsByGroupHeadsKey reads the parts of a key of the form "<group>.<heads>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseCompositionsByGroupHeadsKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after0
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v2 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v0, v2, true
|
||||
}
|
||||
|
||||
// DecodeCompositionsByGroupHeadsValue reads one value of the state compositions under the form "<group>.<heads>", refusing a field CompositionsByGroupHeadsValue does not know and any text after the value.
|
||||
func DecodeCompositionsByGroupHeadsValue(raw []byte) (CompositionsByGroupHeadsValue, error) {
|
||||
var v CompositionsByGroupHeadsValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// AssignmentRevisionsByTrunkRevisionKey is the key of one value of the state assignment-revisions under the form "trunk.<revision>".
|
||||
func AssignmentRevisionsByTrunkRevisionKey(revision string) string { return "trunk." + revision }
|
||||
|
||||
// ParseAssignmentRevisionsByTrunkRevisionKey reads the parts of a key of the form "trunk.<revision>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseAssignmentRevisionsByTrunkRevisionKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "trunk.") {
|
||||
return "", false
|
||||
}
|
||||
rest = rest[6:]
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v1 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v1, true
|
||||
}
|
||||
|
||||
// DecodeAssignmentRevisionsByTrunkRevisionValue reads one value of the state assignment-revisions under the form "trunk.<revision>", refusing a field AssignmentRevisionsByTrunkRevisionValue does not know and any text after the value.
|
||||
func DecodeAssignmentRevisionsByTrunkRevisionValue(raw []byte) (AssignmentRevisionsByTrunkRevisionValue, error) {
|
||||
var v AssignmentRevisionsByTrunkRevisionValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// AssignmentRevisionsByCandidateGroupHeadsKey is the key of one value of the state assignment-revisions under the form "candidate.<group>.<heads>".
|
||||
func AssignmentRevisionsByCandidateGroupHeadsKey(group, heads string) string {
|
||||
return "candidate." + group + "." + heads
|
||||
}
|
||||
|
||||
// ParseAssignmentRevisionsByCandidateGroupHeadsKey reads the parts of a key of the form "candidate.<group>.<heads>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseAssignmentRevisionsByCandidateGroupHeadsKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "candidate.") {
|
||||
return "", "", false
|
||||
}
|
||||
rest = rest[10:]
|
||||
v1, after1, found1 := strings.Cut(rest, ".")
|
||||
if !found1 || v1 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after1
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v3 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v1, v3, true
|
||||
}
|
||||
|
||||
// DecodeAssignmentRevisionsByCandidateGroupHeadsValue reads one value of the state assignment-revisions under the form "candidate.<group>.<heads>", refusing a field AssignmentRevisionsByCandidateGroupHeadsValue does not know and any text after the value.
|
||||
func DecodeAssignmentRevisionsByCandidateGroupHeadsValue(raw []byte) (AssignmentRevisionsByCandidateGroupHeadsValue, error) {
|
||||
var v AssignmentRevisionsByCandidateGroupHeadsValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// AssignmentRevisionsByEntryDigestKey is the key of one value of the state assignment-revisions under the form "entry.<digest>".
|
||||
func AssignmentRevisionsByEntryDigestKey(digest string) string { return "entry." + digest }
|
||||
|
||||
// ParseAssignmentRevisionsByEntryDigestKey reads the parts of a key of the form "entry.<digest>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseAssignmentRevisionsByEntryDigestKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if !strings.HasPrefix(rest, "entry.") {
|
||||
return "", false
|
||||
}
|
||||
rest = rest[6:]
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v1 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v1, true
|
||||
}
|
||||
|
||||
// DecodeAssignmentRevisionsByEntryDigestValue reads one value of the state assignment-revisions under the form "entry.<digest>", refusing a field AssignmentRevisionsByEntryDigestValue does not know and any text after the value.
|
||||
func DecodeAssignmentRevisionsByEntryDigestValue(raw []byte) (AssignmentRevisionsByEntryDigestValue, error) {
|
||||
var v AssignmentRevisionsByEntryDigestValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// InputsByTimeDigestKey is the key of one value of the state inputs under the form "<time>.<digest>".
|
||||
func InputsByTimeDigestKey(time, digest string) string { return time + "." + digest }
|
||||
|
||||
// ParseInputsByTimeDigestKey reads the parts of a key of the form "<time>.<digest>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseInputsByTimeDigestKey(key string) (string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", false
|
||||
}
|
||||
rest = after0
|
||||
if rest == "" {
|
||||
return "", "", false
|
||||
}
|
||||
v2 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", false
|
||||
}
|
||||
return v0, v2, true
|
||||
}
|
||||
|
||||
// DecodeInputsByTimeDigestValue reads one value of the state inputs under the form "<time>.<digest>", refusing a field InputsByTimeDigestValue does not know and any text after the value.
|
||||
func DecodeInputsByTimeDigestValue(raw []byte) (InputsByTimeDigestValue, error) {
|
||||
var v InputsByTimeDigestValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// AssignmentEntry is one module version on a node of an assignment graph revision, stored once by its digest (ADR 0656).
|
||||
type AssignmentEntry struct {
|
||||
// the watched branch its placement names, whose catalog graph the entry comes from (design 47 lines 523-525)
|
||||
Branch string `json:"branch"`
|
||||
// the digest of its catalog graph entry
|
||||
Catalog string `json:"catalog"`
|
||||
Edges []Edge `json:"edges,omitempty"`
|
||||
// the fingerprint it is to run
|
||||
Fp string `json:"fp"`
|
||||
Module string `json:"module"`
|
||||
Node string `json:"node"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// AssignmentRevisionCapabilitiesItem is a type of the contract.
|
||||
type AssignmentRevisionCapabilitiesItem struct {
|
||||
// the digest of the node's capability reading
|
||||
Digest string `json:"digest"`
|
||||
Node string `json:"node"`
|
||||
}
|
||||
|
||||
// AssignmentRevision is an assignment graph revision: the list of its entries' digests and the inputs it was computed from, so it can be computed again and compared.
|
||||
type AssignmentRevision struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Capabilities []AssignmentRevisionCapabilitiesItem `json:"capabilities,omitempty"`
|
||||
// the catalog graph revision of each watched branch a placement names, which the entries come from
|
||||
Catalogs []CatalogOf `json:"catalogs"`
|
||||
// what made it: catalog-revision, placement-changed or capabilities-changed
|
||||
Cause string `json:"cause,omitempty"`
|
||||
Entries []NodeEntryRef `json:"entries"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Heads string `json:"heads,omitempty"`
|
||||
// trunk or candidate
|
||||
Kind string `json:"kind"`
|
||||
// the digest of the placements it was computed from
|
||||
Placements string `json:"placements"`
|
||||
// counted by its holder
|
||||
Revision int64 `json:"revision"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// CatalogOf is one catalog graph revision of a watched branch the revision was computed from (design 47 lines 1416-1418).
|
||||
type CatalogOf struct {
|
||||
// the watched branch
|
||||
Branch string `json:"branch"`
|
||||
// that branch's catalog graph revision
|
||||
Revision int64 `json:"revision"`
|
||||
// the source revision of that branch it carries
|
||||
Source int64 `json:"source,omitempty"`
|
||||
}
|
||||
|
||||
// Change is one module on a node whose version differs between two revisions.
|
||||
type Change struct {
|
||||
// the edges that moved
|
||||
Edges []Edge `json:"edges,omitempty"`
|
||||
// the fingerprint before; absent when it is new there
|
||||
From string `json:"from,omitempty"`
|
||||
Module string `json:"module"`
|
||||
Node string `json:"node"`
|
||||
// the fingerprint after; absent when it goes
|
||||
To string `json:"to,omitempty"`
|
||||
}
|
||||
|
||||
// DifferenceRefusedItem is a type of the contract.
|
||||
type DifferenceRefusedItem struct {
|
||||
Module string `json:"module"`
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// Difference is two assignment graph revisions compared: a change's delivery, with its order read off the edges and no plan stored (ADR 0656).
|
||||
type Difference struct {
|
||||
Changes []Change `json:"changes"`
|
||||
// the revision compared from
|
||||
From int64 `json:"from"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Heads string `json:"heads,omitempty"`
|
||||
// the nodes it touches
|
||||
Nodes []string `json:"nodes,omitempty"`
|
||||
// a module whose fingerprint changed while the difference is empty, refused by name
|
||||
Refused []DifferenceRefusedItem `json:"refused,omitempty"`
|
||||
// the order as a view: each tier the changes whose acting parts acted in the tiers before it (ADR 0603 §6 as ADR 0656 changes it)
|
||||
Tiers [][]NodeEntryRef `json:"tiers,omitempty"`
|
||||
// the revision compared to
|
||||
To int64 `json:"to"`
|
||||
}
|
||||
|
||||
// Edge is an edge from one module version on a node to another: provisioning, contribution, or an acting part's version that is to act on it in a step (ADR 0656).
|
||||
type Edge struct {
|
||||
// for acting, how long the new version may take before it acts
|
||||
Bound string `json:"bound,omitempty"`
|
||||
// the other end's fingerprint
|
||||
Fp string `json:"fp,omitempty"`
|
||||
// provisioning, contribution or acting
|
||||
Kind string `json:"kind"`
|
||||
Module string `json:"module"`
|
||||
Node string `json:"node"`
|
||||
// for provisioning, the provision
|
||||
Provision string `json:"provision,omitempty"`
|
||||
// for contribution, the seat it contributes to; for acting, the seat whose rule gave the edge
|
||||
Seat string `json:"seat,omitempty"`
|
||||
// for acting, the step: take-in, validate, check, build, compose, grant or place
|
||||
Step string `json:"step,omitempty"`
|
||||
}
|
||||
|
||||
// Fill is a store's fill against its cap.
|
||||
type Fill struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Bytes int64 `json:"bytes"`
|
||||
// bytes
|
||||
Cap int64 `json:"cap"`
|
||||
// what full refuses
|
||||
Refused string `json:"refused,omitempty"`
|
||||
// the kept data, by its name in the holder's manifest
|
||||
Store string `json:"store"`
|
||||
}
|
||||
|
||||
// NodeEntryRef is a type of the contract.
|
||||
type NodeEntryRef struct {
|
||||
// the entry's digest, its object's name
|
||||
Digest string `json:"digest"`
|
||||
Module string `json:"module"`
|
||||
Node string `json:"node"`
|
||||
}
|
||||
|
||||
// StepEnded is the composition step's end, said by the assigner on the node it runs on (ADR 0666 sections 7, 21): the runner takes it only from that holder's account, naming the ask, the commit and the fingerprint it was asked at.
|
||||
type StepEnded struct {
|
||||
// for a rerun, the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
Commit string `json:"commit"`
|
||||
Ended *time.Time `json:"ended,omitempty"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
// the ask's id
|
||||
ID string `json:"id"`
|
||||
Module string `json:"module"`
|
||||
// the node the assigner ran it on, as in the subject
|
||||
Node string `json:"node"`
|
||||
// never passed for a step that composed nothing
|
||||
Outcome string `json:"outcome"`
|
||||
Pipeline string `json:"pipeline"`
|
||||
Rerun bool `json:"rerun,omitempty"`
|
||||
// why it failed or could not run: the two modules owning one path, the part not heard
|
||||
Said string `json:"said,omitempty"`
|
||||
Started *time.Time `json:"started,omitempty"`
|
||||
Step string `json:"step"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
// a node asleep, passed with a warning (ADR 0593 section 9)
|
||||
Warnings []string `json:"warnings,omitempty"`
|
||||
}
|
||||
|
||||
// The values of StepEnded's outcome.
|
||||
const (
|
||||
StepEndedOutcomePassed = "passed"
|
||||
StepEndedOutcomeFailed = "failed"
|
||||
StepEndedOutcomeNothingToRun = "nothing to run"
|
||||
StepEndedOutcomeCouldNotRun = "could not run"
|
||||
)
|
||||
|
||||
// The values of StepEnded's step.
|
||||
const (
|
||||
StepEndedStepComposition = "composition"
|
||||
)
|
||||
|
||||
// StepRun is the composition step of one module's pipeline (design 47 *Pipeline steps and the policy*, *The pipeline makes the check*): the assigner composes each machine's declaration at the change's heads with the composer built from them, in the build seat's sandbox, and refuses a change in which two modules own one path.
|
||||
type StepRun struct {
|
||||
// the watched branch, or the branch of a run on request
|
||||
Branch string `json:"branch"`
|
||||
// for a rerun, the caller the runtime proved
|
||||
By string `json:"by,omitempty"`
|
||||
// the commit the step runs at
|
||||
Commit string `json:"commit"`
|
||||
// the module's build-input fingerprint at the commit
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
Module string `json:"module"`
|
||||
// the runner's pipeline key, <branch>.<revision>.<module>, a branch escaped as a key's name is
|
||||
Pipeline string `json:"pipeline"`
|
||||
// the step is asked again by the runner's rerun
|
||||
Rerun bool `json:"rerun,omitempty"`
|
||||
// the catalog graph revision of the branch the pipeline runs for
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
// the run on request's id: its composition writes no want (ADR 0666 section 18)
|
||||
Run string `json:"run,omitempty"`
|
||||
// the source revision of the watched branch; absent for a run on request
|
||||
Source int64 `json:"source,omitempty"`
|
||||
Step string `json:"step"`
|
||||
}
|
||||
|
||||
// The values of StepRun's step.
|
||||
const (
|
||||
StepRunStepComposition = "composition"
|
||||
)
|
||||
|
||||
// Wait is a step's wait the assigner holds: placing, wanting or composing until an acting part's new version runs; the builder's toolchain wait is of this type too, with step build (design 47 G section 702).
|
||||
type Wait struct {
|
||||
// a duration such as 30m
|
||||
Bound string `json:"bound,omitempty"`
|
||||
// on a release, who released it and why
|
||||
By string `json:"by,omitempty"`
|
||||
// the time the bound counts from (design 47 G section 266, section 269, section 498)
|
||||
ClockFrom *time.Time `json:"clock-from,omitempty"`
|
||||
// a put's wait: the fingerprint of the build put
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
Fp string `json:"fp,omitempty"`
|
||||
// on wait-ended: ran, released or superseded
|
||||
How string `json:"how,omitempty"`
|
||||
// a dependent's delivery wait: the machines the dependency's version has yet to reach
|
||||
Machines []string `json:"machines,omitempty"`
|
||||
// the entry that waits
|
||||
Module string `json:"module,omitempty"`
|
||||
Node string `json:"node,omitempty"`
|
||||
// what it waits on (design 47 G section 512, section 629)
|
||||
On string `json:"on,omitempty"`
|
||||
// the seat holding the wait (design 47 G section 512, section 629)
|
||||
Owner string `json:"owner,omitempty"`
|
||||
// the acting part waited for
|
||||
Part string `json:"part,omitempty"`
|
||||
Since time.Time `json:"since"`
|
||||
// which wait: an acting step of section 203 or put, delivery, kept-build, backup, or outside, a moved module's failing check held on an outside cause (design 47 G section 498, section 706)
|
||||
Step string `json:"step"`
|
||||
// its new version's fingerprint
|
||||
Version string `json:"version,omitempty"`
|
||||
// the wait in plain words (design 47 G section 512, section 629)
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// The values of Wait's step.
|
||||
const (
|
||||
WaitStepTakeIn = "take-in"
|
||||
WaitStepValidate = "validate"
|
||||
WaitStepCheck = "check"
|
||||
WaitStepBuild = "build"
|
||||
WaitStepCompose = "compose"
|
||||
WaitStepGrant = "grant"
|
||||
WaitStepPlace = "place"
|
||||
WaitStepPipeline = "pipeline"
|
||||
WaitStepPut = "put"
|
||||
WaitStepDelivery = "delivery"
|
||||
WaitStepKeptBuild = "kept-build"
|
||||
WaitStepBackup = "backup"
|
||||
WaitStepOutside = "outside"
|
||||
)
|
||||
|
||||
// UpgradeInput is what upgrade takes.
|
||||
type UpgradeInput struct {
|
||||
// "true": each node's own composition, by its digest, and the assigner's findings
|
||||
Compare string `json:"compare,omitempty"`
|
||||
// one module
|
||||
Module string `json:"module,omitempty"`
|
||||
// with module: roll, together, record, or default to take a person's choice back
|
||||
Policy string `json:"policy,omitempty"`
|
||||
// with policy: why, required and kept
|
||||
Why string `json:"why,omitempty"`
|
||||
}
|
||||
|
||||
// The values of UpgradeInput's compare.
|
||||
const (
|
||||
UpgradeInputCompareTrue = "true"
|
||||
UpgradeInputCompareFalse = "false"
|
||||
)
|
||||
|
||||
// UpgradeAnswer is what upgrade answers.
|
||||
type UpgradeAnswer = map[string]any
|
||||
|
||||
// BusInput is what bus takes.
|
||||
type BusInput struct {
|
||||
}
|
||||
|
||||
// BusAnswer is what bus answers.
|
||||
type BusAnswer = map[string]any
|
||||
|
||||
// RevisionInput is what revision takes.
|
||||
type RevisionInput struct {
|
||||
// a candidate's group
|
||||
Group string `json:"group,omitempty"`
|
||||
// a candidate's heads
|
||||
Heads string `json:"heads,omitempty"`
|
||||
// a kept revision; absent: the newest of trunk, or of the candidate named
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
}
|
||||
|
||||
// RevisionAnswer is what revision answers.
|
||||
type RevisionAnswer struct {
|
||||
Revision AssignmentRevision `json:"revision"`
|
||||
}
|
||||
|
||||
// EntryInput is what entry takes.
|
||||
type EntryInput struct {
|
||||
Digest string `json:"digest,omitempty"`
|
||||
// a candidate's group
|
||||
Group string `json:"group,omitempty"`
|
||||
// a candidate's heads
|
||||
Heads string `json:"heads,omitempty"`
|
||||
Module string `json:"module,omitempty"`
|
||||
Node string `json:"node,omitempty"`
|
||||
// a kept revision; absent: the newest of trunk, or of the candidate named
|
||||
Revision int64 `json:"revision,omitempty"`
|
||||
}
|
||||
|
||||
// EntryAnswer is what entry answers.
|
||||
type EntryAnswer struct {
|
||||
Digest string `json:"digest"`
|
||||
Entry AssignmentEntry `json:"entry"`
|
||||
}
|
||||
|
||||
// DifferenceInput is what difference takes.
|
||||
type DifferenceInput struct {
|
||||
From int64 `json:"from,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Heads string `json:"heads,omitempty"`
|
||||
To int64 `json:"to,omitempty"`
|
||||
}
|
||||
|
||||
// DifferenceAnswer is what difference answers.
|
||||
type DifferenceAnswer = Difference
|
||||
|
||||
// InputInput is what input takes.
|
||||
type InputInput struct {
|
||||
// the input's sha256
|
||||
Digest string `json:"digest"`
|
||||
}
|
||||
|
||||
// InputAnswer is what input answers.
|
||||
type InputAnswer struct {
|
||||
// the input's sha256
|
||||
Digest string `json:"digest"`
|
||||
// the input's exact bytes, base64
|
||||
Input string `json:"input"`
|
||||
}
|
||||
|
||||
// StepAccept is the body of step.
|
||||
type StepAccept = StepRun
|
||||
|
||||
// PolicyChangedEvent is the body of the event policy-changed.
|
||||
type PolicyChangedEvent = map[string]any
|
||||
|
||||
// AssignmentRevisionEvent is the body of the event assignment-revision.
|
||||
type AssignmentRevisionEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the catalog graph revision of each watched branch a placement names, which the entries come from
|
||||
Catalogs []CatalogOf `json:"catalogs"`
|
||||
Cause string `json:"cause,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Heads string `json:"heads,omitempty"`
|
||||
Kind string `json:"kind"`
|
||||
Revision int64 `json:"revision"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// DifferenceEvent is the body of the event difference.
|
||||
type DifferenceEvent struct {
|
||||
// how many module versions it changes
|
||||
Changes int64 `json:"changes,omitempty"`
|
||||
From int64 `json:"from"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Heads string `json:"heads,omitempty"`
|
||||
Nodes []string `json:"nodes,omitempty"`
|
||||
Source int64 `json:"source,omitempty"`
|
||||
To int64 `json:"to"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// WantedEvent is the body of the event wanted.
|
||||
type WantedEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Fp string `json:"fp"`
|
||||
Module string `json:"module"`
|
||||
Node string `json:"node"`
|
||||
// true when the assigner removes the want of that node and module (the node left, or the module was unplaced); fp is then the fingerprint last wanted there (design 47 G section 693)
|
||||
Removed bool `json:"removed,omitempty"`
|
||||
Revision int64 `json:"revision"`
|
||||
Source int64 `json:"source,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
// WaitHeldEvent is the body of the event wait-held.
|
||||
type WaitHeldEvent = Wait
|
||||
|
||||
// WaitEndedEvent is the body of the event wait-ended.
|
||||
type WaitEndedEvent = Wait
|
||||
|
||||
// FillingEvent is the body of the event filling.
|
||||
type FillingEvent = Fill
|
||||
|
||||
// FullEvent is the body of the event full.
|
||||
type FullEvent = Fill
|
||||
|
||||
// RoomEvent is the body of the event room.
|
||||
type RoomEvent = Fill
|
||||
|
||||
// StepEndedEvent is the body of the event step-ended.
|
||||
type StepEndedEvent = StepEnded
|
||||
|
||||
// VersionDeliveredEvent is the body of the event version-delivered.
|
||||
type VersionDeliveredEvent struct {
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the machines away when it was said
|
||||
Away []string `json:"away,omitempty"`
|
||||
// the module
|
||||
Module string `json:"module"`
|
||||
// the digest of each of its parts, by `<module>:<artifact>`
|
||||
Parts map[string]string `json:"parts"`
|
||||
V int64 `json:"v"`
|
||||
// MAJOR.MINOR.PATCH
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// StepProgressEvent is the body of the event step-progress.
|
||||
type StepProgressEvent struct {
|
||||
Ask string `json:"ask"`
|
||||
Asker string `json:"asker"`
|
||||
At time.Time `json:"at"`
|
||||
Phase string `json:"phase"`
|
||||
}
|
||||
|
||||
// The values of StepProgressEvent's phase.
|
||||
const (
|
||||
StepProgressEventPhaseFetch = "fetch"
|
||||
StepProgressEventPhaseBuild = "build"
|
||||
StepProgressEventPhaseRun = "run"
|
||||
StepProgressEventPhaseReport = "report"
|
||||
)
|
||||
|
||||
// WantsByWantNodeModuleValue is one value of the state wants under the key want.<node>.<module>.
|
||||
type WantsByWantNodeModuleValue struct {
|
||||
// again or skip
|
||||
Backup string `json:"backup,omitempty"`
|
||||
Composed string `json:"composed,omitempty"`
|
||||
Fp string `json:"fp,omitempty"`
|
||||
Hold bool `json:"hold,omitempty"`
|
||||
// for a kept build, the build node that keeps it, from the builder's build.ended; the node-engine fetches the build through that node's seat verb kept-artifact, and a want with none from the store (design 47 G section 526)
|
||||
KeptOn string `json:"kept-on,omitempty"`
|
||||
Newest string `json:"newest,omitempty"`
|
||||
// the digest of each of the module's parts, by `<module>:<artifact>`; the node-engine fetches and checks each part by it (design 47 G section 379)
|
||||
Parts map[string]string `json:"parts,omitempty"`
|
||||
Put bool `json:"put,omitempty"`
|
||||
Release string `json:"release,omitempty"`
|
||||
Removed bool `json:"removed,omitempty"`
|
||||
// the rule that holds the node back, 1 to 10
|
||||
Rule int64 `json:"rule,omitempty"`
|
||||
Self bool `json:"self,omitempty"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
// the module's released version, for people; none for a build of another watched branch (design 47 G section 379)
|
||||
Version string `json:"version,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
Yes string `json:"yes,omitempty"`
|
||||
}
|
||||
|
||||
// The values of WantsByWantNodeModuleValue's backup.
|
||||
const (
|
||||
WantsByWantNodeModuleValueBackupAgain = "again"
|
||||
WantsByWantNodeModuleValueBackupSkip = "skip"
|
||||
)
|
||||
|
||||
// WantsByWantNodeNodeValue is one value of the state wants under the key want.<node>.node.
|
||||
type WantsByWantNodeNodeValue struct {
|
||||
Composed string `json:"composed"`
|
||||
Self bool `json:"self,omitempty"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// WantsByHeldModuleFingerprintValue is one value of the state wants under the key held.<module>.<fingerprint>.
|
||||
type WantsByHeldModuleFingerprintValue struct {
|
||||
Node string `json:"node"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// DifferencesByNodeModuleValue is one value of the state differences under the key <node>.<module>.
|
||||
type DifferencesByNodeModuleValue struct {
|
||||
Rule int64 `json:"rule,omitempty"`
|
||||
Sent string `json:"sent,omitempty"`
|
||||
SentBuild string `json:"sent-build,omitempty"`
|
||||
Unexplained bool `json:"unexplained,omitempty"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
Want string `json:"want,omitempty"`
|
||||
WantRemoved bool `json:"want-removed,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// CompositionsByGroupHeadsValue is one value of the state compositions under the key <group>.<heads>.
|
||||
type CompositionsByGroupHeadsValue struct {
|
||||
Group string `json:"group"`
|
||||
// 12 lowercase hex digits
|
||||
Heads string `json:"heads"`
|
||||
Machine string `json:"machine,omitempty"`
|
||||
Machines []string `json:"machines,omitempty"`
|
||||
Sdk string `json:"sdk,omitempty"`
|
||||
// pass, fail or waits
|
||||
State string `json:"state"`
|
||||
// milliseconds
|
||||
Took int64 `json:"took,omitempty"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
Warnings []string `json:"warnings,omitempty"`
|
||||
Words string `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// AssignmentRevisionsByTrunkRevisionValue is one value of the state assignment-revisions under the key trunk.<revision>.
|
||||
type AssignmentRevisionsByTrunkRevisionValue = AssignmentRevision
|
||||
|
||||
// AssignmentRevisionsByCandidateGroupHeadsValue is one value of the state assignment-revisions under the key candidate.<group>.<heads>.
|
||||
type AssignmentRevisionsByCandidateGroupHeadsValue = AssignmentRevision
|
||||
|
||||
// AssignmentRevisionsByEntryDigestValue is one value of the state assignment-revisions under the key entry.<digest>.
|
||||
type AssignmentRevisionsByEntryDigestValue = AssignmentEntry
|
||||
|
||||
// InputsByTimeDigestValue is one value of the state inputs under the key <time>.<digest>.
|
||||
type InputsByTimeDigestValue = string
|
||||
@@ -1,164 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package meshwants
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/mesh-wants/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "an assignment graph revision kept", subject: "mesh.seat.mesh-wants.event.assignment-revision", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"catalogs\":[{\"branch\":\"main\",\"revision\":12,\"source\":3589}],\"cause\":\"placement-changed\",\"kind\":\"trunk\",\"revision\":40,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"catalogs\":[{\"branch\":\"main\",\"revision\":12,\"source\":3589}],\"cause\":\"placement-changed\",\"kind\":\"trunk\",\"revision\":40,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v AssignmentRevisionEvent
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.assignment-revision$")},
|
||||
{name: "a difference worked out", subject: "mesh.seat.mesh-wants.event.difference", given: "{\"changes\":1,\"from\":40,\"nodes\":[\"n1\"],\"source\":3589,\"to\":41,\"v\":1}", wire: "{\"changes\":1,\"from\":40,\"nodes\":[\"n1\"],\"source\":3589,\"to\":41,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v DifferenceEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.difference$")},
|
||||
{name: "an entry wanted from a trunk revision", subject: "mesh.seat.mesh-wants.event.wanted.n1.xclip", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"revision\":40,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"revision\":40,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v WantedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wanted\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a want removed, its node left or its module unplaced", subject: "mesh.seat.mesh-wants.event.wanted.n1.xclip", given: "{\"at\":\"2026-11-09T19:05:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"removed\":true,\"revision\":41,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:05:00Z\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"removed\":true,\"revision\":41,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v WantedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wanted\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||
{name: "a composing wait held with its bound", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"30m\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}", wire: "{\"bound\":\"30m\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-held$")},
|
||||
{name: "a wait ended, released by hand", subject: "mesh.seat.mesh-wants.event.wait-ended", given: "{\"bound\":\"30m\",\"by\":\"lead@shanks: the node is away\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"how\":\"released\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}", wire: "{\"bound\":\"30m\",\"by\":\"lead@shanks: the node is away\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"how\":\"released\",\"module\":\"xclip\",\"node\":\"n1\",\"part\":\"node-engine\",\"since\":\"2026-11-09T19:00:00Z\",\"step\":\"compose\",\"version\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-ended$")},
|
||||
{name: "the store past 80 % of its cap", subject: "mesh.seat.mesh-wants.event.filling", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":450000000,\"cap\":536870912,\"store\":\"assignment-revisions\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":450000000,\"cap\":536870912,\"store\":\"assignment-revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v FillingEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.filling$")},
|
||||
{name: "the store full, keeping its last revision", subject: "mesh.seat.mesh-wants.event.full", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":536870912,\"cap\":536870912,\"refused\":\"the next revision; no new want is written\",\"store\":\"assignment-revisions\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":536870912,\"cap\":536870912,\"refused\":\"the next revision; no new want is written\",\"store\":\"assignment-revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v FullEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.full$")},
|
||||
{name: "the store back below its cap", subject: "mesh.seat.mesh-wants.event.room", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":300000000,\"cap\":536870912,\"store\":\"assignment-revisions\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"bytes\":300000000,\"cap\":536870912,\"store\":\"assignment-revisions\"}",
|
||||
decode: func(b []byte) (any, error) { var v RoomEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.room$")},
|
||||
{name: "the composition step ended passed on the assigner's node, a node asleep warned", subject: "mesh.seat.mesh-wants.event.step-ended.novox", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:01:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6a\",\"module\":\"nats\",\"node\":\"novox\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"composition\",\"v\":1,\"warnings\":[\"g14 asleep: composed from its last capabilities\"]}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:01:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6a\",\"module\":\"nats\",\"node\":\"novox\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"composition\",\"v\":1,\"warnings\":[\"g14 asleep: composed from its last capabilities\"]}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "the composition step failed, two modules owning one path", subject: "mesh.seat.mesh-wants.event.step-ended.novox", given: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6b\",\"module\":\"nats\",\"node\":\"novox\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats and xclip both own /etc/nats.conf on ace\",\"step\":\"composition\",\"v\":1}", wire: "{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6b\",\"module\":\"nats\",\"node\":\"novox\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats and xclip both own /etc/nats.conf on ace\",\"step\":\"composition\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "a version delivered with the machines away", subject: "mesh.seat.mesh-wants.event.version-delivered", given: "{\"away\":[\"laptop\"],\"module\":\"mesh-sdk\",\"parts\":{\"mesh-sdk:go\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"away\":[\"laptop\"],\"module\":\"mesh-sdk\",\"parts\":{\"mesh-sdk:go\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) { var v VersionDeliveredEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.version-delivered$")},
|
||||
{name: "a composition step's progress", subject: "mesh.seat.mesh-wants.event.step-progress.ace", given: "{\"ask\":\"a1b2\",\"asker\":\"assigner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"build\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"assigner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"build\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.step-progress\\.[^.*> ]+$")},
|
||||
{name: "a put without hold waits, counted from its start", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"ace\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"put\"}", wire: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"ace\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"put\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-held$")},
|
||||
{name: "a dependent's delivery waits for a dependency's version", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"60m\",\"clock-from\":\"2026-11-11T09:58:00Z\",\"machines\":[\"ace\",\"g14\"],\"module\":\"nats\",\"part\":\"mesh-sdk\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"delivery\",\"version\":\"0.1.4\"}", wire: "{\"bound\":\"60m\",\"clock-from\":\"2026-11-11T09:58:00Z\",\"machines\":[\"ace\",\"g14\"],\"module\":\"nats\",\"part\":\"mesh-sdk\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"delivery\",\"version\":\"0.1.4\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-held$")},
|
||||
{name: "the builder's toolchain wait held, in the contract's words", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"src2:aaaa\",\"module\":\"mesh-sdk\",\"on\":\"toolchain\",\"owner\":\"mesh-delivery-builder\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"build\",\"words\":\"waits for the Go build seat to report its toolchain\"}", wire: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"src2:aaaa\",\"module\":\"mesh-sdk\",\"on\":\"toolchain\",\"owner\":\"mesh-delivery-builder\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"build\",\"words\":\"waits for the Go build seat to report its toolchain\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-held$")},
|
||||
{name: "the builder's toolchain wait ended by a newer fingerprint", subject: "mesh.seat.mesh-wants.event.wait-ended", given: "{\"fingerprint\":\"src2:aaaa\",\"how\":\"superseded\",\"module\":\"mesh-sdk\",\"on\":\"toolchain\",\"owner\":\"mesh-delivery-builder\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"build\"}", wire: "{\"fingerprint\":\"src2:aaaa\",\"how\":\"superseded\",\"module\":\"mesh-sdk\",\"on\":\"toolchain\",\"owner\":\"mesh-delivery-builder\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"build\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-ended$")},
|
||||
{name: "an outside wait held on a hub's silence, counted from its first start", subject: "mesh.seat.mesh-wants.event.wait-held", given: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"src2:aaaa\",\"module\":\"nats\",\"node\":\"ace\",\"on\":\"silent:g14\",\"owner\":\"mesh-delivery-assigner\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"outside\"}", wire: "{\"bound\":\"30m\",\"clock-from\":\"2026-11-11T10:00:00Z\",\"fingerprint\":\"src2:aaaa\",\"module\":\"nats\",\"node\":\"ace\",\"on\":\"silent:g14\",\"owner\":\"mesh-delivery-assigner\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"outside\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-held$")},
|
||||
{name: "an outside wait ended by the operator's Go on", subject: "mesh.seat.mesh-wants.event.wait-ended", given: "{\"fingerprint\":\"src2:aaaa\",\"how\":\"go-on\",\"module\":\"nats\",\"node\":\"ace\",\"on\":\"silent:g14\",\"owner\":\"mesh-delivery-assigner\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"outside\"}", wire: "{\"fingerprint\":\"src2:aaaa\",\"how\":\"go-on\",\"module\":\"nats\",\"node\":\"ace\",\"on\":\"silent:g14\",\"owner\":\"mesh-delivery-assigner\",\"since\":\"2026-11-11T10:00:00Z\",\"step\":\"outside\"}",
|
||||
decode: func(b []byte) (any, error) { var v WaitEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.event\\.wait-ended$")},
|
||||
{name: "a want", subject: "", given: "{\"fp\":\"ab12\",\"rule\":3,\"v\":1}", wire: "{\"fp\":\"ab12\",\"rule\":3,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v WantsByWantNodeModuleValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a want for a kept build, naming the node that keeps it", subject: "", given: "{\"fp\":\"ab12\",\"kept-on\":\"n1\",\"parts\":{\"x:image\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"fp\":\"ab12\",\"kept-on\":\"n1\",\"parts\":{\"x:image\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"},\"v\":1,\"version\":\"0.1.15\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v WantsByWantNodeModuleValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's own want", subject: "", given: "{\"composed\":\"sha256:aa\",\"self\":true,\"v\":1}", wire: "{\"composed\":\"sha256:aa\",\"self\":true,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v WantsByWantNodeNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a held fingerprint", subject: "", given: "{\"node\":\"ace\",\"v\":1}", wire: "{\"node\":\"ace\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v WantsByHeldModuleFingerprintValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a difference", subject: "", given: "{\"unexplained\":true,\"v\":1,\"want\":\"ab12\"}", wire: "{\"unexplained\":true,\"v\":1,\"want\":\"ab12\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v DifferencesByNodeModuleValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a composition", subject: "", given: "{\"group\":\"g1\",\"heads\":\"0123456789ab\",\"state\":\"pass\",\"v\":1}", wire: "{\"group\":\"g1\",\"heads\":\"0123456789ab\",\"state\":\"pass\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CompositionsByGroupHeadsValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a trunk assignment graph revision naming its inputs", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"capabilities\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"node\":\"n1\"}],\"catalogs\":[{\"branch\":\"main\",\"revision\":12,\"source\":3589}],\"cause\":\"catalog-revision\",\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}],\"kind\":\"trunk\",\"placements\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"revision\":40,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"capabilities\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"node\":\"n1\"}],\"catalogs\":[{\"branch\":\"main\",\"revision\":12,\"source\":3589}],\"cause\":\"catalog-revision\",\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}],\"kind\":\"trunk\",\"placements\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"revision\":40,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v AssignmentRevisionsByTrunkRevisionValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a candidate's assignment graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"capabilities\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"node\":\"n1\"}],\"catalogs\":[{\"branch\":\"main\",\"revision\":13,\"source\":3589}],\"cause\":\"catalog-revision\",\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"placements\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"revision\":41,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"capabilities\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"node\":\"n1\"}],\"catalogs\":[{\"branch\":\"main\",\"revision\":13,\"source\":3589}],\"cause\":\"catalog-revision\",\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"placements\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"revision\":41,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v AssignmentRevisionsByCandidateGroupHeadsValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "an assignment entry with an acting edge and a provisioning edge", subject: "", given: "{\"branch\":\"main\",\"catalog\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"edges\":[{\"bound\":\"30m\",\"fp\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\",\"kind\":\"acting\",\"module\":\"node-engine\",\"node\":\"n1\",\"seat\":\"node-engine\",\"step\":\"compose\"},{\"kind\":\"provisioning\",\"module\":\"postgres\",\"node\":\"n2\",\"provision\":\"database\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"v\":1}", wire: "{\"branch\":\"main\",\"catalog\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"edges\":[{\"bound\":\"30m\",\"fp\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\",\"kind\":\"acting\",\"module\":\"node-engine\",\"node\":\"n1\",\"seat\":\"node-engine\",\"step\":\"compose\"},{\"kind\":\"provisioning\",\"module\":\"postgres\",\"node\":\"n2\",\"provision\":\"database\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v AssignmentRevisionsByEntryDigestValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "revision asks the trunk's newest", subject: "", given: "{}", wire: "{}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "revision asks a candidate's", subject: "", given: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\"}", wire: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\"}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "revision answers one revision naming its inputs", subject: "", given: "{\"revision\":{\"at\":\"2026-11-09T19:00:00Z\",\"capabilities\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"node\":\"n1\"}],\"catalogs\":[{\"branch\":\"main\",\"revision\":12,\"source\":3589}],\"cause\":\"catalog-revision\",\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}],\"kind\":\"trunk\",\"placements\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"revision\":40,\"v\":1}}", wire: "{\"revision\":{\"at\":\"2026-11-09T19:00:00Z\",\"capabilities\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"node\":\"n1\"}],\"catalogs\":[{\"branch\":\"main\",\"revision\":12,\"source\":3589}],\"cause\":\"catalog-revision\",\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}],\"kind\":\"trunk\",\"placements\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"revision\":40,\"v\":1}}",
|
||||
decode: func(b []byte) (any, error) { var v RevisionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "entry asks by node and module in a revision", subject: "", given: "{\"module\":\"xclip\",\"node\":\"n1\",\"revision\":40}", wire: "{\"module\":\"xclip\",\"node\":\"n1\",\"revision\":40}",
|
||||
decode: func(b []byte) (any, error) { var v EntryInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "entry answers the entry with its edges", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"entry\":{\"branch\":\"main\",\"catalog\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"edges\":[{\"bound\":\"30m\",\"fp\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\",\"kind\":\"acting\",\"module\":\"node-engine\",\"node\":\"n1\",\"seat\":\"node-engine\",\"step\":\"compose\"},{\"kind\":\"provisioning\",\"module\":\"postgres\",\"node\":\"n2\",\"provision\":\"database\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"v\":1}}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"entry\":{\"branch\":\"main\",\"catalog\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"edges\":[{\"bound\":\"30m\",\"fp\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\",\"kind\":\"acting\",\"module\":\"node-engine\",\"node\":\"n1\",\"seat\":\"node-engine\",\"step\":\"compose\"},{\"kind\":\"provisioning\",\"module\":\"postgres\",\"node\":\"n2\",\"provision\":\"database\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"v\":1}}",
|
||||
decode: func(b []byte) (any, error) { var v EntryAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "difference asks a candidate's against trunk", subject: "", given: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\"}", wire: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\"}",
|
||||
decode: func(b []byte) (any, error) { var v DifferenceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "difference answers the changes and their order", subject: "", given: "{\"changes\":[{\"from\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"to\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}],\"from\":40,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"nodes\":[\"n1\"],\"tiers\":[[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}]],\"to\":41}", wire: "{\"changes\":[{\"from\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"module\":\"xclip\",\"node\":\"n1\",\"to\":\"src2:7dd0db8e98224f46121a5ae05c0b9c5a430eff531a5120aa40b1a59237853a3f\"}],\"from\":40,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"nodes\":[\"n1\"],\"tiers\":[[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\",\"node\":\"n1\"}]],\"to\":41}",
|
||||
decode: func(b []byte) (any, error) { var v DifferenceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "difference refuses a changed fingerprint with no difference, by name", subject: "", given: "{\"changes\":[],\"from\":40,\"refused\":[{\"module\":\"xclip\",\"why\":\"its fingerprint changed and its difference is empty\"}],\"to\":41}", wire: "{\"changes\":[],\"from\":40,\"refused\":[{\"module\":\"xclip\",\"why\":\"its fingerprint changed and its difference is empty\"}],\"to\":41}",
|
||||
decode: func(b []byte) (any, error) { var v DifferenceAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a composition step asked by the runner", subject: "mesh.seat.mesh-wants.accept.step", given: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}", wire: "{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"source\":3589,\"step\":\"composition\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-wants\\.accept\\.step$")},
|
||||
{name: "input asks a composition step's input by digest", subject: "", given: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}", wire: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"}",
|
||||
decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "input answers the exact bytes", subject: "", given: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"input\":\"eyJ2IjoxfQ==\"}", wire: "{\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"input\":\"eyJ2IjoxfQ==\"}",
|
||||
decode: func(b []byte) (any, error) { var v InputAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants
|
||||
|
||||
go 1.26.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,150 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package nodebuildgo
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/node-build-go/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a unit step ended passed on its node, with its counts and what it carried", subject: "mesh.seat.node-build-go.event.step-ended.ace", given: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"carried\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\"}],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:02:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5e\",\"kept\":[{\"digest\":\"sha256:cccc\",\"level\":\"unit\",\"package\":\"./modules/nats/b\"}],\"module\":\"nats\",\"node\":\"ace\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"unit\",\"tests\":{\"unit\":14},\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"carried\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\"}],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:02:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5e\",\"kept\":[{\"digest\":\"sha256:cccc\",\"level\":\"unit\",\"package\":\"./modules/nats/b\"}],\"module\":\"nats\",\"node\":\"ace\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"unit\",\"tests\":{\"unit\":14},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "an integration step that could not run, naming the part not heard", subject: "mesh.seat.node-build-go.event.step-ended.g14", given: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5f\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5f\",\"module\":\"nats\",\"node\":\"g14\",\"outcome\":\"could not run\",\"output-object\":\"mesh-build-go_sent-objects/m2kx9a1b3c4d5f\",\"pipeline\":\"main.12.nats\",\"said\":\"the sandbox could not fetch novox/mesh-sdk\",\"step\":\"integration\",\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5f\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5f\",\"module\":\"nats\",\"node\":\"g14\",\"outcome\":\"could not run\",\"output-object\":\"mesh-build-go_sent-objects/m2kx9a1b3c4d5f\",\"pipeline\":\"main.12.nats\",\"said\":\"the sandbox could not fetch novox/mesh-sdk\",\"step\":\"integration\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "a node's toolchain reported", subject: "mesh.seat.node-build-go.event.toolchain-reported.ace", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"ace\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"ace\",\"recipe\":\"1\",\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) { var v ToolchainReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.toolchain-reported\\.[^.*> ]+$")},
|
||||
{name: "a running ask says its progress", subject: "mesh.seat.node-build-go.event.step-progress.ace", given: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.step-progress\\.[^.*> ]+$")},
|
||||
{name: "a builder's build ended, naming its asker and no commit or fingerprint (G 548)", subject: "mesh.seat.node-build-go.event.step-ended.ace", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"ace\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"ace\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "an ask taken, whatever its asker (G 602)", subject: "mesh.seat.node-build-go.event.ask-taken.ace", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:00:00Z\",\"node\":\"ace\"}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:00:00Z\",\"node\":\"ace\"}",
|
||||
decode: func(b []byte) (any, error) { var v AskTakenEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.event\\.ask-taken\\.[^.*> ]+$")},
|
||||
{name: "a running step", subject: "", given: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}", wire: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a paused node", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"operator@shanks\",\"paused\":true,\"v\":1}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"operator@shanks\",\"paused\":true,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PausesByPausedNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's capacity", subject: "", given: "{\"configured\":2,\"effective\":2,\"v\":1,\"why\":\"the configured steps fit the cores\"}", wire: "{\"configured\":2,\"effective\":2,\"v\":1,\"why\":\"the configured steps fit the cores\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PausesByCapacityNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's toolchain", subject: "", given: "{\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ToolchainsByNodeLanguageValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's toolchain with its program's digest (G 472)", subject: "", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ToolchainsByNodeLanguageValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a build ask", subject: "mesh.seat.node-build-go.accept.delivery", given: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b2\",\"kind\":\"build\",\"language\":\"go\"}", wire: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b2\",\"kind\":\"build\",\"language\":\"go\"}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.delivery$")},
|
||||
{name: "a build ask with the version the builder reserved (G 573)", subject: "mesh.seat.node-build-go.accept.delivery", given: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b3\",\"kind\":\"build\",\"language\":\"go\",\"version\":\"1.4.2\"}", wire: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b3\",\"kind\":\"build\",\"language\":\"go\",\"version\":\"1.4.2\"}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.delivery$")},
|
||||
{name: "a check ask with its fetch, siblings and levels", subject: "mesh.seat.node-build-go.accept.check", given: "{\"asker\":\"mesh-delivery-checker\",\"at\":\"2026-11-05T10:00:00Z\",\"check\":{\"fetch\":{\"base\":\"89abcdef0123456789abcdef0123456789abcdef\",\"beside\":[{\"commit\":\"fedcba9876543210fedcba9876543210fedcba98\",\"repository\":\"novox/mesh-sdk\"}],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"fedcba9876543210fedcba9876543210fedcba98\"},\"ref\":\"refs/pull/7/head\",\"repository\":\"novox/mesh-catalog\"},\"kept\":true,\"levels\":[\"unit\",\"integration\"],\"node-names\":[\"ace\",\"g14\"],\"toolchain\":{\"language\":\"go\",\"recipe\":\"2\",\"version\":\"1.26.0\"}},\"id\":\"c3d4\",\"kind\":\"check\",\"language\":\"go\",\"v\":1}", wire: "{\"asker\":\"mesh-delivery-checker\",\"at\":\"2026-11-05T10:00:00Z\",\"check\":{\"fetch\":{\"base\":\"89abcdef0123456789abcdef0123456789abcdef\",\"beside\":[{\"commit\":\"fedcba9876543210fedcba9876543210fedcba98\",\"repository\":\"novox/mesh-sdk\"}],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"fedcba9876543210fedcba9876543210fedcba98\"},\"ref\":\"refs/pull/7/head\",\"repository\":\"novox/mesh-catalog\"},\"kept\":true,\"levels\":[\"unit\",\"integration\"],\"node-names\":[\"ace\",\"g14\"],\"toolchain\":{\"language\":\"go\",\"recipe\":\"2\",\"version\":\"1.26.0\"}},\"id\":\"c3d4\",\"kind\":\"check\",\"language\":\"go\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.check$")},
|
||||
{name: "a finished build step with its artifacts", subject: "", given: "{\"ended\":\"2026-11-05T10:03:00Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"result\":{\"artifacts\":[{\"artifact\":\"go\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reference\":\"container-image-registry/nats/go@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}],\"imports\":[\"git.novox.be/novox/mesh-sdk/go\"],\"toolchain\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"build\",\"v\":1}", wire: "{\"ended\":\"2026-11-05T10:03:00Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"result\":{\"artifacts\":[{\"artifact\":\"go\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reference\":\"container-image-registry/nats/go@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}],\"imports\":[\"git.novox.be/novox/mesh-sdk/go\"],\"toolchain\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a finished build step that kept its artifact on its node", subject: "", given: "{\"ended\":\"2026-11-05T10:03:00Z\",\"id\":\"a1b3\",\"node\":\"ace\",\"result\":{\"artifacts\":[{\"artifact\":\"go\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reference\":\"container-image-registry/nats/go@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}],\"imports\":[\"git.novox.be/novox/mesh-sdk/go\"],\"kept\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"toolchain\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"build\",\"v\":1}", wire: "{\"ended\":\"2026-11-05T10:03:00Z\",\"id\":\"a1b3\",\"node\":\"ace\",\"result\":{\"artifacts\":[{\"artifact\":\"go\",\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reference\":\"container-image-registry/nats/go@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}],\"imports\":[\"git.novox.be/novox/mesh-sdk/go\"],\"kept\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"toolchain\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a finished check step with its levels", subject: "", given: "{\"ended\":\"2026-11-05T10:06:00Z\",\"id\":\"c3d4\",\"node\":\"ace\",\"result\":{\"fetch\":{\"base\":\"abcdef0123456789abcdef0123456789abcdef01\",\"changed\":[\"a.go\",\"modules/m/main.go\"],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"merge\":\"fedcba9876543210fedcba9876543210fedcba98\",\"modules\":[\".\"],\"trees\":{\"modules/m\":{\"locks\":{\"go.sum\":\"c5fc83c01e92404452b986527d239140ccf9a48b88e0c268fbf38c2e1429e9c9\"},\"manifest\":\"ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356\",\"tree\":\"1111111111111111111111111111111111111111\"}},\"workspace\":\"mvii1iwu5414e4\"},\"levels\":[{\"digest\":{\"level\":\"unit\",\"packages\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"package\":\"./modules/a\"}]},\"kept\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"package\":\"./modules/a\",\"tests\":12}],\"level\":\"unit\",\"tests\":[{\"package\":\"./modules/b\",\"pass\":true}],\"unmet\":[{\"needs\":[\"docker\"],\"package\":\"./modules/c\"}]}]},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"check\",\"v\":1}", wire: "{\"ended\":\"2026-11-05T10:06:00Z\",\"id\":\"c3d4\",\"node\":\"ace\",\"result\":{\"fetch\":{\"base\":\"abcdef0123456789abcdef0123456789abcdef01\",\"changed\":[\"a.go\",\"modules/m/main.go\"],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"merge\":\"fedcba9876543210fedcba9876543210fedcba98\",\"modules\":[\".\"],\"trees\":{\"modules/m\":{\"locks\":{\"go.sum\":\"c5fc83c01e92404452b986527d239140ccf9a48b88e0c268fbf38c2e1429e9c9\"},\"manifest\":\"ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356\",\"tree\":\"1111111111111111111111111111111111111111\"}},\"workspace\":\"mvii1iwu5414e4\"},\"levels\":[{\"digest\":{\"level\":\"unit\",\"packages\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"package\":\"./modules/a\"}]},\"kept\":[{\"digest\":\"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"package\":\"./modules/a\",\"tests\":12}],\"level\":\"unit\",\"tests\":[{\"package\":\"./modules/b\",\"pass\":true}],\"unmet\":[{\"needs\":[\"docker\"],\"package\":\"./modules/c\"}]}]},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"check\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a declined step", subject: "", given: "{\"id\":\"c3d5\",\"node\":\"ace\",\"result\":{\"declined\":true,\"lacks\":[\"docker\"],\"needs\":[\"docker\"]},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"refused\",\"tool\":\"check\",\"v\":1}", wire: "{\"id\":\"c3d5\",\"node\":\"ace\",\"result\":{\"declined\":true,\"lacks\":[\"docker\"],\"needs\":[\"docker\"]},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"refused\",\"tool\":\"check\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a finished check step whose head does not merge", subject: "", given: "{\"ended\":\"2026-11-05T10:01:00Z\",\"id\":\"c3d5\",\"node\":\"ace\",\"result\":{\"fetch\":{\"base\":\"abcdef0123456789abcdef0123456789abcdef01\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"conflicts\":[\"a.go\",\"sub/b.go\"],\"modules\":[\".\"],\"workspace\":\"mvii1iwz5050eb\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"check\",\"v\":1}", wire: "{\"ended\":\"2026-11-05T10:01:00Z\",\"id\":\"c3d5\",\"node\":\"ace\",\"result\":{\"fetch\":{\"base\":\"abcdef0123456789abcdef0123456789abcdef01\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"conflicts\":[\"a.go\",\"sub/b.go\"],\"modules\":[\".\"],\"workspace\":\"mvii1iwz5050eb\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"check\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a run ask of the checking program over two heads", subject: "mesh.seat.node-build-go.accept.check", given: "{\"asker\":\"mesh-delivery-checker\",\"at\":\"2026-11-05T10:00:00Z\",\"id\":\"r5e6\",\"kind\":\"check\",\"language\":\"go\",\"run\":{\"args\":[\"-verdict\"],\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\"}],\"input\":{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"size\":7,\"verb\":\"seat:mesh-delivery-checker.input\"},\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"},\"reader\":\"checking program of mesh-delivery head\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-checker\",\"at\":\"2026-11-05T10:00:00Z\",\"id\":\"r5e6\",\"kind\":\"check\",\"language\":\"go\",\"run\":{\"args\":[\"-verdict\"],\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\"}],\"input\":{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"size\":7,\"verb\":\"seat:mesh-delivery-checker.input\"},\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"},\"reader\":\"checking program of mesh-delivery head\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.check$")},
|
||||
{name: "a finished run step whose program exited non-zero", subject: "", given: "{\"ended\":\"2026-11-05T10:01:00Z\",\"id\":\"r5e6\",\"node\":\"ace\",\"result\":{\"built\":true,\"exit\":2,\"key\":\"program-0123456789abcdef\",\"said\":\"the facts name no head\"},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"failed\",\"tool\":\"check\",\"v\":1}", wire: "{\"ended\":\"2026-11-05T10:01:00Z\",\"id\":\"r5e6\",\"node\":\"ace\",\"result\":{\"built\":true,\"exit\":2,\"key\":\"program-0123456789abcdef\",\"said\":\"the facts name no head\"},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"failed\",\"tool\":\"check\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a step ended on a transport fault, given again by the bus", subject: "", given: "{\"again-at\":\"2026-11-05T10:01:30Z\",\"ended\":\"2026-11-05T10:00:30Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"passing\":true,\"reason\":\"fetching the commit: kex_exchange_identification: read: Connection reset by peer\",\"run\":1,\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"again\",\"tool\":\"build\",\"v\":1}", wire: "{\"again-at\":\"2026-11-05T10:01:30Z\",\"ended\":\"2026-11-05T10:00:30Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"passing\":true,\"reason\":\"fetching the commit: kex_exchange_identification: read: Connection reset by peer\",\"run\":1,\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"again\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an ask dropped by the caller that no longer waits", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"mesh-delivery-builder\",\"v\":1,\"why\":\"a newer fingerprint supersedes it\"}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"mesh-delivery-builder\",\"v\":1,\"why\":\"a newer fingerprint supersedes it\"}",
|
||||
decode: func(b []byte) (any, error) { var v PausesByDroppedIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a step ask of the runner with its kept results", subject: "mesh.seat.node-build-go.accept.check.step", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"go\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"go\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckStepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.check\\.step$")},
|
||||
{name: "a recovery's step ask of the runner, on the stream delivery", subject: "mesh.seat.node-build-go.accept.delivery.step", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"go\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"go\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryStepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.delivery\\.step$")},
|
||||
{name: "a run ask of the runner, the program built from the change and run over its heads", subject: "mesh.seat.node-build-go.accept.check.run", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-05T10:00:00Z\",\"id\":\"r5e6\",\"kind\":\"run\",\"language\":\"go\",\"run\":{\"args\":[\"-verdict\"],\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\"}],\"input\":{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"size\":7,\"verb\":\"seat:mesh-delivery-checker.input\"},\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"},\"reader\":\"checking program of mesh-delivery head\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-05T10:00:00Z\",\"id\":\"r5e6\",\"kind\":\"run\",\"language\":\"go\",\"run\":{\"args\":[\"-verdict\"],\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-sdk\"}],\"input\":{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"size\":7,\"verb\":\"seat:mesh-delivery-checker.input\"},\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"},\"reader\":\"checking program of mesh-delivery head\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckRunAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-go\\.accept\\.check\\.run$")},
|
||||
{name: "an artifact's detected steps", subject: "", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats/a\"],\"step\":\"unit\"}],\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats/a\"],\"step\":\"unit\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v DetectedStepsByModuleArtifactValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a step keyed under its asker", subject: "", given: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}", wire: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v StepsByAskerNodeIDValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "drop names the ask and why", subject: "", given: "{\"by\":\"mesh-delivery-builder\",\"id\":\"a1b2\",\"why\":\"a newer fingerprint supersedes it\"}", wire: "{\"by\":\"mesh-delivery-builder\",\"id\":\"a1b2\",\"why\":\"a newer fingerprint supersedes it\"}",
|
||||
decode: func(b []byte) (any, error) { var v DropInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact asks", subject: "", given: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}", wire: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact answers where the bytes are", subject: "", given: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"object\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"size\":18874368,\"store\":\"mesh-build-go-kept\"}", wire: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"object\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"size\":18874368,\"store\":\"mesh-build-go-kept\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a module that is claims no oci-artifact-registry", subject: "", given: "{\"fp\":\"src2:aaaaaaaa\",\"module\":\"mesh-delivery-gate\",\"refused\":\"claims no oci-artifact-registry\",\"words\":\"mesh-delivery-gate claims no oci-artifact-registry: its build is fetched from the store\"}", wire: "{\"fp\":\"src2:aaaaaaaa\",\"module\":\"mesh-delivery-gate\",\"refused\":\"claims no oci-artifact-registry\",\"words\":\"mesh-delivery-gate claims no oci-artifact-registry: its build is fetched from the store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a build it no longer keeps", subject: "", given: "{\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"not kept\",\"words\":\"this node keeps no build of artifact-store at src2:1480985e\"}", wire: "{\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"not kept\",\"words\":\"this node keeps no build of artifact-store at src2:1480985e\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a build kept under another digest", subject: "", given: "{\"digest\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"digest differs\",\"words\":\"artifact-store at src2:1480985e is kept as eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", wire: "{\"digest\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"digest differs\",\"words\":\"artifact-store at src2:1480985e is kept as eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact answers an error, never none", subject: "", given: "{\"error\":\"the kept builds could not be read\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}", wire: "{\"error\":\"the kept builds could not be read\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps asks an artifact's pipeline steps at a commit", subject: "", given: "{\"artifact\":\"nats:program\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}", wire: "{\"artifact\":\"nats:program\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers lint and unit tests", subject: "", given: "{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats\"],\"step\":\"unit\"}]}", wire: "{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats\"],\"step\":\"unit\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps drops an artifact's kept steps with a reason", subject: "", given: "{\"artifact\":\"nats.program\",\"drop\":true,\"module\":\"nats\",\"why\":\"the detection was wrong\"}", wire: "{\"artifact\":\"nats.program\",\"drop\":true,\"module\":\"nats\",\"why\":\"the detection was wrong\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers a drop with the artifact", subject: "", given: "{\"dropped\":\"nats.program\"}", wire: "{\"dropped\":\"nats.program\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers a drop that the hand-act log refused", subject: "", given: "{\"error\":\"the hand-act log refused: nothing was deleted\"}", wire: "{\"error\":\"the hand-act log refused: nothing was deleted\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildgo
|
||||
|
||||
go 1.26.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,132 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package nodebuildimage
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/node-build-image/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a lint step ended passed on its node", subject: "mesh.seat.node-build-image.event.step-ended.ace", given: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:02:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5e\",\"module\":\"nats\",\"node\":\"ace\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"lint\",\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:02:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5e\",\"module\":\"nats\",\"node\":\"ace\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"lint\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "a lint step that could not run, naming the part not heard", subject: "mesh.seat.node-build-image.event.step-ended.g14", given: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5f\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5f\",\"module\":\"nats\",\"node\":\"g14\",\"outcome\":\"could not run\",\"output-object\":\"mesh-build-go_sent-objects/m2kx9a1b3c4d5f\",\"pipeline\":\"main.12.nats\",\"said\":\"the sandbox could not fetch novox/mesh-sdk\",\"step\":\"lint\",\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5f\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5f\",\"module\":\"nats\",\"node\":\"g14\",\"outcome\":\"could not run\",\"output-object\":\"mesh-build-go_sent-objects/m2kx9a1b3c4d5f\",\"pipeline\":\"main.12.nats\",\"said\":\"the sandbox could not fetch novox/mesh-sdk\",\"step\":\"lint\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "a node's toolchain reported", subject: "mesh.seat.node-build-image.event.toolchain-reported.ace", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"ace\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"ace\",\"recipe\":\"1\",\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) { var v ToolchainReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.event\\.toolchain-reported\\.[^.*> ]+$")},
|
||||
{name: "a running ask says its progress", subject: "mesh.seat.node-build-image.event.step-progress.ace", given: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.event\\.step-progress\\.[^.*> ]+$")},
|
||||
{name: "a builder's build ended, naming its asker and no commit or fingerprint (G 548)", subject: "mesh.seat.node-build-image.event.step-ended.ace", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"ace\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"ace\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "an ask taken, whatever its asker (G 602)", subject: "mesh.seat.node-build-image.event.ask-taken.ace", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:00:00Z\",\"node\":\"ace\"}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:00:00Z\",\"node\":\"ace\"}",
|
||||
decode: func(b []byte) (any, error) { var v AskTakenEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.event\\.ask-taken\\.[^.*> ]+$")},
|
||||
{name: "a running step", subject: "", given: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}", wire: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a paused node", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"operator@shanks\",\"paused\":true,\"v\":1}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"operator@shanks\",\"paused\":true,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PausesByPausedNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's capacity", subject: "", given: "{\"configured\":2,\"effective\":2,\"v\":1,\"why\":\"the configured steps fit the cores\"}", wire: "{\"configured\":2,\"effective\":2,\"v\":1,\"why\":\"the configured steps fit the cores\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PausesByCapacityNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's toolchain", subject: "", given: "{\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ToolchainsByNodeLanguageValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's toolchain with its program's digest (G 472)", subject: "", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ToolchainsByNodeLanguageValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a build ask", subject: "mesh.seat.node-build-image.accept.delivery", given: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b2\",\"kind\":\"build\",\"language\":\"go\"}", wire: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b2\",\"kind\":\"build\",\"language\":\"go\"}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.accept\\.delivery$")},
|
||||
{name: "a build ask with the version the builder reserved (G 573)", subject: "mesh.seat.node-build-image.accept.delivery", given: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b3\",\"kind\":\"build\",\"language\":\"go\",\"version\":\"1.4.2\"}", wire: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b3\",\"kind\":\"build\",\"language\":\"go\",\"version\":\"1.4.2\"}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.accept\\.delivery$")},
|
||||
{name: "a step ended on a transport fault, given again by the bus", subject: "", given: "{\"again-at\":\"2026-11-05T10:01:30Z\",\"ended\":\"2026-11-05T10:00:30Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"passing\":true,\"reason\":\"fetching the commit: kex_exchange_identification: read: Connection reset by peer\",\"run\":1,\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"again\",\"tool\":\"build\",\"v\":1}", wire: "{\"again-at\":\"2026-11-05T10:01:30Z\",\"ended\":\"2026-11-05T10:00:30Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"passing\":true,\"reason\":\"fetching the commit: kex_exchange_identification: read: Connection reset by peer\",\"run\":1,\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"again\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an ask dropped by the caller that no longer waits", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"mesh-delivery-builder\",\"v\":1,\"why\":\"a newer fingerprint supersedes it\"}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"mesh-delivery-builder\",\"v\":1,\"why\":\"a newer fingerprint supersedes it\"}",
|
||||
decode: func(b []byte) (any, error) { var v PausesByDroppedIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a lint step ask of the runner with the names", subject: "mesh.seat.node-build-image.accept.check.step", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"image\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"lint\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"image\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"lint\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckStepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.accept\\.check\\.step$")},
|
||||
{name: "a recovery's step ask of the runner, on the stream delivery", subject: "mesh.seat.node-build-image.accept.delivery.step", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"image\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"lint\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"image\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"lint\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryStepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-image\\.accept\\.delivery\\.step$")},
|
||||
{name: "an artifact's detected steps", subject: "", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats/a\"],\"step\":\"unit\"}],\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats/a\"],\"step\":\"unit\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v DetectedStepsByModuleArtifactValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a step keyed under its asker", subject: "", given: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}", wire: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v StepsByAskerNodeIDValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "drop names the ask and why", subject: "", given: "{\"by\":\"mesh-delivery-builder\",\"id\":\"a1b2\",\"why\":\"a newer fingerprint supersedes it\"}", wire: "{\"by\":\"mesh-delivery-builder\",\"id\":\"a1b2\",\"why\":\"a newer fingerprint supersedes it\"}",
|
||||
decode: func(b []byte) (any, error) { var v DropInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact asks", subject: "", given: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}", wire: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact answers where the bytes are", subject: "", given: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"object\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"size\":18874368,\"store\":\"mesh-build-go-kept\"}", wire: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"object\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"size\":18874368,\"store\":\"mesh-build-go-kept\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a module that is claims no oci-artifact-registry", subject: "", given: "{\"fp\":\"src2:aaaaaaaa\",\"module\":\"mesh-delivery-gate\",\"refused\":\"claims no oci-artifact-registry\",\"words\":\"mesh-delivery-gate claims no oci-artifact-registry: its build is fetched from the store\"}", wire: "{\"fp\":\"src2:aaaaaaaa\",\"module\":\"mesh-delivery-gate\",\"refused\":\"claims no oci-artifact-registry\",\"words\":\"mesh-delivery-gate claims no oci-artifact-registry: its build is fetched from the store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a build it no longer keeps", subject: "", given: "{\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"not kept\",\"words\":\"this node keeps no build of artifact-store at src2:1480985e\"}", wire: "{\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"not kept\",\"words\":\"this node keeps no build of artifact-store at src2:1480985e\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a build kept under another digest", subject: "", given: "{\"digest\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"digest differs\",\"words\":\"artifact-store at src2:1480985e is kept as eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", wire: "{\"digest\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"digest differs\",\"words\":\"artifact-store at src2:1480985e is kept as eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact answers an error, never none", subject: "", given: "{\"error\":\"the kept builds could not be read\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}", wire: "{\"error\":\"the kept builds could not be read\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps asks an artifact's pipeline steps at a commit", subject: "", given: "{\"artifact\":\"nats:program\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}", wire: "{\"artifact\":\"nats:program\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers lint and unit tests", subject: "", given: "{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats\"],\"step\":\"unit\"}]}", wire: "{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats\"],\"step\":\"unit\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps drops an artifact's kept steps with a reason", subject: "", given: "{\"artifact\":\"nats.program\",\"drop\":true,\"module\":\"nats\",\"why\":\"the detection was wrong\"}", wire: "{\"artifact\":\"nats.program\",\"drop\":true,\"module\":\"nats\",\"why\":\"the detection was wrong\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers a drop with the artifact", subject: "", given: "{\"dropped\":\"nats.program\"}", wire: "{\"dropped\":\"nats.program\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers a drop that the hand-act log refused", subject: "", given: "{\"error\":\"the hand-act log refused: nothing was deleted\"}", wire: "{\"error\":\"the hand-act log refused: nothing was deleted\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildimage
|
||||
|
||||
go 1.26.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,136 +0,0 @@
|
||||
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
||||
|
||||
package nodebuildnode
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFixtures reads every fixture of seats/node-build-node/fixtures: each decodes into its type, a field the type does not
|
||||
// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's.
|
||||
func TestFixtures(t *testing.T) {
|
||||
cases := []struct {
|
||||
name, subject, given, wire string
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a unit step ended passed on its node, with its counts and what it carried", subject: "mesh.seat.node-build-node.event.step-ended.ace", given: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"carried\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\"}],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:02:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5e\",\"kept\":[{\"digest\":\"sha256:cccc\",\"level\":\"unit\",\"package\":\"./modules/nats/b\"}],\"module\":\"nats\",\"node\":\"ace\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"unit\",\"tests\":{\"unit\":14},\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"carried\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\"}],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"ended\":\"2026-11-10T10:02:00Z\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5e\",\"kept\":[{\"digest\":\"sha256:cccc\",\"level\":\"unit\",\"package\":\"./modules/nats/b\"}],\"module\":\"nats\",\"node\":\"ace\",\"outcome\":\"passed\",\"pipeline\":\"main.12.nats\",\"started\":\"2026-11-10T10:00:00Z\",\"step\":\"unit\",\"tests\":{\"unit\":14},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "an integration step that could not run, naming the part not heard", subject: "mesh.seat.node-build-node.event.step-ended.g14", given: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5f\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5f\",\"module\":\"nats\",\"node\":\"g14\",\"outcome\":\"could not run\",\"output-object\":\"mesh-build-go_sent-objects/m2kx9a1b3c4d5f\",\"pipeline\":\"main.12.nats\",\"said\":\"the sandbox could not fetch novox/mesh-sdk\",\"step\":\"integration\",\"v\":1}", wire: "{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5f\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:02:00Z\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d5f\",\"module\":\"nats\",\"node\":\"g14\",\"outcome\":\"could not run\",\"output-object\":\"mesh-build-go_sent-objects/m2kx9a1b3c4d5f\",\"pipeline\":\"main.12.nats\",\"said\":\"the sandbox could not fetch novox/mesh-sdk\",\"step\":\"integration\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "a node's toolchain reported", subject: "mesh.seat.node-build-node.event.toolchain-reported.ace", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"ace\",\"recipe\":\"1\",\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"node\":\"ace\",\"recipe\":\"1\",\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) { var v ToolchainReportedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.toolchain-reported\\.[^.*> ]+$")},
|
||||
{name: "a running ask says its progress", subject: "mesh.seat.node-build-node.event.step-progress.ace", given: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"runner\",\"at\":\"2026-11-11T10:01:00Z\",\"phase\":\"fetch\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.step-progress\\.[^.*> ]+$")},
|
||||
{name: "a builder's build ended, naming its asker and no commit or fingerprint (G 548)", subject: "mesh.seat.node-build-node.event.step-ended.ace", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"ace\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:03:00Z\",\"id\":\"m2kx9a1b3c4d6a\",\"node\":\"ace\",\"outcome\":\"failed\",\"said\":\"the build failed\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||
{name: "an ask taken, whatever its asker (G 602)", subject: "mesh.seat.node-build-node.event.ask-taken.ace", given: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:00:00Z\",\"node\":\"ace\"}", wire: "{\"ask\":\"m2kx9a1b3c4d6a\",\"asker\":\"mesh-delivery-builder\",\"at\":\"2026-11-11T10:00:00Z\",\"node\":\"ace\"}",
|
||||
decode: func(b []byte) (any, error) { var v AskTakenEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.event\\.ask-taken\\.[^.*> ]+$")},
|
||||
{name: "a running step", subject: "", given: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}", wire: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a paused node", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"operator@shanks\",\"paused\":true,\"v\":1}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"operator@shanks\",\"paused\":true,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PausesByPausedNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's capacity", subject: "", given: "{\"configured\":2,\"effective\":2,\"v\":1,\"why\":\"the configured steps fit the cores\"}", wire: "{\"configured\":2,\"effective\":2,\"v\":1,\"why\":\"the configured steps fit the cores\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v PausesByCapacityNodeValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's toolchain", subject: "", given: "{\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ToolchainsByNodeLanguageValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a node's toolchain with its program's digest (G 472)", subject: "", given: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}", wire: "{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"language\":\"go\",\"recipe\":\"1\",\"v\":1,\"version\":\"1.26.0\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v ToolchainsByNodeLanguageValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a build ask", subject: "mesh.seat.node-build-node.accept.delivery", given: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b2\",\"kind\":\"build\",\"language\":\"go\"}", wire: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b2\",\"kind\":\"build\",\"language\":\"go\"}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.accept\\.delivery$")},
|
||||
{name: "a build ask with the version the builder reserved (G 573)", subject: "mesh.seat.node-build-node.accept.delivery", given: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b3\",\"kind\":\"build\",\"language\":\"go\",\"version\":\"1.4.2\"}", wire: "{\"asker\":\"mesh-delivery-builder\",\"build\":{\"artifacts\":[{\"artifact\":\"go\"}],\"module\":\"nats\"},\"id\":\"a1b3\",\"kind\":\"build\",\"language\":\"go\",\"version\":\"1.4.2\"}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.accept\\.delivery$")},
|
||||
{name: "a check ask with the group's tagged package", subject: "mesh.seat.node-build-node.accept.check", given: "{\"asker\":\"mesh-delivery-checker\",\"at\":\"2026-11-05T10:00:00Z\",\"check\":{\"fetch\":{\"base\":\"89abcdef0123456789abcdef0123456789abcdef\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"package\":{\"name\":\"@novox/mesh-sdk\",\"version\":\"0.1.15-feat-x.1\"},\"ref\":\"refs/pull/7/head\",\"repository\":\"novox/mesh-delivery\"},\"kept\":true,\"levels\":[\"unit\",\"integration\"],\"node-names\":[\"ace\",\"g14\"],\"toolchain\":{\"language\":\"typescript\",\"recipe\":\"1\",\"version\":\"26.12.0\"}},\"id\":\"c3d5\",\"kind\":\"check\",\"language\":\"typescript\",\"v\":1}", wire: "{\"asker\":\"mesh-delivery-checker\",\"at\":\"2026-11-05T10:00:00Z\",\"check\":{\"fetch\":{\"base\":\"89abcdef0123456789abcdef0123456789abcdef\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"package\":{\"name\":\"@novox/mesh-sdk\",\"version\":\"0.1.15-feat-x.1\"},\"ref\":\"refs/pull/7/head\",\"repository\":\"novox/mesh-delivery\"},\"kept\":true,\"levels\":[\"unit\",\"integration\"],\"node-names\":[\"ace\",\"g14\"],\"toolchain\":{\"language\":\"typescript\",\"recipe\":\"1\",\"version\":\"26.12.0\"}},\"id\":\"c3d5\",\"kind\":\"check\",\"language\":\"typescript\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.accept\\.check$")},
|
||||
{name: "a finished check step of a TypeScript merge preview", subject: "", given: "{\"ended\":\"2026-11-05T10:01:00Z\",\"id\":\"c3d6\",\"node\":\"ace\",\"result\":{\"fetch\":{\"base\":\"abcdef0123456789abcdef0123456789abcdef01\",\"changed\":[\"modules/m/package.json\"],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"merge\":\"0123456789abcdef0123456789abcdef01234567\",\"modules\":[\"modules/m\"],\"trees\":{\"modules/m\":{\"manifest\":\"0581b699d9d05517e69b21f5cedbeb2eee8aba2b205280b561be731594d7feef\",\"tree\":\"0123456789abcdef0123456789abcdef01234567\"}},\"workspace\":\"mvii1sxt979f67\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"check\",\"v\":1}", wire: "{\"ended\":\"2026-11-05T10:01:00Z\",\"id\":\"c3d6\",\"node\":\"ace\",\"result\":{\"fetch\":{\"base\":\"abcdef0123456789abcdef0123456789abcdef01\",\"changed\":[\"modules/m/package.json\"],\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"merge\":\"0123456789abcdef0123456789abcdef01234567\",\"modules\":[\"modules/m\"],\"trees\":{\"modules/m\":{\"manifest\":\"0581b699d9d05517e69b21f5cedbeb2eee8aba2b205280b561be731594d7feef\",\"tree\":\"0123456789abcdef0123456789abcdef01234567\"}},\"workspace\":\"mvii1sxt979f67\"}},\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"passed\",\"tool\":\"check\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a step ended on a transport fault, given again by the bus", subject: "", given: "{\"again-at\":\"2026-11-05T10:01:30Z\",\"ended\":\"2026-11-05T10:00:30Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"passing\":true,\"reason\":\"fetching the commit: kex_exchange_identification: read: Connection reset by peer\",\"run\":1,\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"again\",\"tool\":\"build\",\"v\":1}", wire: "{\"again-at\":\"2026-11-05T10:01:30Z\",\"ended\":\"2026-11-05T10:00:30Z\",\"id\":\"a1b2\",\"node\":\"ace\",\"passing\":true,\"reason\":\"fetching the commit: kex_exchange_identification: read: Connection reset by peer\",\"run\":1,\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"again\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v StepsByNodeIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "an ask dropped by the caller that no longer waits", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"mesh-delivery-builder\",\"v\":1,\"why\":\"a newer fingerprint supersedes it\"}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"by\":\"mesh-delivery-builder\",\"v\":1,\"why\":\"a newer fingerprint supersedes it\"}",
|
||||
decode: func(b []byte) (any, error) { var v PausesByDroppedIDValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a step ask of the runner with its kept results", subject: "mesh.seat.node-build-node.accept.check.step", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"typescript\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"typescript\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CheckStepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.accept\\.check\\.step$")},
|
||||
{name: "a recovery's step ask of the runner, on the stream delivery", subject: "mesh.seat.node-build-node.accept.delivery.step", given: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"typescript\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}", wire: "{\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-10T10:00:00Z\",\"id\":\"m2kx9a1b3c4d5e\",\"kind\":\"step\",\"language\":\"typescript\",\"step\":{\"artifact\":\"nats:program\",\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"kept\":[{\"digest\":\"sha256:bbbb\",\"level\":\"unit\",\"package\":\"./modules/nats/a\",\"pipeline\":\"main.11.nats\"}],\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"unit\"},\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v DeliveryStepAccept; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.node-build-node\\.accept\\.delivery\\.step$")},
|
||||
{name: "an artifact's detected steps", subject: "", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats/a\"],\"step\":\"unit\"}],\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats/a\"],\"step\":\"unit\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v DetectedStepsByModuleArtifactValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "a step keyed under its asker", subject: "", given: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}", wire: "{\"id\":\"a1b2\",\"node\":\"ace\",\"started\":\"2026-11-05T10:00:00Z\",\"state\":\"running\",\"tool\":\"build\",\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v StepsByAskerNodeIDValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
return v, err
|
||||
}, subjectIs: nil},
|
||||
{name: "drop names the ask and why", subject: "", given: "{\"by\":\"mesh-delivery-builder\",\"id\":\"a1b2\",\"why\":\"a newer fingerprint supersedes it\"}", wire: "{\"by\":\"mesh-delivery-builder\",\"id\":\"a1b2\",\"why\":\"a newer fingerprint supersedes it\"}",
|
||||
decode: func(b []byte) (any, error) { var v DropInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact asks", subject: "", given: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}", wire: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact answers where the bytes are", subject: "", given: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"object\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"size\":18874368,\"store\":\"mesh-build-go-kept\"}", wire: "{\"digest\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"object\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\"size\":18874368,\"store\":\"mesh-build-go-kept\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a module that is claims no oci-artifact-registry", subject: "", given: "{\"fp\":\"src2:aaaaaaaa\",\"module\":\"mesh-delivery-gate\",\"refused\":\"claims no oci-artifact-registry\",\"words\":\"mesh-delivery-gate claims no oci-artifact-registry: its build is fetched from the store\"}", wire: "{\"fp\":\"src2:aaaaaaaa\",\"module\":\"mesh-delivery-gate\",\"refused\":\"claims no oci-artifact-registry\",\"words\":\"mesh-delivery-gate claims no oci-artifact-registry: its build is fetched from the store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a build it no longer keeps", subject: "", given: "{\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"not kept\",\"words\":\"this node keeps no build of artifact-store at src2:1480985e\"}", wire: "{\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"not kept\",\"words\":\"this node keeps no build of artifact-store at src2:1480985e\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact refuses a build kept under another digest", subject: "", given: "{\"digest\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"digest differs\",\"words\":\"artifact-store at src2:1480985e is kept as eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", wire: "{\"digest\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\",\"refused\":\"digest differs\",\"words\":\"artifact-store at src2:1480985e is kept as eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "kept-artifact answers an error, never none", subject: "", given: "{\"error\":\"the kept builds could not be read\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}", wire: "{\"error\":\"the kept builds could not be read\",\"fp\":\"src2:1480985e\",\"module\":\"artifact-store\"}",
|
||||
decode: func(b []byte) (any, error) { var v KeptArtifactAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps asks an artifact's pipeline steps at a commit", subject: "", given: "{\"artifact\":\"nats:program\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}", wire: "{\"artifact\":\"nats:program\",\"fetch\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-catalog\"},\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers lint and unit tests", subject: "", given: "{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats\"],\"step\":\"unit\"}]}", wire: "{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"steps\":[{\"step\":\"lint\"},{\"packages\":[\"./modules/nats\"],\"step\":\"unit\"}]}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps drops an artifact's kept steps with a reason", subject: "", given: "{\"artifact\":\"nats.program\",\"drop\":true,\"module\":\"nats\",\"why\":\"the detection was wrong\"}", wire: "{\"artifact\":\"nats.program\",\"drop\":true,\"module\":\"nats\",\"why\":\"the detection was wrong\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers a drop with the artifact", subject: "", given: "{\"dropped\":\"nats.program\"}", wire: "{\"dropped\":\"nats.program\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "steps answers a drop that the hand-act log refused", subject: "", given: "{\"error\":\"the hand-act log refused: nothing was deleted\"}", wire: "{\"error\":\"the hand-act log refused: nothing was deleted\"}",
|
||||
decode: func(b []byte) (any, error) { var v StepsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
}
|
||||
for _, c := range cases {
|
||||
v, err := c.decode([]byte(c.given))
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not decode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
back, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
t.Errorf("%s: does not encode: %v", c.name, err)
|
||||
continue
|
||||
}
|
||||
var got, want any
|
||||
if err := json.Unmarshal(back, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(c.wire), &want); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire)
|
||||
}
|
||||
if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) {
|
||||
t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildnode
|
||||
|
||||
go 1.26.0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user