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
@@ -19,7 +19,6 @@ import (
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/catalogkey"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/kept"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
"git.novox.be/novox/mesh-sdk/go/keys"
)
@@ -240,9 +239,6 @@ type BuilderBuild struct {
// its id (novox/hq ADR 0525 §1; issue 1887 A4b): a builder that takes the key over at its start waits for those asks'
// steps and never puts them again. A reader that does not know the field reads the key as before.
Asks map[string]string `json:"asks,omitempty"`
// Imports are, on a done key, the mesh packages the built programs import, as the build module answered them
// (BuildAnswer.Imports; novox/hq ADR 0593 §2): the builder carries them onto the build's end (BuildLogEntry.Imports).
Imports []string `json:"imports,omitempty"`
// Packages are, on a done key only, the mesh packages' versions its Go build was built with, by module path, the ones
// the registry gave a package the entry named with none included (H-A-207): the build step's end reports them, so the
// runner asks the steps that waited for the pins with what the build was built against. A reader that does not know
@@ -272,9 +268,6 @@ func (b BuilderBuild) check() error {
if b.KeptOn != "" && b.State != BuildDone {
return fmt.Errorf("builds: a build is kept on a done key alone, this one is %s", b.State)
}
if err := trunk.CheckImports(b.Imports); err != nil {
return err
}
switch b.State {
case BuildQueued, BuildBuilding, BuildDone, BuildFailed:
default:
+4 -12
View File
@@ -6,7 +6,6 @@ import (
"sort"
"time"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
"git.novox.be/novox/mesh-sdk/go/keys"
)
@@ -70,10 +69,6 @@ type BuildLogEntry struct {
// KeptOn is, at the end of a kept build, the build node that keeps it, once for the build (design 47 G §671): every
// artifact in Made is kept there, with its digest. A build not kept carries none.
KeptOn string `json:"kept-on,omitempty"`
// Imports are, at a build's end, the mesh packages (import paths) the built programs import, their tests left out,
// sorted and each once, as the build module answered them (BuildAnswer.Imports; novox/hq ADR 0593 §2): the indexer
// keeps them on the module (KeptInputs2.Imports) when the build's fingerprint is the module's.
Imports []string `json:"imports,omitempty"`
// OutOfStep are, at a build's end, the generated files its test step found out of step with what their generator
// writes, as the build module answered them (its test step's `out-of-step`): the indexer raises a finding naming them
// for a trunk build, and only a clean build of the same module clears it. A start or a narration names none.
@@ -132,9 +127,9 @@ func EncodeBuildLogEntry(e BuildLogEntry) ([]byte, error) {
switch {
case e.Module == "" || e.FP == "" || e.At.IsZero() || e.Line == "":
return nil, fmt.Errorf("builds: a build's narration names its module, fingerprint, line and time")
case e.Outcome != "" || len(e.Made) > 0 || e.Manifest != "" || len(e.Against) > 0 || len(e.Imports) > 0 || len(e.OutOfStep) > 0 ||
case e.Outcome != "" || len(e.Made) > 0 || e.Manifest != "" || len(e.Against) > 0 || len(e.OutOfStep) > 0 ||
e.Error != "" || e.Step != "":
return nil, fmt.Errorf("builds: a build's narration names no outcome, manifest, base, artifact, import, file out of step, error or step")
return nil, fmt.Errorf("builds: a build's narration names no outcome, manifest, base, artifact, file out of step, error or step")
}
return json.Marshal(e)
case e.Event != BuildStartedEvent && e.Event != BuildEndedEvent:
@@ -145,12 +140,9 @@ func EncodeBuildLogEntry(e BuildLogEntry) ([]byte, error) {
return nil, fmt.Errorf("builds: a build log entry names its module, fingerprint, repository, commit, node and time")
case e.Event == BuildEndedEvent && e.Outcome == "":
return nil, fmt.Errorf("builds: a build's end names its outcome")
case e.Event == BuildStartedEvent && (e.Outcome != "" || len(e.Made) > 0 || e.Manifest != "" || len(e.Against) > 0 || len(e.Imports) > 0 ||
case e.Event == BuildStartedEvent && (e.Outcome != "" || len(e.Made) > 0 || e.Manifest != "" || len(e.Against) > 0 ||
len(e.OutOfStep) > 0 || e.Error != "" || e.Step != ""):
return nil, fmt.Errorf("builds: a build's start names no outcome, manifest, base, artifact, import, file out of step, error or step")
}
if err := trunk.CheckImports(e.Imports); err != nil {
return nil, err
return nil, fmt.Errorf("builds: a build's start names no outcome, manifest, base, artifact, file out of step, error or step")
}
return json.Marshal(e)
}
@@ -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)