A6 reads-share-a-deadline: every read of a run is a kept call stopping at the run's first read plus reads-bound; callRetry, transient and the fixed bounds go

Builds: design 47 H2 H-A-708 (3)
This commit is contained in:
2026-11-25 17:31:09 +01:00
parent 43f2ebc4ba
commit b24dd11ff4
10 changed files with 248 additions and 115 deletions
@@ -10,23 +10,59 @@ import (
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
"git.novox.be/novox/mesh-sdk/go/buscalls"
"git.novox.be/novox/mesh-sdk/go/process"
)
// The reads of a composition step (design 47 G §354, A-252, A-261): the entries of one catalog revision are read once and shared by
// every composition step of that revision, since an entry is content-addressed and a revision never changes; a read that times out
// or fails in transport is made again with a growing wait for a bounded time, said in the journal, and only then ends the step as
// could not run.
// every composition step of that revision, since an entry is content-addressed and a revision never changes. Every read of the
// seats mesh-catalog and mesh-builds is a kept call (§775), paced by the form, and all of one run's reads stop at one deadline: its
// first read's time plus the setting reads-bound (design 47 H2 H-A-708 (3)); past it the run ends could not run with every call's
// time and words.
const (
// readsBound is how long a read is made again before the step could not run.
readsBound = 3 * time.Minute
// readsFirstWait and readsMaxWait bound the wait between two tries.
readsFirstWait = time.Second
readsMaxWait = 15 * time.Second
// defaultReadsBound is the setting reads-bound's default, 8 minutes: it spans the six minutes a seat went unanswered on
// 2026-11-23 and stays below the runner's ask-unanswered-bound (10 minutes, counted from the pull), so the step ends with the
// assigner's words.
defaultReadsBound = 8 * time.Minute
// readsKept is how many catalog revisions' halves are kept; the oldest read goes first.
readsKept = 8
)
// readsBoundSetting is the setting reads-bound, in minutes, read at the start from the file the manifest declares with the content
// ${config:reads-bound}; its default for a file missing or empty.
func readsBoundSetting(getenv func(string) string) (time.Duration, error) {
minutes, err := settingFile(getenv("MESH_ASSIGNER_READS_BOUND_FILE"))
if err != nil || minutes == 0 {
return defaultReadsBound, err
}
return time.Duration(minutes) * time.Minute, nil
}
// readsClock is the deadline of one run's reads: it begins at the run's first read.
type readsClock struct {
mu sync.Mutex
first time.Time
last string
}
type readsClockKey struct{}
// withReadsClock gives ctx the clock of one run's reads; a ctx that has one keeps it.
func withReadsClock(ctx context.Context) context.Context {
if ctx.Value(readsClockKey{}) != nil {
return ctx
}
return context.WithValue(ctx, readsClockKey{}, &readsClock{})
}
// readsClockOf is the clock of the run ctx belongs to, or a clock of its own for a read made outside a run.
func readsClockOf(ctx context.Context) *readsClock {
if c, ok := ctx.Value(readsClockKey{}).(*readsClock); ok {
return c
}
return &readsClock{}
}
// readKey names one revision of one watched branch.
type readKey struct {
branch string
@@ -48,65 +84,68 @@ type compositionReads struct {
seats map[string]json.RawMessage // by seat and digest: the definition, raw
}
// transient says whether a read's fault is of the transport or a timeout, so that it is worth reading again.
func transient(err error, said string) bool {
text := said
// callRead calls the seat verb key as a kept call that stops at the run's deadline (design 47 H2 H-A-708 (3)); it answers the body
// of a good answer, or the holder's own words of an answer that is none, or the fault naming the holder, its machine and every
// call of the form.
func (r *compositionRun) callRead(ctx context.Context, key string, body any) (json.RawMessage, string, error) {
if err := ctx.Err(); err != nil {
return nil, "", err
}
clock := readsClockOf(ctx)
left, bound, first := r.readsLeft(clock)
if left <= 0 {
clock.mu.Lock()
last := clock.last
clock.mu.Unlock()
return nil, "", fmt.Errorf("%s is not read: the run's reads passed their deadline of %s (the setting reads-bound) counted from its first read at %s%s",
key, bound, first.UTC().Format(time.RFC3339), last)
}
raw, err := r.call(process.KeptAsk{Bound: left}, key, body)
if err != nil {
text = err.Error() + " " + said
words := fmt.Errorf("%s%s: %w", key, r.holderWords(key), err)
clock.mu.Lock()
clock.last = "; the last read said: " + words.Error()
clock.mu.Unlock()
return nil, "", words
}
text = strings.ToLower(text)
for _, w := range []string{"deadline exceeded", "timeout", "timed out", "no responders", "connection", "i/o", "eof", "broken pipe", "unavailable"} {
if strings.Contains(text, w) {
return true
}
inner, said, ok := buscalls.Unwrap(raw)
if ok {
return inner, "", nil
}
return false
return nil, said, nil
}
// callRetry calls the seat verb key, again with a growing wait while its fault is transient, for readsBound; it answers the body of
// a good answer, or the last fault.
func (r *compositionRun) callRetry(ctx context.Context, key string, body any) (json.RawMessage, string, error) {
start := r.now()
wait := readsFirstWait
for try := 1; ; try++ {
raw, err := r.call(key, body)
var inner json.RawMessage
var said string
if err == nil {
var ok bool
if inner, said, ok = buscalls.Unwrap(raw); ok {
return inner, "", nil
}
}
if !transient(err, said) {
return nil, said, err
}
if r.now().Sub(start)+wait > readsBound {
return nil, said, err
}
r.logf("composition step: %s is not read (try %d, %v %s), read again in %s", key, try, err, said, wait)
if serr := r.waitFor(ctx, wait); serr != nil {
return nil, said, serr
}
if wait *= 2; wait > readsMaxWait {
wait = readsMaxWait
}
// readsLeft is what stays of the run's reads' deadline, with the deadline's length and its first read's time; the first read
// begins it.
func (r *compositionRun) readsLeft(clock *readsClock) (left, bound time.Duration, first time.Time) {
bound = r.readsBound
if bound <= 0 {
bound = defaultReadsBound
}
now := r.now()
clock.mu.Lock()
defer clock.mu.Unlock()
if clock.first.IsZero() {
clock.first = now
}
return bound - now.Sub(clock.first), bound, clock.first
}
// waitFor waits d, or until ctx ends.
func (r *compositionRun) waitFor(ctx context.Context, d time.Duration) error {
if r.sleep != nil {
return r.sleep(ctx, d)
// holderWords name the module that holds the seat of key and the machines it runs on, as the seat list names them (design 47 H2
// H-A-708 (3)); nothing where they are not read.
func (r *compositionRun) holderWords(key string) string {
seat, _, _ := strings.Cut(strings.TrimPrefix(key, "seat:"), ".")
if r.holder == nil || seat == "" {
return ""
}
t := time.NewTimer(d)
defer t.Stop()
select {
case <-ctx.Done():
return ctx.Err()
case <-t.C:
return nil
module, nodes := r.holder(seat)
if module == "" {
return ""
}
if len(nodes) == 0 {
return " (its holder " + module + ")"
}
return " (its holder " + module + " on " + strings.Join(nodes, ", ") + ")"
}
// half is the revision's half, read once for every step of it: a step that finds it being read waits for that read, and a read that
@@ -58,8 +58,12 @@ type compositionRun struct {
runs *compositionRuns
inputs *compositionInputs
keeper *inputKeeper
// call asks a seat verb held once for the mesh (process.Conn.CallKept).
call func(key string, body any) (json.RawMessage, error)
// call asks a seat verb held once for the mesh as a kept call that stops at the ask's bound (process.Conn.CallKeptAsk).
call func(ask process.KeptAsk, key string, body any) (json.RawMessage, error)
// readsBound is the setting reads-bound: the run's reads stop at its first read's time plus it (H-A-708 (3)); zero: its default.
readsBound time.Duration
// holder is the module holding a seat and the machines it runs on, for the words of a read that met a fault; nil: none named.
holder func(seat string) (module string, nodes []string)
// callFile asks a seat verb held once for the mesh whose answer comes in chunks, as a kept call (process.Conn.CallFileKept),
// answering the verb's answer with the bytes received as its member `file`, base64: the validate step's seat-list (H-A-443).
callFile func(ask process.KeptAsk, key string, body any) (json.RawMessage, error)
@@ -87,9 +91,8 @@ type compositionRun struct {
// own is the assigner's own context: a run's start, and its wait for a package's publish, run on it as the take-up's do, never
// on the starting step's, which a supersede or a drop ends while other steps share the run (design 47 H2 H-A-630 (3)).
own context.Context
// reads shares the catalog reads among steps (compositionreads.go); sleep waits between two tries of a read (nil: a timer).
// reads shares the catalog reads among steps (compositionreads.go).
reads *compositionReads
sleep func(ctx context.Context, d time.Duration) error
// ask asks a seat verb on one node, for the run's answer kept as the build seat's object (buildstep.StepEnded.ReadOutput).
ask buildstep.AskVerb
now func() time.Time
@@ -258,6 +261,7 @@ func (p *runPrep) get(ctx context.Context) error {
// start composes the machine of the run the step asked under stepAsk started (§718): the node's input of this moment, its request kept once in `inputs`,
// the composer program chosen and recorded with the request's digest, and one run ask put. A fault ends the run could not run.
func (r *compositionRun) start(ctx context.Context, key string, run meshwants.CompositionRun, prep *runPrep, stepAsk string) {
ctx = withReadsClock(ctx) // all the run's reads stop at one deadline (design 47 H2 H-A-708 (3))
node, ask := run.Machine, run.Ask
end := func(said string) {
if _, err := r.runs.endRun(key, ask, meshwants.CompositionRunOutcomeCouldNotRun, said, nil); err != nil {
@@ -477,7 +481,7 @@ func (r *compositionRun) readRevision(ctx context.Context, run meshwants.StepRun
half := mcc.Half{Entries: map[string]meshcatalog.CatalogEntry{}}
in := meshcatalog.RevisionInput{Branch: keys.EscapeName(run.Branch), Revision: run.Revision}
for {
body, said, err := r.callRetry(ctx, mcc.RevisionVerb, in)
body, said, err := r.callRead(ctx, mcc.RevisionVerb, in)
if err != nil {
return mcc.Half{}, err
}
@@ -526,7 +530,7 @@ func (r *compositionRun) seats(ctx context.Context, defs []meshcatalog.CatalogRe
// trunkSeats are the definitions of every seat of the trunk's seat list (seat-definitions with no seat names them with their digests).
func (r *compositionRun) trunkSeats(ctx context.Context) ([]json.RawMessage, error) {
what := "the trunk's seat list is not read"
body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{})
body, said, err := r.callRead(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{})
if err != nil || body == nil {
return nil, unreadErr(what, err, said)
}
@@ -554,7 +558,7 @@ func (r *compositionRun) seatAt(ctx context.Context, seat, digest string) (json.
return def, nil
}
what := "the definition of the seat " + seat + " is not read"
body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{Seat: seat})
body, said, err := r.callRead(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{Seat: seat})
if err != nil || body == nil {
return nil, unreadErr(what, err, said)
}
@@ -998,7 +1002,7 @@ func (r *compositionRun) takeUpWaits(ctx context.Context) {
// publishedOf asks the seat mesh-builds' verb published whether by's build is published, answering the pin it is published at
// (vMAJOR.MINOR.PATCH, spec S9) when it is.
func (r *compositionRun) publishedOf(ctx context.Context, by packagePublisher) (string, bool, error) {
body, said, err := r.callRetry(ctx, publishedVerbKey, builds.PublishedInput{Module: by.module, Artifact: by.artifact, Fingerprint: by.fingerprint})
body, said, err := r.callRead(ctx, publishedVerbKey, builds.PublishedInput{Module: by.module, Artifact: by.artifact, Fingerprint: by.fingerprint})
if err != nil || body == nil {
return "", false, unreadErr(builds.VerbPublished+" did not answer", err, said)
}
@@ -1052,7 +1056,7 @@ func (r *compositionRun) programs(ctx context.Context, half mcc.Half) (func(node
return b.program, fp, b.pins, nil
}
what := "the entry of the node-engine's build " + fp + " is not read"
body, said, err := r.callRetry(ctx, entryVerbKey, meshcatalog.EntryInput{Fingerprint: fp})
body, said, err := r.callRead(ctx, entryVerbKey, meshcatalog.EntryInput{Fingerprint: fp})
if err != nil || body == nil {
return buildstep.RunProgram{}, fp, nil, unreadErr(what, err, said)
}
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"git.novox.be/novox/mesh-sdk/go/busretry"
"git.novox.be/novox/mesh-sdk/go/process"
"github.com/nats-io/nats.go/jetstream"
"maps"
@@ -201,7 +202,7 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) *
s.runs = newCompositionRuns(newRunsMem(), defaultRunSettings, time.Now, t.Logf)
s.r = &compositionRun{runs: s.runs,
inputs: &compositionInputs{machines: func(string, string) []string { return []string{"ace", "g14", "shanks"} }, callFile: engines, bound: time.Second},
keeper: keeper, reads: &compositionReads{}, call: call, away: away, own: context.Background(), now: time.Now, logf: t.Logf,
keeper: keeper, reads: &compositionReads{}, call: asKept(call), away: away, own: context.Background(), now: time.Now, logf: t.Logf,
trunk: func() (mcc.Half, bool) {
return mcc.Half{Entries: map[string]meshcatalog.CatalogEntry{"engine": engine(trunkEngine, commitE1)}}, true
},
@@ -663,51 +664,40 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
}
}
// Design 47 G §354, A-252: the entries of one catalog revision are read once for every step of it, and a read that times out is
// made again with a growing wait for a bounded time, said in the journal, before the step could not run.
func TestTheCompositionStepReadsTheRevisionOnceAndAgainOnATimeout(t *testing.T) {
// asKept is a fake seat call as the kept call the run makes: the bound and the hook are the call's own, a fake answers at once.
func asKept(call func(key string, body any) (json.RawMessage, error)) func(process.KeptAsk, string, any) (json.RawMessage, error) {
return func(_ process.KeptAsk, key string, body any) (json.RawMessage, error) { return call(key, body) }
}
// Design 47 G §354, A-252: the entries of one catalog revision are read once for every step of it, and a fault of the holder's own
// answer is not read again.
func TestTheCompositionStepReadsTheRevisionOnce(t *testing.T) {
step := meshwants.StepRun{Module: "m", Branch: "main", Revision: 7, Step: meshwants.StepRunStepComposition}
for _, tc := range []struct {
name string
faults int // consecutive faults of the `revision` read before it answers
fault error // the fault
fault error // the fault of the `revision` read, none: it answers
steps int
want string // the outcome of the last step
revisionCalls int
waits int
}{
{"two steps of one revision read it once", 0, nil, 2, meshwants.StepEndedOutcomeFailed, 2, 0},
{"a timeout is read again", 3, errors.New("context deadline exceeded"), 1, meshwants.StepEndedOutcomeFailed, 5, 3},
{"a fault that stays ends could not run", 1000, errors.New("nats: timeout"), 1, meshwants.StepEndedOutcomeCouldNotRun, -1, -1},
{"a fault of the answer is not read again", 1, errors.New("no such revision"), 1, meshwants.StepEndedOutcomeCouldNotRun, 1, 0},
{"two steps of one revision read it once", nil, 2, meshwants.StepEndedOutcomeFailed, 2},
{"a fault of the answer is not read again", errors.New("no such revision"), 1, meshwants.StepEndedOutcomeCouldNotRun, 1},
} {
t.Run(tc.name, func(t *testing.T) {
s := newRunStand(t, "src2:e1", "src2:e1", "d1")
inner := s.r.call
var mu sync.Mutex
calls, faults := 0, tc.faults
s.r.call = func(key string, body any) (json.RawMessage, error) {
calls := 0
s.r.call = func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) {
if key == mcc.RevisionVerb {
mu.Lock()
calls++
f := faults > 0
faults--
mu.Unlock()
if f {
if tc.fault != nil {
return nil, tc.fault
}
}
return inner(key, body)
}
clock := time.Unix(1000, 0)
var waits []time.Duration
s.r.now = func() time.Time { mu.Lock(); defer mu.Unlock(); return clock }
s.r.sleep = func(_ context.Context, d time.Duration) error {
mu.Lock()
defer mu.Unlock()
waits = append(waits, d)
clock = clock.Add(d)
return nil
return inner(ask, key, body)
}
var wg sync.WaitGroup
outs := make([]stepOutcome, tc.steps)
@@ -721,24 +711,73 @@ func TestTheCompositionStepReadsTheRevisionOnceAndAgainOnATimeout(t *testing.T)
t.Fatalf("a step came to %+v, want %s", o, tc.want)
}
}
if tc.waits == -1 { // never answers: bounded, growing waits
if len(waits) < 3 || waits[0] != readsFirstWait || waits[1] != 2*readsFirstWait || waits[len(waits)-1] != readsMaxWait {
t.Errorf("the waits %v do not grow to %s", waits, readsMaxWait)
}
var total time.Duration
for _, w := range waits {
total += w
}
if total > readsBound {
t.Errorf("read again for %s, bound %s", total, readsBound)
}
if !strings.Contains(outs[0].Said, "catalog revision is not read") || !strings.Contains(outs[0].Said, "timeout") {
t.Errorf("the step said %q", outs[0].Said)
if calls != tc.revisionCalls {
t.Errorf("`revision` asked %d times, want %d", calls, tc.revisionCalls)
}
})
}
}
// Design 47 H2 H-A-708 (3), AC-A6: every read of a run is a kept call that stops at one deadline, the run's first read's time plus
// reads-bound (default 8 minutes): two reads each unanswered in turn end the run could not run with the assigner's words before
// the runner's bound of 10 minutes, naming the holder and its machine, the last fault and the calls; a read answered after a
// fault of two minutes composes.
func TestARunsReadsShareOneDeadline(t *testing.T) {
step := meshwants.StepRun{Module: "m", Branch: "main", Revision: 7, Step: meshwants.StepRunStepComposition}
away := &busretry.Away{Part: "the trunk's revision 512", Words: "not read yet since 23:35:40"}
for _, tc := range []struct {
name string
answer func(clock *time.Time, ask process.KeptAsk, key string) error // a fault of the read, none: it answers
want string
bounds []time.Duration // the bound each kept call was given, in order
}{
{"seat-definitions met by no responders for two minutes and then answered composes", func(clock *time.Time, ask process.KeptAsk, key string) error {
if key == seatDefinitionsKey && clock.Before(time.Unix(1000, 0).Add(2*time.Minute)) {
*clock = clock.Add(2 * time.Minute) // the form met no responders for two minutes, then the holder answered
}
return nil
}, meshwants.StepEndedOutcomeFailed, nil},
{"two reads each unanswered in turn end the run at the shared deadline", func(clock *time.Time, ask process.KeptAsk, key string) error {
if key == mcc.RevisionVerb || key == seatDefinitionsKey {
*clock = clock.Add(ask.Bound) // the form asks again until the bound it is given
return &busretry.Unanswered{Seat: "mesh-catalog", Verb: "x", Bound: ask.Bound, Tries: []busretry.Try{{At: *clock, Words: away.Error()}}, Last: away}
}
return nil
}, meshwants.StepEndedOutcomeCouldNotRun, []time.Duration{8 * time.Minute}},
} {
t.Run(tc.name, func(t *testing.T) {
s := newRunStand(t, "src2:e1", "src2:e1", "d1")
inner := s.r.call
clock := time.Unix(1000, 0)
var mu sync.Mutex
var bounds []time.Duration
s.r.now = func() time.Time { mu.Lock(); defer mu.Unlock(); return clock }
s.r.holder = func(seat string) (string, []string) { return "mesh-delivery-indexer", []string{"novox"} }
s.r.call = func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) {
mu.Lock()
bounds = append(bounds, ask.Bound)
err := tc.answer(&clock, ask, key)
mu.Unlock()
if err != nil {
return nil, err
}
return inner(ask, key, body)
}
out := s.r.run(context.Background(), "ask-step", step)
if out.Outcome != tc.want {
t.Fatalf("the step came to %+v, want %s", out, tc.want)
}
if tc.bounds == nil {
return
}
if calls != tc.revisionCalls || len(waits) != tc.waits {
t.Errorf("`revision` asked %d times with %d waits, want %d and %d", calls, len(waits), tc.revisionCalls, tc.waits)
total := clock.Sub(time.Unix(1000, 0))
if total > 9*time.Minute || bounds[0] != 8*time.Minute {
t.Errorf("the reads took %s with bounds %v, want the first at 8m and all before the runner's 10m", total, bounds)
}
for _, w := range []string{"mesh-delivery-indexer on novox", "not read yet since 23:35:40", "mesh-catalog"} {
if !strings.Contains(out.Said, w) {
t.Errorf("the step said %q, which does not name %q", out.Said, w)
}
}
})
}
@@ -690,7 +690,11 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
if err != nil {
return err
}
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept, callFile: bus.CallFileKept,
readsBound, err := readsBoundSetting(getenv)
if err != nil {
return err
}
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKeptAsk, callFile: bus.CallFileKept, readsBound: readsBound, holder: holderOf(bus, w),
trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, findings: findings, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), own: ctx, ask: bus.CallFile, now: time.Now, logf: logger.Printf}
// The seat's work queue (design 47 H2 §777): pulled through its one worker, each ask taken once in the state taken.
takenBound, err := askTakenBound()
@@ -862,6 +866,25 @@ func hearReadsChanged(ctx context.Context, js jetstream.JetStream, hub *process.
}()
}
// holderOf names the module holding a seat, asked of the seat that places modules (seatlist.HolderOf), and the machines whose
// assignments place it, for the words of a read that met a fault (design 47 H2 H-A-708 (3)).
func holderOf(bus caller, w *world) func(seat string) (string, []string) {
return func(seat string) (string, []string) {
module, err := seatlist.HolderOf(bus.Call, seat)
if err != nil {
return "", nil
}
var nodes []string
for node, modules := range w.assigned() {
if slices.Contains(modules, module) {
nodes = append(nodes, node)
}
}
slices.Sort(nodes)
return module, nodes
}
}
// entriesOf are the catalog entries the passer asks by fingerprint: the followed branches' own, so each catalog-revision asks
// again an entry whose ask failed to reach the holder, at most asks times (the setting entry-asks, 0 its default), and the
// assigner's finding writer writes entry-not-found and entry-unanswered of them (design 47 H, H-A-60). Each change wakes a pass.
@@ -318,6 +318,9 @@ func (b *fakeBus) CallOn(node, key string, body any) (json.RawMessage, error) {
return b.Call(node+"/"+key, body)
}
func (b *fakeBus) CallKept(key string, body any) (json.RawMessage, error) { return b.Call(key, body) }
func (b *fakeBus) CallKeptAsk(_ process.KeptAsk, key string, body any) (json.RawMessage, error) {
return b.Call(key, body)
}
func (b *fakeBus) CallFile(key string, body any) (json.RawMessage, error) { return b.Call(key, body) }
func (b *fakeBus) CallFileKept(_ process.KeptAsk, key string, body any) (json.RawMessage, error) {
return b.Call(key, body)
@@ -43,6 +43,8 @@ type caller interface {
CallOn(node, key string, body any) (json.RawMessage, error)
// CallKept is Call for a kept call, safe to call again (process.Conn.CallKept; ADR 0668).
CallKept(key string, body any) (json.RawMessage, error)
// CallKeptAsk is CallKept stopping at its caller's bound and carrying the ask's id and hook (process.Conn.CallKeptAsk; H2 §775).
CallKeptAsk(ask process.KeptAsk, key string, body any) (json.RawMessage, error)
// CallFile is Call of a verb marked chunks, its answer read whole (process.Conn.CallFile; design 47 G A-291).
CallFile(key string, body any) (json.RawMessage, error)
// CallFileKept is CallFile as a kept call carrying its ask's id, until its bound (process.Conn.CallFileKept; H2 §775).
@@ -250,6 +250,7 @@ func manifestsOf(half mcc.Half) (map[string]composer.Manifest, error) {
// is kept once in `inputs`, its program and input recorded on the run, and one run ask put on the Go build seat. A fault ends
// the run could not run.
func (r *compositionRun) startValidate(ctx context.Context, key string, run meshwants.CompositionRun, step meshwants.StepRun) {
ctx = withReadsClock(ctx) // all the run's reads stop at one deadline (design 47 H2 H-A-708 (3))
ask := run.Ask
end := func(outcome, said string, verdict map[string]any) {
if _, err := r.runs.endRun(key, ask, outcome, said, verdict); err != nil {
@@ -438,7 +439,7 @@ const seatListKey = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbSeatList
// seat-list hands, asked as a kept call under the run's ask.
func (r *compositionRun) validateSeats(ctx context.Context, ask string, defs []meshcatalog.CatalogRevisionDefinitionsItem) ([]json.RawMessage, string, error) {
if len(defs) == 0 {
return r.seatList(ask)
return r.seatList(ctx, ask)
}
sorted := slices.Clone(defs)
slices.SortStableFunc(sorted, func(a, b meshcatalog.CatalogRevisionDefinitionsItem) int { return strings.Compare(a.Seat, b.Seat) })
@@ -466,8 +467,12 @@ func seatListDigest(raw []byte) string {
// seatList is the trunk's seat list as the verb seat-list hands it (H-A-443): its digest and size, then the object's bytes in
// chunks; bytes whose size or sha256 is not the answer's, or that are no JSON array, are refused, so every run of one digest
// judges the same bytes.
func (r *compositionRun) seatList(ask string) ([]json.RawMessage, string, error) {
func (r *compositionRun) seatList(ctx context.Context, ask string) ([]json.RawMessage, string, error) {
what := "the trunk's seat list is not read through " + seatListKey
left, bound, _ := r.readsLeft(readsClockOf(ctx))
if left <= 0 {
return nil, "", errors.New(what + ": the run's reads passed their deadline of " + bound.String() + " (the setting reads-bound)")
}
if r.callFile == nil {
return nil, "", errors.New(what + ": the assigner holds no chunked call")
}
@@ -475,7 +480,7 @@ func (r *compositionRun) seatList(ask string) ([]json.RawMessage, string, error)
if _, err := rand.Read(bits[:]); err != nil {
return nil, "", fmt.Errorf("%s: %w", what, err)
}
raw, err := r.callFile(process.KeptAsk{ID: ask + "." + meshcatalog.VerbSeatList, Bound: readsBound}, seatListKey,
raw, err := r.callFile(process.KeptAsk{ID: ask + "." + meshcatalog.VerbSeatList, Bound: left}, seatListKey,
meshcatalog.SeatListInput{Call: hex.EncodeToString(bits[:])})
if err != nil {
return nil, "", fmt.Errorf("%s: %w", what, err)
@@ -128,7 +128,7 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
}
return nil
}
r := &compositionRun{runs: runs, keeper: keeper, reads: &compositionReads{}, call: call, callFile: callFile, own: context.Background(), now: time.Now, logf: t.Logf,
r := &compositionRun{runs: runs, keeper: keeper, reads: &compositionReads{}, call: asKept(call), callFile: callFile, own: context.Background(), now: time.Now, logf: t.Logf,
put: func(_ context.Context, a buildstep.StepAsk) error {
body, err := keeper.body(a.Run.Input.Digest)
if err != nil {
@@ -234,7 +234,7 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
{"an empty list", listAnswer([]byte(`[]`), seatListDigest([]byte(`[]`)), 2)},
} {
listed = row.answer
if seats, digest, err := r.seatList("ask-row"); err == nil || !strings.Contains(err.Error(), seatListKey) {
if seats, digest, err := r.seatList(context.Background(), "ask-row"); err == nil || !strings.Contains(err.Error(), seatListKey) {
t.Errorf("%s: the seat list read %s %s, %v; want it refused, naming the verb", row.name, digest, seats, err)
}
}
@@ -185,7 +185,7 @@ func TestManifest(t *testing.T) {
}
file, _ := os.ReadFile("module.json")
if err := json.Unmarshal(file, &raw); err != nil || raw.Config["outside-wait-minutes"].Default != float64(30) || raw.Config["outside-settle-seconds"].Default != float64(90) ||
raw.Config["ask-operator-for"].Default != "take-off,remove-node,stops" || len(raw.Config) != 17 || raw.Config["tier-bound"].Default != float64(30) || raw.Config["entry-asks"].Default != float64(5) ||
raw.Config["ask-operator-for"].Default != "take-off,remove-node,stops" || len(raw.Config) != 18 || raw.Config["tier-bound"].Default != float64(30) || raw.Config["entry-asks"].Default != float64(5) || raw.Config["reads-bound"].Default != float64(8) ||
raw.Config["composition-runs-cap-mib"].Default != float64(16) || raw.Config["composition-runs-kept"].Default != "24h" ||
raw.Config["composition-step-bound"].Default != "30m" || raw.Config["run-untaken-bound"].Default != "24h" || raw.Config["blame-tries"].Default != float64(20) ||
// design 47 H2 H-A-628 (3): the bound of a run's wait for a package's publish, the builder's default
@@ -210,6 +210,7 @@ func TestManifest(t *testing.T) {
{"MESH_ASSIGNER_PASS_STALL_FILE", "${dir:state}/pass-stall-seconds", "pass-stall-seconds"}, // design 47 H2 H-A-635
{"MESH_ASSIGNER_TIER_BOUND_FILE", "${dir:state}/tier-bound", "tier-bound"}, // design 47 H §751
{"MESH_ASSIGNER_ENTRY_ASKS_FILE", "${dir:state}/entry-asks", "entry-asks"}, // design 47 H H-A-60
{"MESH_ASSIGNER_READS_BOUND_FILE", "${dir:state}/reads-bound", "reads-bound"}, // design 47 H2 H-A-708 (3)
} {
if !strings.Contains(string(file), `"`+f.env+`": "`+f.path+`"`) || !strings.Contains(string(file), `"path": "`+f.path+`"`) ||
!strings.Contains(string(file), `"content": "${config:`+f.key+`}"`) {
@@ -197,6 +197,14 @@
"trusted": false,
"default": 30
},
"reads-bound": {
"type": "number",
"description": "minutes a composition or validate run's reads of the seats mesh-catalog and mesh-builds may take in all, counted from the run's first read: the reads are kept calls paced by the form, and past it the run ends could not run with every call's time and words. Kept below the runner's ask-unanswered-bound (default 10 minutes, counted from the pull), so the step ends with the assigner's words; one set above it has the runner's bound end the step with its own (design 47 H2 H-A-708 (3)).",
"minimum": 1,
"maximum": 9,
"trusted": false,
"default": 8
},
"entry-asks": {
"type": "number",
"description": "how often the assigner asks a catalog entry again, on each catalog-revision and when its link to the bus opens again, after its ask failed to reach the holder of the seat mesh-catalog; one more failure leaves it unanswered, with the finding entry-unanswered (design 47 H, H-A-60).",
@@ -346,6 +354,14 @@
"mode": "0600",
"content": "${config:tier-bound}"
},
{
"id": "reads-bound",
"type": "file",
"path": "${dir:state}/reads-bound",
"owner": "mesh-delivery-assigner",
"mode": "0600",
"content": "${config:reads-bound}"
},
{
"id": "entry-asks",
"type": "file",
@@ -425,6 +441,7 @@
"MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE": "${dir:state}/ask-operator-for",
"MESH_ASSIGNER_TIER_BOUND_FILE": "${dir:state}/tier-bound",
"MESH_ASSIGNER_ENTRY_ASKS_FILE": "${dir:state}/entry-asks",
"MESH_ASSIGNER_READS_BOUND_FILE": "${dir:state}/reads-bound",
"MESH_ASSIGNER_COMPOSITION_RUNS_CAP_MIB_FILE": "${dir:state}/composition-runs-cap-mib",
"MESH_ASSIGNER_COMPOSITION_RUNS_KEPT_FILE": "${dir:state}/composition-runs-kept",
"MESH_ASSIGNER_COMPOSITION_STEP_BOUND_FILE": "${dir:state}/composition-step-bound",