Review round 1 of H-A-763: a recompute row, the rerun-only refusal, rows for the reopen and the place, the I5/AC2 label

Builds: design 47 H2 H-A-765 (3), H-A-764, H-A-763 (3)
This commit is contained in:
2026-11-25 23:11:01 +01:00
parent 14df4c6906
commit b85d463f66
4 changed files with 233 additions and 65 deletions
@@ -194,69 +194,76 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T
}
}
// Design 47 H2 H-A-763 (1), (2), H-A-530, H-A-204: a release re-pins the packages of an entry on the import form pinned
// Design 47 H2 H-A-763 (1), (2), H-A-765 (3), H-A-530, H-A-204: a release (or a recompute, which keeps it as a re-pin does) re-pins the packages of an entry on the import form pinned
// below the series' newest (repinned names it), its fingerprint stays, and the branch's next revision is kept all the same,
// its call the release and no mover.
func aReleaseRepinsAnImportFormEntryWithNoMovers(t *testing.T) {
ctx := context.Background()
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, ix.Revisions = newMem(), forge{c1: sdkFiles("a1", "b1")}.files, newMem(), newMemObjects(1<<20)
setPackages(t, mods, "avahi", []string{meshSDK})
meshSDKPublished(t, ix, mods)
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, meshSDK, meshSDK+"/announce")); err != nil {
t.Fatal(err)
}
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 = old.Inputs2.ImportForm, map[string]string{meshSDK: "v0.1.19"}
raw, err := meshcatalogclient.EncodeModule(old)
if err != nil {
t.Fatal(err)
}
mods.put("avahi", raw)
if err := ix.Recompute(ctx); err != nil { // the held fingerprint stands (H-A-529): the graph and the value agree
t.Fatal(err)
}
entries, err := ix.viewEntries(ctx)
if err != nil {
t.Fatal(err)
}
if err := ix.KeepBranchEntries(ctx, TrunkBranch, 5, entries, nil); err != nil {
t.Fatal(err)
}
if _, err := hearReleased(ctx, ix, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c1, GoModule: meshSDK, Published: true}, "mesh-sdk", "go"); err != nil {
t.Fatal(err)
}
if only, err := ix.repinned(ctx, "mesh-sdk"); err != nil || !only["avahi"] {
t.Fatalf("a re-pin of mesh-sdk names %v (%v), want avahi, on the import form", only, err)
}
if n, err := ix.Repin(ctx, "mesh-sdk", "0.1.20"); err != nil || n != 1 {
t.Fatalf("a release re-pinned %d modules (%v), want avahi", n, err)
}
now, _ := moduleOf(t, mods, "avahi")
if now.Fp2 != old.Fp2 || now.Packages[meshSDK] != "v0.1.20" {
t.Fatalf("avahi after the re-pin: fp2 %q (was %q), packages %v; want the fingerprint as it was, pinned to v0.1.20", now.Fp2, old.Fp2, now.Packages)
}
rev, kept, found, err := readNewestOf(ctx, ix.Revisions, TrunkBranch)
if err != nil || !found || rev.Revision != 2 || rev.Source != 5 || rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || len(rev.Movers) != 0 {
t.Fatalf("main's newest = %+v (%v), want revision 2 of source 5, its call the release, no movers", rev, err)
}
if i := slices.IndexFunc(kept, func(e meshcatalog.CatalogEntry) bool { return e.Module == "avahi" }); i < 0 || kept[i].Packages[meshSDK] != "v0.1.20" || kept[i].Fp != old.Fp2 {
t.Fatalf("the kept entries hold %+v for avahi, want it at %s pinned to v0.1.20", kept, old.Fp2)
for _, how := range []string{"re-pin", "recompute"} {
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, ix.Revisions = newMem(), forge{c1: sdkFiles("a1", "b1")}.files, newMem(), newMemObjects(1<<20)
setPackages(t, mods, "avahi", []string{meshSDK})
meshSDKPublished(t, ix, mods)
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, meshSDK, meshSDK+"/announce")); err != nil {
t.Fatal(err)
}
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 = old.Inputs2.ImportForm, map[string]string{meshSDK: "v0.1.19"}
raw, err := meshcatalogclient.EncodeModule(old)
if err != nil {
t.Fatal(err)
}
mods.put("avahi", raw)
if err := ix.Recompute(ctx); err != nil { // the held fingerprint stands (H-A-529): the graph and the value agree
t.Fatal(err)
}
entries, err := ix.viewEntries(ctx)
if err != nil {
t.Fatal(err)
}
if err := ix.KeepBranchEntries(ctx, TrunkBranch, 5, entries, nil); err != nil {
t.Fatal(err)
}
if _, err := hearReleased(ctx, ix, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c1, GoModule: meshSDK, Published: true}, "mesh-sdk", "go"); err != nil {
t.Fatal(err)
}
if only, err := ix.repinned(ctx, "mesh-sdk"); err != nil || !only["avahi"] {
t.Fatalf("a re-pin of mesh-sdk names %v (%v), want avahi, on the import form", only, err)
}
if how == "re-pin" {
if n, err := ix.Repin(ctx, "mesh-sdk", "0.1.20"); err != nil || n != 1 {
t.Fatalf("a release re-pinned %d modules (%v), want avahi", n, err)
}
} else if err := ix.RecomputeKept(ctx, "the packages moved"); err != nil { // H-A-765 (3): a recompute keeps it as a re-pin does
t.Fatal(err)
}
now, _ := moduleOf(t, mods, "avahi")
if now.Fp2 != old.Fp2 || now.Packages[meshSDK] != "v0.1.20" {
t.Fatalf("avahi after the re-pin: fp2 %q (was %q), packages %v; want the fingerprint as it was, pinned to v0.1.20", now.Fp2, old.Fp2, now.Packages)
}
rev, kept, found, err := readNewestOf(ctx, ix.Revisions, TrunkBranch)
if err != nil || !found || rev.Revision != 2 || rev.Source != 5 || (how == "re-pin" && rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease) || len(rev.Movers) != 0 {
t.Fatalf("main's newest = %+v (%v), want revision 2 of source 5, its call the release (a re-pin), no movers", rev, err)
}
if i := slices.IndexFunc(kept, func(e meshcatalog.CatalogEntry) bool { return e.Module == "avahi" }); i < 0 || kept[i].Packages[meshSDK] != "v0.1.20" || kept[i].Fp != old.Fp2 {
t.Fatalf("the kept entries hold %+v for avahi, want it at %s pinned to v0.1.20", kept, old.Fp2)
}
}
}
@@ -80,6 +80,8 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
if _, err := hearReleased(ctx, ix, HeardVersion{Package: "mesh-sdk/go", GoModule: "git.novox.be/novox/mesh-sdk/go", Version: "0.1.27", Published: true}, "mesh-sdk", "go"); err != nil {
t.Fatal(err)
}
// I5/AC1 (design 47 H2 H-A-530, narrowed by H-A-763 (1)): a module on the import form is named as well, in imports_test.go's
// row aReleaseRepinsAnImportFormEntryWithNoMovers; I5/AC2: on the version line, as g is, it is.
mods.put("g", mustEncode(t, g))
if only, err := ix.repinned(ctx, "mesh-sdk"); err != nil || !only["g"] {
t.Errorf("a re-pin of mesh-sdk names %v (%v), want g, on the version line", only, err)
@@ -422,3 +422,161 @@ func (k rawKept) Value(key string) (json.RawMessage, error) {
v, _, err := k.r.Get(key)
return v, err
}
// design 47 H2 H-A-763 (3), H-A-764: a mover of a failed pipeline whose kept revision holds older pins than the head's entry at the same
// fingerprint is asked again with the head's pins, by start's reopen (ownFailedPipelines) and by runner_unfinished_place's plan; a declined
// step's ask of a running pipeline still reads the kept revision (H-A-286, H-A-445).
func TestAMoverReopenedIsAskedWithTheHeadsPins(t *testing.T) {
const sdk = "git.novox.be/novox/mesh-sdk/go"
reg, entries := placeFixture()
pin := func(v string) catalog.CatalogEntry {
e := entries["app"]
e.Fp, e.Packages, e.Commit, e.Repository = "src2:ab", map[string]string{sdk: v}, "c1", "o/app"
return e
}
keptHalf := Half{Revision: 11, Source: 41, Entries: map[string]catalog.CatalogEntry{"app": pin("v0.1.26"), "mesh-build-go": entries["mesh-build-go"]}}
head := Half{Revision: 13, Source: 41, Entries: map[string]catalog.CatalogEntry{"app": pin("v0.1.27"), "mesh-build-go": entries["mesh-build-go"]}}
for _, how := range []string{"start", "place-unfinished", "declined step of a running pipeline"} {
store := &MoverStore{Raw: newMemRaw()}
asks := &stepAsks{}
u := memUnfinished{}
s := &Starter{Pipelines: store, Store: store, Steps: asks, Name: "the-runner", Now: ticking(), Say: func(string, any) error { return nil },
Revision: func(_ string, r int64) (Half, error) { return keptHalf, nil },
Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }}
s.Unfinished = &Unfinished{Store: u, Kept: func(string) map[string]int64 { return map[string]int64{"app": 11} }}
key := Key("main", 10)
if ok, err := s.Start(Begin{Branch: "main", Source: 41, Revision: 10, Entries: map[string]catalog.CatalogEntry{"app": pin("v0.1.26"), "mesh-build-go": entries["mesh-build-go"]},
Movers: []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:ab", Repository: "o/app"}}}); !ok || err != nil {
t.Fatalf("%s: start = %v, %v", how, ok, err)
}
p, rev, _ := store.Get(key)
end := time.Unix(50, 0)
for i := range p.Steps {
if how == "place-unfinished" { // its steps never ran: the mover is left unfinished, placed again from the head's entry
p.Steps[i].Outcome, p.Steps[i].Ask = seat.StepResultOutcomeNotAsked, ""
} else if p.Steps[i].Step == seat.StepResultStepLint && p.Steps[i].Artifact == "app:program" {
p.Steps[i].Outcome, p.Steps[i].Ended = seat.StepResultOutcomeFailed, &end
}
}
if how != "declined step of a running pipeline" {
p.Outcome, p.Ended, p.EndCount = seat.PipelineOutcomeFailed, &end, 1
}
if _, err := store.UpdateKept(key, p, rev, map[string]int64{"app": 11}); err != nil {
t.Fatal(err)
}
v := Verbs{Starter: s, Hearer: &Hearer{Store: store, Unfinished: s.Unfinished, Say: func(string, any) error { return nil }}, View: func(string) (Half, bool) { return head, true }, Acts: &actLog{}}
before := len(asks.asks)
switch how {
case "start":
if _, err := v.Start("op@shanks", seat.StartInput{Branch: "main", Module: "app", Why: "again"}); err != nil {
t.Fatalf("%s: %v", how, err)
}
case "place-unfinished":
u["main.app"] = `{"fingerprint":"src2:ab","revision":10,"pipeline":"` + key + `","outcome":"failed"}`
if a, err := v.PlaceUnfinished("op@shanks", seat.PlaceUnfinishedInput{Key: "main.app", Why: "again"}); err != nil {
t.Fatalf("%s: %v (%+v)", how, err, a)
} else if len(a.Placed) != 1 {
t.Fatalf("%s: placed %+v", how, a)
}
default:
cur, _, _ := store.Get(key)
a, err := v.DeclinedAsk(cur, stepNamed(cur, "app:program", "lint"), time.Unix(60, 0))
if err != nil {
t.Fatalf("%s: %v", how, err)
}
asks.asks = append(asks.asks, a.Ask)
}
if len(asks.asks) == before {
t.Fatalf("%s: nothing was asked", how)
}
want := "v0.1.27"
if how != "start" && how != "place-unfinished" {
want = "v0.1.26"
}
seen := 0
for _, ask := range asks.asks[before:] {
if b, ok := ask.(nodebuildgo.StepAsk); ok && b.Step != nil && b.Step.Fetch.Packages != nil {
if seen++; b.Step.Fetch.Packages[sdk] != want {
t.Errorf("%s: asked %+v, want mesh-sdk pinned to %s", how, b.Step, want)
}
}
}
if seen == 0 {
t.Errorf("%s: no step was asked with pins", how)
}
}
}
// design 47 H2 H-A-763 (3): the group a hand place or start's reopen closes is read over the head's entries, whose edges are the newest:
// an edge the head's entry of lib has and its kept revision's has not puts app, which lib waits for, in the group.
func TestAReopenedGroupIsClosedOverTheHeadsEdges(t *testing.T) {
reg, entries := placeFixture()
mk := func(module, fp string, edges []catalog.Edge) catalog.CatalogEntry {
return catalog.CatalogEntry{Module: module, Fp: fp, Commit: "c1", Repository: "o/" + module, Path: "modules/" + module, Edges: edges,
Artifacts: []catalog.Artifact{{Ref: catalog.ArtifactRef(module + ":program"), Language: "go"}}}
}
view := func(edges []catalog.Edge) map[string]catalog.CatalogEntry {
return map[string]catalog.CatalogEntry{"app": mk("app", "src2:aa", nil), "lib": mk("lib", "src2:bb", edges), "mesh-build-go": entries["mesh-build-go"]}
}
kept := Half{Revision: 10, Source: 41, Entries: view(nil)}
head := Half{Revision: 13, Source: 41, Entries: view([]catalog.Edge{{From: "app:program", Kind: 2}})}
for _, how := range []string{"start", "place-unfinished"} {
store := &MoverStore{Raw: newMemRaw()}
asks := &stepAsks{}
u := memUnfinished{}
s := &Starter{Pipelines: store, Store: store, Steps: asks, Name: "the-runner", Now: ticking(), Say: func(string, any) error { return nil },
Revision: func(string, int64) (Half, error) { return kept, nil },
Registration: func(string) (catalog.Registration, bool) { return reg, true }, Unfinished: &Unfinished{Store: u}}
key := Key("main", 10)
if ok, err := s.Start(Begin{Branch: "main", Source: 41, Revision: 10, Entries: kept.Entries, Movers: []seat.Mover{
{Module: "app", Commit: "c1", Fingerprint: "src2:aa", Repository: "o/app"}, {Module: "lib", Commit: "c1", Fingerprint: "src2:bb", Repository: "o/lib"}}}); !ok || err != nil {
t.Fatalf("%s: start = %v, %v", how, ok, err)
}
p, rev, _ := store.Get(key)
end := time.Unix(50, 0)
for i := range p.Steps {
switch {
case how == "place-unfinished":
p.Steps[i].Outcome, p.Steps[i].Ask = seat.StepResultOutcomeNotAsked, ""
case p.Steps[i].Step == seat.StepResultStepLint && p.Steps[i].Artifact != "":
p.Steps[i].Outcome, p.Steps[i].Ended = seat.StepResultOutcomeFailed, &end
}
}
p.Outcome, p.Ended, p.EndCount = seat.PipelineOutcomeFailed, &end, 1
if _, err := store.Update(key, p, rev); err != nil {
t.Fatal(err)
}
v := Verbs{Starter: s, Hearer: &Hearer{Store: store, Unfinished: s.Unfinished, Say: func(string, any) error { return nil }}, View: func(string) (Half, bool) { return head, true }, Acts: &actLog{}}
var group []string
switch how {
case "start":
if _, err := v.Start("op@shanks", seat.StartInput{Branch: "main", Module: "lib", Why: "again"}); err != nil {
t.Fatalf("%s: %v", how, err)
}
for _, a := range asks.asks[2:] {
if b, ok := a.(nodebuildgo.StepAsk); ok && b.Step != nil && !slices.Contains(group, b.Step.Module) {
group = append(group, b.Step.Module)
}
}
default:
u["main.app"] = `{"fingerprint":"src2:aa","revision":10,"pipeline":"` + key + `","outcome":"failed"}`
u["main.lib"] = `{"fingerprint":"src2:bb","revision":10,"pipeline":"` + key + `","outcome":"failed"}`
a, err := v.PlaceUnfinished("op@shanks", seat.PlaceUnfinishedInput{Key: "main.lib", Why: "again"})
if err != nil {
t.Fatalf("%s: %v", how, err)
}
for _, pl := range a.Placed {
group = append(group, pl.Key)
}
slices.Sort(group)
group = []string{strings.Join(group, ",")}
if group[0] == "main.app,main.lib" {
group = []string{"app", "lib"}
}
}
slices.Sort(group)
if !slices.Equal(group, []string{"app", "lib"}) {
t.Errorf("%s: the group reopened = %v, want app and lib (lib's head edge from app)", how, group)
}
}
}
@@ -647,7 +647,7 @@ func (v Verbs) askOf(p seat.Pipeline, s seat.StepResult, caller string, now time
if s.Seat == wants.Seat && s.Step == seat.StepResultStepValidate {
id = keptAskID(now, p.Pipeline, "", "", seat.StepResultStepValidate, rev)
}
a, err := v.placedAsk(p, s, id, now)
a, err := v.placedAsk(p, s, id, now, true)
if err != nil {
return nil, err
}
@@ -659,7 +659,7 @@ func (v Verbs) askOf(p seat.Pipeline, s seat.StepResult, caller string, now time
// rerun's is (a kept mover's kept revision mixed in), naming s's not-on.
func (v Verbs) DeclinedAsk(p seat.Pipeline, s seat.StepResult, now time.Time) (*Asked, error) {
id := keptAskID(now, p.Pipeline, s.Module, s.Artifact, s.Step+" not on "+strings.Join(s.NotOn, ","), v.keptOf(p.Pipeline)[s.Module])
a, err := v.placedAsk(p, s, id, now)
a, err := v.placedAsk(p, s, id, now, p.EndCount > 0)
if err != nil {
return nil, err
}
@@ -670,9 +670,9 @@ func (v Verbs) DeclinedAsk(p seat.Pipeline, s seat.StepResult, now time.Time) (*
return a, nil
}
// placedAsk is the ask of step s under id: a validate or composition step of the seat mesh-wants built directly for its
// placedAsk is the ask of step s under id (atHead: a rerun, or a mover of an ended pipeline, read at the head and refused where the head no longer holds its fingerprint, design 47 H2 H-A-763 (3), H-A-764; otherwise a kept mover reads its kept revision, H-A-286): a validate or composition step of the seat mesh-wants built directly for its
// mover (H-A-236), any other the one Place makes for it.
func (v Verbs) placedAsk(p seat.Pipeline, s seat.StepResult, id string, now time.Time) (*Asked, error) {
func (v Verbs) placedAsk(p seat.Pipeline, s seat.StepResult, id string, now time.Time, atHead bool) (*Asked, error) {
if v.Starter == nil || v.Starter.Registration == nil || v.Starter.Steps == nil || (v.View == nil && p.Run == "") {
return nil, errors.New("the runner cannot ask a step: it holds no registration or no ask")
}
@@ -711,12 +711,13 @@ func (v Verbs) placedAsk(p seat.Pipeline, s seat.StepResult, id string, now time
// A kept mover's step is placed under its kept ids (H-A-286), from the head's entry when that holds the mover at its
// fingerprint, so its build is asked with the newest pins (design 47 H2 H-A-763 (3)); else from the revision it is kept at.
entries, rev := half.Entries, v.keptOf(p.Pipeline)[m.Module]
if p.Run == "" && half.Entries[m.Module].Fp != m.Fingerprint {
atHead = atHead && p.Run == ""
if atHead && half.Entries[m.Module].Fp != m.Fingerprint {
// An older fingerprint is never built again after a newer one (design 47 H2 H-A-764 (2), as H-A-761).
return nil, fmt.Errorf("%s of %s is asked again at fingerprint %s, which the head's revision %d of %s no longer holds (it holds %q); its pipeline's revision is %d and its kept revision %d: nothing was asked",
s.Step, m.Module, m.Fingerprint, half.Revision, p.Branch, half.Entries[m.Module].Fp, p.Revision, rev)
}
if rev > 0 && p.Run != "" {
if rev > 0 && !atHead {
var err error
if entries, err = v.Starter.keptEntries(p.Branch, rev); err != nil {
return nil, fmt.Errorf("revision %d of %s, which %s is kept at, is not read (%v): the step is asked when it is", rev, p.Branch, m.Module, err)