From f1e4ab1cf616d14de0d5aea79e2501d69d9d82d4 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:08:54 +0100 Subject: [PATCH] I3: the indexer reads no imports from the builder's build log ApplyBuildEnd and its start replay go: a module's import set reaches the indexer only as imports-reported. The build-log read stays for the module paths and the out-of-step findings. Builds: design 47 H2 H-A-517, H-A-532 DQ-7 --- .../cmd/mesh-delivery-indexer/main.go | 20 ++---- .../internal/index/imports.go | 65 ------------------- 2 files changed, 5 insertions(+), 80 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index eef0293aa..2a9b11597 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -426,19 +426,16 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro done = step("reading the build log") // The log's entries at the start are read before any fingerprint is computed (below). var started atomic.Bool - var startEnds []stdio.LogEntry // the log's entries read at the start, whose imports are kept once the packages are published + var startEnds []stdio.LogEntry // the log's entries read at the start, whose out-of-step findings are judged below if err := calls.ReadLog(builds.BuilderModule, builds.BuilderLog).Watch("", stdio.LogFromAll, func(le stdio.LogEntry) error { if err := known.Put(le.Value); err != nil { logger.Printf("%s entry %d is not read: %v", builds.BuildLogRead, le.Sequence, err) return nil } if started.Load() { - // A trunk build's generated files out of step with their seat definitions (DLV-I20). + // A trunk build's generated files out of step with their seat definitions (DLV-I20). Its imports are not read + // here: the build module says them as imports-reported (design 47 H2 H-A-517, H-A-532 DQ-7). ix.ApplyOutOfStepBuild(ctx, le.Value) - // A done build's imports are kept on its module (ADR 0593 §2); at the start they are kept once the packages are. - if err := ix.ApplyBuildEnd(ctx, le.Value); err != nil { - logger.Printf("%s entry %d: its imports are not kept: %v", builds.BuildLogRead, le.Sequence, err) - } } else { startEnds = append(startEnds, le) } @@ -502,8 +499,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro buildFollow.Store(buildModules) // Only now, with the toolchains read, are the fingerprints computed once (before it every Go module would be written as // having no toolchain reported, and back). - // The packages the held modules reach and the state does not hold yet are published at their trunk's taken merge, and - // the imports the log's done builds reported are then kept, before the fingerprints are computed (ADR 0593 §2, §4). + // The packages the held modules reach and the state does not hold yet are published at their trunk's taken merge, + // before the fingerprints are computed (ADR 0593 §2, §4). done() packages.Ready(func(jetstream.KeyValue) { done := step("publishing the packages at start") @@ -513,20 +510,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro done() }) done = step(fmt.Sprintf("the out-of-step findings of %d build ends", len(startEnds))) - values := make([][]byte, len(startEnds)) for i, le := range startEnds { ix.ApplyOutOfStepBuild(ctx, le.Value) - values[i] = le.Value if (i+1)%50000 == 0 { logger.Printf("start: out-of-step findings: %d of %d entries", i+1, len(startEnds)) } } done() - if err := ix.ApplyBuildEndsAtStart(ctx, values, func(i int, err error) { - logger.Printf("%s entry %d: its imports are not kept: %v", builds.BuildLogRead, startEnds[i].Sequence, err) - }); err != nil { - logger.Printf("keeping the view after the build ends at start: %v", err) - } startEnds = nil done = step("computing the fingerprints") if err := ix.RecomputeAtStart(ctx); err != nil { diff --git a/modules/mesh-delivery-indexer/internal/index/imports.go b/modules/mesh-delivery-indexer/internal/index/imports.go index 06a034458..68888d8a6 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports.go +++ b/modules/mesh-delivery-indexer/internal/index/imports.go @@ -6,9 +6,7 @@ import ( "maps" "slices" "strings" - "time" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" @@ -16,69 +14,6 @@ import ( "mesh-delivery-indexer/internal/fingerprint" ) -// ApplyBuildEnd keeps the imports a done build reports at its end (builds.BuildLogEntry.Imports; novox/hq ADR 0593 -// §2) on the module it built, when the build's fingerprint is the one the module holds: the import set of the module's -// last trunk build. With them it keeps ImportForm, the import-form fingerprint of exactly what the build was built from: -// the module's kept inputs and the toolchains its fingerprint was computed with, and each imported package's digest at -// the version the build took it at (another repository's at the version the module's fingerprint pins, its own -// repository's at the commit built). A recompute that gives that value again keeps the fingerprint (§4); one that -// differs writes the import form. The fingerprint itself is not changed here. -// -// An entry that is no done build's end, reports no imports, or is of a fingerprint the module no longer holds is left. -// Imports that cannot be resolved (a package the forge cannot list) are kept with no ImportForm: the next recompute that -// resolves them writes the import form, one rebuild too many, never a stale module. -func (ix *Indexer) ApplyBuildEnd(ctx context.Context, value []byte) error { - _, err := ix.applyBuildEnd(ctx, value) - return err // the imports reach the next take-in's revision (design 47 H §743, H-A-49) -} - -// ApplyBuildEndsAtStart applies every entry of the build log read at start as ApplyBuildEnd does, and keeps the view -// once, after them, when any entry wrote a module: KeepView writes the whole catalog view, so once per entry is a start -// that never ends (measured: 50 min CPU per start). An entry that fails is passed to failed with its position. -func (ix *Indexer) ApplyBuildEndsAtStart(ctx context.Context, values [][]byte, failed func(i int, err error)) error { - began := time.Now() - ix.logf("replaying %d build ends of the build log at start", len(values)) - wrote := 0 - slow := 0 // entries that took over a second - for i, v := range values { - if (i+1)%50000 == 0 { - ix.logf("replaying the build ends at start: %d of %d, %d wrote a module, %d took over a second, %s so far", i+1, len(values), wrote, slow, time.Since(began).Round(time.Millisecond)) - } - t := time.Now() - w, err := ix.applyBuildEnd(ctx, v) - if d := time.Since(t); d > time.Second { - slow++ - ix.logf("replaying the build ends at start: entry %d took %s", i+1, d.Round(time.Millisecond)) - } - if err != nil { - if failed != nil { - failed(i, err) - } - continue - } - if w { - wrote++ - } - } - ix.logf("replayed %d build ends at start: %d wrote a module, in %s", len(values), wrote, time.Since(began).Round(time.Millisecond)) - return nil -} - -// applyBuildEnd reports whether it wrote the module (its final write changed the held value). -func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error) { - if !builds.IsBuildEntry(value) { - return false, nil - } - e, err := builds.DecodeBuildLogEntry(value) - if err != nil { - return false, err - } - if e.Event != builds.BuildEndedEvent || e.Outcome != builds.BuildDone || len(e.Imports) == 0 || ix.Modules == nil || e.FP == "" { - return false, nil - } - return ix.keepImports(ctx, reported{module: e.Module, fp: e.FP, commit: e.Commit, imports: e.Imports}) -} - // reported is one build's import set as its build module reported it (design 47 H2 H-A-517): the module, the // fingerprint built, its commit and the imported mesh packages by import path. type reported struct {