Ejemplo
google.golang.org/grpc v1.75.1
Muestra verificada para golang google.golang.org/grpc v1.75.1. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.
sha256:59493ece4a4007799b61aa40714ef039ce228292f559cda319a649542901743e
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-14 |
Caso
HOW- Objetivo
- verify pkg:golang/google.golang.org/grpc@v1.75.1
- Paquetes
- Creado
- 2026-09-14T20:38:15Z
Contrato
- grpc.NewServer creates a server instance configured with unary interceptors and options.
- grpc.NewClient configures an in-memory client connection using WithContextDialer and insecure transport credentials.
- status.New constructs a status object with designated code and message, and status.Code extracts codes.Code.
- metadata.Pairs and metadata.NewIncomingContext inject and retrieve metadata key-value pairs across gRPC context.
- status.Error returns an error wrapping the given status code and description that status.Convert recognizes.
Archivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código fuente
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/grpc@v1.75.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/grpc@v1.75.1
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.
{"case":{"caseId":"case:sha256:6f8bfbfac6debb05da0a8e8fd4a68a41b5bdd2c0462b3e3ee36e1f37c649d3a1","contract":["grpc.NewServer creates a server instance configured with unary interceptors and options.","grpc.NewClient configures an in-memory client connection using WithContextDialer and insecure transport credentials.","status.New constructs a status object with designated code and message, and status.Code extracts codes.Code.","metadata.Pairs and metadata.NewIncomingContext inject and retrieve metadata key-value pairs across gRPC context.","status.Error returns an error wrapping the given status code and description that status.Convert recognizes."],"goal":"verify pkg:golang/google.golang.org/grpc@v1.75.1","kind":"HOW","packages":["pkg:golang/google.golang.org/grpc@v1.75.1"],"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/grpc@v1.75.1"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/grpc@v1.75.1","verifierAdapter":"golang@1"}
module example.com/grpc-sample
go 1.25.0
require google.golang.org/grpc v1.75.1
require (
golang.org/x/net v0.58.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.41.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
google.golang.org/protobuf v1.36.11 // indirect
)
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
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=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
package main
import (
"context"
"fmt"
"net"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/grpc/test/bufconn"
)
const bufSize = 1024 * 1024
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
return handler(ctx, req)
}
func main() {
lis := bufconn.Listen(bufSize)
server := grpc.NewServer(grpc.UnaryInterceptor(unaryInterceptor))
defer server.Stop()
go func() {
if err := server.Serve(lis); err != nil && err != grpc.ErrServerStopped {
fmt.Printf("server error: %v\n", err)
}
}()
conn, err := grpc.NewClient(
"passthrough://bufnet",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
fmt.Printf("client creation failed: %v\n", err)
return
}
defer conn.Close()
md := metadata.Pairs("key", "value")
ctx := metadata.NewIncomingContext(context.Background(), md)
readMD, ok := metadata.FromIncomingContext(ctx)
if !ok || len(readMD.Get("key")) == 0 {
fmt.Println("metadata retrieval failed")
return
}
st := status.New(codes.NotFound, "resource not found")
if st.Code() != codes.NotFound {
fmt.Println("unexpected status code")
return
}
fmt.Println("gRPC verification sample ran successfully")
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/google.golang.org/grpc@v1.75.1",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/grpc@v1.75.1"
]
}
package main
import (
"context"
"fmt"
"net"
"os"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/grpc/test/bufconn"
)
func assert(cond bool, msg string, args ...any) {
if !cond {
fmt.Fprintf(os.Stderr, "CONTRACT ASSERTION FAILED: "+msg+"\n", args...)
os.Exit(1)
}
}
func main() {
// Assertion 1: grpc.NewServer creates a server instance configured with unary interceptors and options.
{
interceptorCalled := false
dummyInterceptor := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
interceptorCalled = true
return handler(ctx, req)
}
server := grpc.NewServer(
grpc.UnaryInterceptor(dummyInterceptor),
grpc.MaxRecvMsgSize(4*1024*1024),
grpc.MaxSendMsgSize(4*1024*1024),
)
assert(server != nil, "grpc.NewServer returned nil")
info := server.GetServiceInfo()
assert(info != nil, "server.GetServiceInfo() returned nil")
server.Stop()
assert(!interceptorCalled, "interceptor should not be called before any request")
}
// Assertion 2: grpc.NewClient configures an in-memory client connection using WithContextDialer and insecure transport credentials.
{
lis := bufconn.Listen(1024 * 1024)
defer lis.Close()
conn, err := grpc.NewClient(
"passthrough://bufnet",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
assert(err == nil, "grpc.NewClient failed: %v", err)
assert(conn != nil, "conn is nil")
assert(conn.Target() == "passthrough://bufnet", "unexpected target: %s", conn.Target())
err = conn.Close()
assert(err == nil, "conn.Close() failed: %v", err)
}
// Assertion 3: status.New constructs a status object with designated code and message, and status.Code extracts codes.Code.
{
st := status.New(codes.NotFound, "resource not found")
assert(st.Code() == codes.NotFound, "expected NotFound code, got %v", st.Code())
assert(st.Message() == "resource not found", "expected message 'resource not found', got %q", st.Message())
err := st.Err()
assert(err != nil, "st.Err() should not be nil")
assert(status.Code(err) == codes.NotFound, "status.Code(err) mismatch: got %v", status.Code(err))
assert(status.Code(nil) == codes.OK, "status.Code(nil) should be OK, got %v", status.Code(nil))
fromErr, ok := status.FromError(err)
assert(ok, "status.FromError should return true for status error")
assert(fromErr.Code() == codes.NotFound, "fromErr.Code() mismatch")
assert(fromErr.Message() == "resource not found", "fromErr.Message() mismatch")
}
// Assertion 4: metadata.Pairs and metadata.NewIncomingContext inject and retrieve metadata key-value pairs across gRPC context.
{
md := metadata.Pairs("x-request-id", "req-12345", "authorization", "bearer-token")
assert(len(md.Get("x-request-id")) == 1 && md.Get("x-request-id")[0] == "req-12345", "metadata.Pairs failed for x-request-id")
assert(len(md.Get("authorization")) == 1 && md.Get("authorization")[0] == "bearer-token", "metadata.Pairs failed for authorization")
ctx := metadata.NewIncomingContext(context.Background(), md)
retrievedMD, ok := metadata.FromIncomingContext(ctx)
assert(ok, "metadata.FromIncomingContext failed")
assert(len(retrievedMD.Get("x-request-id")) == 1 && retrievedMD.Get("x-request-id")[0] == "req-12345", "retrieved x-request-id mismatch")
outCtx := metadata.NewOutgoingContext(context.Background(), md)
retrievedOutMD, outOk := metadata.FromOutgoingContext(outCtx)
assert(outOk, "metadata.FromOutgoingContext failed")
assert(len(retrievedOutMD.Get("authorization")) == 1 && retrievedOutMD.Get("authorization")[0] == "bearer-token", "retrieved authorization mismatch")
}
// Assertion 5: status.Error returns an error wrapping the given status code and description that status.Convert recognizes.
{
err := status.Errorf(codes.InvalidArgument, "invalid field: %s", "userId")
assert(err != nil, "status.Errorf returned nil")
st := status.Convert(err)
assert(st.Code() == codes.InvalidArgument, "expected InvalidArgument, got %v", st.Code())
assert(st.Message() == "invalid field: userId", "unexpected message: %s", st.Message())
}
fmt.Println("All contract assertions passed successfully.")
}
Seeder de origen
anónimo