Merge pull request 'A build step whose revision the picture has passed ends superseded too (design 47 H2 H-A-508 second addendum)' (#346) from fix/stale-revision-superseded into main

This commit was merged in pull request #346.
This commit is contained in:
2026-11-23 00:05:20 +00:00
2 changed files with 40 additions and 11 deletions
@@ -80,7 +80,8 @@ func (b *Builder) holdsRevision(branch string, source int64, entries []meshbuild
}
// keptRevisionHolds answers no outcome when the catalog keeps the ask's revision (its catalog revision by number) and that
// revision names every entry of the ask (H-A-205, H-A-222); else failed or could not run, with its words.
// revision names every entry of the ask (H-A-205, H-A-222); superseded when it names a newer fingerprint of an entry (H-A-508
// second addendum); else failed or could not run, with its words.
func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, held int64) (outcome, said string) {
below := fmt.Sprintf("revision %d of %s is not named by the builder's picture, which holds source revision %d", run.Source, run.Branch, held)
if run.Source < held {
@@ -100,11 +101,25 @@ func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun,
b.logf("%s: %s, and the catalog's revision %d is of source revision %d, the ask names %d: the step fails, nothing is built", run.Pipeline, below, run.Revision, source, run.Source)
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d is of source revision %d, the ask names %d", below, run.Revision, source, run.Source)
}
// A step whose fingerprint the catalog's revision no longer names but names a newer one of its module, found below the
// picture or by the revision's number, ends superseded with the superseding fingerprint in its why, never failed (design
// 47 H2 H-A-508 second addendum: one outcome for one fact, found by either check). Failed stays for any other mismatch.
var superseded []string
for _, e := range run.Entries {
if fps[e.Module] != e.Fingerprint {
b.logf("%s: %s, and the catalog's revision %d names %s at %q, not %s: the step fails, nothing is built", run.Pipeline, below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d names %s at %q, not %s", below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
if fps[e.Module] == e.Fingerprint {
continue
}
if fps[e.Module] != "" {
superseded = append(superseded, stepSuperseded(e.Module, e.Fingerprint, fps[e.Module]))
continue
}
b.logf("%s: %s, and the catalog's revision %d names %s at %q, not %s: the step fails, nothing is built", run.Pipeline, below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d names %s at %q, not %s", below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
}
if len(superseded) > 0 {
said := strings.Join(superseded, "; ")
b.logf("%s: %s, and the catalog's revision %d names newer fingerprints: %s; nothing is built", run.Pipeline, below, run.Revision, said)
return meshbuilds.StepEndedOutcomeSuperseded, said
}
// Each asked fingerprint is recorded as the branch's, so its build reserves its version (H-A-155) as one the picture
// took in does; what the picture heard stays as it is, so the newer fingerprint's build is not superseded. Once the picture
@@ -136,9 +151,10 @@ func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (ou
if (run.Revision > 0 && b.KeptRevision != nil) || below {
// By its number (H-A-222), whatever the source the picture holds; for an ask naming none, only below the
// picture (H-A-205). A kept revision of another source or naming other fingerprints is a mismatch the wait
// cannot mend: it fails at once; only a revision the catalog does not answer is waited for.
// cannot mend: it fails at once, or ends superseded at once when it names a newer fingerprint of the module (H-A-508
// second addendum); only a revision the catalog does not answer is waited for.
outcome, said := b.keptRevisionHolds(ctx, run, held)
if outcome == "" || below || outcome == meshbuilds.StepEndedOutcomeFailed {
if outcome == "" || below || outcome == meshbuilds.StepEndedOutcomeFailed || outcome == meshbuilds.StepEndedOutcomeSuperseded {
return outcome, said
}
}
@@ -477,7 +477,7 @@ func aStepAskWaitsForItsRevision(t *testing.T) {
// H-A-205: two pipelines of consecutive revisions run at once; the picture holds source revision 46, while the older pipeline
// asks the build of revision 45. Its kept catalog revision is read by number and the build runs while the picture never heard
// a newer entry of m (a restart); once it heard one on the first branch, H-A-489 overrides H-A-205 and the older ask is refused
// superseded. A kept revision naming another fingerprint fails the step, naming it.
// superseded. A kept revision naming another fingerprint ends the step superseded, naming it (H-A-508 second addendum).
func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
var held atomic.Int64
held.Store(46)
@@ -524,8 +524,10 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
r2.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) {
return 45, map[string]string{"m": "src2:other"}, nil
}
if end := r2.b.BuildStep(t.Context(), "a1", run); end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "names m at \"src2:other\"") {
t.Errorf("end = %+v; want failed naming the fingerprint the kept revision names", end)
// H-A-508 second addendum: below the picture, a kept revision naming another fingerprint of the module superseded the
// ask's: the step ends superseded naming it, never failed with the "below" words.
if end := r2.b.BuildStep(t.Context(), "a1", run); end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || end.Said != stepSuperseded("m", fp1, "src2:other") {
t.Errorf("end = %+v; want superseded naming the fingerprint the kept revision names", end)
}
// H-A-222: an ask of the very source the picture holds, whose entries the picture no longer names (a re-pin kept revision 48
// of the same source 46 and the picture took its entries in), is held by its revision read by number, never waited for.
@@ -544,7 +546,7 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
if end3.Outcome != meshbuilds.StepEndedOutcomePassed || !slices.Equal(read3, []string{"main 48"}) || len(res3.sources) != 1 || res3.sources[0].CatalogRevision != 48 {
t.Errorf("end = %+v, kept revisions read %v, reserved %+v; want passed, revision 48 of main read once and reserved at it", end3, read3, res3.sources)
}
// H-A-218, H-A-222: a kept revision of another source than the ask names, or naming another fingerprint, is a mismatch:
// H-A-218, H-A-222: a kept revision of another source than the ask names is a mismatch:
// the step fails at once naming it, never waiting out its bound (the bound here is long, the ask is not below the picture).
for _, c := range []struct {
name string
@@ -553,7 +555,6 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
said string
}{
{"another source", 45, fp1, "the catalog's revision 48 is of source revision 45, the ask names 46"},
{"another fingerprint", 46, "src2:other", "names m at \"src2:other\""},
} {
rc, resc, _ := revisionRig(t, &held, make(chan struct{}, 1))
rc.b.RevisionWait = time.Hour
@@ -566,6 +567,18 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
t.Errorf("%s: end = %+v, reserved %+v; want failed at once saying %q, nothing reserved", c.name, end, resc.sources, c.said)
}
}
// H-A-508 second addendum, found by either check: a revision read by its number (H-A-222) whose kept revision names another
// fingerprint of m superseded the ask's: it ends superseded at once naming it, never failed and never waiting its bound.
rs, ress, _ := revisionRig(t, &held, make(chan struct{}, 1))
rs.b.RevisionWait = time.Hour
rs.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) {
return 46, map[string]string{"m": "src2:other"}, nil
}
ends := rs.b.BuildStep(t.Context(), "a1", same)
rs.b.Wait()
if ends.Outcome != meshbuilds.StepEndedOutcomeSuperseded || ends.Said != stepSuperseded("m", fp1, "src2:other") || len(ress.sources) != 0 {
t.Errorf("by its number, another fingerprint: end = %+v, reserved %+v; want superseded by src2:other at once, nothing reserved", ends, ress.sources)
}
}
func aStepAskPastItsRevisionBoundFails(t *testing.T) {