assigner: a released build counts as done for rule 1

Rule 1 held mesh-delivery-pipeline's want as being built after a restart lost its build end, though 0.1.6 was released.
A build whose version is released counts as done for rule 1, and its build.ended counts only for a build not released.

Builds: design 47 G A-429, §379
This commit is contained in:
2026-11-15 16:16:17 +01:00
parent e0f0a56630
commit d57fa43bcc
2 changed files with 19 additions and 0 deletions
@@ -94,6 +94,10 @@ func TestATrunkEntryTakesItsVersionFromTheReleaseOfItsFingerprintsSource(t *test
}
// The release names each artifact by its whole reference, as the catalog says it, and the parts are keyed so (A-96); the
// assigner reads the entry's fp-src from its inputs (A-419).
// A-429: a released version's build counts as done for rule 1; a kept build (no version) and an unknown one do not.
if !releasedBuild(p.namedBuild("mail", "t", 7), "t") || releasedBuild(p.namedBuild("mail", "t", 7), "k") || releasedBuild(p.namedBuild("mail", "t", 8), "t") || releasedBuild(nil, "t") {
t.Error("rule 1's released build: the release of the entry's fingerprint counts, a kept build, another source or none does not")
}
if v, _, _ := fromEntry(meshcatalog.CatalogEntry{Module: "mail", Fp: "t", Inputs: &meshcatalog.EntryInputs{Src: 9, FpSrc: 7}}); v.FpSrc != 7 || v.Src != 9 {
t.Errorf("the entry's module value carries fp-src %d and src %d, want 7 and 9", v.FpSrc, v.Src)
}
@@ -371,6 +371,11 @@ func (p *passer) wants(ctx context.Context) {
m.Kept = p.answeredWith(hold, "keep")
m.Built, m.Held, m.Granted = p.w.built(name, fp), p.w.has(buckets.Wants(), held) && !m.Released, p.w.has(grants, grant)
m.BuildFailed, m.BuildError = p.w.buildStanding(name, fp)
// A build whose version is released counts as done for rule 1; its build.ended counts only for a build not
// released (design 47 G A-429), so a restart that lost the end loses nothing of a released build.
if releasedBuild(m.KeptBuilds, fp) {
m.Built, m.BuildFailed, m.BuildError = true, false, ""
}
if raw := p.w.value(grants, grant); raw != nil {
if g, err := grantsstate.DecodeGrant(raw); err == nil {
m.GrantedOn = func(node string) bool { return assign.GrantNamesNode(g, node, name) }
@@ -1532,3 +1537,13 @@ func runnerFirstStart(module string, manifests map[string]catalogue.Manifest, ru
}
return true
}
// releasedBuild says whether the build at fp is a released version's, as a want of it names it (namedBuild): such a build counts as
// done for rule 1 whatever the builder's build.ended said or the assigner kept of it (design 47 G A-429).
func releasedBuild(named func(fp string) (assign.KeptBuild, bool), fp string) bool {
if named == nil {
return false
}
k, ok := named(fp)
return ok && k.Version != ""
}