R12: the runner's manifest: its findings history drops its oldest at 8 MiB, every state capped, the kept call's pace
The findings stream is 8 MiB, kept 7 days, its oldest dropped when full (no findings-max-age setting: nothing reads one). Every state names its cap: 8 MiB, bounds 16 MiB above four times its live fill (2,188,123 bytes on novox, 2026-11-22 00:16 UTC; queue 50,604, findings 285,807, the rest under 3 KB). ask-silent-bound, its file and its environment go. The kept call's pace is declared, kept-call-pace-first 1s and kept-call-pace-max 30s, read at runtime. The runner consumes mesh-builds' and mesh-wants' ask-taken and invokes their drop. The whole test writes 10,000 findings past the manifest's cap and none is refused. Builds: design 47 H2 §783, §775, §777, §778, §820; H-A-411 (1), (2), H-A-437
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||
@@ -370,9 +371,50 @@ func readPipeline(ctx context.Context, kv jetstream.KeyValue, key string, p *sea
|
||||
// findingsStream makes the stream of the module's own finding events, as its manifest's streams ask the bus for
|
||||
// (`mesh.stream.<module>.event.>`), so a finding the runner writes, such as the unhandled-event count of the SDK's view
|
||||
// reader (H-A-166, H-A-169), is acknowledged at once and holds no event behind its 3 s wait for the bus.
|
||||
// Its cap and life are the manifest's, the bus dropping the oldest when full (design 47 H2 §783): 10,000 findings written
|
||||
// past the cap are each taken, none refused.
|
||||
func findingsStream(t *testing.T, ctx context.Context, js jetstream.JetStream, module string) {
|
||||
t.Helper()
|
||||
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: module + "-findings", Subjects: []string{"mesh.stream." + module + ".event.>"}}); err != nil {
|
||||
raw, err := os.ReadFile("../../module.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m, err := catalogue.Decode(raw)
|
||||
if err != nil || len(m.Streams) != 1 {
|
||||
t.Fatalf("the manifest's findings stream: %v", err)
|
||||
}
|
||||
cap := int64(m.Streams[0].MaxMiB) << 20
|
||||
st, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: module + "-findings", Subjects: []string{"mesh.stream." + module + ".event.>"},
|
||||
MaxBytes: cap, MaxAge: time.Duration(m.Streams[0].MaxAgeDays) * 24 * time.Hour, Discard: jetstream.DiscardOld})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body := []byte(`{"v":1,"finding":"x","words":"` + strings.Repeat("w", 1024) + `"}`)
|
||||
var acks []jetstream.PubAckFuture
|
||||
for i := range 10000 {
|
||||
f, err := js.PublishAsync(fmt.Sprintf("mesh.stream.%s.event.finding-written.f%d", module, i), body)
|
||||
if err != nil {
|
||||
t.Fatalf("finding %d is refused: %v", i, err)
|
||||
}
|
||||
acks = append(acks, f)
|
||||
}
|
||||
select {
|
||||
case <-js.PublishAsyncComplete():
|
||||
case <-ctx.Done():
|
||||
t.Fatal("the findings were not all acknowledged")
|
||||
}
|
||||
for i, f := range acks {
|
||||
select {
|
||||
case err := <-f.Err():
|
||||
t.Fatalf("finding %d past the cap is refused: %v", i, err)
|
||||
default:
|
||||
}
|
||||
}
|
||||
info, err := st.Info(ctx)
|
||||
if err != nil || info.State.Bytes > uint64(cap) || info.State.Msgs >= 10000 {
|
||||
t.Fatalf("the findings stream holds %d bytes in %d messages (%v), want at most its cap %d, the oldest dropped", info.State.Bytes, info.State.Msgs, err, cap)
|
||||
}
|
||||
if err := st.Purge(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package pipeline_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"maps"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -58,6 +59,10 @@ func TestManifest(t *testing.T) {
|
||||
{"old state sections", equalSets(states, []string{seat.StatePipelines, seat.StateKept, "aged", "recoveries", "bounds", "test-runs", "toolchains", "findings", "first-views", "consumers", seat.StateQueue, "unfinished"})},
|
||||
// design 47 H2 §786, §820: unfinished is a state of 8 MiB.
|
||||
{"unfinished 8 MiB", stateMiB["unfinished"] == 8},
|
||||
// design 47 H2 §814, §820; H-A-411 (2), H-A-437: every state names its cap, 8 MiB where its live fill allows, bounds
|
||||
// 16 MiB (2.1 MiB live on 2026-11-22).
|
||||
{"every state capped", !slices.Contains(slices.Collect(maps.Values(stateMiB)), 0) && stateMiB["bounds"] == 16 &&
|
||||
stateMiB[seat.StateQueue] == 8 && stateMiB["findings"] == 8},
|
||||
// §535, §647, A-77, A-104: an ask no holder takes is bound by a key with its own time to live.
|
||||
{"bounds is key-ttl", keyTTL["bounds"]},
|
||||
// §725, A-469w, A-470: test-runs holds its runs' bound keys, each with its own time to live; 64 MiB its ceiling.
|
||||
@@ -73,7 +78,8 @@ func TestManifest(t *testing.T) {
|
||||
{"old streams section", equalSets(streams, []string{"mesh-delivery-pipeline-findings"})},
|
||||
{"step-log an old logs section of 100 days and 128 MiB", len(m.Logs) == 1 && m.Logs[0].Name == seat.StateStepLog &&
|
||||
m.Logs[0].MaxAgeDays == 100 && m.Logs[0].MaxMiB == 128},
|
||||
{"finding stream 7 days 16 MiB", len(m.Streams) == 1 && m.Streams[0].MaxAgeDays == 7 && m.Streams[0].MaxMiB == 16 &&
|
||||
// design 47 H2 §783, H-A-411 (1): the findings history drops its oldest at 8 MiB, kept 7 days.
|
||||
{"finding stream 7 days 8 MiB", len(m.Streams) == 1 && m.Streams[0].MaxAgeDays == 7 && m.Streams[0].MaxMiB == 8 &&
|
||||
equalSets(m.Streams[0].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"})},
|
||||
// RN24 (§368): the version as MAJOR.MINOR, 0.1 with none published.
|
||||
{"version 0.1", m.Version == "0.1"},
|
||||
@@ -84,7 +90,9 @@ func TestManifest(t *testing.T) {
|
||||
// §333, §54, §44, §53, §376, §24, §37, §4, §77: what the runner hears.
|
||||
{"consumes", equalSets(m.Consumes, []string{
|
||||
"mesh-delivery-indexer.take-in.taken", "mesh-builds.package-published", "mesh-builds.toolchain-agreed", "mesh-builds.step-ended",
|
||||
"operator-channel.decided", "node-build-go.step-ended", "node-build-node.step-ended",
|
||||
"operator-channel.decided", "node-build-go.step-ended",
|
||||
// design 47 H2 §777, §778: the bound of an ask on mesh-builds and mesh-wants counts from its holder's pull.
|
||||
"mesh-builds.ask-taken", "mesh-wants.ask-taken", "node-build-node.step-ended",
|
||||
"node-build-image.step-ended", "node-build-go.ask-taken", "node-build-node.ask-taken", "node-build-image.ask-taken",
|
||||
"node-build-go.step-progress", "node-build-node.step-progress", "node-build-image.step-progress", "mesh-wants.step-ended", "mesh-wants.step-progress", "node-engine.running", "mesh-catalog.registration-changed",
|
||||
"mesh-catalog.catalog-revision", "mesh-catalog.version-released", "mesh-conditions.findings-asked", "mesh-delivery.recovery-merged",
|
||||
@@ -112,6 +120,8 @@ func TestManifest(t *testing.T) {
|
||||
"seat:node-build-image.check.step",
|
||||
// H-A-328: whether a package a mover waits on is published, read when the wait is written.
|
||||
"seat:mesh-builds.published",
|
||||
// design 47 H2 §778: a step ended by its bound drops its ask through the seat's drop.
|
||||
"seat:mesh-builds.drop", "seat:mesh-wants.drop",
|
||||
// RN22 (§86, §415, A-207): a recovery's steps on the build seats' stream delivery.
|
||||
"seat:node-build-go.delivery.step", "seat:node-build-node.delivery.step", "seat:node-build-image.delivery.step",
|
||||
// A-231: the queues of the build seats it asks, check for the steps and delivery for a recovery's.
|
||||
@@ -211,13 +221,15 @@ func runSettingsOf(raw []byte) bool {
|
||||
if json.Unmarshal(raw, &m) != nil {
|
||||
return false
|
||||
}
|
||||
want := map[string]string{"test-runs-cap-mib": "number", "test-runs-kept": "string", "test-step-bound": "string", "run-untaken-bound": "string", "ask-unanswered-bound": "string", "ask-silent-bound": "string", "widens-read-bound": "string", "revisions-kept": "number",
|
||||
want := map[string]string{"test-runs-cap-mib": "number", "test-runs-kept": "string", "test-step-bound": "string", "run-untaken-bound": "string", "ask-unanswered-bound": "string", "widens-read-bound": "string", "revisions-kept": "number",
|
||||
"pipelines-at-once": "number", "pipelines-waiting-cap": "number"}
|
||||
// design 47 H2 §790, §781: stalled-bound is read through mesh-sdk's settings reader, by the process and the tools
|
||||
// program alike, from the words the node-engine composes: no file of its own.
|
||||
words := map[string]string{"stalled-bound": "string"}
|
||||
for key, kind := range words {
|
||||
if m.Config[key]["type"] != kind || m.Config[key]["default"] != "5m" || m.Config[key]["runtime"] != true {
|
||||
// design 47 H2 §775: the kept-call form's pace, read by mesh-sdk at the process's and the bundle's start; §777:
|
||||
// ask-silent-bound goes.
|
||||
words := map[string]string{"stalled-bound": "5m", "kept-call-pace-first": "1s", "kept-call-pace-max": "30s"}
|
||||
for key, def := range words {
|
||||
if m.Config[key]["type"] != "string" || m.Config[key]["default"] != def || m.Config[key]["runtime"] != true {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
"mesh-builds.package-published",
|
||||
"mesh-builds.toolchain-agreed",
|
||||
"mesh-builds.step-ended",
|
||||
"mesh-builds.ask-taken",
|
||||
"operator-channel.decided",
|
||||
"node-build-go.step-ended",
|
||||
"node-build-node.step-ended",
|
||||
@@ -66,6 +67,7 @@
|
||||
"node-build-image.step-progress",
|
||||
"mesh-wants.step-ended",
|
||||
"mesh-wants.step-progress",
|
||||
"mesh-wants.ask-taken",
|
||||
"node-engine.running",
|
||||
"mesh-catalog.registration-changed",
|
||||
"mesh-catalog.catalog-revision",
|
||||
@@ -87,7 +89,9 @@
|
||||
"seat:mesh-grants.grants-for",
|
||||
"seat:mesh-builds.step",
|
||||
"seat:mesh-builds.published",
|
||||
"seat:mesh-builds.drop",
|
||||
"seat:mesh-wants.step",
|
||||
"seat:mesh-wants.drop",
|
||||
"seat:node-build-go.check.step",
|
||||
"seat:node-build-node.check.step",
|
||||
"seat:node-build-image.check.step",
|
||||
@@ -179,11 +183,19 @@
|
||||
"runtime": true,
|
||||
"default": "5m"
|
||||
},
|
||||
"ask-silent-bound": {
|
||||
"kept-call-pace-first": {
|
||||
"type": "string",
|
||||
"description": "how long an ask the runner puts on a seat whose holder says nothing before the step's end (mesh-builds, mesh-wants) may go without that end before its step ends could not run, a Go duration such as 45m (design 47 H H-A-243).",
|
||||
"description": "how long a kept call waits after its first transport fault before it calls again, a Go duration such as 1s; each wait doubles to kept-call-pace-max and is drawn within 20 % of its value (design 47 H2 section 775).",
|
||||
"trusted": false,
|
||||
"default": "45m"
|
||||
"runtime": true,
|
||||
"default": "1s"
|
||||
},
|
||||
"kept-call-pace-max": {
|
||||
"type": "string",
|
||||
"description": "the longest wait between two calls of a kept call met by transport faults, a Go duration such as 30s (design 47 H2 section 775).",
|
||||
"trusted": false,
|
||||
"runtime": true,
|
||||
"default": "30s"
|
||||
}
|
||||
},
|
||||
"state": [
|
||||
@@ -199,24 +211,29 @@
|
||||
},
|
||||
{
|
||||
"name": "queue",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "aged",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "recoveries",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "toolchains",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "bounds",
|
||||
"history": 1,
|
||||
"key-ttl": true
|
||||
"key-ttl": true,
|
||||
"max-mib": 16
|
||||
},
|
||||
{
|
||||
"name": "test-runs",
|
||||
@@ -226,15 +243,18 @@
|
||||
},
|
||||
{
|
||||
"name": "findings",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "first-views",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "consumers",
|
||||
"history": 1
|
||||
"history": 1,
|
||||
"max-mib": 8
|
||||
},
|
||||
{
|
||||
"name": "unfinished",
|
||||
@@ -251,7 +271,7 @@
|
||||
"findings-stated.*"
|
||||
],
|
||||
"max-age-days": 7,
|
||||
"max-mib": 16
|
||||
"max-mib": 8
|
||||
}
|
||||
],
|
||||
"objects": [
|
||||
@@ -320,14 +340,6 @@
|
||||
"mode": "0600",
|
||||
"content": "${config:ask-unanswered-bound}"
|
||||
},
|
||||
{
|
||||
"id": "ask-silent-bound",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/ask-silent-bound",
|
||||
"owner": "mesh-delivery-pipeline",
|
||||
"mode": "0600",
|
||||
"content": "${config:ask-silent-bound}"
|
||||
},
|
||||
{
|
||||
"id": "widens-read-bound",
|
||||
"type": "file",
|
||||
@@ -377,7 +389,6 @@
|
||||
"MESH_RUNNER_REVISIONS_KEPT_FILE": "${dir:state}/revisions-kept",
|
||||
"MESH_RUNNER_RUN_UNTAKEN_BOUND_FILE": "${dir:state}/run-untaken-bound",
|
||||
"MESH_RUNNER_ASK_UNANSWERED_BOUND_FILE": "${dir:state}/ask-unanswered-bound",
|
||||
"MESH_RUNNER_ASK_SILENT_BOUND_FILE": "${dir:state}/ask-silent-bound",
|
||||
"MESH_RUNNER_PIPELINES_AT_ONCE_FILE": "${dir:state}/pipelines-at-once",
|
||||
"MESH_RUNNER_PIPELINES_WAITING_CAP_FILE": "${dir:state}/pipelines-waiting-cap"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user