CodeSampleX

Sample

github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443: v3.ResourceLocator_Scheme

Verified sample for golang github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443: v3.ResourceLocator_Scheme. The contract ran on go 1.26 · linux…

sha256:0965e9bfd83ecc3449d267d6ecd37a16befb093a2b1233dc95613156e50cf416

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 go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

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-09

Case

HOW
Goal
verify github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme in pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443
Packages
Symbols
  • github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme
Environment
go 1.26.6
Created
2026-10-09T21:36:52Z

Contract

  1. ResourceLocator_Scheme enum constants evaluate to expected integer values 0 for XDSTP, 1 for HTTP, and 2 for FILE
  2. ResourceLocator_Scheme String method returns the protobuf identifier names XDSTP, HTTP, and FILE
  3. ResourceLocator_Scheme_name and ResourceLocator_Scheme_value maps correctly convert between enum values and strings
  4. ResourceLocator GetScheme returns the configured ResourceLocator_Scheme or default XDSTP when unset or nil

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • 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/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme in pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443
Demonstrate these symbols/APIs:
  - github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme

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:ebb2773d0dc8041cb3ac3c17943c5bae6b3cfe25c8ad72bb38fc96d6861342ca","contract":["ResourceLocator_Scheme enum constants evaluate to expected integer values 0 for XDSTP, 1 for HTTP, and 2 for FILE","ResourceLocator_Scheme String method returns the protobuf identifier names XDSTP, HTTP, and FILE","ResourceLocator_Scheme_name and ResourceLocator_Scheme_value maps correctly convert between enum values and strings","ResourceLocator GetScheme returns the configured ResourceLocator_Scheme or default XDSTP when unset or nil"],"goal":"verify github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme in pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443","kind":"HOW","packages":["pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443"],"schemaVersion":1,"symbols":["github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443"],"schemaVersion":1,"subject":"pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443","symbols":["github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443

require (
	github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
	google.golang.org/protobuf v1.33.0 // indirect
)
go.sum
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/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
main.go
package main

import (
	"fmt"

	v3 "github.com/cncf/xds/go/xds/core/v3"
)

func main() {
	xdstpScheme := v3.ResourceLocator_XDSTP
	httpScheme := v3.ResourceLocator_HTTP
	fileScheme := v3.ResourceLocator_FILE

	fmt.Printf("Scheme values: XDSTP=%d (%s), HTTP=%d (%s), FILE=%d (%s)\n",
		xdstpScheme, xdstpScheme.String(),
		httpScheme, httpScheme.String(),
		fileScheme, fileScheme.String(),
	)

	locator := &v3.ResourceLocator{
		Scheme:       v3.ResourceLocator_XDSTP,
		Authority:    "example.com",
		ResourceType: "envoy.config.cluster.v3.Cluster",
		Id:           "service-cluster",
	}

	fmt.Printf("Configured ResourceLocator Scheme: %s (number: %d)\n",
		locator.GetScheme().String(),
		locator.GetScheme().Number(),
	)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme in pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/cncf/xds/go@v0.0.0-20250501225837-2ac532fd4443"
  ],
  "symbols": [
    "github.com/cncf/xds/go/xds/core/v3.ResourceLocator_Scheme"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	v3 "github.com/cncf/xds/go/xds/core/v3"
)

func main() {
	// Assertion 1: ResourceLocator_Scheme enum constants evaluate to expected integer values 0 for XDSTP, 1 for HTTP, and 2 for FILE
	{
		if v3.ResourceLocator_XDSTP != 0 || v3.ResourceLocator_HTTP != 1 || v3.ResourceLocator_FILE != 2 {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: enum integer values mismatch\n")
			os.Exit(1)
		}
		if v3.ResourceLocator_XDSTP.Number() != 0 || v3.ResourceLocator_HTTP.Number() != 1 || v3.ResourceLocator_FILE.Number() != 2 {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: enum Number() return values mismatch\n")
			os.Exit(1)
		}
	}

	// Assertion 2: ResourceLocator_Scheme String method returns the protobuf identifier names XDSTP, HTTP, and FILE
	{
		if v3.ResourceLocator_XDSTP.String() != "XDSTP" {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: XDSTP string mismatch, got %q\n", v3.ResourceLocator_XDSTP.String())
			os.Exit(1)
		}
		if v3.ResourceLocator_HTTP.String() != "HTTP" {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: HTTP string mismatch, got %q\n", v3.ResourceLocator_HTTP.String())
			os.Exit(1)
		}
		if v3.ResourceLocator_FILE.String() != "FILE" {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: FILE string mismatch, got %q\n", v3.ResourceLocator_FILE.String())
			os.Exit(1)
		}
	}

	// Assertion 3: ResourceLocator_Scheme_name and ResourceLocator_Scheme_value maps correctly convert between enum values and strings
	{
		if v3.ResourceLocator_Scheme_name[0] != "XDSTP" || v3.ResourceLocator_Scheme_name[1] != "HTTP" || v3.ResourceLocator_Scheme_name[2] != "FILE" {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: ResourceLocator_Scheme_name map values mismatch\n")
			os.Exit(1)
		}
		if v3.ResourceLocator_Scheme_value["XDSTP"] != 0 || v3.ResourceLocator_Scheme_value["HTTP"] != 1 || v3.ResourceLocator_Scheme_value["FILE"] != 2 {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: ResourceLocator_Scheme_value map values mismatch\n")
			os.Exit(1)
		}
	}

	// Assertion 4: ResourceLocator GetScheme returns the configured ResourceLocator_Scheme or default XDSTP when unset or nil
	{
		loc := &v3.ResourceLocator{Scheme: v3.ResourceLocator_HTTP}
		if loc.GetScheme() != v3.ResourceLocator_HTTP {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: GetScheme on configured locator failed\n")
			os.Exit(1)
		}

		emptyLoc := &v3.ResourceLocator{}
		if emptyLoc.GetScheme() != v3.ResourceLocator_XDSTP {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: GetScheme on empty locator should default to XDSTP\n")
			os.Exit(1)
		}

		var nilLoc *v3.ResourceLocator
		if nilLoc.GetScheme() != v3.ResourceLocator_XDSTP {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: GetScheme on nil locator should return XDSTP\n")
			os.Exit(1)
		}
	}

	fmt.Println("All ResourceLocator_Scheme contract assertions passed successfully.")
}

Origin Seeder

anonymous