CodeSampleX

Sample

google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d

Verified sample for golang google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d. The contract ran on go 1.26 · linux debian/x64 …

sha256:e7f10f018cd5ae8b0d828a6445f2ebaa4d489b8fdadd75992779fe3550423da8

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

Case

HOW
Goal
verify pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d
Packages
Created
2026-10-13T03:35:08Z

Contract

  1. Status fields Code, Message, and Details store RPC status information and are accessible via GetCode, GetMessage, and GetDetails getters.
  2. Status getters return safe zero values (0, empty string, and nil slice) when called on nil or zero-initialized Status receivers.
  3. Status details field supports packing and unpacking structured error messages such as ErrorInfo via anypb.New and UnmarshalTo.
  4. Status serializes and deserializes accurately with proto.Marshal and proto.Unmarshal, preserving Code, Message, and Details.
  5. Status messages support deep copying with proto.Clone, semantic equality with proto.Equal, and resetting via Reset.

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 pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d

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:1e73c373c01ceafe583740dd7af463623add365627f02547b8325930aad1cec7","contract":["Status fields Code, Message, and Details store RPC status information and are accessible via GetCode, GetMessage, and GetDetails getters.","Status getters return safe zero values (0, empty string, and nil slice) when called on nil or zero-initialized Status receivers.","Status details field supports packing and unpacking structured error messages such as ErrorInfo via anypb.New and UnmarshalTo.","Status serializes and deserializes accurately with proto.Marshal and proto.Unmarshal, preserving Code, Message, and Details.","Status messages support deep copying with proto.Clone, semantic equality with proto.Equal, and resetting via Reset."],"goal":"verify pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d"],"schemaVersion":1},"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-20260715232425-e75dac1f907d"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d","verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require (
	google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d
	google.golang.org/protobuf v1.36.12
)
go.sum
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d h1:Jkpk39hlTZOIp3RbfvNX9R8Hv+Sw0X89nlU/xFOErsc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
main.go
package main

import (
	"fmt"

	"google.golang.org/genproto/googleapis/rpc/code"
	"google.golang.org/genproto/googleapis/rpc/errdetails"
	"google.golang.org/genproto/googleapis/rpc/status"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/types/known/anypb"
)

func main() {
	detail := &errdetails.ErrorInfo{
		Reason: "RATE_LIMIT_EXCEEDED",
		Domain: "example.com",
		Metadata: map[string]string{
			"service": "api.example.com",
		},
	}
	anyDetail, err := anypb.New(detail)
	if err != nil {
		panic(err)
	}

	st := &status.Status{
		Code:    int32(code.Code_RESOURCE_EXHAUSTED),
		Message: "request quota exceeded",
		Details: []*anypb.Any{anyDetail},
	}

	fmt.Printf("Code: %d, Message: %s\n", st.GetCode(), st.GetMessage())
	fmt.Printf("Details count: %d\n", len(st.GetDetails()))

	data, err := proto.Marshal(st)
	if err != nil {
		panic(err)
	}

	var decoded status.Status
	if err := proto.Unmarshal(data, &decoded); err != nil {
		panic(err)
	}

	fmt.Printf("Decoded Code: %d, Message: %s\n", decoded.GetCode(), decoded.GetMessage())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260715232425-e75dac1f907d"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/rpc/code"
	"google.golang.org/genproto/googleapis/rpc/errdetails"
	"google.golang.org/genproto/googleapis/rpc/status"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/types/known/anypb"
)

func main() {
	// Assertion 1: Status fields Code, Message, and Details store RPC status information and are accessible via GetCode, GetMessage, and GetDetails getters.
	{
		detail := &errdetails.ErrorInfo{
			Reason: "RESOURCE_EXHAUSTED",
			Domain: "example.com",
			Metadata: map[string]string{
				"quota": "100",
			},
		}
		anyDetail, err := anypb.New(detail)
		if err != nil {
			fmt.Fprintf(os.Stderr, "FAIL: anypb.New failed: %v\n", err)
			os.Exit(1)
		}

		st := &status.Status{
			Code:    int32(code.Code_RESOURCE_EXHAUSTED),
			Message: "quota limit reached",
			Details: []*anypb.Any{anyDetail},
		}

		if got := st.GetCode(); got != int32(code.Code_RESOURCE_EXHAUSTED) {
			fmt.Fprintf(os.Stderr, "FAIL: GetCode() = %d, want %d\n", got, int32(code.Code_RESOURCE_EXHAUSTED))
			os.Exit(1)
		}
		if got := st.GetMessage(); got != "quota limit reached" {
			fmt.Fprintf(os.Stderr, "FAIL: GetMessage() = %q, want quota limit reached\n", got)
			os.Exit(1)
		}
		if got := st.GetDetails(); len(got) != 1 || got[0] != anyDetail {
			fmt.Fprintf(os.Stderr, "FAIL: GetDetails() = %v, want [%v]\n", got, anyDetail)
			os.Exit(1)
		}
	}

	// Assertion 2: Status getters return safe zero values (0, empty string, and nil slice) when called on nil or zero-initialized Status receivers.
	{
		var nilSt *status.Status
		if got := nilSt.GetCode(); got != 0 {
			fmt.Fprintf(os.Stderr, "FAIL: nil.GetCode() = %d, want 0\n", got)
			os.Exit(1)
		}
		if got := nilSt.GetMessage(); got != "" {
			fmt.Fprintf(os.Stderr, "FAIL: nil.GetMessage() = %q, want empty string\n", got)
			os.Exit(1)
		}
		if got := nilSt.GetDetails(); got != nil {
			fmt.Fprintf(os.Stderr, "FAIL: nil.GetDetails() = %v, want nil\n", got)
			os.Exit(1)
		}

		zeroSt := &status.Status{}
		if got := zeroSt.GetCode(); got != 0 {
			fmt.Fprintf(os.Stderr, "FAIL: zero.GetCode() = %d, want 0\n", got)
			os.Exit(1)
		}
		if got := zeroSt.GetMessage(); got != "" {
			fmt.Fprintf(os.Stderr, "FAIL: zero.GetMessage() = %q, want empty string\n", got)
			os.Exit(1)
		}
		if got := zeroSt.GetDetails(); got != nil {
			fmt.Fprintf(os.Stderr, "FAIL: zero.GetDetails() = %v, want nil\n", got)
			os.Exit(1)
		}
	}

	// Assertion 3: Status details field supports packing and unpacking structured error messages such as ErrorInfo via anypb.New and UnmarshalTo.
	{
		original := &errdetails.ErrorInfo{
			Reason: "PERMISSION_DENIED",
			Domain: "example.com",
			Metadata: map[string]string{
				"permission": "read",
			},
		}
		anyDetail, err := anypb.New(original)
		if err != nil {
			fmt.Fprintf(os.Stderr, "FAIL: anypb.New failed: %v\n", err)
			os.Exit(1)
		}

		st := &status.Status{
			Code:    int32(code.Code_PERMISSION_DENIED),
			Message: "access forbidden",
			Details: []*anypb.Any{anyDetail},
		}

		if len(st.GetDetails()) != 1 {
			fmt.Fprintf(os.Stderr, "FAIL: expected 1 detail, got %d\n", len(st.GetDetails()))
			os.Exit(1)
		}

		var unpacked errdetails.ErrorInfo
		if err := st.GetDetails()[0].UnmarshalTo(&unpacked); err != nil {
			fmt.Fprintf(os.Stderr, "FAIL: UnmarshalTo failed: %v\n", err)
			os.Exit(1)
		}

		if !proto.Equal(original, &unpacked) {
			fmt.Fprintf(os.Stderr, "FAIL: unpacked detail %+v does not match original %+v\n", &unpacked, original)
			os.Exit(1)
		}
	}

	// Assertion 4: Status serializes and deserializes accurately with proto.Marshal and proto.Unmarshal, preserving Code, Message, and Details.
	{
		detail := &errdetails.ErrorInfo{
			Reason: "INVALID_ARGUMENT",
			Domain: "example.com",
		}
		anyDetail, err := anypb.New(detail)
		if err != nil {
			fmt.Fprintf(os.Stderr, "FAIL: anypb.New failed: %v\n", err)
			os.Exit(1)
		}

		st := &status.Status{
			Code:    int32(code.Code_INVALID_ARGUMENT),
			Message: "bad request parameter",
			Details: []*anypb.Any{anyDetail},
		}

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

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

		if !proto.Equal(st, &decoded) {
			fmt.Fprintf(os.Stderr, "FAIL: unmarshaled status %+v does not match original %+v\n", &decoded, st)
			os.Exit(1)
		}
	}

	// Assertion 5: Status messages support deep copying with proto.Clone, semantic equality with proto.Equal, and resetting via Reset.
	{
		st := &status.Status{
			Code:    int32(code.Code_UNAVAILABLE),
			Message: "service unavailable",
		}

		cloned, ok := proto.Clone(st).(*status.Status)
		if !ok {
			fmt.Fprintf(os.Stderr, "FAIL: proto.Clone did not return *status.Status\n")
			os.Exit(1)
		}

		if !proto.Equal(st, cloned) {
			fmt.Fprintf(os.Stderr, "FAIL: cloned status %+v not equal to original %+v\n", cloned, st)
			os.Exit(1)
		}

		st.Reset()
		if st.GetCode() != 0 || st.GetMessage() != "" || len(st.GetDetails()) != 0 {
			fmt.Fprintf(os.Stderr, "FAIL: Reset did not restore zero values: code=%d message=%q details=%v\n",
				st.GetCode(), st.GetMessage(), st.GetDetails())
			os.Exit(1)
		}
	}

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

Origin Seeder

anonymous