diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 1243287d0..56e1fc6c4 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -369,6 +369,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc } } finals[key] = final + ix.saySetAside(k.manifest, r.fp, k.held.Fp2) continue } if !stale[key] && k.cur.Fp2 == r.fp && k.cur.None2 == r.none && sameUsed(k.cur, r.tcs, r.pkgs) { @@ -398,6 +399,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc } if wrote { w.wrote(key) + ix.saySetAside(k.manifest, r.fp, k.held.Fp2) } } if err := ix.writeOverlay(ctx, overlay, finals, w); err != nil { @@ -409,6 +411,17 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc return nil // only a take-in keeps a catalog revision (design 47 H ยง743, H-A-49) } +// saySetAside says, in one journal line, each word the take-in's read set aside of a module's manifest, with its path +// (SetAside), once per module and fingerprint: when a pass gives the module a fingerprint other than the one the bucket +// held (design 47 H2 H-A-809). It is not a finding: a word set aside is the normal state while a newer manifest form +// reaches an older indexer, and it ends when the indexer that reads the word runs. +func (ix *Indexer) saySetAside(m catalogue.Manifest, fp, held string) { + if fp == "" || fp == held || m.SetAside() == "" { + return + } + ix.logf("%s: its fingerprint %s is taken from the words of its manifest this indexer knows; set aside: %s", m.Module, fp, m.SetAside()) +} + // writeOverlay writes the records of a merge, each once and only if it differs from what the bucket holds; finals has // the ones that were computed, the others are written as the merge gave them. // diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 98f4ebd3b..ef4d71460 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -903,3 +903,39 @@ func TestATakeInMovesTheImportersOfThePackagesItsRepositoryPublishes(t *testing. } } } + +// H-A-809: a take-in of a manifest with a word set aside inside a known one says, once per module and fingerprint, one +// journal line naming the module, its fingerprint and the word with its path; a pass that gives it no other fingerprint +// says nothing more. +func TestATakeInSaysEachWordItSetAsideOncePerFingerprint(t *testing.T) { + raw := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "zzz-unknown-word": true,`, 1) + ix, mods, f := newFormIndexerUnmerged(t, mod{"avahi", raw}) + var said []string + ix.Logf = func(format string, args ...any) { said = append(said, fmt.Sprintf(format, args...)) } + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1") + naming := func() []string { + var lines []string + for _, line := range said { + if strings.Contains(line, "zzz-unknown-word") { + lines = append(lines, line) + } + } + return lines + } + if err := ix.Apply(context.Background(), f); err != nil { + t.Fatal(err) + } + m, _ := moduleOf(t, mods, "avahi") + lines := naming() + if m.Fp2 == "" || len(lines) != 1 || !strings.HasPrefix(lines[0], "avahi: ") || !strings.Contains(lines[0], m.Fp2) || + !strings.Contains(lines[0], "build.artifacts[0].zzz-unknown-word") { + t.Errorf("fingerprint %q (none %q), lines naming the word %q, want one naming avahi, its fingerprint and the path", m.Fp2, m.None2, lines) + } + if err := ix.Recompute(context.Background()); err != nil { + t.Fatal(err) + } + if again := naming(); len(again) != len(lines) { + t.Errorf("a pass giving the same fingerprint said it again: %q", again) + } +}