B2: the builder carries no imports on its done key or its build log

A build module says a module's import set as its build seat's event
imports-reported, which the indexer hears (design 47 H2 H-A-517, DQ-7): the
builder's done key and its build log's end entry no longer carry the imports
a build answered, so nothing reads another part's state for them.

Builds: design 47 H2 H-A-517, H-A-532 (DQ-7)
This commit is contained in:
2026-11-23 11:56:02 +01:00
parent 37e1f3c297
commit 23533893bb
5 changed files with 34 additions and 51 deletions
@@ -10,9 +10,9 @@ import (
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
)
// ADR 0593 §2 (F3): the imports a Go build module answers at a build's end reach the done key and the log's end entry,
// where the indexer keeps them on the module.
func importsABuildAnswersReachTheDoneKeyAndTheLog(t *testing.T) {
// B2/AC1 (design 47 H2 H-A-517, H-A-532 DQ-7): the imports a Go build module answers at a build's end reach neither the done
// key nor the log's end entry; the build module says them as imports-reported, its own build seat's event.
func importsABuildAnswersReachNeitherTheDoneKeyNorTheLog(t *testing.T) {
r := newRig(t, goBundle)
imports := []string{"git.novox.be/novox/mesh-sdk/go", "git.novox.be/novox/mesh-sdk/go/announce"}
r.asks.Answer = func(a buildstep.StepAsk) buildstep.Step {
@@ -24,15 +24,32 @@ func importsABuildAnswersReachTheDoneKeyAndTheLog(t *testing.T) {
}
return step
}
var logged []builds.BuildLogEntry
var logged [][]byte
var mu sync.Mutex
r.b.Node, r.b.Log = "novox", func(e builds.BuildLogEntry) { mu.Lock(); logged = append(logged, e); mu.Unlock() }
v := r.consider(t, "modules/m")
if v.State != builds.BuildDone || strings.Join(v.Imports, ",") != strings.Join(imports, ",") {
t.Fatalf("done key %+v, want the imports", v)
r.b.Node, r.b.Log = "novox", func(e builds.BuildLogEntry) {
raw, err := builds.EncodeBuildLogEntry(e)
if err != nil {
t.Errorf("a log entry does not encode: %v", err)
}
mu.Lock()
logged = append(logged, raw)
mu.Unlock()
}
if len(logged) != 2 || strings.Join(logged[1].Imports, ",") != strings.Join(imports, ",") || len(logged[0].Imports) != 0 {
t.Fatalf("log %+v, want the imports on the end alone", logged)
if v := r.consider(t, "modules/m"); v.State != builds.BuildDone {
t.Fatalf("done key %+v, want it done", v)
}
if raw := string(r.st.vals[r.key]); strings.Contains(raw, `"imports"`) || strings.Contains(raw, "announce") {
t.Errorf("the done key %s carries the imports", raw)
}
mu.Lock()
defer mu.Unlock()
if len(logged) != 2 {
t.Fatalf("log %d entries, want the start and the end", len(logged))
}
for _, raw := range logged {
if strings.Contains(string(raw), `"imports"`) || strings.Contains(string(raw), "announce") {
t.Errorf("a log entry %s carries the imports", raw)
}
}
}
@@ -906,7 +906,6 @@ type lane struct {
toolchain *builds.ToolchainUsed
digests map[string]string // artifact -> digest
references map[string]string // artifact -> the reference an image was pushed to (a trunk build only)
imports []string // the mesh packages the lane's programs import, as its build module answered them
resolved map[string][]sdkstep.AskResolved // artifact -> the mesh packages its build resolved (design 47 G §466)
tcDigest string // the digest of the toolchain program the building node ran, kind 3's (design 47 G §466, §472)
tcVersion string // and the version it ran
@@ -1062,7 +1061,7 @@ func (b *Builder) build(ctx context.Context, module string, m meshcatalog.Module
used = nil
}
done := builds.BuilderBuild{State: builds.BuildDone, By: b.Claimer.By, Manifest: m.Manifest, Step: step, Artifacts: artifacts, Toolchains: used,
Imports: importsOf(lanes), Needs: forms.Current.Needs(artifacts), Packages: pinsOf(lanes)} // the forms it is written in (ADR 0618 §1)
Needs: forms.Current.Needs(artifacts), Packages: pinsOf(lanes)} // the forms it is written in (ADR 0618 §1)
for _, l := range lanes {
if l.kept != "" {
done.KeptOn = l.node // design 47 G §671: the build node that keeps the build
@@ -1287,7 +1286,6 @@ func (b *Builder) runLane(ctx context.Context, l *lane, repository string, m mes
l.err = fmt.Errorf("the ask of %s on %s answered what is not a build: %s", l.module, step.Node, step.Result)
return
}
l.imports = answer.Imports
l.kept = answer.Kept
if answer.Toolchain != nil {
l.tcDigest, l.tcVersion = answer.Toolchain.Digest, answer.Toolchain.Version
@@ -1368,8 +1366,7 @@ func LogEnded(module string, m meshcatalog.ModulesByModuleValue, ref, by string,
}
e.Made = append([]builds.BuiltArtifact(nil), result.Artifacts...)
e.KeptOn = result.KeptOn
e.Imports = append([]string(nil), result.Imports...) // the indexer keeps them on the module (novox/hq ADR 0593 §2)
e.Error, e.Step = result.Error, result.Step // a failed build's reason, not only its outcome
e.Error, e.Step = result.Error, result.Step // a failed build's reason, not only its outcome
e.Needs = append([]string(nil), result.Needs...)
return e
}
@@ -1404,9 +1401,6 @@ func (b *Builder) takeOutOfStep(key string) []string {
return files
}
// importsOf are the mesh packages the lanes' programs import, as their build modules answered them (novox/hq ADR 0593
// §2): sorted and each once; nil when none answered any. A lane kept from a prior build answered none, so a build that
// kept one reports only what it built.
// pinsOf is the mesh packages' versions the lanes were built with (H-A-207), nil when none was pinned.
func pinsOf(lanes []*lane) map[string]string {
var out map[string]string
@@ -1421,19 +1415,6 @@ func pinsOf(lanes []*lane) map[string]string {
return out
}
func importsOf(lanes []*lane) []string {
seen := map[string]bool{}
for _, l := range lanes {
for _, p := range l.imports {
seen[p] = true
}
}
if len(seen) == 0 {
return nil
}
return slices.Sorted(maps.Keys(seen))
}
// SittingOutWords says, per node that is not on the agreed toolchain of a language, that it sits out and which version
// it has against the agreed one: "ace sits out: typescript 26.12.1, agreed 26.13.0" (novox/hq ADR 0584 clause 2).
func SittingOutWords(language string, a sdkstep.Agreement) []string {
@@ -227,7 +227,7 @@ var (
)
func TestABundleAndAnArchiveAreBuiltOnOneNodeAndDone(t *testing.T) { // 1607/AC7, ADR 0478 clauses 1, 4
t.Run("the imports a build answers reach the done key and the log", importsABuildAnswersReachTheDoneKeyAndTheLog)
t.Run("the imports a build answers reach neither the done key nor the log", importsABuildAnswersReachNeitherTheDoneKeyNorTheLog)
t.Run("a kept build names its node in its end", aKeptBuildNamesItsNodeInItsEnd)
t.Run("the out-of-step files a build answers reach the log", outOfStepFilesABuildAnswersReachTheLog)
t.Run("ADR 0624: a done key keeps each form a counted node reads", aDoneKeyKeepsEachFormACountedNodeReads)