js.core: Change vdl go codegen to emit __VDLInit funcs.

Fixes a subtle init-ordering issue in vdl-generated go code.  The
basic problem looks something like this; there are many variants
to this problem, this is just one simple example:

// User's file a.go
package foo
import "v.io/v23/vdl"
var myType := vdl.TypeOf(FooType{})

// Generated file foo.vdl.go
package foo
import "v.io/v23/vdl"
func init() {
vdl.RegisterNative(FooToNative, FooFromNative)
}

The problem is that the vdl.RegisterNative call must occur before
the vdl.TypeOf call, so that the vdl package knows about native
types, and can analyze the type correctly.  But init funcs are
always processed after all package-level variables have been
initialized, so we get the wrong order above.

We fix that by moving all initialization into a generated
__VDLInit func, with a trick to turn it into a var
initialization.  Note that we still haven't fixed the above
example, since the package-level vars in a.go are typically
processed before foo.vdl.go.  In the rare case where this
happens, the user can add a call to __VDLInit in a var
initializer early in their a.go file.

Similar problems existed with vom.RawBytesOf, and the
manually-generated types we were storing in package-level vars.

The new strategy is to put all ordering-dependent init logic in
__VDLInit, and to ensure that the order that we call things
within the function is correct.  We also sort types, consts and
interfaces in the compiler as best we can.  Note that sorting
types isn't strictly required (or meaningful), since we allow
cyclic types.  But it still might be nice for some generated
languages.

There are further cleanups possible; we can probably add
error-checking more methodically for cases like above where the
user needs to add a call to __VDLInit, and we should replace the
long hex hash for generated type names to a simple counter.  But
that'll occur in a separate CL; this is the more important one.

MultiPart: 4/6

Change-Id: I746ffa1db20fa8002f17f323d284e69803c02652
diff --git a/go/src/v.io/x/js.core/stress/stress.vdl.go b/go/src/v.io/x/js.core/stress/stress.vdl.go
index 2545652..d367973 100644
--- a/go/src/v.io/x/js.core/stress/stress.vdl.go
+++ b/go/src/v.io/x/js.core/stress/stress.vdl.go
@@ -18,6 +18,11 @@
 	_ "v.io/v23/vdlroot/time"
 )
 
+var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
+
+//////////////////////////////////////////////////
+// Type definitions
+
 type StressResults struct {
 	Iterations  int64
 	Qps         float64
@@ -30,9 +35,6 @@
 }
 
 func (m *StressResults) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
-	if __VDLType_v_io_x_js_core_stress_StressResults == nil || __VDLType0 == nil {
-		panic("Initialization order error: types generated for FillVDLTarget not initialized. Consider moving caller to an init() block.")
-	}
 	fieldsTarget1, err := t.StartFields(tt)
 	if err != nil {
 		return err
@@ -43,7 +45,7 @@
 		return err
 	}
 	if err != vdl.ErrFieldNoExist {
-		if err := fieldTarget3.FromInt(int64(m.Iterations), vdl.Int64Type); err != nil {
+		if err := fieldTarget3.FromInt(int64(m.Iterations), tt.NonOptional().Field(0).Type); err != nil {
 			return err
 		}
 		if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
@@ -55,7 +57,7 @@
 		return err
 	}
 	if err != vdl.ErrFieldNoExist {
-		if err := fieldTarget5.FromFloat(float64(m.Qps), vdl.Float64Type); err != nil {
+		if err := fieldTarget5.FromFloat(float64(m.Qps), tt.NonOptional().Field(1).Type); err != nil {
 			return err
 		}
 		if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
@@ -67,7 +69,7 @@
 		return err
 	}
 	if err != vdl.ErrFieldNoExist {
-		if err := fieldTarget7.FromFloat(float64(m.MsecsPerRpc), vdl.Float64Type); err != nil {
+		if err := fieldTarget7.FromFloat(float64(m.MsecsPerRpc), tt.NonOptional().Field(2).Type); err != nil {
 			return err
 		}
 		if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
@@ -95,8 +97,8 @@
 
 func (t *StressResultsTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
 
-	if !vdl.Compatible(tt, __VDLType_v_io_x_js_core_stress_StressResults) {
-		return nil, fmt.Errorf("type %v incompatible with %v", tt, __VDLType_v_io_x_js_core_stress_StressResults)
+	if ttWant := vdl.TypeOf((*StressResults)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
+		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
 	}
 	return t, nil
 }
@@ -115,7 +117,7 @@
 		target, err := &t.msecsPerRpcTarget, error(nil)
 		return nil, target, err
 	default:
-		return nil, nil, fmt.Errorf("field %s not in struct %v", name, __VDLType_v_io_x_js_core_stress_StressResults)
+		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/js.core/stress.StressResults", name)
 	}
 }
 func (t *StressResultsTarget) FinishField(_, _ vdl.Target) error {
@@ -126,15 +128,8 @@
 	return nil
 }
 
-func init() {
-	vdl.Register((*StressResults)(nil))
-}
-
-var __VDLType0 *vdl.Type = vdl.TypeOf((*StressResults)(nil))
-var __VDLType_v_io_x_js_core_stress_StressResults *vdl.Type = vdl.TypeOf(StressResults{})
-
-func __VDLEnsureNativeBuilt() {
-}
+//////////////////////////////////////////////////
+// Interface definitions
 
 // StressClientMethods is the client interface
 // containing Stress methods.
@@ -265,3 +260,29 @@
 		},
 	},
 }
+
+var __VDLInitCalled bool
+
+// __VDLInit performs vdl initialization.  It is safe to call multiple times.
+// If you have an init ordering issue, just insert the following line verbatim
+// into your source files in this package, right after the "package foo" clause:
+//
+//    var _ = __VDLInit()
+//
+// The purpose of this function is to ensure that vdl initialization occurs in
+// the right order, and very early in the init sequence.  In particular, vdl
+// registration and package variable initialization needs to occur before
+// functions like vdl.TypeOf will work properly.
+//
+// This function returns a dummy value, so that it can be used to initialize the
+// first var in the file, to take advantage of Go's defined init order.
+func __VDLInit() struct{} {
+	if __VDLInitCalled {
+		return struct{}{}
+	}
+
+	// Register types.
+	vdl.Register((*StressResults)(nil))
+
+	return struct{}{}
+}
diff --git a/go/src/v.io/x/js.core/test_service/test_service.vdl.go b/go/src/v.io/x/js.core/test_service/test_service.vdl.go
index 9680242..140cf97 100644
--- a/go/src/v.io/x/js.core/test_service/test_service.vdl.go
+++ b/go/src/v.io/x/js.core/test_service/test_service.vdl.go
@@ -22,6 +22,11 @@
 	"v.io/v23/vom"
 )
 
+var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
+
+//////////////////////////////////////////////////
+// Type definitions
+
 // KeyPageResult is a page of 10 keys.
 type KeyPageResult [10]string
 
@@ -31,7 +36,7 @@
 }
 
 func (m *KeyPageResult) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
-	listTarget1, err := t.StartList(__VDLType_v_io_x_js_core_test_service_KeyPageResult, 10)
+	listTarget1, err := t.StartList(tt, 10)
 	if err != nil {
 		return err
 	}
@@ -40,7 +45,7 @@
 		if err != nil {
 			return err
 		}
-		if err := elemTarget2.FromString(string(elem3), vdl.StringType); err != nil {
+		if err := elemTarget2.FromString(string(elem3), tt.NonOptional().Elem()); err != nil {
 			return err
 		}
 		if err := listTarget1.FinishElem(elemTarget2); err != nil {
@@ -67,8 +72,8 @@
 
 func (t *KeyPageResultTarget) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {
 
-	if !vdl.Compatible(tt, __VDLType_v_io_x_js_core_test_service_KeyPageResult) {
-		return nil, fmt.Errorf("type %v incompatible with %v", tt, __VDLType_v_io_x_js_core_test_service_KeyPageResult)
+	if ttWant := vdl.TypeOf((*KeyPageResult)(nil)); !vdl.Compatible(tt, ttWant) {
+		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
 	}
 	return t, nil
 }
@@ -97,9 +102,6 @@
 }
 
 func (m *KeyValuePair) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
-	if __VDLType_v_io_x_js_core_test_service_KeyValuePair == nil || __VDLType0 == nil {
-		panic("Initialization order error: types generated for FillVDLTarget not initialized. Consider moving caller to an init() block.")
-	}
 	fieldsTarget1, err := t.StartFields(tt)
 	if err != nil {
 		return err
@@ -110,7 +112,7 @@
 		return err
 	}
 	if err != vdl.ErrFieldNoExist {
-		if err := fieldTarget3.FromString(string(m.Key), vdl.StringType); err != nil {
+		if err := fieldTarget3.FromString(string(m.Key), tt.NonOptional().Field(0).Type); err != nil {
 			return err
 		}
 		if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
@@ -124,11 +126,11 @@
 	if err != vdl.ErrFieldNoExist {
 
 		if m.Value == nil {
-			if err := fieldTarget5.FromNil(vdl.AnyType); err != nil {
+			if err := fieldTarget5.FromNil(tt.NonOptional().Field(1).Type); err != nil {
 				return err
 			}
 		} else {
-			if err := m.Value.FillVDLTarget(fieldTarget5, vdl.AnyType); err != nil {
+			if err := m.Value.FillVDLTarget(fieldTarget5, tt.NonOptional().Field(1).Type); err != nil {
 				return err
 			}
 		}
@@ -156,8 +158,8 @@
 
 func (t *KeyValuePairTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
 
-	if !vdl.Compatible(tt, __VDLType_v_io_x_js_core_test_service_KeyValuePair) {
-		return nil, fmt.Errorf("type %v incompatible with %v", tt, __VDLType_v_io_x_js_core_test_service_KeyValuePair)
+	if ttWant := vdl.TypeOf((*KeyValuePair)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
+		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
 	}
 	return t, nil
 }
@@ -171,7 +173,7 @@
 		target, err := vdl.ReflectTarget(reflect.ValueOf(&t.Value.Value))
 		return nil, target, err
 	default:
-		return nil, nil, fmt.Errorf("field %s not in struct %v", name, __VDLType_v_io_x_js_core_test_service_KeyValuePair)
+		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/js.core/test_service.KeyValuePair", name)
 	}
 }
 func (t *KeyValuePairTarget) FinishField(_, _ vdl.Target) error {
@@ -193,9 +195,6 @@
 }
 
 func (m *TestCaveatData) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
-	if __VDLType_v_io_x_js_core_test_service_TestCaveatData == nil || __VDLType1 == nil {
-		panic("Initialization order error: types generated for FillVDLTarget not initialized. Consider moving caller to an init() block.")
-	}
 	fieldsTarget1, err := t.StartFields(tt)
 	if err != nil {
 		return err
@@ -206,7 +205,7 @@
 		return err
 	}
 	if err != vdl.ErrFieldNoExist {
-		if err := fieldTarget3.FromString(string(m.A), vdl.StringType); err != nil {
+		if err := fieldTarget3.FromString(string(m.A), tt.NonOptional().Field(0).Type); err != nil {
 			return err
 		}
 		if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
@@ -220,11 +219,11 @@
 	if err != vdl.ErrFieldNoExist {
 
 		if m.B == nil {
-			if err := fieldTarget5.FromNil(vdl.AnyType); err != nil {
+			if err := fieldTarget5.FromNil(tt.NonOptional().Field(1).Type); err != nil {
 				return err
 			}
 		} else {
-			if err := m.B.FillVDLTarget(fieldTarget5, vdl.AnyType); err != nil {
+			if err := m.B.FillVDLTarget(fieldTarget5, tt.NonOptional().Field(1).Type); err != nil {
 				return err
 			}
 		}
@@ -252,8 +251,8 @@
 
 func (t *TestCaveatDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
 
-	if !vdl.Compatible(tt, __VDLType_v_io_x_js_core_test_service_TestCaveatData) {
-		return nil, fmt.Errorf("type %v incompatible with %v", tt, __VDLType_v_io_x_js_core_test_service_TestCaveatData)
+	if ttWant := vdl.TypeOf((*TestCaveatData)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
+		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
 	}
 	return t, nil
 }
@@ -267,7 +266,7 @@
 		target, err := vdl.ReflectTarget(reflect.ValueOf(&t.Value.B))
 		return nil, target, err
 	default:
-		return nil, nil, fmt.Errorf("field %s not in struct %v", name, __VDLType_v_io_x_js_core_test_service_TestCaveatData)
+		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/js.core/test_service.TestCaveatData", name)
 	}
 }
 func (t *TestCaveatDataTarget) FinishField(_, _ vdl.Target) error {
@@ -278,20 +277,8 @@
 	return nil
 }
 
-func init() {
-	vdl.Register((*KeyPageResult)(nil))
-	vdl.Register((*KeyValuePair)(nil))
-	vdl.Register((*TestCaveatData)(nil))
-}
-
-var __VDLType0 *vdl.Type = vdl.TypeOf((*KeyValuePair)(nil))
-var __VDLType1 *vdl.Type = vdl.TypeOf((*TestCaveatData)(nil))
-var __VDLType_v_io_x_js_core_test_service_KeyPageResult *vdl.Type = vdl.TypeOf(KeyPageResult{})
-var __VDLType_v_io_x_js_core_test_service_KeyValuePair *vdl.Type = vdl.TypeOf(KeyValuePair{})
-var __VDLType_v_io_x_js_core_test_service_TestCaveatData *vdl.Type = vdl.TypeOf(TestCaveatData{})
-
-func __VDLEnsureNativeBuilt() {
-}
+//////////////////////////////////////////////////
+// Const definitions
 
 var ConditionallyValidatingTestCaveat = security.CaveatDescriptor{
 	Id: uniqueid.Id{
@@ -312,9 +299,12 @@
 		238,
 		255,
 	},
-	ParamType: vdl.TypeOf(TestCaveatData{}),
+	ParamType: vdl.TypeOf((*TestCaveatData)(nil)).Elem(),
 }
 
+//////////////////////////////////////////////////
+// Interface definitions
+
 // CacheClientMethods is the client interface
 // containing Cache methods.
 //
@@ -1729,3 +1719,31 @@
 		},
 	},
 }
+
+var __VDLInitCalled bool
+
+// __VDLInit performs vdl initialization.  It is safe to call multiple times.
+// If you have an init ordering issue, just insert the following line verbatim
+// into your source files in this package, right after the "package foo" clause:
+//
+//    var _ = __VDLInit()
+//
+// The purpose of this function is to ensure that vdl initialization occurs in
+// the right order, and very early in the init sequence.  In particular, vdl
+// registration and package variable initialization needs to occur before
+// functions like vdl.TypeOf will work properly.
+//
+// This function returns a dummy value, so that it can be used to initialize the
+// first var in the file, to take advantage of Go's defined init order.
+func __VDLInit() struct{} {
+	if __VDLInitCalled {
+		return struct{}{}
+	}
+
+	// Register types.
+	vdl.Register((*KeyPageResult)(nil))
+	vdl.Register((*KeyValuePair)(nil))
+	vdl.Register((*TestCaveatData)(nil))
+
+	return struct{}{}
+}
diff --git a/src/gen-vdl/v.io/v23/vdlroot/signature/index.js b/src/gen-vdl/v.io/v23/vdlroot/signature/index.js
index 668427b..8948c48 100644
--- a/src/gen-vdl/v.io/v23/vdlroot/signature/index.js
+++ b/src/gen-vdl/v.io/v23/vdlroot/signature/index.js
@@ -26,19 +26,19 @@
 var _typeMethod = new vdl.Type();
 _type1.kind = vdl.kind.LIST;
 _type1.name = "";
-_type1.elem = _typeEmbed;
-_type2.kind = vdl.kind.LIST;
+_type1.elem = _typeArg;
+_type2.kind = vdl.kind.OPTIONAL;
 _type2.name = "";
-_type2.elem = _typeMethod;
+_type2.elem = _typeArg;
 _type3.kind = vdl.kind.LIST;
 _type3.name = "";
-_type3.elem = _typeArg;
-_type4.kind = vdl.kind.OPTIONAL;
+_type3.elem = vdl.types.ANY;
+_type4.kind = vdl.kind.LIST;
 _type4.name = "";
-_type4.elem = _typeArg;
+_type4.elem = _typeEmbed;
 _type5.kind = vdl.kind.LIST;
 _type5.name = "";
-_type5.elem = vdl.types.ANY;
+_type5.elem = _typeMethod;
 _typeArg.kind = vdl.kind.STRUCT;
 _typeArg.name = "signature.Arg";
 _typeArg.fields = [{name: "Name", type: vdl.types.STRING}, {name: "Doc", type: vdl.types.STRING}, {name: "Type", type: vdl.types.TYPEOBJECT}];
@@ -47,10 +47,10 @@
 _typeEmbed.fields = [{name: "Name", type: vdl.types.STRING}, {name: "PkgPath", type: vdl.types.STRING}, {name: "Doc", type: vdl.types.STRING}];
 _typeInterface.kind = vdl.kind.STRUCT;
 _typeInterface.name = "signature.Interface";
-_typeInterface.fields = [{name: "Name", type: vdl.types.STRING}, {name: "PkgPath", type: vdl.types.STRING}, {name: "Doc", type: vdl.types.STRING}, {name: "Embeds", type: _type1}, {name: "Methods", type: _type2}];
+_typeInterface.fields = [{name: "Name", type: vdl.types.STRING}, {name: "PkgPath", type: vdl.types.STRING}, {name: "Doc", type: vdl.types.STRING}, {name: "Embeds", type: _type4}, {name: "Methods", type: _type5}];
 _typeMethod.kind = vdl.kind.STRUCT;
 _typeMethod.name = "signature.Method";
-_typeMethod.fields = [{name: "Name", type: vdl.types.STRING}, {name: "Doc", type: vdl.types.STRING}, {name: "InArgs", type: _type3}, {name: "OutArgs", type: _type3}, {name: "InStream", type: _type4}, {name: "OutStream", type: _type4}, {name: "Tags", type: _type5}];
+_typeMethod.fields = [{name: "Name", type: vdl.types.STRING}, {name: "Doc", type: vdl.types.STRING}, {name: "InArgs", type: _type1}, {name: "OutArgs", type: _type1}, {name: "InStream", type: _type2}, {name: "OutStream", type: _type2}, {name: "Tags", type: _type3}];
 _type1.freeze();
 _type2.freeze();
 _type3.freeze();
diff --git a/src/gen-vdl/v.io/v23/vdlroot/vdltool/index.js b/src/gen-vdl/v.io/v23/vdlroot/vdltool/index.js
index 560f685..110419a 100644
--- a/src/gen-vdl/v.io/v23/vdlroot/vdltool/index.js
+++ b/src/gen-vdl/v.io/v23/vdlroot/vdltool/index.js
@@ -27,23 +27,23 @@
 var _typeGoType = new vdl.Type();
 var _typeJavaConfig = new vdl.Type();
 var _typeJavascriptConfig = new vdl.Type();
-_type1.kind = vdl.kind.SET;
+_type1.kind = vdl.kind.LIST;
 _type1.name = "";
-_type1.key = _typeGenLanguage;
+_type1.elem = _typeGoImport;
 _type2.kind = vdl.kind.MAP;
 _type2.name = "";
 _type2.elem = _typeGoType;
 _type2.key = vdl.types.STRING;
-_type3.kind = vdl.kind.LIST;
+_type3.kind = vdl.kind.MAP;
 _type3.name = "";
-_type3.elem = _typeGoImport;
-_type4.kind = vdl.kind.MAP;
+_type3.elem = vdl.types.STRING;
+_type3.key = vdl.types.STRING;
+_type4.kind = vdl.kind.SET;
 _type4.name = "";
-_type4.elem = vdl.types.STRING;
-_type4.key = vdl.types.STRING;
+_type4.key = _typeGenLanguage;
 _typeConfig.kind = vdl.kind.STRUCT;
 _typeConfig.name = "vdltool.Config";
-_typeConfig.fields = [{name: "GenLanguages", type: _type1}, {name: "Go", type: _typeGoConfig}, {name: "Java", type: _typeJavaConfig}, {name: "Javascript", type: _typeJavascriptConfig}];
+_typeConfig.fields = [{name: "GenLanguages", type: _type4}, {name: "Go", type: _typeGoConfig}, {name: "Java", type: _typeJavaConfig}, {name: "Javascript", type: _typeJavascriptConfig}];
 _typeGenLanguage.kind = vdl.kind.ENUM;
 _typeGenLanguage.name = "vdltool.GenLanguage";
 _typeGenLanguage.labels = ["Go", "Java", "Javascript"];
@@ -55,10 +55,10 @@
 _typeGoImport.fields = [{name: "Path", type: vdl.types.STRING}, {name: "Name", type: vdl.types.STRING}];
 _typeGoType.kind = vdl.kind.STRUCT;
 _typeGoType.name = "vdltool.GoType";
-_typeGoType.fields = [{name: "Type", type: vdl.types.STRING}, {name: "Imports", type: _type3}];
+_typeGoType.fields = [{name: "Type", type: vdl.types.STRING}, {name: "Imports", type: _type1}];
 _typeJavaConfig.kind = vdl.kind.STRUCT;
 _typeJavaConfig.name = "vdltool.JavaConfig";
-_typeJavaConfig.fields = [{name: "WireToNativeTypes", type: _type4}, {name: "WireTypeRenames", type: _type4}];
+_typeJavaConfig.fields = [{name: "WireToNativeTypes", type: _type3}, {name: "WireTypeRenames", type: _type3}];
 _typeJavascriptConfig.kind = vdl.kind.STRUCT;
 _typeJavascriptConfig.name = "vdltool.JavascriptConfig";
 _typeJavascriptConfig.fields = [];
diff --git a/src/gen-vdl/v.io/v23/vtrace/index.js b/src/gen-vdl/v.io/v23/vtrace/index.js
index e515180..561f705 100644
--- a/src/gen-vdl/v.io/v23/vtrace/index.js
+++ b/src/gen-vdl/v.io/v23/vtrace/index.js
@@ -28,10 +28,10 @@
 var _typeTraceRecord = new vdl.Type();
 _type1.kind = vdl.kind.LIST;
 _type1.name = "";
-_type1.elem = _typeSpanRecord;
+_type1.elem = _typeAnnotation;
 _type2.kind = vdl.kind.LIST;
 _type2.name = "";
-_type2.elem = _typeAnnotation;
+_type2.elem = _typeSpanRecord;
 _typeAnnotation.kind = vdl.kind.STRUCT;
 _typeAnnotation.name = "v.io/v23/vtrace.Annotation";
 _typeAnnotation.fields = [{name: "When", type: new time.Time()._type}, {name: "Message", type: vdl.types.STRING}];
@@ -43,12 +43,12 @@
 _typeResponse.fields = [{name: "Flags", type: _typeTraceFlags}, {name: "Trace", type: _typeTraceRecord}];
 _typeSpanRecord.kind = vdl.kind.STRUCT;
 _typeSpanRecord.name = "v.io/v23/vtrace.SpanRecord";
-_typeSpanRecord.fields = [{name: "Id", type: new uniqueid.Id()._type}, {name: "Parent", type: new uniqueid.Id()._type}, {name: "Name", type: vdl.types.STRING}, {name: "Start", type: new time.Time()._type}, {name: "End", type: new time.Time()._type}, {name: "Annotations", type: _type2}];
+_typeSpanRecord.fields = [{name: "Id", type: new uniqueid.Id()._type}, {name: "Parent", type: new uniqueid.Id()._type}, {name: "Name", type: vdl.types.STRING}, {name: "Start", type: new time.Time()._type}, {name: "End", type: new time.Time()._type}, {name: "Annotations", type: _type1}];
 _typeTraceFlags.kind = vdl.kind.INT32;
 _typeTraceFlags.name = "v.io/v23/vtrace.TraceFlags";
 _typeTraceRecord.kind = vdl.kind.STRUCT;
 _typeTraceRecord.name = "v.io/v23/vtrace.TraceRecord";
-_typeTraceRecord.fields = [{name: "Id", type: new uniqueid.Id()._type}, {name: "Spans", type: _type1}];
+_typeTraceRecord.fields = [{name: "Id", type: new uniqueid.Id()._type}, {name: "Spans", type: _type2}];
 _type1.freeze();
 _type2.freeze();
 _typeAnnotation.freeze();
diff --git a/src/gen-vdl/v.io/x/ref/services/wspr/internal/app/index.js b/src/gen-vdl/v.io/x/ref/services/wspr/internal/app/index.js
index 3a62568..531e800 100644
--- a/src/gen-vdl/v.io/x/ref/services/wspr/internal/app/index.js
+++ b/src/gen-vdl/v.io/x/ref/services/wspr/internal/app/index.js
@@ -39,10 +39,10 @@
 var _typeRpcServerOption = new vdl.Type();
 _type1.kind = vdl.kind.LIST;
 _type1.name = "";
-_type1.elem = _typeRpcCallOption;
+_type1.elem = new security.BlessingPattern()._type;
 _type2.kind = vdl.kind.LIST;
 _type2.name = "";
-_type2.elem = new security.BlessingPattern()._type;
+_type2.elem = _typeRpcCallOption;
 _type3.kind = vdl.kind.LIST;
 _type3.name = "";
 _type3.elem = vdl.types.ANY;
@@ -75,10 +75,10 @@
 _typeGranterResponse.fields = [{name: "Blessings", type: new security.WireBlessings()._type}, {name: "Err", type: vdl.types.ERROR}];
 _typeRpcCallOption.kind = vdl.kind.UNION;
 _typeRpcCallOption.name = "v.io/x/ref/services/wspr/internal/app.RpcCallOption";
-_typeRpcCallOption.fields = [{name: "AllowedServersPolicy", type: _type2}, {name: "Granter", type: _typeGranterHandle}];
+_typeRpcCallOption.fields = [{name: "AllowedServersPolicy", type: _type1}, {name: "Granter", type: _typeGranterHandle}];
 _typeRpcRequest.kind = vdl.kind.STRUCT;
 _typeRpcRequest.name = "v.io/x/ref/services/wspr/internal/app.RpcRequest";
-_typeRpcRequest.fields = [{name: "Name", type: vdl.types.STRING}, {name: "Method", type: vdl.types.STRING}, {name: "NumInArgs", type: vdl.types.INT32}, {name: "NumOutArgs", type: vdl.types.INT32}, {name: "IsStreaming", type: vdl.types.BOOL}, {name: "Deadline", type: new time.WireDeadline()._type}, {name: "TraceRequest", type: new vtrace.Request()._type}, {name: "Context", type: new server.Context()._type}, {name: "CallOptions", type: _type1}];
+_typeRpcRequest.fields = [{name: "Name", type: vdl.types.STRING}, {name: "Method", type: vdl.types.STRING}, {name: "NumInArgs", type: vdl.types.INT32}, {name: "NumOutArgs", type: vdl.types.INT32}, {name: "IsStreaming", type: vdl.types.BOOL}, {name: "Deadline", type: new time.WireDeadline()._type}, {name: "TraceRequest", type: new vtrace.Request()._type}, {name: "Context", type: new server.Context()._type}, {name: "CallOptions", type: _type2}];
 _typeRpcResponse.kind = vdl.kind.STRUCT;
 _typeRpcResponse.name = "v.io/x/ref/services/wspr/internal/app.RpcResponse";
 _typeRpcResponse.fields = [{name: "OutArgs", type: _type3}, {name: "TraceResponse", type: new vtrace.Response()._type}];