P6 widens-at-the-base: a pipeline's widens is its revision against the revision's own base, and a carried mover says its first pipeline's
Builds: design 47 H2 H-A-582, H-A-595
This commit is contained in:
@@ -192,5 +192,5 @@ func (v catalogView) View() (pipeline.Half, bool) {
|
||||
if !ok {
|
||||
return pipeline.Half{}, false
|
||||
}
|
||||
return pipeline.Half{Revision: h.Revision.Revision, Source: h.Revision.Source, Entries: h.Entries}, true
|
||||
return pipeline.Half{Revision: h.Revision.Revision, Source: h.Revision.Source, Base: h.Revision.Base, Entries: h.Entries}, true
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ func catalogRevision(call func(string, any) (json.RawMessage, error), kept *revi
|
||||
if h, ok := kept.get(branch, a.Revision.Revision); ok {
|
||||
return h, nil
|
||||
}
|
||||
half = pipeline.Half{Revision: a.Revision.Revision, Source: a.Revision.Source, Entries: map[string]catalog.CatalogEntry{},
|
||||
half = pipeline.Half{Revision: a.Revision.Revision, Source: a.Revision.Source, Base: a.Revision.Base, Entries: map[string]catalog.CatalogEntry{},
|
||||
Call: a.Revision.Call, Movers: a.Revision.Movers}
|
||||
in.Revision = a.Revision.Revision // the pages of one revision, though a newer one is said between them
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
|
||||
store.refused["main.118"], store.refused["main.119"] = true, true
|
||||
grants, revisions := 0, 0
|
||||
w := &Widener{
|
||||
Revision: func(string, int64) (Half, error) { revisions++; return Half{}, nil },
|
||||
Revision: func(string, int64) (Half, error) { revisions++; return Half{Base: 4}, nil },
|
||||
Holder: func(s string) (string, error) { return s, nil },
|
||||
GrantsFor: func(string, int64) (meshgrants.GrantsFor, error) {
|
||||
grants++
|
||||
|
||||
@@ -98,7 +98,9 @@ type readyView interface{ Ready() <-chan struct{} }
|
||||
type Half struct {
|
||||
Revision int64
|
||||
Source int64
|
||||
Entries map[string]catalog.CatalogEntry
|
||||
// Base is the revision's base, the newest kept revision of its branch below it (H-A-151); 0 on the branch's first take-in.
|
||||
Base int64
|
||||
Entries map[string]catalog.CatalogEntry
|
||||
// Call and Movers are the revision's own, as the revision verb answers them (H-A-213): what made it and its movers;
|
||||
// a view's half names none.
|
||||
Call string
|
||||
|
||||
@@ -1085,7 +1085,10 @@ func (h *Hearer) endPipeline(p *seat.Pipeline, now time.Time, wr func(seat.Pipel
|
||||
}
|
||||
if wr != nil {
|
||||
for i := range p.Movers {
|
||||
p.Movers[i].Widens = wr(*p, p.Movers[i].Module)
|
||||
// A carried or reopened mover says the widens its first pipeline computed and never computes it again (H-A-595).
|
||||
if len(p.Movers[i].Widens) == 0 {
|
||||
p.Movers[i].Widens = wr(*p, p.Movers[i].Module)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -105,9 +105,13 @@ func (r *endReads) widens(p seat.Pipeline, module string) []seat.Widening {
|
||||
if err != nil {
|
||||
return could("mesh-catalog", fmt.Sprintf("the candidate's revision %d is not read: %v", p.Revision, err))
|
||||
}
|
||||
newest, err := r.revision(p.Branch, 0)
|
||||
if err != nil {
|
||||
return could("mesh-catalog", fmt.Sprintf("the branch's newest revision is not read: %v", err))
|
||||
// A change is what its movers alter against the revision's own base, never against a branch's newest (design 47 H2 H-A-582);
|
||||
// the branch's first take-in has no base and alters nothing against it.
|
||||
newest := cand
|
||||
if cand.Base > 0 {
|
||||
if newest, err = r.revision(p.Branch, cand.Base); err != nil {
|
||||
return could("mesh-catalog", fmt.Sprintf("the base revision %d of revision %d is not read: %v", cand.Base, p.Revision, err))
|
||||
}
|
||||
}
|
||||
var out []seat.Widening
|
||||
for _, s := range servingSeats(p) {
|
||||
|
||||
@@ -27,7 +27,7 @@ func halfOf(rev int64, es ...catalog.CatalogEntry) Half {
|
||||
// (the runner, the catalog, each step's seat, the node-engine) by fingerprint, an acting rule gained or matching more, a
|
||||
// credential named that was not, and the grants the grants part adds; each is said by name, a grants part that does not answer says
|
||||
// `could not run` and nothing is refused (design 47 G §71, §275, §441, A-207, A-215, A-220).
|
||||
func TestWidensIsTheCandidateAgainstTheNewest(t *testing.T) {
|
||||
func TestWidensIsTheCandidateAgainstItsBase(t *testing.T) {
|
||||
p := seat.Pipeline{Pipeline: "main.8.app", Branch: "main", Source: 31, Revision: 8,
|
||||
Steps: []seat.StepResult{{Module: "app", Step: "unit", Seat: "node-build-go"}, {Module: "app", Step: "lint", Seat: "node-build-go"}, {Module: "app", Step: "approval"}}, Movers: []seat.Mover{{Module: "app"}}}
|
||||
holders := map[string]string{seat.Seat: "runner", catalog.Seat: "indexer", "node-build-go": "build-go", "node-engine": "host"}
|
||||
@@ -65,13 +65,16 @@ func TestWidensIsTheCandidateAgainstTheNewest(t *testing.T) {
|
||||
for _, c := range cases {
|
||||
w := &Widener{
|
||||
Revision: func(_ string, rev int64) (Half, error) {
|
||||
if rev == 0 {
|
||||
// The base of revision 8 is revision 9 here (design 47 H2 H-A-582): never the branch's newest, revision 0.
|
||||
if rev == 9 {
|
||||
return newest, nil
|
||||
}
|
||||
if rev != 8 {
|
||||
t.Errorf("%s: the candidate asked as revision %d", c.name, rev)
|
||||
t.Errorf("%s: revision %d asked, want the candidate 8 or its base 9", c.name, rev)
|
||||
}
|
||||
return c.cand, nil
|
||||
cand := c.cand
|
||||
cand.Base = 9
|
||||
return cand, nil
|
||||
},
|
||||
Holder: func(s string) (string, error) { return holders[s], nil },
|
||||
GrantsFor: func(string, int64) (meshgrants.GrantsFor, error) { return c.grants, c.grantsErr },
|
||||
@@ -98,6 +101,12 @@ func TestAnEndKeepsEachMoversWidens(t *testing.T) {
|
||||
if !h.endPipeline(&p, time.Unix(1, 0), h.widensReads()) || len(p.Movers[0].Widens) != 1 || p.Movers[0].Widens[0].Name != "app s v" || p.Movers[1].Widens[0].Name != "lib s v" {
|
||||
t.Errorf("the ended movers = %+v", p.Movers)
|
||||
}
|
||||
// design 47 H2 H-A-595 (AC-P6b): a carried mover says its first pipeline's widens, never computed again.
|
||||
c := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app", Widens: []seat.Widening{{What: seat.WideningWhatGrant, Name: "first"}}}},
|
||||
Steps: []seat.StepResult{{Module: "app", Step: "build", Outcome: "passed"}}}
|
||||
if !h.endPipeline(&c, time.Unix(1, 0), h.widensReads()) || len(c.Movers[0].Widens) != 1 || c.Movers[0].Widens[0].Name != "first" {
|
||||
t.Errorf("a carried mover's widens = %+v, want its first pipeline's", c.Movers[0].Widens)
|
||||
}
|
||||
h.Widens = nil
|
||||
q := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app"}}, Steps: []seat.StepResult{{Module: "app", Step: "build", Outcome: "passed"}}}
|
||||
if !h.endPipeline(&q, time.Unix(1, 0), h.widensReads()) || len(q.Movers[0].Widens) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user