CodeSampleX

Sample

github.com/envoyproxy/go-control-plane/envoy v1.32.2: v3.DiscoveryResponse

Verified sample for golang github.com/envoyproxy/go-control-plane/envoy v1.32.2: v3.DiscoveryResponse. The contract ran on go 1.26 · linux debian/x64 …

sha256:25fd41903919be0b5b9e731a9698bfd7ade65bd2cf026b0b4d1c6939b1f5d602

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 go

Verification-run environments

Environment Contract Stages Run
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-10-15

Case

HOW
Goal
verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2
Packages
Symbols
  • github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse
Created
2026-10-15T03:52:30Z

Contract

  1. DiscoveryResponse constructs with VersionInfo, Resources, Canary, TypeUrl, Nonce, and ControlPlane
  2. DiscoveryResponse Validate and ValidateAll succeed on valid xDS response message
  3. DiscoveryResponse protobuf Marshal and Unmarshal preserve fields and typed Any resources

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2
Demonstrate these symbols/APIs:
  - github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:ce13684da17c7887f96a38b29271ca2e3ded3da8c81fee6412a348b0042f31dd","contract":["DiscoveryResponse constructs with VersionInfo, Resources, Canary, TypeUrl, Nonce, and ControlPlane","DiscoveryResponse Validate and ValidateAll succeed on valid xDS response message","DiscoveryResponse protobuf Marshal and Unmarshal preserve fields and typed Any resources"],"goal":"verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2","kind":"HOW","packages":["pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2"],"schemaVersion":1,"symbols":["github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2","symbols":["github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require (
	github.com/envoyproxy/go-control-plane/envoy v1.32.2
	google.golang.org/protobuf v1.35.2
)

require (
	github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 // indirect
	github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
	github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
	golang.org/x/net v0.28.0 // indirect
	golang.org/x/sys v0.24.0 // indirect
	golang.org/x/text v0.17.0 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
	google.golang.org/grpc v1.67.1 // indirect
)
go.sum
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 h1:N+3sFI5GUjRKBi+i0TxYVST9h4Ie192jJWpHvthBBgg=
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/envoyproxy/go-control-plane/envoy v1.32.2 h1:zidqwmijfcbyKqVxjQDFx042PgX+p9U+/fu/f9VtSk8=
github.com/envoyproxy/go-control-plane/envoy v1.32.2/go.mod h1:eR2SOX2IedqlPvmiKjUH7Wu//S602JKI7HPC/L3SRq8=
github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM=
github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2"
  ],
  "symbols": [
    "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryResponse"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
	discoveryv3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/types/known/anypb"
	"google.golang.org/protobuf/types/known/wrapperspb"
)

func main() {
	resVal, err := anypb.New(wrapperspb.String("cluster-resource-1"))
	if err != nil {
		fmt.Fprintf(os.Stderr, "anypb.New failed: %v\n", err)
		os.Exit(1)
	}

	resp := &discoveryv3.DiscoveryResponse{
		VersionInfo: "v1.0.0",
		Resources:   []*anypb.Any{resVal},
		Canary:      true,
		TypeUrl:     "type.googleapis.com/google.protobuf.StringValue",
		Nonce:       "nonce-001",
		ControlPlane: &corev3.ControlPlane{
			Identifier: "cp-main",
		},
	}

	if err := resp.Validate(); err != nil {
		fmt.Fprintf(os.Stderr, "Validate failed: %v\n", err)
		os.Exit(1)
	}
	if err := resp.ValidateAll(); err != nil {
		fmt.Fprintf(os.Stderr, "ValidateAll failed: %v\n", err)
		os.Exit(1)
	}

	raw, err := proto.Marshal(resp)
	if err != nil {
		fmt.Fprintf(os.Stderr, "proto.Marshal failed: %v\n", err)
		os.Exit(1)
	}

	var decoded discoveryv3.DiscoveryResponse
	if err := proto.Unmarshal(raw, &decoded); err != nil {
		fmt.Fprintf(os.Stderr, "proto.Unmarshal failed: %v\n", err)
		os.Exit(1)
	}

	if decoded.GetVersionInfo() != "v1.0.0" {
		fmt.Fprintf(os.Stderr, "unexpected VersionInfo: %q\n", decoded.GetVersionInfo())
		os.Exit(1)
	}
	if !decoded.GetCanary() {
		fmt.Fprintf(os.Stderr, "expected Canary=true\n")
		os.Exit(1)
	}
	if decoded.GetTypeUrl() != "type.googleapis.com/google.protobuf.StringValue" {
		fmt.Fprintf(os.Stderr, "unexpected TypeUrl: %q\n", decoded.GetTypeUrl())
		os.Exit(1)
	}
	if decoded.GetNonce() != "nonce-001" {
		fmt.Fprintf(os.Stderr, "unexpected Nonce: %q\n", decoded.GetNonce())
		os.Exit(1)
	}
	if decoded.GetControlPlane().GetIdentifier() != "cp-main" {
		fmt.Fprintf(os.Stderr, "unexpected ControlPlane Identifier: %q\n", decoded.GetControlPlane().GetIdentifier())
		os.Exit(1)
	}
	if len(decoded.GetResources()) != 1 {
		fmt.Fprintf(os.Stderr, "unexpected Resources len: %d\n", len(decoded.GetResources()))
		os.Exit(1)
	}

	var unwrapped wrapperspb.StringValue
	if err := decoded.GetResources()[0].UnmarshalTo(&unwrapped); err != nil {
		fmt.Fprintf(os.Stderr, "UnmarshalTo failed: %v\n", err)
		os.Exit(1)
	}
	if unwrapped.GetValue() != "cluster-resource-1" {
		fmt.Fprintf(os.Stderr, "unexpected resource value: %q\n", unwrapped.GetValue())
		os.Exit(1)
	}

	decoded.Reset()
	if decoded.GetVersionInfo() != "" || len(decoded.GetResources()) != 0 {
		fmt.Fprintf(os.Stderr, "Reset did not clear fields\n")
		os.Exit(1)
	}
}

Origin Seeder

anonymous