CodeSampleX

Sample

google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7: errdetails.RequestInfo

Verified sample for golang google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7: errdetails.RequestInfo. The contract ran on go 1.26…

sha256:8297d254ab546dc9843b1ed9801b2ba62b3dad85934e596caee1b87f208dd4b7

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 alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-27

Case

HOW
Goal
verify google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7
Packages
Symbols
  • google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo
Created
2026-08-27T17:31:33Z

Contract

  1. RequestInfo correctly stores and returns RequestId and ServingData fields via getters
  2. Getters return safe empty string defaults when called on a nil RequestInfo pointer
  3. RequestInfo correctly serializes to and deserializes from protocol buffer binary format
  4. Reset clears all fields of a RequestInfo instance to their zero values
  5. ProtoReflect returns a valid Message descriptor matching google.rpc.RequestInfo full name

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 google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7
Demonstrate these symbols/APIs:
  - google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo

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:524d89c03945786edfcfefd423638f16a388ce1e228e0ea85249ba05795de46a","contract":["RequestInfo correctly stores and returns RequestId and ServingData fields via getters","Getters return safe empty string defaults when called on a nil RequestInfo pointer","RequestInfo correctly serializes to and deserializes from protocol buffer binary format","Reset clears all fields of a RequestInfo instance to their zero values","ProtoReflect returns a valid Message descriptor matching google.rpc.RequestInfo full name"],"goal":"verify google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo"]},"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/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7","symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22.0

require (
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7
	google.golang.org/protobuf v1.34.2
)
go.sum
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 h1:2035KHhUv+EpyB+hWgJnaWKJOdX1E95w2S8Rr4uWKTs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
main.go
package main

import (
	"fmt"

	"google.golang.org/genproto/googleapis/rpc/errdetails"
	"google.golang.org/protobuf/proto"
)

// CreateRequestInfo creates a RequestInfo instance with the given request ID and serving data.
func CreateRequestInfo(requestID, servingData string) *errdetails.RequestInfo {
	return &errdetails.RequestInfo{
		RequestId:   requestID,
		ServingData: servingData,
	}
}

// MarshalRequestInfo serializes a RequestInfo proto message to binary format.
func MarshalRequestInfo(info *errdetails.RequestInfo) ([]byte, error) {
	return proto.Marshal(info)
}

// UnmarshalRequestInfo deserializes binary data into a RequestInfo proto message.
func UnmarshalRequestInfo(data []byte) (*errdetails.RequestInfo, error) {
	var info errdetails.RequestInfo
	if err := proto.Unmarshal(data, &info); err != nil {
		return nil, err
	}
	return &info, nil
}

func main() {
	info := CreateRequestInfo("req-12345-abcde", "cluster-us-east-1a:service-worker-42")

	fmt.Printf("Request ID: %s\n", info.GetRequestId())
	fmt.Printf("Serving Data: %s\n", info.GetServingData())

	data, err := MarshalRequestInfo(info)
	if err != nil {
		panic(err)
	}

	decoded, err := UnmarshalRequestInfo(data)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Decoded Request ID: %s\n", decoded.GetRequestId())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20240826202546-f6391c0de4c7"
  ],
  "symbols": [
    "google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/rpc/errdetails"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/reflect/protoreflect"
)

func main() {
	// Assertion 1: RequestInfo correctly stores and returns RequestId and ServingData fields via getters
	req := &errdetails.RequestInfo{
		RequestId:   "req-trace-987654",
		ServingData: "us-west2/pod-981-worker",
	}

	if got := req.GetRequestId(); got != "req-trace-987654" {
		fmt.Fprintf(os.Stderr, "FAIL: GetRequestId mismatch: got %q, want %q\n", got, "req-trace-987654")
		os.Exit(1)
	}
	if got := req.GetServingData(); got != "us-west2/pod-981-worker" {
		fmt.Fprintf(os.Stderr, "FAIL: GetServingData mismatch: got %q, want %q\n", got, "us-west2/pod-981-worker")
		os.Exit(1)
	}

	// Assertion 2: Getters return safe empty string defaults when called on a nil RequestInfo pointer
	var nilReq *errdetails.RequestInfo
	if got := nilReq.GetRequestId(); got != "" {
		fmt.Fprintf(os.Stderr, "FAIL: nil GetRequestId expected empty string, got %q\n", got)
		os.Exit(1)
	}
	if got := nilReq.GetServingData(); got != "" {
		fmt.Fprintf(os.Stderr, "FAIL: nil GetServingData expected empty string, got %q\n", got)
		os.Exit(1)
	}

	// Assertion 3: RequestInfo correctly serializes to and deserializes from protocol buffer binary format
	data, err := proto.Marshal(req)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: proto.Marshal failed: %v\n", err)
		os.Exit(1)
	}
	if len(data) == 0 {
		fmt.Fprintf(os.Stderr, "FAIL: marshaled proto data is empty\n")
		os.Exit(1)
	}

	var unmarshaled errdetails.RequestInfo
	if err := proto.Unmarshal(data, &unmarshaled); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: proto.Unmarshal failed: %v\n", err)
		os.Exit(1)
	}
	if !proto.Equal(req, &unmarshaled) {
		fmt.Fprintf(os.Stderr, "FAIL: unmarshaled proto does not equal original\n")
		os.Exit(1)
	}

	// Assertion 4: Reset clears all fields of a RequestInfo instance to their zero values
	copyReq := &errdetails.RequestInfo{
		RequestId:   "temp-id",
		ServingData: "temp-data",
	}
	copyReq.Reset()
	if copyReq.GetRequestId() != "" || copyReq.GetServingData() != "" {
		fmt.Fprintf(os.Stderr, "FAIL: Reset failed to clear all fields\n")
		os.Exit(1)
	}

	// Assertion 5: ProtoReflect returns a valid Message descriptor matching google.rpc.RequestInfo full name
	msg := req.ProtoReflect()
	descriptor := msg.Descriptor()
	if string(descriptor.FullName()) != "google.rpc.RequestInfo" {
		fmt.Fprintf(os.Stderr, "FAIL: Descriptor FullName mismatch: got %q, want %q\n", descriptor.FullName(), "google.rpc.RequestInfo")
		os.Exit(1)
	}
	reqIdField := descriptor.Fields().ByName(protoreflect.Name("request_id"))
	if reqIdField == nil {
		fmt.Fprintf(os.Stderr, "FAIL: field descriptor for request_id not found\n")
		os.Exit(1)
	}
	servingDataField := descriptor.Fields().ByName(protoreflect.Name("serving_data"))
	if servingDataField == nil {
		fmt.Fprintf(os.Stderr, "FAIL: field descriptor for serving_data not found\n")
		os.Exit(1)
	}

	fmt.Println("PASS: google.golang.org/genproto/googleapis/rpc/errdetails.RequestInfo contract verified")
}

Origin Seeder

anonymous