R3-1, R3-2, R3-3: the node-engine reads no build of the builder; the shadow builds from the entry it holds

The composer's Build is made from the catalog half's entry it holds and the parts of the want that names it (buildOf); the
inputs of the indexer's modules and the builder's builds, takeBuildDone, takeModule and the builder read are gone, and mesh-host
names no BuilderBuildsBucket. The shadow takes the entries of the builds it composes from (askBuildsEntries), builds a module a
candidate adds from its entry and the candidate's `added` parts (A-316), and holds, with the reason, a module whose entry
has no part given, whose fingerprint the verb module does not give, or for which it errors (A-312). Its composer is given the
entry call as the node's own is. Rows: a built module added with and without parts, the verb module answering no fingerprint
and erroring.

Builds: design 47 G §421, §628, A-308, A-312, A-316
This commit is contained in:
2026-11-12 23:05:06 +01:00
parent e558510a54
commit 23799a30ed
12 changed files with 279 additions and 359 deletions
+30 -60
View File
@@ -63,13 +63,31 @@ func (f *fakeComposed) Delete(_ context.Context, key string) error {
func (f *fakeComposed) written() []string {
f.mu.Lock()
defer f.mu.Unlock()
return slices.Clone(f.puts)
var out []string
for _, key := range f.puts {
// The entries and wants the node keeps are its composition state's too (§683), not compositions.
if !strings.HasPrefix(key, keptEntryPrefix) && !strings.HasPrefix(key, keptWantPrefix) {
out = append(out, key)
}
}
return out
}
// keep holds in the state, as an earlier run of the node left them, the entry of fp and the want of module at it (§683): the
// composer then composes at its start from what it kept, and asks the catalog half of nothing first.
func (f *fakeComposed) keep(t *testing.T, half catalogHalf, module, fp string) {
t.Helper()
entry, _ := json.Marshal(meshcatalog.EntryAnswer{Entry: half[fp]})
want, _ := json.Marshal(keptWant{V: 1, Since: time.Now(), Want: meshwants.WantsByWantNodeModuleValue{Fp: fp, Self: true}})
f.mu.Lock()
defer f.mu.Unlock()
f.kv[entryKey(fp)] = ComposedEntry{Value: entry, Revision: 1}
f.kv[wantStateKey(module)] = ComposedEntry{Value: want, Revision: 1}
}
// novox/hq ADR 0593 §6: the node publishes each composition it makes in its composition state, a record never applied:
// the wanted module and the node's own at the first pass; nothing again for a pass that changes nothing; a done build
// of a module placed here that no want names, at its trunk's build, written once as its own key (before any want moves);
// the same build landing again writes nothing. And a module's keys are kept while among the five it wrote last or named
// the wanted module and the node's own at the first pass, from the entry and want it kept; nothing again for a pass that
// changes nothing; a failed build of a placed module said refused by its build-ended event. And a module's keys are kept while among the five it wrote last or named
// by a want, and deleted otherwise.
func TestTheNodePublishesItsCompositions(t *testing.T) {
t.Run("the verb compose is answered while a pass runs", composeAnsweredWhileAPassRuns)
@@ -90,6 +108,12 @@ func TestTheNodePublishesItsCompositions(t *testing.T) {
state := &fakeComposed{kv: map[string]ComposedEntry{}}
env := b.env()
env.ComposedState = state
ofp0 := meshcatalogclient.SourcePrefix2 + strings.Repeat("c", 64)
half := catalogHalf{}
half.add(t, "lemurs", fp, lemurs)
half.add(t, "oldie", ofp0, oldie)
env.Entry = half.call()
state.keep(t, half, "lemurs", fp)
// Design 47, *What each step says*: each module composition written says composed, with its fingerprint and digest.
var saidMu sync.Mutex
var saidComposed []string
@@ -124,13 +148,12 @@ func TestTheNodePublishesItsCompositions(t *testing.T) {
}
b.put(t, buckets.Wants, "want.n1.lemurs", want)
b.put(t, buckets.Wants, "want.n1.node", nodeWant)
for _, bucket := range []string{buckets.Wants, buckets.Assignments, buckets.Have, buckets.Modules, ResolvedBucket, builds.BuilderBuildsBucket} {
for _, bucket := range []string{buckets.Wants, buckets.Assignments, buckets.Have, ResolvedBucket} {
b.send(bucket, agent.Update{Caught: true})
}
for u := next(t, out); !u.Caught; u = next(t, out) {
}
lemursKey, _ := engcomp.Key("n1", "lemurs", fp)
oldieKey, _ := engcomp.Key("n1", "oldie", ofp)
waitFor := func(what string, ok func([]string) bool) []string {
t.Helper()
deadline := time.Now().Add(5 * time.Second)
@@ -190,60 +213,6 @@ func TestTheNodePublishesItsCompositions(t *testing.T) {
if got := state.written(); len(got) != 2 {
t.Errorf("a pass that changed nothing wrote %v", got[2:])
}
// oldie's trunk build is done: its key at that build is written once, though no want names it.
build, _ := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildDone, Manifest: odigest})
bkey, _ := builds.BuilderBuildKey("oldie", ofp)
b.mu.Lock()
b.kv[builds.BuilderBuildsBucket+"/"+bkey] = build
b.mu.Unlock()
b.put(t, builds.BuilderBuildsBucket, bkey, build)
got := waitFor("oldie's done build", func(got []string) bool { return len(got) >= 3 })
if got[2] != oldieKey {
t.Errorf("the done build of oldie wrote %v, want %s", got[2:], oldieKey)
}
b.put(t, builds.BuilderBuildsBucket, bkey, build)
time.Sleep(100 * time.Millisecond)
if got := state.written(); len(got) != 3 {
t.Errorf("the same build landing again wrote %v", got[3:])
}
// A placed module whose newest build failed is published as a refusal at that build with the build's words (the
// provisioner holds it and does not wait); one whose build is queued or running stays unpublished.
for m, st := range map[string]builds.BuilderBuild{
"broken": {State: builds.BuildFailed, Error: `refused kind: package of language "go"`},
"waiting": {State: builds.BuildQueued},
} {
f := map[string]string{"broken": bfp, "waiting": wfp}[m]
raw, _ := builds.EncodeBuilderBuild(st)
k, _ := builds.BuilderBuildKey(m, f)
b.mu.Lock()
b.kv[builds.BuilderBuildsBucket+"/"+k] = raw
b.mu.Unlock()
b.put(t, builds.BuilderBuildsBucket, k, raw)
}
brokenKey, _ := engcomp.Key("n1", "broken", bfp)
got = waitFor("broken's failed build", func(got []string) bool { return len(got) >= 4 })
// The pass that wrote it says so ("1 key(s) written" was said once before, for oldie); then only brokenKey is new.
for deadline := time.Now().Add(5 * time.Second); time.Now().Before(deadline); time.Sleep(10 * time.Millisecond) {
n := 0
b.mu.Lock()
for _, l := range b.said {
if strings.Contains(l, "this node's composition state: 1 key(s) written") {
n++
}
}
b.mu.Unlock()
if n >= 2 {
break
}
}
if got := state.written(); len(got) != 4 || got[3] != brokenKey {
t.Errorf("a failed build and a queued one wrote %v, want only %s", got[3:], brokenKey)
}
if comp, err := engcomp.Decode(state.kv[brokenKey].Value); err != nil || comp.Refused != `refused kind: package of language "go"` || len(comp.Resources) != 0 {
t.Errorf("the failed build's key: %+v, %v", comp, err)
}
// What is kept: the five keys of a module written last, and one a want names; the rest is deleted.
keep := New(b.env())
keep.pubKept = map[string]ComposedEntry{}
@@ -262,6 +231,7 @@ func TestTheNodePublishesItsCompositions(t *testing.T) {
t.Errorf("past keeping with a want naming the oldest: %v, want none", past)
}
brokenKey, _ := engcomp.Key("n1", "broken", bfp)
// Design 47 G A-293: reading the catalog half by fingerprint, a placed module's newest build that ended is the last trunk
// build.ended heard of it; a failed one is said refused with the event's words once the first read ended, an end naming a
// branch moves nothing, a module with no end (queued or running) stays unpublished, and a later done end, at any