CodeSampleX

Exemplo

github.com/envoyproxy/go-control-plane v0.14.0: v3.Type

Amostra verificada para golang github.com/envoyproxy/go-control-plane v0.14.0: v3.Type. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:7e288e297f30aef227715995de1821558e5a07109d8ffe349eb120a57c653fb0

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-09-15

Caso

HOW
Objetivo
verify github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type in pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0
Pacotes
Símbolos
  • github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type
Criado
2026-09-15T22:36:38Z

Contrato

  1. resource.APITypePrefix is type.googleapis.com/ for xDS v3 resource URLs
  2. standard resource.Type constants match expected xDS v3 type URLs with APITypePrefix
  3. resource.AnyType is defined as empty string for Aggregated Discovery Service (ADS)
  4. resource.Type values allow assignment and equality comparison as string alias

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/pkg/resource/v3.Type in pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0
Demonstrate these symbols/APIs:
  - github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type

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:1c3fef63644f4b872ef7d0b8f62380685ef6d9fa05f046572084ceed610a76b7","contract":["resource.APITypePrefix is type.googleapis.com/ for xDS v3 resource URLs","standard resource.Type constants match expected xDS v3 type URLs with APITypePrefix","resource.AnyType is defined as empty string for Aggregated Discovery Service (ADS)","resource.Type values allow assignment and equality comparison as string alias"],"goal":"verify github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type in pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0","kind":"HOW","packages":["pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0"],"schemaVersion":1,"symbols":["github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type"]},"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@v0.14.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0","symbols":["github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.23.0

require github.com/envoyproxy/go-control-plane v0.14.0

require (
	cel.dev/expr v0.24.0 // indirect
	github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
	github.com/envoyproxy/go-control-plane/envoy v1.36.0 // indirect
	github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
	github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
	google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 // indirect
	google.golang.org/protobuf v1.36.10 // indirect
)
go.sum
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 h1:aQ3y1lwWyqYPiWZThqv1aFbZMiM9vblcSArJRf2Irls=
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA=
github.com/envoyproxy/go-control-plane v0.14.0/go.mod h1:NcS5X47pLl/hfqxU70yPwL9ZMkUlwlKxtAohpi2wBEU=
github.com/envoyproxy/go-control-plane/envoy v1.36.0 h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g=
github.com/envoyproxy/go-control-plane/envoy v1.36.0/go.mod h1:ty89S1YCCVruQAm9OtKeEkQLTb+Lkz0k8v9W0Oxsv98=
github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8=
github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
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=
google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0 h1:0UOBWO4dC+e51ui0NFKSPbkHHiQ4TmrEfEZMLDyRmY8=
google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0/go.mod h1:8ytArBbtOy2xfht+y2fqKd5DRDJRUQhqbyEnQ4bDChs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 h1:MAKi5q709QWfnkkpNQ0M12hYJ1+e8qYVDyowc4U1XZM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
main.go
package main

import (
	"fmt"

	resource "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
)

func main() {
	var clusterType resource.Type = resource.ClusterType
	var endpointType resource.Type = resource.EndpointType
	var listenerType resource.Type = resource.ListenerType
	var routeType resource.Type = resource.RouteType
	var secretType resource.Type = resource.SecretType

	fmt.Printf("Cluster Type: %s\n", clusterType)
	fmt.Printf("Endpoint Type: %s\n", endpointType)
	fmt.Printf("Listener Type: %s\n", listenerType)
	fmt.Printf("Route Type: %s\n", routeType)
	fmt.Printf("Secret Type: %s\n", secretType)
	fmt.Println("go-control-plane resource v3 types demonstrated successfully.")
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type in pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/envoyproxy/go-control-plane@v0.14.0"
  ],
  "symbols": [
    "github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

	resource "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
)

func main() {
	// Assertion 1: resource.APITypePrefix is "type.googleapis.com/"
	expectedPrefix := "type.googleapis.com/"
	if resource.APITypePrefix != expectedPrefix {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: APITypePrefix expected %s, got %s\n", expectedPrefix, resource.APITypePrefix)
		os.Exit(1)
	}

	// Assertion 2: standard resource.Type constants match expected xDS v3 type URLs with APITypePrefix
	types := map[resource.Type]string{
		resource.EndpointType:        "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",
		resource.ClusterType:         "type.googleapis.com/envoy.config.cluster.v3.Cluster",
		resource.RouteType:           "type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
		resource.ScopedRouteType:     "type.googleapis.com/envoy.config.route.v3.ScopedRouteConfiguration",
		resource.VirtualHostType:     "type.googleapis.com/envoy.config.route.v3.VirtualHost",
		resource.ListenerType:        "type.googleapis.com/envoy.config.listener.v3.Listener",
		resource.SecretType:          "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret",
		resource.ExtensionConfigType: "type.googleapis.com/envoy.config.core.v3.TypedExtensionConfig",
		resource.RuntimeType:         "type.googleapis.com/envoy.service.runtime.v3.Runtime",
		resource.ThriftRouteType:     "type.googleapis.com/envoy.extensions.filters.network.thrift_proxy.v3.RouteConfiguration",
		resource.RateLimitConfigType: "type.googleapis.com/ratelimit.config.ratelimit.v3.RateLimitConfig",
	}

	for resType, expectedURL := range types {
		if !strings.HasPrefix(string(resType), resource.APITypePrefix) {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: %s does not start with prefix %s\n", resType, resource.APITypePrefix)
			os.Exit(1)
		}
		if string(resType) != expectedURL {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: expected %s, got %s\n", expectedURL, resType)
			os.Exit(1)
		}
	}

	// Assertion 3: resource.AnyType is empty string for ADS
	if resource.AnyType != "" {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: AnyType expected empty string, got %s\n", resource.AnyType)
		os.Exit(1)
	}

	// Assertion 4: resource.Type supports assignment and equality comparison as a string alias
	var currentType resource.Type = resource.ClusterType
	if currentType != resource.ClusterType {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: resource.Type comparison failed\n")
		os.Exit(1)
	}
	if currentType == resource.EndpointType {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: distinct resource.Type values should not match\n")
		os.Exit(1)
	}

	fmt.Println("PASS: github.com/envoyproxy/go-control-plane/pkg/resource/v3.Type verification successful")
}

Seeder de origem

anônimo