diff --git a/modules/mesh-grants/grants_test.go b/modules/mesh-grants/grants_test.go index 1e5f6fad..15c4a284 100644 --- a/modules/mesh-grants/grants_test.go +++ b/modules/mesh-grants/grants_test.go @@ -5223,10 +5223,14 @@ func TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo(t *testing.T) { name string entry bool // the want's entry is answered (the older build); else it is not answered wantsOld bool + newest string // "entry": the want names a newest build whose entry is answered; "none": it names one with no entry }{ - {"the want's entry is not answered", false, false}, - {"the want names an entry that is asked", false, false}, - {"the want's entry is an older build", true, true}, + {"the want's entry is not answered", false, false, ""}, + {"the want names an entry that is asked", false, false, ""}, + {"the want's entry is an older build", true, true, ""}, + // A-414: a running build with no entry composes from its want's newest build's entry; with neither entry it carries as today. + {"no entry for the fingerprint but one for newest", false, true, "entry"}, + {"neither entry", false, false, "none"}, } for _, row := range rows { t.Run(row.name, func(t *testing.T) { @@ -5244,6 +5248,15 @@ func TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo(t *testing.T) { b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Composed: "sha256:" + strings.Repeat("ef", 32)}) b.entry(fp, digest) } + if row.newest != "" { + fp, newest := "src2:"+strings.Repeat("cd", 32), "src2:"+strings.Repeat("ab", 32) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Newest: newest, Rule: meshwantsclient.RuleStep, Composed: "sha256:" + strings.Repeat("ef", 32)}) + if row.newest == "entry" { + digest := meshcatalogclient.ManifestDigest([]byte(older)) + b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: older}) + b.entry(newest, digest) + } + } b.mu.Lock() b.catalogWaited = []string{"the catalog half of the branch main"} b.mu.Unlock() diff --git a/modules/mesh-grants/internal/grants/inputs.go b/modules/mesh-grants/internal/grants/inputs.go index 5ca9e683..1ec8adf1 100644 --- a/modules/mesh-grants/internal/grants/inputs.go +++ b/modules/mesh-grants/internal/grants/inputs.go @@ -601,6 +601,7 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { in.Gaps = append(in.Gaps, Gap{Input: ReadWants, Why: "not read: the modules are placed by the node-engines' haves this pass, so what runs is composed from each have's fingerprint"}) fromTrunk = runningByHaves(r, &in, cache, in.Running) } + var viaNewest []string for key, raw := range wants { node, module, err := meshwantsclient.ParseWantKey(key) if err != nil || !slices.Contains(in.Assigned[node], module) { @@ -617,10 +618,19 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { // The manifest of the build the want names is the catalog graph's entry of its fingerprint (design 47 G §444, §614). if m, _, err := cache.entryManifest(r, w.Fp); err == nil { in.Running[node+"."+module] = m + } else if m, _, nerr := cache.entryManifest(r, w.Newest); w.Newest != "" && w.Newest != w.Fp && nerr == nil { + // A running build with no catalog entry (from before the catalog graph) is composed from the entry of the build its want + // says is being built, for its account's grants, membership and seat traffic alone (A-414, as A-407 does for the node). + in.Running[node+"."+module] = m + viaNewest = append(viaNewest, node+"."+module) } else { fromTrunk = append(fromTrunk, node+"."+module) } } + if len(viaNewest) > 0 { + sort.Strings(viaNewest) + in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "no catalog entry holds the running build, so its account is composed from the entry of the build its want says is being built: " + strings.Join(viaNewest, ", ")}) + } if len(fromTrunk) > 0 { sort.Strings(fromTrunk) in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "no build record names the manifest at the wanted fingerprint, so the trunk's is used: " + strings.Join(fromTrunk, ", ")})