B4 (H-A-454): publishes is the builder's own work-queue stream, read by the verb publish-queue
The work queue publishes is declared in the manifest's old streams section (retention work-queue, duplicates 24 h, max-deliveries 10, 64 MiB, 7 days), the module's own stream consumed on the module's account, so the bus binding asked of the broker seat goes; the consumers per holder and class are still made at run time. The seat mesh-builds gains the read verb publish-queue, served by the builder from its own stream (counts per holder and class, oldest and newest, a list capped at 50, capped past 4,000 items read), and builder_publish_queue asks it in place of the runtime's stream and work-queue reads. Two whole tests of a gone artifact are folded into one, so the builder's integration count stays at 18 with the publishes whole test. Builds: design 47 H2 §793, §819, §820; H-A-440 (1), H-A-446 (2), H-A-454 and its addendum
This commit is contained in:
@@ -435,7 +435,7 @@ func main() {
|
||||
tools = append(tools, reservedTools(rr, buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
as := stdio.State(versions.ActedState)
|
||||
tools = append(tools, publishActTools(buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
tools = append(tools, republishTools(workQueueReader(stdio.BusState, versions.PublishesLocal), readerOf(as), readerOf(reasks), buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
tools = append(tools, republishTools(publishQueueVia(stdio.Ask), readerOf(as), readerOf(reasks), buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
ws := stdio.State(build.WaitsState)
|
||||
wr := versions.Reader{Keys: ws.Keys, Get: func(key string) (json.RawMessage, bool, error) {
|
||||
e, err := ws.Get(key)
|
||||
|
||||
@@ -4,13 +4,12 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
|
||||
"mesh-delivery-builder/internal/build"
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
@@ -55,54 +54,23 @@ func onePage(page func(after string, maxBytes int, budget time.Duration) (stdio.
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// workQueuePageItems and workQueueItemsRead bound the read of the work queue publishes: pages of 500 items, at most 4,000 read
|
||||
// (H-A-293: past them the answer is capped, naming the items read and the queue's size).
|
||||
const (
|
||||
workQueuePageItems = 500
|
||||
workQueueItemsRead = 4000
|
||||
)
|
||||
// publishQueueVerbKey is the seat verb builder_publish_queue asks (the manifest's invokes): the builder reads its own work queue
|
||||
// publishes (design 47 H2 §793, H-A-454).
|
||||
const publishQueueVerbKey = "seat:" + meshbuilds.Seat + "." + meshbuilds.VerbPublishQueue
|
||||
|
||||
// workQueueReader is the builder's work queue local as the versions package's reader (design 47 H2 §793, H-A-448): its items read
|
||||
// through the tool runtime's stream read in pages, each keyed by its sequence, and its size through the work queue's size; a
|
||||
// read past workQueueItemsRead is capped. call is stdio.BusState.
|
||||
func workQueueReader(call func(method string, params any) (json.RawMessage, error), local string) versions.Reader {
|
||||
none := func() ([]string, error) { return nil, errors.ErrUnsupported }
|
||||
return versions.Reader{Keys: none, All: func() (versions.StatePage, error) {
|
||||
out := versions.StatePage{Values: map[string]json.RawMessage{}}
|
||||
from := uint64(0)
|
||||
for {
|
||||
raw, err := call(buscalls.StreamRead, buscalls.StreamReadRequest{Stream: local, From: from, Limit: workQueuePageItems})
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
var pg buscalls.StreamPage
|
||||
if err := json.Unmarshal(raw, &pg); err != nil {
|
||||
return out, fmt.Errorf("the work queue %s answered what is no page of items: %w", local, err)
|
||||
}
|
||||
for _, m := range pg.Messages {
|
||||
out.Values[strconv.FormatUint(m.Sequence, 10)] = m.Body
|
||||
}
|
||||
if pg.Next == 0 || len(pg.Messages) == 0 {
|
||||
return out, nil
|
||||
}
|
||||
if len(out.Values) >= workQueueItemsRead {
|
||||
out.More = true
|
||||
break
|
||||
}
|
||||
from = pg.Next
|
||||
}
|
||||
raw, err := call(buscalls.WorkQueueSize, buscalls.WorkQueueRequest{Queue: local})
|
||||
var size buscalls.WorkQueueSized
|
||||
if err == nil {
|
||||
err = json.Unmarshal(raw, &size)
|
||||
}
|
||||
// publishQueueVia asks the seat mesh-builds' verb publish-queue through ask (stdio.Ask).
|
||||
func publishQueueVia(ask func(key string, body any) (json.RawMessage, error)) func(module, version string) (meshbuilds.PublishQueueAnswer, error) {
|
||||
return func(module, version string) (meshbuilds.PublishQueueAnswer, error) {
|
||||
var a meshbuilds.PublishQueueAnswer
|
||||
raw, err := ask(publishQueueVerbKey, meshbuilds.PublishQueueInput{Module: module, Version: version})
|
||||
if err != nil {
|
||||
out.InfoWords = fmt.Sprintf("the work queue's size cannot be read: %v", err)
|
||||
} else {
|
||||
out.Keys, out.Bytes = size.Count, size.Bytes
|
||||
return a, fmt.Errorf("the builder's verb %s did not answer: %w", meshbuilds.VerbPublishQueue, err)
|
||||
}
|
||||
return out, nil
|
||||
}}
|
||||
if err := json.Unmarshal(raw, &a); err != nil {
|
||||
return a, fmt.Errorf("the verb %s answered what is no queue: %w", meshbuilds.VerbPublishQueue, err)
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
}
|
||||
|
||||
// publishActTools are builder_publish_drop and builder_publish_first (design 47 H2 §793): hand acts, recorded in the hand-act log
|
||||
@@ -147,7 +115,7 @@ func publishActTools(ask queueAsker, now func() time.Time, acts meshhandactsclie
|
||||
// republishTools are builder_publish_again and builder_publish_queue (design 47 G §588). The publish again is a hand act:
|
||||
// it is recorded in the hand-act log first, then written to reasks for the builder, which owns the queue, to answer
|
||||
// with the versions it queued.
|
||||
func republishTools(queue, acted, reasks versions.Reader, ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
||||
func republishTools(queue func(module, version string) (meshbuilds.PublishQueueAnswer, error), acted, reasks versions.Reader, ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
||||
str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
|
||||
return []stdio.Tool{
|
||||
{Name: versions.PublishAgainTool, Description: versions.PublishAgainDescription,
|
||||
@@ -182,7 +150,11 @@ func republishTools(queue, acted, reasks versions.Reader, ask queueAsker, now fu
|
||||
"module": map[string]any{"type": "string", "description": "list only this module's queued versions, each with its class"},
|
||||
"version": map[string]any{"type": "string", "description": "with module: only this version, MAJOR.MINOR.PATCH"}}},
|
||||
Run: func(args map[string]any) (any, error) {
|
||||
return versions.AnswerQueue(queue, acted, reasks, str(args, "module"), str(args, "version"))
|
||||
q, err := queue(str(args, "module"), str(args, "version"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return versions.AnswerQueue(q, acted, reasks)
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
|
||||
"mesh-delivery-builder/internal/build"
|
||||
|
||||
@@ -65,33 +65,25 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
||||
t.Errorf("health four minutes in = %+v, want healthy", a)
|
||||
}
|
||||
})
|
||||
// Design 47 H2 §793, H-A-448: builder_publish_queue reads the work queue publishes through the runtime's stream read, in pages,
|
||||
// and a read past its bound is capped with the queue's size from the work queue's size; builder_publish_drop and
|
||||
// Design 47 H2 §793, H-A-454: builder_publish_queue asks the seat mesh-builds' verb publish-queue, which the builder serves from
|
||||
// its own stream, and answers its counts, list and cap with the states beside them; builder_publish_drop and
|
||||
// builder_publish_first record the hand act first, then write their reasks value.
|
||||
t.Run("the work queue is read in pages, capped past its bound", func(t *testing.T) {
|
||||
for _, total := range []int{1200, 9000} {
|
||||
var methods []string
|
||||
call := func(method string, params any) (json.RawMessage, error) {
|
||||
methods = append(methods, method)
|
||||
if method == buscalls.WorkQueueSize {
|
||||
return json.Marshal(buscalls.WorkQueueSized{Fill: buscalls.Fill{Count: uint64(total), Bytes: 4096}})
|
||||
}
|
||||
req := params.(buscalls.StreamReadRequest)
|
||||
var pg buscalls.StreamPage
|
||||
for n := req.From + 1; n <= uint64(total) && len(pg.Messages) < req.Limit; n++ {
|
||||
pg.Messages = append(pg.Messages, buscalls.StreamMessage{Sequence: n, Body: json.RawMessage(`{"holder":"oci","class":"again"}`)})
|
||||
pg.Next = n
|
||||
}
|
||||
if pg.Next == uint64(total) {
|
||||
pg.Next = 0
|
||||
}
|
||||
return json.Marshal(pg)
|
||||
}
|
||||
pg, err := workQueueReader(call, versions.PublishesLocal).All()
|
||||
capped := total > workQueueItemsRead
|
||||
if err != nil || pg.More != capped || len(pg.Values) != min(total, workQueueItemsRead) || (capped && pg.Keys != uint64(total)) {
|
||||
t.Errorf("%d items: read %d, more %v, keys %d (%v) after %v", total, len(pg.Values), pg.More, pg.Keys, err, methods)
|
||||
}
|
||||
t.Run("the queue is the builder's verb publish-queue", func(t *testing.T) {
|
||||
var asked []string
|
||||
ask := func(key string, body any) (json.RawMessage, error) {
|
||||
in := body.(meshbuilds.PublishQueueInput)
|
||||
asked = append(asked, key+" "+in.Module)
|
||||
return json.Marshal(meshbuilds.PublishQueueAnswer{Total: 9000, Listed: 1, Capped: true, ItemsRead: 4000, QueueItems: 9000, QueueBytes: 4096,
|
||||
Counts: []meshbuilds.PublishQueueAnswerCountsItem{{Holder: "oci", Class: versions.PublishClassStart, Count: 4000}},
|
||||
Queue: []meshbuilds.PublishQueueAnswerQueueItem{{Holder: "oci", Module: "m", Version: "0.1.0", Class: versions.PublishClassStart}}})
|
||||
}
|
||||
none := versions.Reader{Keys: func() ([]string, error) { return nil, nil }}
|
||||
tools := republishTools(publishQueueVia(ask), none, none, nil, time.Now, meshhandactsclient.Recorder{})
|
||||
raw, err := tools[1].Run(map[string]any{"module": "m"})
|
||||
a, _ := raw.(versions.Queued)
|
||||
if err != nil || fmt.Sprint(asked) != "[seat:mesh-builds.publish-queue m]" || a.Total != 9000 || len(a.Queue) != 1 || a.Queue[0].Module != "m" ||
|
||||
len(a.Counts) != 1 || !a.Capped || len(a.Read) != 1 || a.Read[0].KeysRead != 4000 || a.Read[0].StateKeys != 9000 {
|
||||
t.Errorf("%s asked %v, answered %+v (%v): want the verb asked with the module, its answer carried with its cap", tools[1].Name, asked, a, err)
|
||||
}
|
||||
})
|
||||
t.Run("drop and first record the hand act, then ask the builder", func(t *testing.T) {
|
||||
|
||||
@@ -103,9 +103,16 @@ func revisionOf(t *testing.T, b *bed, module string) uint64 {
|
||||
return e.Revision()
|
||||
}
|
||||
|
||||
// TestAGoneArtifactIsBuiltAgain: 1937/AC3 and AC4, one whole test of the two (design 47 H2 §819: the builder's integration count does
|
||||
// not rise with the work queue publishes' whole test).
|
||||
func TestAGoneArtifactIsBuiltAgain(t *testing.T) {
|
||||
t.Run("a done key whose blob is gone is built again at start", aDoneKeyWhoseBlobIsGoneIsBuiltAgainAtStart)
|
||||
t.Run("artifacts-gone leads the builder to build the key again", artifactsGoneLeadsTheBuilderToBuildTheKeyAgain)
|
||||
}
|
||||
|
||||
// 1937/AC3 (integration): the builder, started whole, finds the done key of the trunk's fingerprint naming a blob held
|
||||
// answers gone, builds it again as a new revision whose step says so, and leaves the rebuilt key done.
|
||||
func TestADoneKeyWhoseBlobIsGoneIsBuiltAgainAtStart(t *testing.T) {
|
||||
func aDoneKeyWhoseBlobIsGoneIsBuiltAgainAtStart(t *testing.T) {
|
||||
b := startBed(t)
|
||||
eventsConsumer(t, b, "n1")
|
||||
manifest := b.archive(t, "ca-trust", "modules/ca-trust", commit)
|
||||
@@ -135,7 +142,7 @@ func TestADoneKeyWhoseBlobIsGoneIsBuiltAgainAtStart(t *testing.T) {
|
||||
|
||||
// 1937/AC4 (integration): a done key whose blob held answers held at start stays done; when the controller says
|
||||
// artifacts-gone for it, the builder asks again and builds it again.
|
||||
func TestArtifactsGoneLeadsTheBuilderToBuildTheKeyAgain(t *testing.T) {
|
||||
func artifactsGoneLeadsTheBuilderToBuildTheKeyAgain(t *testing.T) {
|
||||
b := startBed(t)
|
||||
eventsConsumer(t, b, "n1")
|
||||
manifest := b.archive(t, "ca-trust", "modules/ca-trust", commit)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshbroker"
|
||||
"io"
|
||||
"io/fs"
|
||||
"log"
|
||||
@@ -40,7 +39,6 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
"git.novox.be/novox/mesh-sdk/go/membership"
|
||||
"git.novox.be/novox/mesh-sdk/go/operatorask"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
@@ -270,14 +268,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// The versions' hand acts (builder_publish_again, builder_floor_again) come through reasks, as builder_build_again.
|
||||
acts := versions.Acts{Numberer: numberer, DropReserved: reserved.dropped, Reconsider: b.Reconsider}
|
||||
// A reserved version left unpublished is published again, by the builder on an event or by a person's tool (design 47 G
|
||||
// §588): its items on the work queue publishes its requires asks for, named by the bus's binding (design 47 H2 §793, H-A-448).
|
||||
// §588): its items on the work queue publishes, the module's own stream of its old streams section (design 47 H2 §793, H-A-454).
|
||||
actedKV := process.AwaitBucket(ctx, js, conn, own.acted, "no version is published again on an event or by builder_publish_again", logger.Printf)
|
||||
publishesBinding := process.NewBinding(meshbroker.Seat, cred.Module, calls.CallKept, logger.Printf, versions.PublishesLocal)
|
||||
if err := publishesBinding.Register(hub); err != nil {
|
||||
return fmt.Errorf("hearing the bus's binding of %s: %w", versions.PublishesLocal, err)
|
||||
}
|
||||
pq := &publishQueue{js: js, logf: logger.Printf,
|
||||
binding: func() (membership.BusBinding, error) { return publishesBinding.Names(versions.PublishesLocal) }}
|
||||
pq := &publishQueue{js: js, logf: logger.Printf, binding: publishesOf(cred.Module)}
|
||||
republish := &versions.Republisher{Reserved: reserved.r, Put: pq.put,
|
||||
Entry: entryVia(calls.Call), Send: sendVia(calls.CallKeptAsk),
|
||||
Unreleased: reserved.unreleasedWords, Logf: logger.Printf,
|
||||
@@ -355,10 +348,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
return fmt.Errorf("hearing the operator's answers: %w", err)
|
||||
}
|
||||
retake := &retaking{rt: &build.Retaker{Builder: b, Acted: retakeActed, Entry: entryVia(calls.Call), Ask: operator.Ask, Logf: logger.Printf}}
|
||||
// Once the bus names the work queue: what waits on it is pulled, and the old state's items are put on it once (§793).
|
||||
publishesBinding.Start()
|
||||
// What waits on the work queue is pulled, and the old state's items are put on it once (§793).
|
||||
go func() {
|
||||
publishesBinding.Ask(versions.PublishesLocal)
|
||||
if err := pq.learnAll(ctx); err != nil {
|
||||
logger.Printf("the publishes waiting on the work queue %s are not pulled yet: %v; each holder's are pulled when an item of it is put", versions.PublishesLocal, err)
|
||||
}
|
||||
@@ -531,7 +522,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// published (H-A-328): whether a package built at a fingerprint is published, asked by the runner writing a wait on it.
|
||||
meshbuilds.VerbPublished: publishedVerb(ctx, reserved.r.PublishedOf),
|
||||
// drop (§778; H-A-401, H-A-404): an ask its caller no longer waits for ends could-not-run naming the drop.
|
||||
meshbuilds.VerbDrop: dropVerb(steps)})
|
||||
meshbuilds.VerbDrop: dropVerb(steps),
|
||||
// publish-queue (§793; H-A-454): the work queue publishes read from its own stream, for builder_publish_queue.
|
||||
meshbuilds.VerbPublishQueue: publishQueueVerb(ctx, pq)})
|
||||
if err != nil {
|
||||
return fmt.Errorf("answering the verb reserved: %w", err)
|
||||
}
|
||||
|
||||
+13
-5
@@ -14,8 +14,8 @@ import (
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/membership"
|
||||
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
)
|
||||
@@ -23,12 +23,14 @@ import (
|
||||
// Design 47 H2 §793 (whole, against the bus): the builder's work queue publishes, its pull consumers made as it learns a holder.
|
||||
// A live publish enqueued behind 100 again items while the builder was away is sent first; a dropped item is never sent, and
|
||||
// put again within the duplicates window is not stored; the move of the old state run twice puts each item once, and asks the
|
||||
// bus module to drop the old state.
|
||||
// bus module to drop the old state. The seat mesh-builds' verb publish-queue reads the stream: counts per holder and class, the
|
||||
// oldest and newest, the live item listed first (H-A-454).
|
||||
func TestThePublishQueueSendsLiveFirstAndNeverADroppedItem(t *testing.T) {
|
||||
b := startBed(t)
|
||||
ctx := b.ctx
|
||||
bind := membership.BusBinding{Local: versions.PublishesLocal, Stream: "mesh-delivery-builder_publishes", Subject: "mesh.bus.mesh-delivery-builder.publishes"}
|
||||
if _, err := b.js.CreateOrUpdateStream(ctx, jetstream.StreamConfig{Name: bind.Stream, Subjects: []string{bind.Subject + ".>"},
|
||||
// The stream as the manifest's old streams section declares it: the module's own, retention work-queue, duplicates 24 hours.
|
||||
bind, _ := publishesOf("mesh-delivery-builder")()
|
||||
if _, err := b.js.CreateOrUpdateStream(ctx, jetstream.StreamConfig{Name: bind.Stream, Subjects: []string{bind.Subject + ".publish.>"},
|
||||
Retention: jetstream.WorkQueuePolicy, Discard: jetstream.DiscardNew, Duplicates: 24 * time.Hour, MaxAge: 7 * 24 * time.Hour}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -51,7 +53,7 @@ func TestThePublishQueueSendsLiveFirstAndNeverADroppedItem(t *testing.T) {
|
||||
sentCh <- q.Module
|
||||
return versions.SendFate{Sent: true}
|
||||
}}
|
||||
pq := &publishQueue{js: b.js, ackWait: time.Minute, logf: t.Logf, take: items.take, binding: func() (membership.BusBinding, error) { return bind, nil }}
|
||||
pq := &publishQueue{js: b.js, ackWait: time.Minute, logf: t.Logf, take: items.take, binding: publishesOf("mesh-delivery-builder")}
|
||||
item := func(module, class string) versions.QueuedPublish {
|
||||
return versions.QueuedPublish{V: 1, Holder: "oci", Module: module, Version: "0.1.0", Artifacts: map[string]string{module + ":a": "sha256:a"}, Class: class, Queued: time.Now()}
|
||||
}
|
||||
@@ -74,6 +76,12 @@ func TestThePublishQueueSendsLiveFirstAndNeverADroppedItem(t *testing.T) {
|
||||
if dup, err := pq.put(ctx, item("dropme", versions.PublishClassStart)); err != nil || !dup {
|
||||
t.Errorf("a dropped item put again within the window: duplicate %v (%v), want it not stored", dup, err)
|
||||
}
|
||||
raw, err := publishQueueVerb(ctx, pq)("op@node", json.RawMessage(`{}`))
|
||||
if a, ok := raw.(meshbuilds.PublishQueueAnswer); err != nil || !ok || a.Total != 101 || len(a.Counts) != 2 || a.Counts[0].Class != versions.PublishClassStart ||
|
||||
a.Counts[0].Count != 100 || a.Counts[1].Count != 1 || a.Counts[0].Oldest.After(a.Counts[0].Newest) || len(a.Queue) != versions.PublishQueueListCap ||
|
||||
a.Queue[0].Module != "live" || a.Capped {
|
||||
t.Errorf("publish-queue answered %+v (%v), want 101 items, oci's 100 again and 1 live, fifty listed, the live first", raw, err)
|
||||
}
|
||||
if err := pq.learnAll(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/membership"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
|
||||
"mesh-delivery-builder/internal/build"
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
@@ -524,14 +527,15 @@ func builtOf(all []versions.ReservedVersion) []versions.ReservedVersion {
|
||||
return out
|
||||
}
|
||||
|
||||
// publishQueue is the builder's work queue publishes on the bus (design 47 H2 §793; H-A-440, H-A-446 (2), H-A-448): asked for in
|
||||
// its requires and named by the bus's binding; each item on `<binding subject>.publish.<holder>.<class>.<module>.<version>` under
|
||||
// the message id `<holder>.<class>.<module>.<version>`. The builder makes the pull consumers at run time as it learns a holder,
|
||||
// publishQueue is the builder's work queue publishes on the bus (design 47 H2 §793; H-A-440, H-A-446 (2), H-A-454): a stream of
|
||||
// the manifest's old streams section with the work-queue retention, the module's own, consumed by the process on the module's
|
||||
// account; each item on `mesh.stream.<module>.event.publish.<holder>.<class>.<module>.<version>` under the message id
|
||||
// `<holder>.<class>.<module>.<version>`. The builder makes the pull consumers at run time as it learns a holder,
|
||||
// `publishes-<holder>-<class>`, with ack wait publish-pause-max, max ack pending four and max deliveries ten, and pulls the live
|
||||
// class first, at most four sends at once per holder.
|
||||
type publishQueue struct {
|
||||
js jetstream.JetStream
|
||||
binding func() (membership.BusBinding, error)
|
||||
binding func() (publishesStream, error)
|
||||
ackWait time.Duration
|
||||
take func(ctx context.Context, m itemMsg)
|
||||
logf func(string, ...any)
|
||||
@@ -540,6 +544,16 @@ type publishQueue struct {
|
||||
pulling map[string]bool
|
||||
}
|
||||
|
||||
// publishesStream is where the work queue publishes is on the bus: its stream's name and the subject its items open with.
|
||||
type publishesStream struct{ Stream, Subject string }
|
||||
|
||||
// publishesOf is module's work queue publishes, its own stream (H-A-454): the stream's bus name and its events' subject.
|
||||
func publishesOf(module string) func() (publishesStream, error) {
|
||||
b := publishesStream{Stream: catalogue.StreamBusName(versions.PublishesLocal),
|
||||
Subject: strings.TrimSuffix(buscompose.ModuleStreamSubject(module, ""), ".")}
|
||||
return func() (publishesStream, error) { return b, nil }
|
||||
}
|
||||
|
||||
// The consumers' numbers (H-A-446 (2)): at most four sends in flight per holder and class, and ten deliveries, the work queue's
|
||||
// largest; the builder ends an item at publish-tries anyway.
|
||||
const (
|
||||
@@ -553,7 +567,7 @@ func publishesConsumer(holder, class string) string {
|
||||
}
|
||||
|
||||
// subject is the item's subject on the bus.
|
||||
func (pq *publishQueue) subject(b membership.BusBinding, q versions.QueuedPublish) string {
|
||||
func (pq *publishQueue) subject(b publishesStream, q versions.QueuedPublish) string {
|
||||
return b.Subject + "." + versions.PublishEvent(q.Holder, q.Class, q.Module, q.Version)
|
||||
}
|
||||
|
||||
@@ -744,6 +758,53 @@ func (pq *publishQueue) itemsOf(ctx context.Context, module, version, class stri
|
||||
return out, st, nil
|
||||
}
|
||||
|
||||
// publishQueueItemsRead bounds the verb publish-queue's read of the work queue: at most 4,000 items, past them the answer is capped,
|
||||
// naming the items read and the queue's size (H-A-293).
|
||||
const publishQueueItemsRead = 4000
|
||||
|
||||
// reader is the work queue as the versions package's reader, for the seat mesh-builds' verb publish-queue (§793, H-A-454): its
|
||||
// items read from the stream by sequence, at most publishQueueItemsRead, each keyed by its sequence; a queue holding more is read
|
||||
// capped, with the stream's message count and bytes.
|
||||
func (pq *publishQueue) reader(ctx context.Context) versions.Reader {
|
||||
none := func() ([]string, error) { return nil, errors.ErrUnsupported }
|
||||
return versions.Reader{Keys: none, All: func() (versions.StatePage, error) {
|
||||
out := versions.StatePage{Values: map[string]json.RawMessage{}}
|
||||
b, err := pq.binding()
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
st, err := pq.js.Stream(ctx, b.Stream)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
info, err := st.Info(ctx)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
held := int(info.State.Msgs)
|
||||
if held == 0 {
|
||||
return out, nil
|
||||
}
|
||||
// A work queue takes no second consumer over its subjects, so its items are read by sequence, the deleted passed over.
|
||||
for seq := info.State.FirstSeq; seq <= info.State.LastSeq && len(out.Values) < publishQueueItemsRead; seq++ {
|
||||
m, err := st.GetMsg(ctx, seq)
|
||||
if errors.Is(err, jetstream.ErrMsgNotFound) {
|
||||
continue // acknowledged or terminated since
|
||||
}
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
if strings.HasPrefix(m.Subject, b.Subject+".publish.") {
|
||||
out.Values[strconv.FormatUint(seq, 10)] = json.RawMessage(m.Data)
|
||||
}
|
||||
}
|
||||
if held > len(out.Values) && len(out.Values) >= publishQueueItemsRead {
|
||||
out.More, out.Keys, out.Bytes = true, info.State.Msgs, info.State.Bytes
|
||||
}
|
||||
return out, nil
|
||||
}}
|
||||
}
|
||||
|
||||
// drop is builder_publish_drop (§793): the version's publish item is ended with who dropped it and why, so no item of it is ever
|
||||
// sent or put again; its items waiting on the work queue are removed, and one held is terminated.
|
||||
func (pq *publishQueue) drop(ctx context.Context, items *publishItems, module, version, by, why string) (string, error) {
|
||||
@@ -886,3 +947,17 @@ func moveOld(ctx context.Context, js jetstream.JetStream, bucket, module string,
|
||||
|
||||
// natsDropTool is the bus module's drop of an entry no accepted manifest asks for (H-A-126), which the old state goes by.
|
||||
const natsDropTool = "nats.nats_drop"
|
||||
|
||||
// publishQueueVerb is the handler of the seat mesh-builds' verb publish-queue (§793; H-A-454): the builder reads its own work queue
|
||||
// and answers its counts per holder and class, the oldest and newest, and a capped list; builder_publish_queue asks it.
|
||||
func publishQueueVerb(ctx context.Context, pq *publishQueue) process.SeatHandler {
|
||||
return func(_ string, body json.RawMessage) (any, error) {
|
||||
var in meshbuilds.PublishQueueInput
|
||||
if len(body) > 0 {
|
||||
if err := json.Unmarshal(body, &in); err != nil {
|
||||
return nil, fmt.Errorf("the arguments do not fit the verb publish-queue: %w", err)
|
||||
}
|
||||
}
|
||||
return versions.PublishQueueOf(pq.reader(ctx), in.Module, in.Version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ go 1.26.0
|
||||
require (
|
||||
git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-contracts/go/seats/meshbroker v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000
|
||||
git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshwatchdogs v0.0.0-00010101000000-000000000000
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
@@ -509,17 +510,20 @@ func PublishItemKey(module, version string) string {
|
||||
return PublishItemKeyPrefix + EscapeToken(module) + "." + EscapeToken(version)
|
||||
}
|
||||
|
||||
// AnswerQueue is builder_publish_queue over the work queue publishes (its items, read in pages through the tool runtime, §793,
|
||||
// H-A-448) and the two states as the tools bundle reads them (H-A-290 (5)): each read in bulk (Reader.All), the answer counted and capped at PublishQueueListCap whatever the queue holds; module (and version) narrow the
|
||||
// listed queue to one module's (one version's), so an item's class can be read.
|
||||
func AnswerQueue(queue, acted, reasks Reader, module, version string) (Queued, error) {
|
||||
out := Queued{Counts: []QueueCount{}, Queue: []QueuedPublish{}, Acted: map[string]uint64{}, Items: []PublishItem{}}
|
||||
// PublishQueueOf is the seat mesh-builds' verb publish-queue (design 47 H2 §793; H-A-454): the builder's read of its own work queue
|
||||
// publishes (queue, its items read in bulk, capped past its bound), small at any size of the queue (H-A-290 (5)): the items' count
|
||||
// per holder and class with the oldest and newest queue time, and the first PublishQueueListCap in the order they are sent; module
|
||||
// (and version) narrow the list to one module's (one version's), so an item's class can be read.
|
||||
func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQueueAnswer, error) {
|
||||
out := meshbuilds.PublishQueueAnswer{Counts: []meshbuilds.PublishQueueAnswerCountsItem{}, Queue: []meshbuilds.PublishQueueAnswerQueueItem{}}
|
||||
vals, c, err := queue.values(PublishesLocal)
|
||||
out.capped(c)
|
||||
if c != nil {
|
||||
out.Capped, out.ItemsRead, out.QueueItems, out.QueueBytes = true, int64(c.KeysRead), int64(c.StateKeys), int64(c.StateBytes)
|
||||
}
|
||||
if err != nil {
|
||||
return out, fmt.Errorf("the work queue %s cannot be read: %w", PublishesLocal, err)
|
||||
}
|
||||
counts := map[[2]string]*QueueCount{}
|
||||
counts := map[[2]string]*meshbuilds.PublishQueueAnswerCountsItem{}
|
||||
var listed []QueuedPublish
|
||||
for _, raw := range vals {
|
||||
var q QueuedPublish
|
||||
@@ -532,7 +536,7 @@ func AnswerQueue(queue, acted, reasks Reader, module, version string) (Queued, e
|
||||
out.Total++
|
||||
c := counts[[2]string{q.Holder, q.Class}]
|
||||
if c == nil {
|
||||
c = &QueueCount{Holder: q.Holder, Class: q.Class, Oldest: q.Queued, Newest: q.Queued}
|
||||
c = &meshbuilds.PublishQueueAnswerCountsItem{Holder: q.Holder, Class: q.Class, Oldest: q.Queued, Newest: q.Queued}
|
||||
counts[[2]string{q.Holder, q.Class}] = c
|
||||
}
|
||||
c.Count++
|
||||
@@ -571,10 +575,27 @@ func AnswerQueue(queue, acted, reasks Reader, module, version string) (Queued, e
|
||||
if len(out.Queue) == PublishQueueListCap {
|
||||
break
|
||||
}
|
||||
out.Queue = append(out.Queue, q)
|
||||
out.Queue = append(out.Queue, meshbuilds.PublishQueueAnswerQueueItem{Holder: q.Holder, Module: q.Module, Version: q.Version,
|
||||
Class: q.Class, Artifacts: q.Artifacts, Queued: q.Queued})
|
||||
}
|
||||
}
|
||||
out.Listed = len(out.Queue)
|
||||
out.Listed = int64(len(out.Queue))
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AnswerQueue is builder_publish_queue: the seat mesh-builds' publish-queue answer the builder gave (q, §793, H-A-454) and the two
|
||||
// states as the tools bundle reads them (H-A-290 (5)), each read in bulk (Reader.All), capped at PublishQueueListCap.
|
||||
func AnswerQueue(q meshbuilds.PublishQueueAnswer, acted, reasks Reader) (Queued, error) {
|
||||
out := Queued{Total: int(q.Total), Counts: []QueueCount{}, Queue: []QueuedPublish{}, Listed: int(q.Listed), Acted: map[string]uint64{}, Items: []PublishItem{}}
|
||||
if q.Capped {
|
||||
out.capped(&StateCapped{State: PublishesLocal, KeysRead: int(q.ItemsRead), StateKeys: uint64(q.QueueItems), StateBytes: uint64(q.QueueBytes)})
|
||||
}
|
||||
for _, c := range q.Counts {
|
||||
out.Counts = append(out.Counts, QueueCount{Holder: c.Holder, Class: c.Class, Count: int(c.Count), Oldest: c.Oldest, Newest: c.Newest})
|
||||
}
|
||||
for _, it := range q.Queue {
|
||||
out.Queue = append(out.Queue, QueuedPublish{V: 1, Holder: it.Holder, Module: it.Module, Version: it.Version, Artifacts: it.Artifacts, Queued: it.Queued, Class: it.Class})
|
||||
}
|
||||
avals, c, err := acted.values(ActedState)
|
||||
out.capped(c)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
@@ -239,7 +240,7 @@ func TestRepublish(t *testing.T) {
|
||||
return json.RawMessage(`{"mode":"publish","module":"m","version":"0.1.0","tries":3,"next-try":"2026-11-17T01:00:00Z","why":"w"}`), true, nil
|
||||
}}
|
||||
none := Reader{Keys: func() ([]string, error) { return nil, nil }}
|
||||
answer, err := AnswerQueue(none, none, items, "", "")
|
||||
answer, err := answerOf(none, none, items, "", "")
|
||||
if err != nil || len(answer.Items) != 1 || answer.Items[0].Tries != 3 || answer.Items[0].Version != "0.1.0" {
|
||||
t.Errorf("builder_publish_queue items = %+v (%v), want the one publish item with its tries", answer.Items, err)
|
||||
}
|
||||
@@ -384,6 +385,24 @@ func TestAQueuedItemIsSentWhileItsBuildStands(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// answerOf is builder_publish_queue whole: the builder's verb publish-queue over its work queue (queue), then the tool over the
|
||||
// verb's answer and the two states (design 47 H2 §793, H-A-454).
|
||||
func answerOf(queue, acted, reasks Reader, module, version string) (Queued, error) {
|
||||
q, err := PublishQueueOf(queue, module, version)
|
||||
if err != nil {
|
||||
return Queued{}, err
|
||||
}
|
||||
raw, err := json.Marshal(q) // the verb's answer travels the bus
|
||||
if err != nil {
|
||||
return Queued{}, err
|
||||
}
|
||||
var heard meshbuilds.PublishQueueAnswer
|
||||
if err := json.Unmarshal(raw, &heard); err != nil {
|
||||
return Queued{}, err
|
||||
}
|
||||
return AnswerQueue(heard, acted, reasks)
|
||||
}
|
||||
|
||||
// TestThePublishQueueToolAnswersAtAnySize: design 47 H H-A-290 (5) — builder_publish_queue over two thousand queued versions answers
|
||||
// within a second and small: counts per holder and class with the oldest and newest queue time, a list capped at fifty in the
|
||||
// order they are sent, and one module's item with its class; each state read in bulk where the reader can.
|
||||
@@ -407,7 +426,7 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||
Get: func(k string) (json.RawMessage, bool, error) { gets++; v, ok := vals[k]; return v, ok, nil }}
|
||||
none := Reader{Keys: func() ([]string, error) { return nil, nil }}
|
||||
start := time.Now()
|
||||
a, err := AnswerQueue(queue, none, none, "", "")
|
||||
a, err := answerOf(queue, none, none, "", "")
|
||||
took := time.Since(start)
|
||||
raw, _ := json.Marshal(a)
|
||||
if err != nil || took > time.Second || a.Total != 2000 || len(a.Queue) != PublishQueueListCap || a.Listed != PublishQueueListCap || len(raw) > 64<<10 || gets != 0 {
|
||||
@@ -419,7 +438,7 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||
if a.Queue[0].Class != PublishClassLive || a.Queue[0].Holder != "go" {
|
||||
t.Errorf("the list opens with %+v, want the go holder's live class, sent first", a.Queue[0])
|
||||
}
|
||||
one, err := AnswerQueue(queue, none, none, "m1995", "")
|
||||
one, err := answerOf(queue, none, none, "m1995", "")
|
||||
if err != nil || len(one.Queue) != 1 || one.Queue[0].Class != PublishClassLive || one.Total != 2000 {
|
||||
t.Errorf("one module's answer %+v (%v), want its item with its class", one.Queue, err)
|
||||
}
|
||||
@@ -427,12 +446,12 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||
t.Errorf("a state one page holds is answered capped: %+v", a.Read)
|
||||
}
|
||||
queue.All = func() (StatePage, error) { return StatePage{Values: vals, More: true, Keys: 5000, Bytes: 3 << 20}, nil }
|
||||
if c, err := AnswerQueue(queue, none, none, "", ""); err != nil || !c.Capped || len(c.Read) != 1 || c.Read[0].State != PublishesLocal ||
|
||||
if c, err := answerOf(queue, none, none, "", ""); err != nil || !c.Capped || len(c.Read) != 1 || c.Read[0].State != PublishesLocal ||
|
||||
c.Read[0].KeysRead != 2000 || c.Read[0].StateKeys != 5000 || c.Read[0].StateBytes != 3<<20 || c.Total != 2000 {
|
||||
t.Errorf("a state past its one page answered capped %v, read %+v (%v): want capped, 2000 keys read of 5000, its size said (H-A-293)", c.Capped, c.Read, err)
|
||||
}
|
||||
queue.All = func() (StatePage, error) { return StatePage{}, errors.ErrUnsupported }
|
||||
if b, err := AnswerQueue(queue, none, none, "", ""); err != nil || b.Total != 2000 || gets != 2000 {
|
||||
if b, err := answerOf(queue, none, none, "", ""); err != nil || b.Total != 2000 || gets != 2000 {
|
||||
t.Errorf("a reader with no bulk read answered %d (%v) with %d single reads, want every key read one by one", b.Total, err, gets)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
)
|
||||
|
||||
// The controller's manifest reader is mesh-controller internal/catalogue (Manifest, manifest.go: Consumes :521,
|
||||
@@ -58,6 +60,9 @@ type manifest struct {
|
||||
MaxAgeDays int `json:"max-age-days"`
|
||||
MaxMiB int `json:"max-mib"`
|
||||
LastPerSubject bool `json:"last-per-subject"`
|
||||
Retention string `json:"retention"`
|
||||
Duplicates int `json:"duplicates"`
|
||||
MaxDeliveries int `json:"max-deliveries"`
|
||||
} `json:"streams"`
|
||||
Logs []struct {
|
||||
Name string `json:"name"`
|
||||
@@ -146,7 +151,7 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
||||
// The watchdogs seat's presence says a node's machine is heard (issue 1966, ADR 0596 §2, ADR 0668 §3).
|
||||
if want := []string{"seat:mesh-catalog.entry", "seat:mesh-catalog.registrations", "seat:mesh-catalog.seat-definitions", "seat:mesh-catalog.revision", "seat:mesh-delivery.source", "seat:container-image-registry.publish", "seat:container-image-registry.remove", "seat:container-image-registry.versions",
|
||||
"seat:git.tag", "seat:git.tags",
|
||||
"seat:go-package-registry.publish", "seat:go-package-registry.remove", "seat:go-package-registry.versions", "seat:mesh-artifact-sweep.held", "seat:mesh-builds.reserved", "seat:mesh-builds.drop", "seat:mesh-catalog.versions", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:mesh-watchdogs.presence", "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", "seat:node-build-go.answer", "seat:node-build-image.answer", "seat:node-build-node.answer", "seat:node-engine.manifest-reads", "seat:npm-package-registry.publish", "seat:npm-package-registry.remove",
|
||||
"seat:go-package-registry.publish", "seat:go-package-registry.remove", "seat:go-package-registry.versions", "seat:mesh-artifact-sweep.held", "seat:mesh-builds.reserved", "seat:mesh-builds.drop", "seat:mesh-builds.publish-queue", "seat:mesh-catalog.versions", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:mesh-watchdogs.presence", "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", "seat:node-build-go.answer", "seat:node-build-image.answer", "seat:node-build-node.answer", "seat:node-engine.manifest-reads", "seat:npm-package-registry.publish", "seat:npm-package-registry.remove",
|
||||
"seat:npm-package-registry.versions", "seat:oci-artifact-registry.publish", "seat:oci-artifact-registry.remove", "seat:oci-artifact-registry.versions",
|
||||
// A-231: the build asks on each build seat's queue delivery (accept.delivery.<asker>).
|
||||
"seat:node-build-go.accept.delivery", "seat:node-build-node.accept.delivery", "seat:node-build-image.accept.delivery"}; !reflect.DeepEqual(sorted(m.Invokes), sorted(want)) {
|
||||
@@ -182,9 +187,12 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
||||
}
|
||||
// Design 47 G §672: the toolchain waits' stream, kept 7 days within 16 MiB, and the bound's setting, 60 minutes.
|
||||
// Design 47 G A-30, §383: and its own findings' events, which its finding writer says.
|
||||
if len(m.Streams) != 3 || m.Streams[0].Name != "waits" || !reflect.DeepEqual(m.Streams[0].Events, []string{"wait-held.**", "wait-ended.**"}) || m.Streams[0].MaxAgeDays != 7 || m.Streams[0].MaxMiB != 16 ||
|
||||
if len(m.Streams) != 4 || m.Streams[0].Name != "waits" || !reflect.DeepEqual(m.Streams[0].Events, []string{"wait-held.**", "wait-ended.**"}) || m.Streams[0].MaxAgeDays != 7 || m.Streams[0].MaxMiB != 16 ||
|
||||
m.Streams[1].Name != builds.BuildsStream || !reflect.DeepEqual(m.Streams[1].Events, []string{builds.BuildsStreamEvents}) || m.Streams[1].MaxAgeDays != 7 || !m.Streams[1].LastPerSubject ||
|
||||
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) {
|
||||
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) ||
|
||||
// Design 47 H2 §793, §820, H-A-446 (2), H-A-454: the work queue publishes in the old section, 64 MiB, 7 days, duplicates 24 h.
|
||||
m.Streams[3].Name != versions.PublishesLocal || !reflect.DeepEqual(m.Streams[3].Events, []string{"publish.**"}) || m.Streams[3].Retention != "work-queue" ||
|
||||
m.Streams[3].Duplicates != 24 || m.Streams[3].MaxDeliveries != 10 || m.Streams[3].MaxAgeDays != 7 || m.Streams[3].MaxMiB != 64 {
|
||||
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
||||
}
|
||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 10 ||
|
||||
@@ -202,9 +210,10 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
||||
if len(m.Logs) != 1 || m.Logs[0].Name != builds.BuilderLog || m.Logs[0].MaxAgeDays != builds.BuilderLogDays || m.Logs[0].MaxMiB != builds.BuilderLogMiB {
|
||||
t.Errorf("logs = %+v, want %s kept %d days in %d MiB", m.Logs, builds.BuilderLog, builds.BuilderLogDays, builds.BuilderLogMiB)
|
||||
}
|
||||
// Design 47 G §52, §369, H-A-328, H2 §778: the seat mesh-builds, held once for the mesh, serving reserved, published and drop.
|
||||
if len(m.Claims) != 1 || m.Claims[0].Name != "mesh-builds" || m.Claims[0].Scope != "mesh" || !reflect.DeepEqual(m.Claims[0].Serves, []string{"reserved", "published", "drop"}) {
|
||||
t.Errorf("claims = %+v, want mesh-builds, scope mesh, serving reserved, published and drop", m.Claims)
|
||||
// Design 47 G §52, §369, H-A-328, H2 §778, §793: the seat mesh-builds, held once for the mesh, serving reserved, published, drop
|
||||
// and publish-queue (H-A-454).
|
||||
if len(m.Claims) != 1 || m.Claims[0].Name != "mesh-builds" || m.Claims[0].Scope != "mesh" || !reflect.DeepEqual(m.Claims[0].Serves, []string{"reserved", "published", "drop", "publish-queue"}) {
|
||||
t.Errorf("claims = %+v, want mesh-builds, scope mesh, serving reserved, published, drop and publish-queue", m.Claims)
|
||||
}
|
||||
// A-115: the process answers the verb itself and says so in `serves` beside its process, with no `bus`; the bundle serves no tool named so.
|
||||
var resources []map[string]any
|
||||
@@ -212,8 +221,8 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, r := range resources {
|
||||
if r["type"] == "process" && !reflect.DeepEqual(r["serves"], []any{"seat:mesh-builds.reserved", "seat:mesh-builds.published", "seat:mesh-builds.drop"}) {
|
||||
t.Errorf("the process serves %v, want seat:mesh-builds.reserved, published and drop (A-115, H-A-328, H2 §778)", r["serves"])
|
||||
if r["type"] == "process" && !reflect.DeepEqual(r["serves"], []any{"seat:mesh-builds.reserved", "seat:mesh-builds.published", "seat:mesh-builds.drop", "seat:mesh-builds.publish-queue"}) {
|
||||
t.Errorf("the process serves %v, want seat:mesh-builds.reserved, published, drop and publish-queue (A-115, H-A-328, H2 §778, §793)", r["serves"])
|
||||
}
|
||||
}
|
||||
if slices.Contains(m.Tools, "reserved") {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"serves": [
|
||||
"reserved",
|
||||
"published",
|
||||
"drop"
|
||||
"drop",
|
||||
"publish-queue"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -95,6 +96,7 @@
|
||||
"seat:mesh-artifact-sweep.held",
|
||||
"seat:mesh-builds.reserved",
|
||||
"seat:mesh-builds.drop",
|
||||
"seat:mesh-builds.publish-queue",
|
||||
"seat:mesh-catalog.versions",
|
||||
"seat:mesh-hand-acts.hand-act",
|
||||
"seat:mesh-module-assigner.assignments",
|
||||
@@ -149,7 +151,8 @@
|
||||
"streams": [
|
||||
{ "name": "waits", "events": ["wait-held.**", "wait-ended.**"], "max-age-days": 7, "max-mib": 16 },
|
||||
{ "name": "mesh-delivery-builder-builds", "events": ["build.ended.**"], "max-age-days": 7, "max-mib": 16, "last-per-subject": true },
|
||||
{ "name": "mesh-delivery-builder-findings", "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 16 }
|
||||
{ "name": "mesh-delivery-builder-findings", "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 16 },
|
||||
{ "name": "publishes", "events": ["publish.**"], "retention": "work-queue", "duplicates": 24, "max-deliveries": 10, "max-age-days": 7, "max-mib": 64 }
|
||||
],
|
||||
"config": {
|
||||
"toolchain-wait-minutes": {
|
||||
@@ -329,7 +332,8 @@
|
||||
"serves": [
|
||||
"seat:mesh-builds.reserved",
|
||||
"seat:mesh-builds.published",
|
||||
"seat:mesh-builds.drop"
|
||||
"seat:mesh-builds.drop",
|
||||
"seat:mesh-builds.publish-queue"
|
||||
],
|
||||
"run": [
|
||||
"./mesh-delivery-builder"
|
||||
|
||||
Reference in New Issue
Block a user