CodeSampleX

Sample

google.golang.org/grpc v1.82.0: codes.OK

Verified sample for golang google.golang.org/grpc v1.82.0: codes.OK. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:415dba91ea1735ad654ea8476afc82e4c692fe0130b2bd6cf565e0ae9767ed4f

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

Case

HOW
Goal
verify google.golang.org/grpc/codes.OK in pkg:golang/google.golang.org/grpc@v1.82.0
Packages
Symbols
  • google.golang.org/grpc/codes.OK
Environment
go
Created
2026-10-12T12:29:35Z

Contract

  1. codes.OK has numeric value 0 and string representation 'OK'.
  2. codes.OK unmarshals from JSON string 'OK' and JSON number 0, and marshals to numeric 0.
  3. status.Code returns codes.OK for nil error, and status.New(codes.OK, msg) has code codes.OK with Err() == nil.

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • sample.go
  • spec.json
  • test/contract_test.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/grpc/codes.OK in pkg:golang/google.golang.org/grpc@v1.82.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/grpc@v1.82.0
Demonstrate these symbols/APIs:
  - google.golang.org/grpc/codes.OK

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:feec787f4b66745bbdc2e9fe09578a6e57549db344104ae8d76a3369273a3c6b","contract":["codes.OK has numeric value 0 and string representation 'OK'.","codes.OK unmarshals from JSON string 'OK' and JSON number 0, and marshals to numeric 0.","status.Code returns codes.OK for nil error, and status.New(codes.OK, msg) has code codes.OK with Err() == nil."],"goal":"verify google.golang.org/grpc/codes.OK in pkg:golang/google.golang.org/grpc@v1.82.0","kind":"HOW","packages":["pkg:golang/google.golang.org/grpc@v1.82.0"],"schemaVersion":1,"symbols":["google.golang.org/grpc/codes.OK"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","moduleSystem":"go.mod","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/google.golang.org/grpc@v1.82.0"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/grpc@v1.82.0","symbols":["google.golang.org/grpc/codes.OK"],"verifierAdapter":"golang@1"}
go.mod
module example.com/grpcok

go 1.25.0

require google.golang.org/grpc v1.82.0

require (
	golang.org/x/sys v0.43.0 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect
	google.golang.org/protobuf v1.36.11 // indirect
)
go.sum
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
sample.go
package grpcok

import (
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

// IsOK reports whether the code is codes.OK.
func IsOK(c codes.Code) bool {
	return c == codes.OK
}

// StatusCode returns the gRPC status code for err, returning codes.OK if err is nil.
func StatusCode(err error) codes.Code {
	return status.Code(err)
}

// NewOKStatus creates a gRPC Status with codes.OK and the provided message.
func NewOKStatus(msg string) *status.Status {
	return status.New(codes.OK, msg)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/grpc/codes.OK in pkg:golang/google.golang.org/grpc@v1.82.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/grpc@v1.82.0"
  ],
  "symbols": [
    "google.golang.org/grpc/codes.OK"
  ]
}
test/contract_test.go
package contract_test

import (
	"encoding/json"
	"testing"

	grpcok "example.com/grpcok"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

func TestCodesOKValueAndString(t *testing.T) {
	if got := uint32(codes.OK); got != 0 {
		t.Fatalf("expected uint32(codes.OK) == 0, got %d", got)
	}

	if got := codes.OK.String(); got != "OK" {
		t.Fatalf("expected codes.OK.String() == %q, got %q", "OK", got)
	}

	if !grpcok.IsOK(codes.OK) {
		t.Fatalf("expected grpcok.IsOK(codes.OK) == true")
	}

	if grpcok.IsOK(codes.NotFound) {
		t.Fatalf("expected grpcok.IsOK(codes.NotFound) == false")
	}
}

func TestCodesOKJSON(t *testing.T) {
	var c codes.Code
	if err := json.Unmarshal([]byte(`"OK"`), &c); err != nil {
		t.Fatalf("Unmarshal \"OK\" failed: %v", err)
	}
	if c != codes.OK {
		t.Fatalf("expected c == codes.OK, got %v", c)
	}

	if err := json.Unmarshal([]byte(`0`), &c); err != nil {
		t.Fatalf("Unmarshal 0 failed: %v", err)
	}
	if c != codes.OK {
		t.Fatalf("expected c == codes.OK, got %v", c)
	}

	b, err := json.Marshal(codes.OK)
	if err != nil {
		t.Fatalf("Marshal codes.OK failed: %v", err)
	}
	if string(b) != "0" {
		t.Fatalf("expected Marshal(codes.OK) == %q, got %q", "0", string(b))
	}
}

func TestCodesOKStatusIntegration(t *testing.T) {
	if got := status.Code(nil); got != codes.OK {
		t.Fatalf("expected status.Code(nil) == codes.OK, got %v", got)
	}
	if got := grpcok.StatusCode(nil); got != codes.OK {
		t.Fatalf("expected grpcok.StatusCode(nil) == codes.OK, got %v", got)
	}

	st := grpcok.NewOKStatus("operation succeeded")
	if st.Code() != codes.OK {
		t.Fatalf("expected st.Code() == codes.OK, got %v", st.Code())
	}
	if st.Message() != "operation succeeded" {
		t.Fatalf("expected st.Message() == 'operation succeeded', got %q", st.Message())
	}
	if err := st.Err(); err != nil {
		t.Fatalf("expected st.Err() == nil for OK status, got %v", err)
	}
}

Origin Seeder

anonymous