From 7ffec1b56b266128578b6e80bdcb6f35be0002bb Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 00:53:49 +0100 Subject: [PATCH] I1: a module's fingerprint takes a package by what is published, never by a commit of its repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A package of another repository none publishes leaves the module without a fingerprint (NoPackageVersion) instead of taking the gate's source head; one of the module's own repository none publishes enters by its directory's tree, which the tree input carries, so the same source gives the same fingerprint. Builds: design 47 H2 §802, H-A-349 DQ-8, H-A-350 DMC-5 --- .../internal/fingerprint/fingerprint.go | 7 ++-- .../internal/fingerprint/fingerprint_test.go | 13 +++++- .../internal/index/form.go | 37 ++++++----------- .../internal/index/imports_test.go | 41 +++++++++++-------- .../internal/index/source.go | 7 ---- .../internal/index/toolchains.go | 8 ++-- 6 files changed, 54 insertions(+), 59 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go index 64bf2d128..6c3cd5637 100644 --- a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go +++ b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go @@ -229,8 +229,10 @@ func ReplacedSiblings(goMod []byte, repository string) []string { // VersionLine is the version line's value of each package (Inputs.Packages) of a module of repository: a mesh Go // module of another repository by its version (versions), and one of repository itself, replaced by its directory // (ReplacedSiblings), by the content its directory publishes, `content:` and the hex sha256 of its requirements' digest -// and each package's digest (empty while it is not published, which gives no fingerprint until it is, as a version -// none publishes does). +// and each package's digest. A package of another repository with no version is empty, which gives no fingerprint until +// it is published (NoPackageVersion); one of repository that is not published yet has no line: it enters by its +// directory's tree, which the module's tree input carries (its own directory, or a derived directory of H-A-202), never by +// a commit (design 47 H2 §802, H-A-349 DQ-8). func VersionLine(repository string, packages []string, versions sdkstep.PackageVersions, published map[string]meshcatalog.PackagesByModuleValue) map[string]string { if len(packages) == 0 { return nil @@ -244,7 +246,6 @@ func VersionLine(repository string, packages []string, versions sdkstep.PackageV } pub, held := published[p] if !held { - out[p] = "" continue } lines := []string{"requires " + pub.Requires} diff --git a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go index 6a1d68bbc..257e6781f 100644 --- a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go +++ b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go @@ -62,8 +62,17 @@ func versionLineTakesASiblingDirectoryByItsContent(t *testing.T) { if a, b := line("d1"), line("d2"); a == b { t.Error("a change of the sibling directory alone left the importer's fingerprint where it was") } - if got := VersionLine(repo, []string{buildrun}, nil, nil)[buildrun]; got != "" { - t.Errorf("an unpublished sibling is taken as %q, want none (no fingerprint until it is published)", got) + // An unpublished sibling has no line: it enters by its directory's tree, which the tree input carries (design 47 H2 + // §802, H-A-349 DQ-8); one of another repository with no version still gives no fingerprint. + if got, ok := VersionLine(repo, []string{buildrun}, nil, nil)[buildrun]; ok { + t.Errorf("an unpublished sibling is taken as %q, want no line (it enters by its directory's tree)", got) + } + in := base() + if in.Packages = VersionLine(repo, []string{sdk}, nil, nil); in.Packages[sdk] != "" { + t.Fatalf("a package of another repository with no version is taken as %q", in.Packages[sdk]) + } + if fp, none := Of(in); fp != "" || !strings.HasPrefix(none, NoPackageVersion) { + t.Errorf("a package of another repository with no version gives %q (%q), want none naming it", fp, none) } } diff --git a/modules/mesh-delivery-indexer/internal/index/form.go b/modules/mesh-delivery-indexer/internal/index/form.go index 133f42e1b..8e9c0687f 100644 --- a/modules/mesh-delivery-indexer/internal/index/form.go +++ b/modules/mesh-delivery-indexer/internal/index/form.go @@ -7,7 +7,6 @@ import ( "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" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "mesh-delivery-indexer/internal/fingerprint" ) @@ -39,14 +38,15 @@ type form struct { // 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. -// A package of another repository none of them publishes takes the commit the gate's source names for its repository -// (heads, design 47 G A-365). +// A package of another repository none of them publishes leaves the module without a fingerprint until one does +// (fingerprint.NoPackageVersion), and one of its own repository none publishes enters by its directory's tree alone, +// never by a commit: the same source, the same fingerprint (design 47 H2 §802, H-A-349 DQ-8). // - **An accepted series** (DLV-I6): published and pins come from acceptedSeries, so a mesh Go module of another // repository whose series the module accepts enters, in either form, by its series' newest published version and the // 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, heads map[string]string, logf func(string, ...any)) 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 { in := inputsFrom(module, *kept, toolchains) if len(kept.Imports) > 0 { r := fingerprint.Resolve(repository, kept.Imports, published) @@ -58,11 +58,11 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp return form{none: none} 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, heads), + 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} } kept.ImportForm = fp - return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins, heads)} + return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins)} } if logf != nil { logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", ")) @@ -71,7 +71,7 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp // The fingerprint written here is the version line's, not the import form's: no import form is held for the inputs it was // computed from, so a later pass whose import form computes the same does not take this one for the build's (issue 1966). kept.ImportForm = "" - versions := lineVersions(module, repository, kept, held, pins, heads, logf) + versions := lineVersions(module, repository, kept, held, pins, logf) in.Packages = fingerprint.VersionLine(repository, kept.Packages, versions, published) fp, none := fingerprint.Of(in) if fp == "" { @@ -83,22 +83,22 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp // refined are an import form's versions: the first of sets that names a package, else, while the module's go.mod // requires a mesh package of another repository (kept.Packages), the version line's, so a build's reported imports // refine the go.mod's set and never empty it (design 47 H-A-157); nil when nothing names one. -func refined(versions, then sdkstep.PackageVersions, module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string) sdkstep.PackageVersions { +func refined(versions, then sdkstep.PackageVersions, module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions) sdkstep.PackageVersions { switch { case len(versions) > 0: return versions case len(then) > 0: return then case len(fingerprint.OtherPackages(kept.Packages, repository)) > 0: - return lineVersions(module, repository, kept, held, pins, heads, nil) + return lineVersions(module, repository, kept, held, pins, nil) } return versions } // lineVersions are the version line's versions of the mesh Go modules of other repositories the module's go.mod requires -// (kept.Packages): each as the indexer has always read it, an accepted series' pin over it, else the commit the gate's -// source names for its repository. -func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, logf func(string, ...any)) sdkstep.PackageVersions { +// (kept.Packages): each as the indexer has always read it, an accepted series' pin over it; one neither gives has no +// version, so the module has no fingerprint until it is published (design 47 H2 §802). +func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) sdkstep.PackageVersions { others := fingerprint.OtherPackages(kept.Packages, repository) versions, unpublished := fingerprint.HeldVersionsOf(others, held) for p, v := range pins { // an accepted series' newest published version (acceptedSeries, DLV-I6) @@ -110,19 +110,6 @@ func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleVa unpublished = slices.DeleteFunc(unpublished, func(u string) bool { return u == p }) } } - // A mesh Go package no module the indexer holds publishes is built at the commit the gate's source names for its - // repository, as an import of the same repository is; once a version is published, the version applies (design 47 G A-365). - for _, p := range slices.Clone(unpublished) { - if repo, _, ok := trunk.PackageRepository(p); ok { - if head := heads[repo]; len(head) == 40 { - if versions == nil { - versions = sdkstep.PackageVersions{} - } - versions[p] = head - unpublished = slices.DeleteFunc(unpublished, func(u string) bool { return u == p }) - } - } - } if len(unpublished) > 0 && logf != nil { logf("%s: no module the indexer holds publishes %s, so its fingerprint takes no version of it", module, strings.Join(unpublished, ", ")) } diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 65876c137..762b8bbd9 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -11,6 +11,8 @@ import ( "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-sdk/go/process" + + "mesh-delivery-indexer/internal/fingerprint" ) const meshSDK = "git.novox.be/novox/mesh-sdk/go" @@ -402,41 +404,44 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * t.Fatalf("fingerprints again of a module not held answered stored: %+v", r) } }) - t.Run("formOf builds a package no module publishes at the source's commit of its repository", func(t *testing.T) { // design 47 G A-365 - head := strings.Repeat("c", 40) + t.Run("formOf takes a package by what is published, never by a commit of its repository", func(t *testing.T) { // design 47 H2 §802, H-A-349 DQ-8 contracts := "git.novox.be/novox/mesh-contracts/go/seats/findings" held := map[string]meshcatalog.ModulesByModuleValue{"other": {Repository: "novox/mesh-sdk", Commit: strings.Repeat("d", 40), Path: "go"}} // A build's imports of its own repository alone (design 47 H-A-157): they refine the go.mod's set and never empty it. own := "git.novox.be/novox/mesh-catalog/modules/avahi/lib" - published := map[string]meshcatalog.PackagesByModuleValue{own: {Module: own, Repository: "novox/mesh-catalog", Commit: head, Requires: "r1", + published := map[string]meshcatalog.PackagesByModuleValue{own: {Module: own, Repository: "novox/mesh-catalog", Commit: strings.Repeat("c", 40), Requires: "r1", Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: own, Digest: "d1"}}}} for _, c := range []struct { name string - heads map[string]string held map[string]meshcatalog.ModulesByModuleValue imports []string want string }{ - {"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, nil, head}, - {"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, nil, ""}, - {"a module the indexer holds publishes it", map[string]string{"novox/mesh-contracts": head}, - map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, nil, strings.Repeat("e", 40)}, - {"a build's imports naming none of another repository keep the go.mod's", map[string]string{"novox/mesh-contracts": head}, held, []string{own}, head}, + {"a package of another repository none publishes", held, nil, ""}, + {"a module the indexer holds publishes it", map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, nil, strings.Repeat("e", 40)}, + {"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, c.heads, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, 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) } - if c.imports == nil { - continue - } - // The build that reported them stands, its held versions empty (a version line read from go.sum). - f = formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{Fp2: "src2:" + strings.Repeat("b", 64)}, c.held, published, nil, c.heads, nil) - if got := f.versions[contracts]; got != c.want || f.fp != "src2:"+strings.Repeat("b", 64) { - t.Errorf("%s, the build standing: version of %s = %q (fp %q), want %q", c.name, contracts, got, f.fp, c.want) + if c.want == "" && c.imports == nil && (f.fp != "" || !strings.HasPrefix(f.none, fingerprint.NoPackageVersion)) { + t.Errorf("%s: fingerprint %q (none %q), want none naming %s", c.name, f.fp, f.none, fingerprint.NoPackageVersion) } } + // A package of the module's own repository no module has published enters by its directory's tree (the tree input), + // 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) + 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 { + t.Errorf("the sibling's directory changed: fingerprint %q, was %q; want a new one", g.fp, f.fp) + } }) t.Run("formOf clears the import form when it writes the version line", func(t *testing.T) { for _, c := range []struct { @@ -444,7 +449,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, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, 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/source.go b/modules/mesh-delivery-indexer/internal/index/source.go index a0d2ba74f..55fbf1937 100644 --- a/modules/mesh-delivery-indexer/internal/index/source.go +++ b/modules/mesh-delivery-indexer/internal/index/source.go @@ -24,13 +24,6 @@ type sourceNow struct { heads map[string]string } -// sourceHeads is the head the latest source seen names for each repository (a copy), nil while none has been seen. -func (ix *Indexer) sourceHeads() map[string]string { - ix.mu.Lock() - defer ix.mu.Unlock() - return maps.Clone(ix.source.heads) -} - // wholeAt reads repository's trees at the commit head through the seat git (design 47 H §743): every module directory's manifest, // templates' needs, lock files and packages, and the catalogue's predefined list where the repository is the catalogue's (§769). func (ix *Indexer) wholeAt(ctx context.Context, repository, head string) (whole, error) { diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index dfba512a6..0a4553916 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -303,11 +303,11 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r.none = strings.Join(missing, "; ") case noToolchain != "": r.none = noToolchain - if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, ix.sourceHeads(), series); ok { + if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, series); ok { 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.sourceHeads(), ix.logf) + f := formOf(module, k.cur.Repository, &kept, 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) @@ -510,7 +510,7 @@ func hasContext(m catalogue.Manifest) bool { // with the toolchains it was computed with in place of the languages agreed on none, give it again, in its form. Any // other input that moved (a merge, a base, an agreed toolchain, an imported package) gives another fingerprint, and the // module has none until they agree. -func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, series map[string]SeriesPackage) (string, sdkstep.PackageVersions, bool) { +func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, series map[string]SeriesPackage) (string, sdkstep.PackageVersions, bool) { if k.held.Fp2 == "" { return "", nil, false } @@ -526,7 +526,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, heads, nil) + f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, nil) if f.none != "" || f.fp == "" { return "", nil, false }