diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go index 21f87b008..362a94532 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go @@ -56,6 +56,20 @@ const RevertLive = seat.WantsByWantNodeModuleValueRevertLive // want:version: it awaits its hand placement (design 47 H §772, H-A-73). Beside a put it is the one held want. const HoldAwaitsHandPlacement = "awaits-hand-placement" +// HoldAwaitsReadsPrefix begins the words of a want the assigner holds for a reader capability the node's node-engine does +// not state, followed by the missing capabilities (design 47 H2 H-A-682 (2), H-A-706 (DMC-14)). +const HoldAwaitsReadsPrefix = "awaits-reads:" + +// HoldAwaitsEntryPrefix begins the words of a want the assigner holds until the catalog entry of its fingerprint is read, +// followed by the fingerprint (design 47 H2 H-A-698 (2), H-A-706 (DMC-14)). +const HoldAwaitsEntryPrefix = "awaits-entry:" + +// holdWords says whether words are a held want's other than a put's: awaiting its hand placement, or beginning with one of +// the two prefixes. +func holdWords(words string) bool { + return words == HoldAwaitsHandPlacement || strings.HasPrefix(words, HoldAwaitsReadsPrefix) || strings.HasPrefix(words, HoldAwaitsEntryPrefix) +} + // NodeWord is the last part of a node's own key. const NodeWord = "node" @@ -182,8 +196,8 @@ func checkWant(w Want) error { } return nil } - if w.Hold && !w.Put && w.Words != HoldAwaitsHandPlacement { - return fmt.Errorf("wants: only a put, or a want awaiting its hand placement (%s), holds a want", HoldAwaitsHandPlacement) + if w.Hold && !w.Put && !holdWords(w.Words) { + return fmt.Errorf("wants: only a put, or a want awaiting its hand placement (%s), its reads (%s) or its entry (%s), holds a want", HoldAwaitsHandPlacement, HoldAwaitsReadsPrefix, HoldAwaitsEntryPrefix) } if err := checkFingerprint(w.Fp, "a want's fingerprint"); err != nil { return err diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go index 9a0d4a17d..da98e58b8 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go @@ -45,6 +45,9 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { "a placement's build": {Want{Fp: a, Version: "0.1.14"}, `{"v":1,"fp":"` + a + `","version":"0.1.14"}`}, // design 47 H §772, H-A-73: a node whose node-engine reads no want by version is held, awaiting its hand placement. "awaits its hand placement": {Want{Fp: a, Version: "0.1.15", Pipeline: "main.3589", Rank: 1, Hold: true, Words: HoldAwaitsHandPlacement}, `{"v":1,"fp":"` + a + `","version":"0.1.15","pipeline":"main.3589","rank":1,"hold":true,"words":"awaits-hand-placement"}`}, + // design 47 H2 H-A-682 (2), H-A-698 (2), H-A-706 (DMC-14): held for a reader capability the engine does not state, or for an entry not read yet. + "awaits its reads": {Want{Fp: a, Version: "0.1.15", Hold: true, Words: HoldAwaitsReadsPrefix + "directory-contents-owner"}, `{"v":1,"fp":"` + a + `","version":"0.1.15","hold":true,"words":"awaits-reads:directory-contents-owner"}`}, + "awaits its entry": {Want{Fp: a, Version: "0.1.15", Hold: true, Words: HoldAwaitsEntryPrefix + a}, `{"v":1,"fp":"` + a + `","version":"0.1.15","hold":true,"words":"awaits-entry:` + a + `"}`}, } { t.Run(name, func(t *testing.T) { raw, err := EncodeWant(row.w)