A4 engine-need-refused: a mover claiming the seat node-engine whose entry needs a capability no node's words hold is refused manifest-refused, counted as new
Builds: design 47 H2 H-A-682 (5)
This commit is contained in:
@@ -64,6 +64,9 @@ type compositionRun struct {
|
||||
readsBound time.Duration
|
||||
// holder is the module holding a seat and the machines it runs on, for the words of a read that met a fault; nil: none named.
|
||||
holder func(seat string) (module string, nodes []string)
|
||||
// engineReads is what each node's engine states it reads (the state engine-reads), for the validate run's refusal of a node-engine
|
||||
// that needs what none states (design 47 H2 H-A-682 (5)); nil: none is judged.
|
||||
engineReads *engineReadsKept
|
||||
// readMu guards inflight, the reads now waiting by seat verb, and raised, the seat verbs whose finding call-unanswered this
|
||||
// process wrote (H-A-708 (4)).
|
||||
readMu sync.Mutex
|
||||
|
||||
@@ -694,7 +694,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKeptAsk, callFile: bus.CallFileKept, readsBound: readsBound, holder: holderOf(bus, w),
|
||||
run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKeptAsk, callFile: bus.CallFileKept, readsBound: readsBound, holder: holderOf(bus, w), engineReads: reads,
|
||||
trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, findings: findings, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), own: ctx, ask: bus.CallFile, now: time.Now, logf: logger.Printf}
|
||||
// The seat's work queue (design 47 H2 §777): pulled through its one worker, each ask taken once in the state taken.
|
||||
takenBound, err := askTakenBound()
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
@@ -127,7 +128,11 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR
|
||||
if half.Revision.Base <= 0 {
|
||||
empty = emptyBeforeWords
|
||||
}
|
||||
if problems := causedProblems(v.Change, v.Before); len(problems) > 0 {
|
||||
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)
|
||||
}
|
||||
if len(problems) > 0 {
|
||||
said := reasonManifestRefused + ": " + strings.Join(problems, "; ")
|
||||
if empty != "" {
|
||||
said += " (" + empty + ")"
|
||||
@@ -137,6 +142,58 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR
|
||||
return stepOutcome{Outcome: meshwants.StepEndedOutcomePassed, Said: empty}
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (r *compositionRun) engineNeedProblems(half mcc.Half) map[string][]string {
|
||||
if r.engineReads == nil {
|
||||
return nil
|
||||
}
|
||||
var stated []string
|
||||
nodes := r.engineReads.nodes()
|
||||
for _, node := range nodes {
|
||||
words, _ := r.engineReads.words(node)
|
||||
stated = append(stated, words...)
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := map[string][]string{}
|
||||
for module, e := range half.Entries {
|
||||
if !claimsSeat(e.Manifest, ne.Seat) {
|
||||
continue
|
||||
}
|
||||
for _, need := range e.Needs {
|
||||
if !slices.Contains(stated, need) {
|
||||
out[module] = append(out[module], "needs "+need+", which no node-engine states")
|
||||
}
|
||||
}
|
||||
slices.Sort(out[module])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// claimsSeat says whether a manifest, as the catalog entry keeps it, claims the seat.
|
||||
func claimsSeat(manifest map[string]any, seat string) bool {
|
||||
raw, err := json.Marshal(manifest)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
var m struct {
|
||||
Claims []struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"claims"`
|
||||
}
|
||||
if json.Unmarshal(raw, &m) != nil {
|
||||
return false
|
||||
}
|
||||
return slices.ContainsFunc(m.Claims, func(c struct {
|
||||
Name string `json:"name"`
|
||||
}) bool {
|
||||
return c.Name == seat
|
||||
})
|
||||
}
|
||||
|
||||
// emptyBeforeWords say, in a validate step's end, that its revision names no base: the branch's first take-in, judged against
|
||||
// an empty case before (H-A-151, H-A-154).
|
||||
const emptyBeforeWords = "the case before is empty: the revision names no base, the branch's first take-in"
|
||||
@@ -559,7 +616,8 @@ func (r *compositionRun) validateOnRequest(ctx context.Context, record func(mesh
|
||||
if in.Candidate != "" && in.Candidate != candidate {
|
||||
return couldNot(fmt.Sprintf("the candidate %s is not the pipeline %s's, %s", in.Candidate, pipeline, candidate))
|
||||
}
|
||||
if _, err := r.revision(withReadsClock(ctx), step); err != nil {
|
||||
half, err := r.revision(withReadsClock(ctx), step)
|
||||
if err != nil {
|
||||
return couldNot(fmt.Sprintf("the indexer holds no candidate %s of the pipeline %s: %v", candidate, pipeline, err))
|
||||
}
|
||||
key, err := validateKeyOf(step)
|
||||
@@ -589,13 +647,13 @@ func (r *compositionRun) validateOnRequest(ctx context.Context, record func(mesh
|
||||
}
|
||||
}
|
||||
run.Key = key
|
||||
return validateAnswerOf(run, step.Module)
|
||||
return validateAnswerOf(run, step.Module, r.engineNeedProblems(half))
|
||||
}
|
||||
|
||||
// validateAnswerOf is the validate run as it stands: running with its start, or its end: passed, failed `cycle` naming the
|
||||
// cycle, failed `manifest-refused` with every problem per manifest (those the case before holds too marked), or could not run with
|
||||
// why; the problems narrowed to module when one is named (H-A-684 (1)).
|
||||
func validateAnswerOf(run meshwants.CompositionRun, module string) (meshwants.ValidateAnswer, error) {
|
||||
func validateAnswerOf(run meshwants.CompositionRun, module string, engine map[string][]string) (meshwants.ValidateAnswer, error) {
|
||||
out := meshwants.ValidateAnswer{Run: &run}
|
||||
if run.Ended == nil {
|
||||
out.Outcome, out.Started = meshwants.ValidateAnswerOutcomeRunning, run.Started
|
||||
@@ -634,6 +692,15 @@ func validateAnswerOf(run meshwants.CompositionRun, module string) (meshwants.Va
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, name := range slices.Sorted(maps.Keys(engine)) { // H-A-682 (5): a node-engine's needs no node-engine states
|
||||
if module != "" && name != module {
|
||||
continue
|
||||
}
|
||||
for _, p := range engine[name] {
|
||||
out.Problems = append(out.Problems, meshwants.ValidateAnswerProblemsItem{Module: name, Problem: p})
|
||||
counted = true
|
||||
}
|
||||
}
|
||||
out.Outcome = meshwants.ValidateAnswerOutcomePassed
|
||||
if counted {
|
||||
out.Outcome, out.Reason = meshwants.ValidateAnswerOutcomeFailed, meshwants.ValidateAnswerReasonManifestRefused
|
||||
|
||||
@@ -302,6 +302,29 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
t.Errorf("the validate run's reader was said waiting %v; want mesh-sdk's publish, then a build node again at the put (H-A-632)", held)
|
||||
}
|
||||
|
||||
// H2 H-A-682 (5) (A4): a mover claiming the seat node-engine whose entry needs a capability no node's words hold ends
|
||||
// manifest-refused naming it, counted as new; one that a node states is not refused for it; the verb's answer lists it.
|
||||
engine := meshcatalog.CatalogEntry{Module: "engine", Fp: "src2:eng", Needs: []string{"directory-contents-owner"}, ManifestDigest: "d-eng",
|
||||
Manifest: map[string]any{"module": "engine", "claims": []any{map[string]any{"name": "node-engine"}}}}
|
||||
revisions[15], revisions[16] = []meshcatalog.CatalogEntry{indexer, engine}, []meshcatalog.CatalogEntry{indexer, engine}
|
||||
engineStep := func(revision int64) meshwants.StepRun {
|
||||
return meshwants.StepRun{Step: meshwants.StepRunStepValidate, Pipeline: "main." + string(rune('0'+revision)), Branch: "main", Module: "engine", Revision: revision, Source: revision}
|
||||
}
|
||||
r.engineReads = &engineReadsKept{by: map[string]engineWords{"ace": {Words: []string{"want:version"}}}}
|
||||
if o := r.validate(ctx, "ask-engine", engineStep(15)); o.Outcome != meshwants.StepEndedOutcomeFailed || !strings.HasPrefix(o.Said, reasonManifestRefused+": ") ||
|
||||
!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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
ended := time.Now()
|
||||
passed := meshwants.CompositionRun{Started: &ended, Ended: &ended, Outcome: meshwants.CompositionRunOutcomePassed, Verdict: map[string]any{}}
|
||||
if a, _ := validateAnswerOf(passed, "", map[string][]string{"engine": {"needs directory-contents-owner, which no node-engine states"}}); a.Outcome != meshwants.ValidateAnswerOutcomeFailed ||
|
||||
len(a.Problems) != 1 || a.Problems[0].Before || a.Problems[0].Module != "engine" {
|
||||
t.Errorf("the verb's answer for a node-engine needing what none states is %+v", a)
|
||||
}
|
||||
// H2 H-A-684, H-A-702, H-A-727, H-A-739 (A5): the verb validate, which the tool assigner_validate calls, joins or starts the run.
|
||||
var acts []meshhandactsclient.Request
|
||||
record := func(q meshhandactsclient.Request) error { acts = append(acts, q); return nil }
|
||||
|
||||
Reference in New Issue
Block a user