Assigner: a put's want names the version released at its build (H-A-490 addendum)
A put wrote its want by fingerprint alone, which the node-engine cannot compose. The put now finds the version released at its build's parts, as the pass does, names it in the want, and is refused when none is released. Builds: design 47 H2 H-A-490 (addendum)
This commit is contained in:
@@ -409,7 +409,12 @@ func putOfTheBus(t *testing.T) {
|
|||||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: mdigest, Repository: "novox/mesh-catalog", Commit: strings.Repeat("c", 40)})
|
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: mdigest, Repository: "novox/mesh-catalog", Commit: strings.Repeat("c", 40)})
|
||||||
putModuleRaw(p.w, trunkBranch, "nats", mod)
|
putModuleRaw(p.w, trunkBranch, "nats", mod)
|
||||||
p.w.manifests[mdigest] = parsed{module: "nats", manifest: catalogue.Manifest{Module: "nats", Provides: []catalogue.Offer{{Name: "mesh-bus"}}}}
|
p.w.manifests[mdigest] = parsed{module: "nats", manifest: catalogue.Manifest{Module: "nats", Provides: []catalogue.Offer{{Name: "mesh-bus"}}}}
|
||||||
endDone(t, p.w, "nats", fp, mdigest)
|
// The build and its release (H-A-490 addendum): the put's want names the version released at its parts.
|
||||||
|
built, _ := json.Marshal(builds.BuildEnded{Module: "nats", Fingerprint: fp, Outcome: builds.BuildDone, Manifest: mdigest, Made: map[string]string{"program": "sha256:5"}})
|
||||||
|
rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "nats", Source: 8, Version: "2.10.1", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "nats:program", Digest: "sha256:5"}}})
|
||||||
|
if p.w.ends.put(built) != nil || p.w.released.put(rel) != nil {
|
||||||
|
t.Fatal("the build or its release is not heard")
|
||||||
|
}
|
||||||
hkey, _ := nodeengineclient.HaveKey("novox", "nats")
|
hkey, _ := nodeengineclient.HaveKey("novox", "nats")
|
||||||
before, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
before, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
||||||
world(buckets.Have, hkey, before)
|
world(buckets.Have, hkey, before)
|
||||||
@@ -489,7 +494,7 @@ func putOfTheBus(t *testing.T) {
|
|||||||
<-woke
|
<-woke
|
||||||
got = step()
|
got = step()
|
||||||
w, err := mwc.DecodeWant(wantsKV.values["want.novox.nats"])
|
w, err := mwc.DecodeWant(wantsKV.values["want.novox.nats"])
|
||||||
if got.Step != puts.Wanted || err != nil || w.Fp != fp || !w.Put || !w.Hold {
|
if got.Step != puts.Wanted || err != nil || w.Fp != fp || w.Version != "2.10.1" || !w.Put || !w.Hold {
|
||||||
t.Fatalf("snapshotted, the put stands at %s (%s); the want %+v, %v", got.Step, got.Words, w, err)
|
t.Fatalf("snapshotted, the put stands at %s (%s); the want %+v, %v", got.Step, got.Words, w, err)
|
||||||
}
|
}
|
||||||
if call := <-bus.calls; !strings.HasPrefix(call, "seat:mesh-hand-acts.warranted ") || !strings.Contains(call, a.Ask.ID) { // ADR 0565 §11: into the seat
|
if call := <-bus.calls; !strings.HasPrefix(call, "seat:mesh-hand-acts.warranted ") || !strings.Contains(call, a.Ask.ID) { // ADR 0565 §11: into the seat
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ func (p *passer) putWorld(node, module string, put puts.Put, manifest catalogue.
|
|||||||
if e, ok := p.w.ends.endOf(module, put.FP); ok { // the build's end heard (A-181): none heard, no state
|
if e, ok := p.w.ends.endOf(module, put.FP); ok { // the build's end heard (A-181): none heard, no state
|
||||||
w.Build, w.BuildWords = e.Outcome, e.Error
|
w.Build, w.BuildWords = e.Outcome, e.Error
|
||||||
}
|
}
|
||||||
|
w.Version, _ = p.w.releasedOf(module, put.FP) // matched by its build's parts, as the pass matches a mover's (H-A-490 addendum)
|
||||||
w.Composed, w.Granted = p.composedFor(node, module, put.FP)
|
w.Composed, w.Granted = p.composedFor(node, module, put.FP)
|
||||||
if d := w.Composed; d != nil {
|
if d := w.Composed; d != nil {
|
||||||
policy := d.Policy
|
policy := d.Policy
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ type PutWorld struct {
|
|||||||
Build, BuildWords string
|
Build, BuildWords string
|
||||||
// Newest is the module's newest fingerprint at the trunk, which the builder builds by itself.
|
// Newest is the module's newest fingerprint at the trunk, which the builder builds by itself.
|
||||||
Newest string
|
Newest string
|
||||||
|
// Version is the version released at the put's fingerprint, matched by its build's parts as the pass matches a mover's;
|
||||||
|
// "" when none is released (design 47 H2 H-A-490 addendum).
|
||||||
|
Version string
|
||||||
// Composed is the composition of the module for the node at the fingerprint, as its writer holds it; nil when there is
|
// Composed is the composition of the module for the node at the fingerprint, as its writer holds it; nil when there is
|
||||||
// none. Granted says the grant at the fingerprint names the node's accounts. Both are read, never asked for (clause 4).
|
// none. Granted says the grant at the fingerprint names the node's accounts. Both are read, never asked for (clause 4).
|
||||||
Composed *ComposedDigest
|
Composed *ComposedDigest
|
||||||
@@ -87,7 +90,10 @@ func StepPut(w PutWorld) PutNext {
|
|||||||
if h := w.Have; h == nil || h.Fp != p.FP || h.Composed == "" {
|
if h := w.Have; h == nil || h.Fp != p.FP || h.Composed == "" {
|
||||||
return say(puts.Refused, "%s runs %s at %s, and its have names no composition at that fingerprint, so the want cannot name what runs", w.Node, w.Module, fp)
|
return say(puts.Refused, "%s runs %s at %s, and its have names no composition at that fingerprint, so the want cannot name what runs", w.Node, w.Module, fp)
|
||||||
}
|
}
|
||||||
p.Composed = w.Have.Composed
|
if w.Version == "" {
|
||||||
|
return say(puts.Refused, "no version released at %s: build or release it first", fp)
|
||||||
|
}
|
||||||
|
p.Composed, p.Version = w.Have.Composed, w.Version
|
||||||
words := fmt.Sprintf("the want of %s on %s names %s, the build it runs now (composition %s), from its running statement; the builder's store is not asked",
|
words := fmt.Sprintf("the want of %s on %s names %s, the build it runs now (composition %s), from its running statement; the builder's store is not asked",
|
||||||
w.Module, w.Node, fp, short(p.Composed))
|
w.Module, w.Node, fp, short(p.Composed))
|
||||||
if p.Hold {
|
if p.Hold {
|
||||||
@@ -115,6 +121,14 @@ func StepPut(w PutWorld) PutNext {
|
|||||||
default:
|
default:
|
||||||
return say(puts.Build, "waits for the builder's build of %s at %s, which is %s", w.Module, fp, w.Build)
|
return say(puts.Build, "waits for the builder's build of %s at %s, which is %s", w.Module, fp, w.Build)
|
||||||
}
|
}
|
||||||
|
if p.Step != puts.Wanted && p.Step != puts.Holding {
|
||||||
|
// The want names the build's released version beside its fingerprint, which the node-engine composes from (H-A-490
|
||||||
|
// addendum): a build with none released is refused, never wanted by its fingerprint alone.
|
||||||
|
if w.Version == "" {
|
||||||
|
return say(puts.Refused, "no version released at %s: build or release it first", fp)
|
||||||
|
}
|
||||||
|
p.Version = w.Version
|
||||||
|
}
|
||||||
if w.Composed == nil || !w.Granted {
|
if w.Composed == nil || !w.Granted {
|
||||||
missing := fmt.Sprintf("no composition of %s for %s at %s is written", w.Module, w.Node, fp)
|
missing := fmt.Sprintf("no composition of %s for %s at %s is written", w.Module, w.Node, fp)
|
||||||
if w.Composed != nil {
|
if w.Composed != nil {
|
||||||
@@ -212,9 +226,10 @@ func needsPerson(w PutWorld, d ComposedDigest) bool {
|
|||||||
return d.Judgement == JudgedRecreates || d.Judgement == JudgedMovesData || d.Judgement == JudgedCannot
|
return d.Judgement == JudgedRecreates || d.Judgement == JudgedMovesData || d.Judgement == JudgedCannot
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutWant is the want a put writes once it is wanted: the fingerprint, marked put, and held when it holds.
|
// PutWant is the want a put writes once it is wanted: the fingerprint and the version released at it, marked put, and held when
|
||||||
|
// it holds.
|
||||||
func PutWant(p puts.Put) mwc.Want {
|
func PutWant(p puts.Put) mwc.Want {
|
||||||
return mwc.Want{Fp: p.FP, Put: true, Hold: p.Hold, Words: "put: " + p.Why}
|
return mwc.Want{Fp: p.FP, Version: p.Version, Put: true, Hold: p.Hold, Words: "put: " + p.Why}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutOwns says what a put does to the node's want: owns says the rules pass over it, want the want it writes (nil: what
|
// PutOwns says what a put does to the node's want: owns says the rules pass over it, want the want it writes (nil: what
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome {
|
|||||||
if !put && had && before.Put && before.Hold {
|
if !put && had && before.Put && before.Hold {
|
||||||
// The want is the truth (ADR 0546 clause 5): a want marked put and held stands while its put is not heard; only a put
|
// The want is the truth (ADR 0546 clause 5): a want marked put and held stands while its put is not heard; only a put
|
||||||
// heard released gives it back to the rule.
|
// heard released gives it back to the rule.
|
||||||
p, put = puts.Put{FP: before.Fp, Hold: true, Why: strings.TrimPrefix(before.Words, "put: "), Step: puts.Holding}, true
|
p, put = puts.Put{FP: before.Fp, Version: before.Version, Hold: true, Why: strings.TrimPrefix(before.Words, "put: "), Step: puts.Holding}, true
|
||||||
}
|
}
|
||||||
if put {
|
if put {
|
||||||
if want, owns := PutOwns(p); owns {
|
if want, owns := PutOwns(p); owns {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ func TestAWantNamesTheNewestPassedVersion(t *testing.T) {
|
|||||||
// want stands, marked put and held, and once released the rule writes the passed version again.
|
// want stands, marked put and held, and once released the rule writes the passed version again.
|
||||||
func TestAPutOwnsItsNodesWant(t *testing.T) {
|
func TestAPutOwnsItsNodesWant(t *testing.T) {
|
||||||
m := released()
|
m := released()
|
||||||
put := puts.Put{FP: fNew, Hold: true, Why: "the bus's user list", Composed: dig(fNew)}
|
put := puts.Put{FP: fNew, Version: "1.2.3", Hold: true, Why: "the bus's user list", Composed: dig(fNew)}
|
||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
name string
|
name string
|
||||||
step string
|
step string
|
||||||
@@ -100,7 +100,7 @@ func TestAPutOwnsItsNodesWant(t *testing.T) {
|
|||||||
want *mwc.Want // nil: nothing written on ace
|
want *mwc.Want // nil: nothing written on ace
|
||||||
}{
|
}{
|
||||||
{"waiting for the operator", puts.Person, wantedOld(), nil},
|
{"waiting for the operator", puts.Person, wantedOld(), nil},
|
||||||
{"wanted", puts.Wanted, wantedOld(), &mwc.Want{Fp: fNew, Put: true, Hold: true, Words: "put: the bus's user list"}},
|
{"wanted", puts.Wanted, wantedOld(), &mwc.Want{Fp: fNew, Version: "1.2.3", Put: true, Hold: true, Words: "put: the bus's user list"}},
|
||||||
{"holding, written already", puts.Holding, map[string]mwc.Want{"ace": PutWant(put)}, nil},
|
{"holding, written already", puts.Holding, map[string]mwc.Want{"ace": PutWant(put)}, nil},
|
||||||
{"released: the rule again", puts.Released, map[string]mwc.Want{"ace": PutWant(put)}, &mwc.Want{Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2}},
|
{"released: the rule again", puts.Released, map[string]mwc.Want{"ace": PutWant(put)}, &mwc.Want{Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2}},
|
||||||
{"not heard: a held want at an older fingerprint stands", "", map[string]mwc.Want{"ace": {Fp: fOld, Put: true, Hold: true, Words: "put: back"}}, nil},
|
{"not heard: a held want at an older fingerprint stands", "", map[string]mwc.Want{"ace": {Fp: fOld, Put: true, Hold: true, Words: "put: back"}}, nil},
|
||||||
@@ -144,7 +144,7 @@ func stepsOfAPut(t *testing.T) {
|
|||||||
running := nodeengine.HaveByNodeModuleValue{Fp: fOld, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}
|
running := nodeengine.HaveByNodeModuleValue{Fp: fOld, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}
|
||||||
bus := func() PutWorld {
|
bus := func() PutWorld {
|
||||||
return PutWorld{Node: "novox", Module: "nats", Put: base, Assigned: true, Bus: true, Build: builds.BuildDone, Newest: fNew,
|
return PutWorld{Node: "novox", Module: "nats", Put: base, Assigned: true, Bus: true, Build: builds.BuildDone, Newest: fNew,
|
||||||
Composed: &d, Granted: true, Have: &running, Now: now}
|
Version: "1.2.3", Composed: &d, Granted: true, Have: &running, Now: now}
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -172,6 +172,16 @@ func stepsOfAPut(t *testing.T) {
|
|||||||
w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew}
|
w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew}
|
||||||
return w
|
return w
|
||||||
}, puts.Refused, "names no composition", false, false, false},
|
}, puts.Refused, "names no composition", false, false, false},
|
||||||
|
// H-A-490 (addendum): a want names the build's released version, so a done build with none released is refused, and so
|
||||||
|
// is the build the node runs now when no release names its parts.
|
||||||
|
{"a done build with no released version: refused", func() PutWorld { w := bus(); w.Version = ""; return w }, puts.Refused, "no version released at", false, false, false},
|
||||||
|
{"the build the node runs now, no version released: refused", func() PutWorld {
|
||||||
|
w := bus()
|
||||||
|
w.Build, w.Newest, w.Version = "", fpOf('c'), ""
|
||||||
|
w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew}
|
||||||
|
w.Have = &nodeengine.HaveByNodeModuleValue{Fp: fNew, Composed: dig(fNew), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}
|
||||||
|
return w
|
||||||
|
}, puts.Refused, "build or release it first", false, false, false},
|
||||||
{"a failed build", func() PutWorld { w := bus(); w.Build, w.BuildWords = builds.BuildFailed, "go vet"; return w }, puts.Refused, "go vet", false, false, false},
|
{"a failed build", func() PutWorld { w := bus(); w.Build, w.BuildWords = builds.BuildFailed, "go vet"; return w }, puts.Refused, "go vet", false, false, false},
|
||||||
{"no composition yet: waits", func() PutWorld { w := bus(); w.Composed = nil; return w }, puts.Compose, "no composition of nats for novox", false, false, false},
|
{"no composition yet: waits", func() PutWorld { w := bus(); w.Composed = nil; return w }, puts.Compose, "no composition of nats for novox", false, false, false},
|
||||||
{"composed, grant not naming the node", func() PutWorld { w := bus(); w.Granted = false; return w }, puts.Compose, "does not name novox", false, false, false},
|
{"composed, grant not naming the node", func() PutWorld { w := bus(); w.Granted = false; return w }, puts.Compose, "does not name novox", false, false, false},
|
||||||
@@ -256,6 +266,9 @@ func stepsOfAPut(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
next := StepPut(c.world())
|
next := StepPut(c.world())
|
||||||
|
if (next.Put.Step == puts.Wanted || next.Put.Step == puts.Holding) && c.world().Put.Step == puts.Asked && next.Put.Version != "1.2.3" {
|
||||||
|
t.Errorf("put, %s: its want names version %q, want the build's released 1.2.3", c.name, next.Put.Version)
|
||||||
|
}
|
||||||
if next.Put.Step != c.step || !strings.Contains(next.Put.Words, c.says) {
|
if next.Put.Step != c.step || !strings.Contains(next.Put.Words, c.says) {
|
||||||
t.Errorf("put, %s: at %s, %q; want %s saying %q", c.name, next.Put.Step, next.Put.Words, c.step, c.says)
|
t.Errorf("put, %s: at %s, %q; want %s saying %q", c.name, next.Put.Step, next.Put.Words, c.step, c.says)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ type Put struct {
|
|||||||
V int `json:"v"`
|
V int `json:"v"`
|
||||||
// FP is the fingerprint put, of the new form.
|
// FP is the fingerprint put, of the new form.
|
||||||
FP string `json:"fp"`
|
FP string `json:"fp"`
|
||||||
|
// Version is the version released at FP, which the want names beside it, once the put found it (design 47 H2 H-A-490
|
||||||
|
// addendum).
|
||||||
|
Version string `json:"version,omitempty"`
|
||||||
// Hold keeps the want at FP until released.
|
// Hold keeps the want at FP until released.
|
||||||
Hold bool `json:"hold,omitempty"`
|
Hold bool `json:"hold,omitempty"`
|
||||||
Why string `json:"why"`
|
Why string `json:"why"`
|
||||||
|
|||||||
Reference in New Issue
Block a user