A4b engine-need-in-verdict: the validate run writes a node-engine mover's unstated need into its kept verdict, for the mover's manifest
Builds: design 47 H2 H-A-682 (5)
This commit is contained in:
@@ -128,10 +128,12 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR
|
||||
if half.Revision.Base <= 0 {
|
||||
empty = emptyBeforeWords
|
||||
}
|
||||
problems := causedProblems(v.Change, v.Before)
|
||||
for _, p := range r.engineNeedProblems(half)[step.Module] { // H-A-682 (5): the node-engine's own build is refused, never held
|
||||
problems = append(problems, step.Module+": "+p)
|
||||
// H-A-682 (5): the node-engine's own build is refused, never held; the run adds the problem to its verdict, for the mover's
|
||||
// manifest, so the run kept in composition-runs holds it and every step reads it as it reads the validator's.
|
||||
if needs := r.engineNeedProblems(half)[step.Module]; len(needs) > 0 {
|
||||
v = r.keepEngineNeeds(step, v, needs)
|
||||
}
|
||||
problems := causedProblems(v.Change, v.Before)
|
||||
if len(problems) > 0 {
|
||||
said := reasonManifestRefused + ": " + strings.Join(problems, "; ")
|
||||
if empty != "" {
|
||||
@@ -142,6 +144,53 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR
|
||||
return stepOutcome{Outcome: meshwants.StepEndedOutcomePassed, Said: empty}
|
||||
}
|
||||
|
||||
// keepEngineNeeds adds needs, the problems of step's module, to the verdict the validate run of its revision keeps, as the refusal of
|
||||
// that module's manifest in the change case (none the verdict holds already), and answers the verdict as it is then; where the run
|
||||
// cannot be written, the verdict it was read as with them added, said in the journal.
|
||||
func (r *compositionRun) keepEngineNeeds(step meshwants.StepRun, read validateVerdict, needs []string) validateVerdict {
|
||||
add := func(v *validateVerdict) bool {
|
||||
m := v.Change.Manifests[step.Module]
|
||||
held := strings.Split(m.Refused, "\n")
|
||||
changed := false
|
||||
for _, p := range needs {
|
||||
if !slices.Contains(held, p) {
|
||||
held, changed = append(held, p), true
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
return false
|
||||
}
|
||||
m.Accepted, m.Refused = false, strings.Join(slices.DeleteFunc(held, func(p string) bool { return p == "" }), "\n")
|
||||
if v.Change.Manifests == nil {
|
||||
v.Change.Manifests = map[string]composer.ManifestRead{}
|
||||
}
|
||||
v.Change.Manifests[step.Module] = m
|
||||
return true
|
||||
}
|
||||
if !add(&read) {
|
||||
return read
|
||||
}
|
||||
key, err := validateKeyOf(step)
|
||||
if err == nil {
|
||||
_, _, err = r.runs.change(key, func(c *meshwants.CompositionRun) bool {
|
||||
var v validateVerdict
|
||||
if raw, e := json.Marshal(c.Verdict); e != nil || json.Unmarshal(raw, &v) != nil || !add(&v) {
|
||||
return false
|
||||
}
|
||||
verdict, e := v.asVerdict()
|
||||
if e != nil {
|
||||
return false
|
||||
}
|
||||
c.Verdict = verdict
|
||||
return true
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
r.logf("the validate run's verdict is not written with the problems of %s: %v", step.Module, err)
|
||||
}
|
||||
return read
|
||||
}
|
||||
|
||||
// engineNeedProblems are, by module, the problems of the revision's entries that claim the seat node-engine and need a reader capability
|
||||
// that no node's words in the state engine-reads hold: such an engine would be held on every machine and none could state it, so its
|
||||
// validate run refuses it (design 47 H2 H-A-682 (5)), counted as a new problem. None while no node's words are held.
|
||||
@@ -697,6 +746,9 @@ func validateAnswerOf(run meshwants.CompositionRun, module string, engine map[st
|
||||
continue
|
||||
}
|
||||
for _, p := range engine[name] {
|
||||
if slices.ContainsFunc(out.Problems, func(q meshwants.ValidateAnswerProblemsItem) bool { return q.Module == name && q.Problem == p }) {
|
||||
continue // the run's verdict holds it already
|
||||
}
|
||||
out.Problems = append(out.Problems, meshwants.ValidateAnswerProblemsItem{Module: name, Problem: p})
|
||||
counted = true
|
||||
}
|
||||
|
||||
@@ -315,6 +315,15 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
!strings.Contains(o.Said, "engine: needs directory-contents-owner, which no node-engine states") {
|
||||
t.Errorf("a node-engine needing what no node states ended %+v", o)
|
||||
}
|
||||
// The run kept in composition-runs holds the problem in its verdict, for the mover's manifest (H-A-682 (5)).
|
||||
if k, _ := validateKeyOf(engineStep(15)); true {
|
||||
kept, _, _, _ := r.runs.read(k)
|
||||
var v validateVerdict
|
||||
raw, _ := json.Marshal(kept.Verdict)
|
||||
if json.Unmarshal(raw, &v) != nil || v.Change.Manifests["engine"].Accepted || !strings.Contains(v.Change.Manifests["engine"].Refused, "needs directory-contents-owner, which no node-engine states") {
|
||||
t.Errorf("the kept validate run's verdict is %+v, want the engine's manifest refused for its need", kept.Verdict)
|
||||
}
|
||||
}
|
||||
r.engineReads = &engineReadsKept{by: map[string]engineWords{"ace": {Words: []string{"want:version"}}, "g14": {Words: []string{"directory-contents-owner"}}}}
|
||||
if o := r.validate(ctx, "ask-engine-2", engineStep(16)); strings.Contains(o.Said, "which no node-engine states") {
|
||||
t.Errorf("a node-engine needing what g14 states ended %+v", o)
|
||||
|
||||
Reference in New Issue
Block a user