diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go index 8bebbd58d..3a86574d5 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go @@ -69,6 +69,12 @@ func TestManifestAndModuleValuesKeepTheirRules(t *testing.T) { if m, err := DecodeModule(raw); err != nil || m.Fp2 != good.Fp2 || m.Path != RootPath { t.Errorf("DecodeModule = %+v, %v", m, err) } + // Design 47 H2 H-A-536, H-A-538: an import form with no imports is a reported empty import set. + empty := good + empty.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", ImportForm: SourcePrefix2 + hex64("a")} + if _, err := EncodeModule(empty); err != nil { + t.Errorf("a reported empty import set: %v", err) + } refused := good refused.Verdict, refused.Problems = VerdictRefused, []string{"p"} if _, err := EncodeModule(refused); err != nil { @@ -90,8 +96,8 @@ func TestManifestAndModuleValuesKeepTheirRules(t *testing.T) { "a toolchain with no recipe": func(m *seat.ModulesByModuleValue) { m.Toolchains = map[string]seat.ToolchainUsed{"go": {Language: "go", Version: "1.26"}} }, - "an import form with no imports": func(m *seat.ModulesByModuleValue) { - m.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", ImportForm: SourcePrefix2 + hex64("a")} + "an import form of another form": func(m *seat.ModulesByModuleValue) { + m.Inputs2 = &seat.ModulesByModuleValueInputs2{Tree: "t", Imports: []string{"p"}, ImportForm: "src1:" + hex64("a")} }, } { m := good diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go index 87c4d7c8d..1179fa7ff 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/module.go @@ -68,8 +68,9 @@ func CheckModule(m seat.ModulesByModuleValue) error { } } if in := m.Inputs2; in != nil { - if f := in.ImportForm; f != "" && (len(in.Imports) == 0 || !strings.HasPrefix(f, SourcePrefix2) || !keys.IsHex64(f[len(SourcePrefix2):])) { - return fmt.Errorf("meshcatalogclient: the kept import form %q is set only with imports, and is %s and 64 hex digits", f, SourcePrefix2) + // An import form with no imports says a reported empty import set (design 47 H2 H-A-536, H-A-538). + if f := in.ImportForm; f != "" && (!strings.HasPrefix(f, SourcePrefix2) || !keys.IsHex64(f[len(SourcePrefix2):])) { + return fmt.Errorf("meshcatalogclient: the kept import form %q is not %s and 64 hex digits", f, SourcePrefix2) } for p, object := range in.Paths { if !cleanInside(p) { diff --git a/modules/mesh-delivery-indexer/internal/index/form.go b/modules/mesh-delivery-indexer/internal/index/form.go index 8e9c0687f..1b1874c8a 100644 --- a/modules/mesh-delivery-indexer/internal/index/form.go +++ b/modules/mesh-delivery-indexer/internal/index/form.go @@ -16,25 +16,25 @@ import ( type form struct { fp, none string versions sdkstep.PackageVersions - // stands: fp is the held fingerprint of the build that reported the imports, made with the pins built (its held - // packages) from the import form raw; pinnedOf keeps it while the pins are those (H-A-172). - stands bool - raw string - built map[string]string + // imports: fp is of the import form, which takes each imported package by its content and no pin (design 47 H2 + // H-A-530), so pinnedOf leaves it as it is; the held fingerprint of the build that reported the imports stands as held, + // whatever pins it was made with (ADR 0593 §4, H-A-529). + imports bool } // formOf is the module's fingerprint from its kept inputs (bases already its bases' fingerprints) and toolchains, in the // form they call for (novox/hq ADR 0593 §2, §4): // -// - **The import form**, for a module whose last trunk build reported its imports (kept.Imports) when every import is -// published (the packages state): the content digest of each imported package and the requirements' digest of each +// - **The import form**, for a module whose import set is reported (reported: a key in the state imports, whatever the +// set's length, or a set its value held before that state was, design 47 H2 H-A-536, H-A-537; the set is kept.Imports) +// when every import is published (the packages state): the content digest of each imported package and the requirements' digest of each // mesh Go module holding one. Its versions are each holding module's published commit (another repository's only); an // import set naming none of another repository while the go.mod requires one keeps the version line's (refined). // - **A change of form never rebuilds by itself** (§4): kept.ImportForm is the import-form fingerprint of the inputs // the build that reported the imports was built from. While the import form computes to it, nothing the build was // built from changed: the module keeps the fingerprint it holds (prev), in whatever form, and its versions. // Otherwise the import form is written, and ImportForm moves with it. -// - **The version line** otherwise (no import set, or an import none publishes): the version of each mesh Go module of +// - **The version line** otherwise (no reported import set, or an import none publishes): the version of each mesh Go module of // another repository its go.mod requires, at any version (design 47 H-A-157), read as the indexer always read it // (fingerprint.HeldVersionsOf), and the content of each mesh Go module of its own repository its go.mod replaces by a // directory (fingerprint.VersionLine), so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone. @@ -46,9 +46,9 @@ type form struct { // digests of that version's commit. // // It sets kept.ImportForm when it writes the import form. -func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { +func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, reported bool, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { in := inputsFrom(module, *kept, toolchains) - if len(kept.Imports) > 0 { + if reported { r := fingerprint.Resolve(repository, kept.Imports, published) if len(r.Missing) == 0 { in.Imports, in.Requires = r.Digests, r.Requires @@ -59,10 +59,10 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp case kept.ImportForm == fp && prev.Fp2 != "": // The build that reported the imports stands, and so do its versions. return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins), - stands: true, raw: fp, built: prev.Packages} + imports: true} } kept.ImportForm = fp - return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins)} + return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins), imports: true} } if logf != nil { logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", ")) diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index a2710c314..d4ab0b575 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -56,6 +56,8 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T t.Run("a change of a sibling directory alone moves its importer", aSiblingDirectoryAloneMovesItsImporter) t.Run("an unread packages state writes no fingerprint, and they are computed again by hand (issue 1966)", anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain) t.Run("an accepted series' newest published version pins it, by that version's contents", anAcceptedSeriesPinsItsNewest) + t.Run("only the version line's fingerprint takes a release's pin", onlyTheVersionLineTakesAPin) + t.Run("a reported set is a key of the state imports, an empty one too, or a set held before it", aReportedSetIsAKeyOrAHeldSet) ctx := context.Background() ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") @@ -176,8 +178,9 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != moved.Fp2 || m.Packages[meshSDK] != "" { t.Fatalf("after mesh-sdk's module release alone: fp2 %q (was %q), versions %v; want it unpinned where it was", m.Fp2, moved.Fp2, m.Packages) } - // The registry publishes its Go package at 0.1.20, another version than the module's release: the import form's - // fingerprint takes that pin and moves, once (H-A-172, H-A-183). + // The registry publishes its Go package at 0.1.20, another version than the module's release, from c3, whose content + // avahi's fingerprint already takes: its build is pinned to v0.1.20, and the import form takes no pin, so the + // fingerprint stands (I4/AC1; design 47 H2 H-A-530, H-A-183). if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c3, GoModule: meshSDK, Published: true}); err != nil { t.Fatal(err) } @@ -186,13 +189,137 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T t.Fatal(err) } } - if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 == moved.Fp2 || m.Fp2 == "" || m.Packages[meshSDK] != "v0.1.20" || m.Inputs2.ImportForm != moved.Inputs2.ImportForm { - t.Fatalf("after mesh-sdk's release: fp2 %q (was %q), versions %v, import form %q; want a new fingerprint pinned to v0.1.20, the import form kept", + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != moved.Fp2 || m.Packages[meshSDK] != "v0.1.20" || m.Inputs2.ImportForm != moved.Inputs2.ImportForm { + t.Fatalf("after mesh-sdk's release: fp2 %q (was %q), versions %v, import form %q; want the fingerprint where it was, pinned to v0.1.20 (H-A-530)", m.Fp2, moved.Fp2, m.Packages, m.Inputs2.ImportForm) - } else if err := ix.Recompute(ctx); err != nil { + } +} + +// Design 47 H2 H-A-530: only the version line's fingerprint takes a release's pin, so a release moves a module with no +// reported import set (I4/AC2, H-A-167 for the version line); a held fingerprint made with a pin from before stands +// while the import form computes to the one its build reported (I4/AC3, ADR 0593 §4, H-A-529). +func onlyTheVersionLineTakesAPin(t *testing.T) { + ctx := context.Background() + start := func() (*Indexer, *memStore) { + t.Helper() + ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + ix.Packages, ix.Files, ix.Imports = newMem(), forge{c1: sdkFiles("a1", "b1")}.files, newMem() + setPackages(t, mods, "avahi", []string{meshSDK}) + sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) + if err != nil { + t.Fatal(err) + } + mods.put("mesh-sdk", sdkModule) + held, _ := ix.heldModules(ctx) + if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + return ix, mods + } + release := func(ix *Indexer) { + t.Helper() + if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c1, GoModule: meshSDK, Published: true}); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + } + + // I4/AC2: avahi reports no imports, so it is on the version line; mesh-sdk's release moves it. + ix, mods := start() + line, _ := moduleOf(t, mods, "avahi") + release(ix) + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 == line.Fp2 || m.Fp2 == "" || m.Packages[meshSDK] != "v0.1.20" { + t.Fatalf("the version line after the release: fp2 %q (was %q), versions %v; want moved, pinned to v0.1.20", m.Fp2, line.Fp2, m.Packages) + } + + // I4/AC3: avahi's build reports its imports, and its held fingerprint was made with a pin from before (H-A-172): + // the release of the same content leaves it as held. + ix, mods = start() + before, _ := moduleOf(t, mods, "avahi") + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce")); err != nil { t.Fatal(err) - } else if again, _ := moduleOf(t, mods, "avahi"); again.Fp2 != m.Fp2 { - t.Fatalf("a pass with nothing moved moved the pinned fingerprint %q to %q", m.Fp2, again.Fp2) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + old, _ := moduleOf(t, mods, "avahi") + if old.Inputs2 == nil || old.Inputs2.ImportForm == "" { + t.Fatalf("no import form kept from the report: %+v", old.Inputs2) + } + old.Fp2, old.Packages = fingerprint.WithPins(old.Inputs2.ImportForm, map[string]string{meshSDK: "v0.1.19"}), map[string]string{meshSDK: "v0.1.19"} + raw, err := meshcatalogclient.EncodeModule(old) + if err != nil { + t.Fatal(err) + } + mods.put("avahi", raw) + release(ix) + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != old.Fp2 || m.Packages[meshSDK] != "v0.1.20" { + t.Fatalf("a held fingerprint with a pin from before after the release: fp2 %q (was %q), versions %v; want it as held, pinned to v0.1.20", + m.Fp2, old.Fp2, m.Packages) + } +} + +// Design 47 H2 H-A-536, H-A-537: a module's import set is reported when the state imports keeps a key for it, whatever +// the set's length, or, until its next report, when its modules value holds a set from before that state: either is +// on the import form, so mesh-sdk's release of a commit whose content avahi does not import moves neither, while the +// version line would. +func aReportedSetIsAKeyOrAHeldSet(t *testing.T) { + ctx := context.Background() + for _, c := range []struct { + name string + imports []string + dropKey bool + }{ + {"a reported empty set (H-A-536)", nil, false}, + {"a set held before the state imports, no key (H-A-537)", []string{meshSDK + "/buildstep"}, true}, + } { + ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + ix.Packages, ix.Files, ix.Imports = newMem(), forge{c1: sdkFiles("a1", "b1"), c3: sdkFiles("a2", "b1")}.files, newMem() + setPackages(t, mods, "avahi", []string{meshSDK}) + sdkModule, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Path: ".", Commit: c1, None2: "a TypeScript package"}) + if err != nil { + t.Fatal(err) + } + mods.put("mesh-sdk", sdkModule) + held, _ := ix.heldModules(ctx) + if err := ix.publish(ctx, "novox/mesh-sdk", c1, held, false, TrunkBranch); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + before, _ := moduleOf(t, mods, "avahi") + if err := ix.HearImportsReported(ctx, buildEnd(t, "avahi", before.Fp2, c.imports...)); err != nil { + t.Fatal(err) + } + if c.dropKey { + if err := ix.dropImportSet(ctx, "avahi"); err != nil { + t.Fatal(err) + } + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != before.Fp2 || m.Inputs2.ImportForm == "" { + t.Fatalf("%s: after the report fp2 %q (was %q), import form %q; want the fingerprint as it was, on the import form", c.name, m.Fp2, before.Fp2, m.Inputs2.ImportForm) + } + // mesh-sdk 0.1.20 is published from c3, which changes announce alone: avahi imports none of it. + if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c3, GoModule: meshSDK, Published: true}); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != before.Fp2 || m.Packages[meshSDK] != "v0.1.20" { + t.Errorf("%s: after the release fp2 %q (was %q), versions %v; want it where it was, pinned to v0.1.20", c.name, m.Fp2, before.Fp2, m.Packages) + } } } @@ -475,7 +602,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * {"a build's imports naming none of another repository, which none publishes", held, []string{own}, ""}, } { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}, Imports: c.imports} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) if got := f.versions[contracts]; got != c.want { t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want) } @@ -487,12 +614,12 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * // so the module has a fingerprint, and the same tree gives the same one whatever commit names it. sibling := "git.novox.be/novox/mesh-catalog/modules/sibling" kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t\nderived modules/sibling o1", Packages: []string{sibling}} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, false, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) if f.fp == "" { t.Fatalf("an unpublished package of the same repository: none %q, want a fingerprint by its directory's tree", f.none) } kept.Tree = "t\nderived modules/sibling o2" - if g := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { + if g := formOf("avahi", "novox/mesh-catalog", &kept, false, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { t.Errorf("the sibling's directory changed: fingerprint %q, was %q; want a new one", g.fp, f.fp) } }) @@ -502,7 +629,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * imports []string }{{"an import no package holds", []string{meshSDK + "/announce"}}, {"no import reported", nil}} { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Imports: c.imports, ImportForm: "src2:" + strings.Repeat("a", 64)} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, c.imports != nil, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) if kept.ImportForm != "" { t.Errorf("%s: kept import form %q after the version line %q", c.name, kept.ImportForm, f.fp) } diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go index 13eb30137..09a6601f4 100644 --- a/modules/mesh-delivery-indexer/internal/index/importset.go +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -143,24 +143,28 @@ func ImportsReadTool(st Store) stdio.Tool { // another set takes it with main's import form while main's value holds that set (so the form costs no rebuild of its // own, H-A-529), else with none, so its next computation writes the import form. cur is left as it is when the state // keeps no set for key, or it holds no inputs. -func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur meshcatalog.ModulesByModuleValue) meshcatalog.ModulesByModuleValue { +// +// reported says whether the module's import set is reported (H-A-536, H-A-537): the state imports keeps a key for it, +// whatever the set's length, or, until its next report replaces it, its value already holds a set (one kept before the +// state imports was), read as it is. +func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur meshcatalog.ModulesByModuleValue) (_ meshcatalog.ModulesByModuleValue, reported bool) { if cur.Inputs2 == nil { - return cur + return cur, false } set, found, err := ix.ImportSetOf(ctx, key) if err != nil { ix.logf("%s.%s cannot be read, so %s keeps the import set its value holds: %v", ImportsState, key, key, err) - return cur + return cur, len(cur.Inputs2.Imports) > 0 } if !found { - return cur + return cur, len(cur.Inputs2.Imports) > 0 } imports := make([]string, 0, len(set.Imports)) for _, p := range set.Imports { imports = append(imports, p.Package) } if slices.Equal(cur.Inputs2.Imports, imports) { - return cur + return cur, true } in := *cur.Inputs2 in.Imports, in.ImportForm = imports, ix.trunkImportForm(ctx, key, imports) @@ -168,7 +172,7 @@ func (ix *Indexer) withReportedImports(ctx context.Context, key string, cur mesh in.Imports = nil } cur.Inputs2 = &in - return cur + return cur, true } // trunkImportForm is the import form main's modules value of key holds with imports, "" when it holds another set. diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 66df18707..bc1688871 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -130,6 +130,9 @@ type known struct { // held is the fingerprint the bucket holds for the module and the toolchains it was computed with (for a merge, the // value before it): what stillComputed keeps while the builders agree on no toolchain. held meshcatalog.ModulesByModuleValue + // reported: the module's import set is reported (withReportedImports; design 47 H2 H-A-536, H-A-537), so its + // fingerprint takes the import form, an empty set's too. + reported bool } // Recompute writes again every module whose new-form fingerprint, or reason for none, is no longer what it holds: from @@ -221,8 +224,8 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc cur, stale[key] = again, true held[key] = cur } - cur = ix.withReportedImports(ctx, key, cur) - all[key] = &known{key: key, cur: cur, manifest: m, languages: languagesOf(m), bases: basesOf(m), contexts: hasContext(m), held: before} + cur, reported := ix.withReportedImports(ctx, key, cur) + all[key] = &known{key: key, cur: cur, manifest: m, languages: languagesOf(m), bases: basesOf(m), contexts: hasContext(m), held: before, reported: reported} } tools := ix.agreed() published, err := ix.publishedForPass(ctx, held) @@ -309,7 +312,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs} } default: - f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.logf) + f := formOf(module, k.cur.Repository, &kept, k.reported, toolchains, k.held, held, pub, pins, ix.logf) r.fp, r.none = f.fp, f.none if r.fp != "" { // a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167) @@ -532,7 +535,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, } toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe} } - f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, nil) + f := formOf(module, k.held.Repository, &kept, k.reported, toolchains, k.held, held, published, pins, nil) if f.none != "" || f.fp == "" { return "", nil, false } diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index 5dd969287..9bba033c5 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -458,17 +458,15 @@ func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPack return out } -// pinnedOf is a form's fingerprint and its pins (releasedPins): the pins are part of what a build is made of, so every -// form's fingerprint takes them (design 47 H-A-167, H-A-172; ADR 0573 §4) and a re-pin moves it, the module a mover -// built again against the release; a fingerprint with no pin is the form's as it is. The held fingerprint of a build that -// stands is kept while its pins are the ones it was built with, else its import form takes the new pins. +// pinnedOf is a form's fingerprint and its pins (releasedPins), which the catalog entry's packages name for its build. +// Only the version line's fingerprint takes the pins (design 47 H-A-167, as H2 H-A-530 keeps it for the version line), so +// a re-pin moves it, the module a mover built again against the release. The import form's takes none (H-A-530): it +// takes each imported package by its content, so a release whose content is unchanged leaves it, and the held +// fingerprint of the build that reported the imports stands as held (ADR 0593 §4, H-A-529). func pinnedOf(f form, series map[string]SeriesPackage, m catalogue.Manifest, repository string, required []string) (string, sdkstep.PackageVersions) { pins := releasedPins(f.versions, series, m, repository, required) - if f.stands { - if maps.Equal(f.built, map[string]string(pins)) { - return f.fp, pins - } - return fingerprint.WithPins(f.raw, pins), pins + if f.imports { + return f.fp, pins } return fingerprint.WithPins(f.fp, pins), pins }