composer: a request carries blame_tries, a machine's verdict names the modules it blames (K1)
The assigner bounds the composer's culprit search through the request, since the composer program has no settings; a verdict always writes blamed, an empty list when it blames none, so an old composer's absent field stays tellable. Builds: design 47 G §721, §729; A-469h, A-469i
This commit is contained in:
@@ -67,6 +67,11 @@ type Request struct {
|
||||
// them (the definitions of the seat mesh-catalog, resolved), raw so that this package names no seat (ADR 0635 §4, ADR 0636
|
||||
// §1). The judge and the composer read them. None is no list at hand: a composer handed none judges no machine (ADR 0636 §1).
|
||||
Seats []json.RawMessage `json:"seats,omitempty"`
|
||||
// BlameTries bounds the composer's search for the modules a machine that does not compose blames: it composes at
|
||||
// most this many times more, the assigner's setting blame-tries, since the composer has no settings of its own
|
||||
// (design 47 G §721, §729; A-469i). None is no search: the composer blames only what its composition holds or
|
||||
// refuses (A-468i).
|
||||
BlameTries int `json:"blame_tries,omitempty"`
|
||||
}
|
||||
|
||||
// Case is one catalogue composed: every module's manifest by name, and per node the manifests kept at the build it runs.
|
||||
@@ -168,6 +173,11 @@ type ManifestRead struct {
|
||||
// in words, why the composer did not judge the machine (an older node-engine's input that does not say how it composes,
|
||||
// novox/hq ADR 0593 §9): the machine is then neither composed nor refused, and a reader decides by this field alone,
|
||||
// never by the words of Reason.
|
||||
//
|
||||
// Blamed names each module the candidate's composition of the machine holds or refuses and the composition without the
|
||||
// candidate does not, with its problem (design 47 G §721). A composer of this shape always writes it, an empty list when
|
||||
// it blames none (A-469h); nil is a verdict with no such field, a composer from before §721, which its reader judges as
|
||||
// before it ("the composer names no culprits").
|
||||
type Machine struct {
|
||||
Composes bool `json:"composes"`
|
||||
NotJudged string `json:"not_judged,omitempty"`
|
||||
@@ -175,6 +185,10 @@ type Machine struct {
|
||||
Problems []string `json:"problems,omitempty"`
|
||||
Refusals []string `json:"refusals,omitempty"`
|
||||
Declared []Path `json:"declared,omitempty"`
|
||||
Blamed []struct {
|
||||
Module string `json:"module"`
|
||||
Problem string `json:"problem"`
|
||||
} `json:"blamed,omitzero"`
|
||||
}
|
||||
|
||||
// Path is one path a declaration puts on the machine, with its kind (the resource's type), owner, group and mode as
|
||||
|
||||
@@ -57,6 +57,42 @@ func TestAManifestIsItsBytesOrItsDigest(t *testing.T) {
|
||||
t.Errorf("the known packages %#v went as %s and read back %#v (%v)", known, wire, back.Packages, err)
|
||||
}
|
||||
}
|
||||
// K1/AC4 (design 47 G §721, §729; A-469h, A-469i): a request's blame_tries and a verdict's blamed read back whole; a
|
||||
// verdict with no blamed (a composer from before §721) reads back as no field, told apart from an empty list.
|
||||
wire, err = json.Marshal(Request{V: Version, BlameTries: 20})
|
||||
if back, derr := Decode(wire); err != nil || derr != nil || back.BlameTries != 20 || !strings.Contains(string(wire), `"blame_tries":20`) {
|
||||
t.Errorf("blame_tries 20 went as %s and read back %d (%v, %v)", wire, back.BlameTries, err, derr)
|
||||
}
|
||||
one := Machine{}
|
||||
one.Blamed = append(one.Blamed, struct {
|
||||
Module string `json:"module"`
|
||||
Problem string `json:"problem"`
|
||||
}{Module: "a", Problem: "holds /etc/x"})
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
wire string
|
||||
blamed int
|
||||
old bool
|
||||
}{
|
||||
{"blames one", `{"composes":false,"blamed":[{"module":"a","problem":"holds /etc/x"}]}`, 1, false},
|
||||
{"blames none", `{"composes":false,"blamed":[]}`, 0, false},
|
||||
{"an old composer", `{"composes":false}`, 0, true},
|
||||
} {
|
||||
var m Machine
|
||||
if err := json.Unmarshal([]byte(c.wire), &m); err != nil {
|
||||
t.Fatalf("%s: %v", c.name, err)
|
||||
}
|
||||
if len(m.Blamed) != c.blamed || (m.Blamed == nil) != c.old {
|
||||
t.Errorf("%s: %s read back blamed %#v", c.name, c.wire, m.Blamed)
|
||||
}
|
||||
again, err := json.Marshal(m)
|
||||
if err != nil || string(again) != c.wire {
|
||||
t.Errorf("%s: %s went again as %s (%v)", c.name, c.wire, again, err)
|
||||
}
|
||||
}
|
||||
if wire, _ := json.Marshal(one); string(wire) != `{"composes":false,"blamed":[{"module":"a","problem":"holds /etc/x"}]}` {
|
||||
t.Errorf("a machine blaming a went as %s", wire)
|
||||
}
|
||||
bad := Request{V: Version, Cases: []Case{{Name: "c", Manifests: map[string]Manifest{"x": {Digest: "nope"}}}}}
|
||||
if err := Fill(&bad, func(Manifest) ([]byte, error) { return nil, errors.New("not there") }); err == nil || !strings.Contains(err.Error(), "nope") {
|
||||
t.Fatalf("a digest the indexer does not hold: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user