Ejemplo
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401001100-f93e5f3e9f0f: code.Code_INVALID_ARGUMENT
Muestra verificada para golang google.golang.org/genproto/googleapis/rpc v0.0.0-20260401001100-f93e5f3e9f0f: code.Code_INVALID_ARGUMENT. El contrato se…
sha256:8de04c3c3f70efba01a80ac1f9112c02f2ac0ea2fdf98de061425bee3348a3e9
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-10-14 |
Caso
HOW- Objetivo
- verify google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f
- Símbolos
-
- google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT
- Creado
- 2026-10-14T19:19:16Z
Contrato
- code.Code_INVALID_ARGUMENT has numeric enum value 3
- code.Code_INVALID_ARGUMENT string formatting and lookup tables (Code_name and Code_value) round-trip
- status.Status with Code_INVALID_ARGUMENT marshals and unmarshals via protobuf preserving code and message
- status.Status with Code_INVALID_ARGUMENT attaches and unpacks errdetails.BadRequest field violations
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 google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT
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:70af42cad3d193b7e655b5f05b860704bdf57416c8967b224ebfb25babf44a9d","contract":["code.Code_INVALID_ARGUMENT has numeric enum value 3","code.Code_INVALID_ARGUMENT string formatting and lookup tables (Code_name and Code_value) round-trip","status.Status with Code_INVALID_ARGUMENT marshals and unmarshals via protobuf preserving code and message","status.Status with Code_INVALID_ARGUMENT attaches and unpacks errdetails.BadRequest field violations"],"goal":"verify google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT"]},"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-20260401001100-f93e5f3e9f0f"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f","symbols":["google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401001100-f93e5f3e9f0f
google.golang.org/protobuf v1.36.11
)
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-20260401001100-f93e5f3e9f0f h1:Rka45QInERYknkHYfJEPBQaoobXl+YpxTMjAKgWUq2A=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401001100-f93e5f3e9f0f/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
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 (
"fmt"
"log"
"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() {
badRequest := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{
{
Field: "request_id",
Description: "request_id must be a non-empty string",
},
},
}
anyDetail, err := anypb.New(badRequest)
if err != nil {
log.Fatalf("failed to pack BadRequest detail: %v", err)
}
st := &status.Status{
Code: int32(code.Code_INVALID_ARGUMENT),
Message: "invalid argument in client request",
Details: []*anypb.Any{anyDetail},
}
raw, err := proto.Marshal(st)
if err != nil {
log.Fatalf("failed to marshal status: %v", err)
}
var roundtrip status.Status
if err := proto.Unmarshal(raw, &roundtrip); err != nil {
log.Fatalf("failed to unmarshal status: %v", err)
}
fmt.Printf("Code: %d (%s)\n", roundtrip.GetCode(), code.Code(roundtrip.GetCode()).String())
fmt.Printf("Message: %s\n", roundtrip.GetMessage())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260401001100-f93e5f3e9f0f"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/code.Code_INVALID_ARGUMENT"
]
}
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 assert(cond bool, msg string) {
if !cond {
fmt.Fprintf(os.Stderr, "contract failure: %s\n", msg)
os.Exit(1)
}
}
func main() {
// 1. code.Code_INVALID_ARGUMENT has numeric enum value 3
assert(code.Code_INVALID_ARGUMENT == 3, "Code_INVALID_ARGUMENT must equal 3")
assert(int32(code.Code_INVALID_ARGUMENT) == 3, "int32(Code_INVALID_ARGUMENT) must equal 3")
assert(code.Code_INVALID_ARGUMENT.Number() == 3, "Code_INVALID_ARGUMENT.Number() must equal 3")
// 2. code.Code_INVALID_ARGUMENT string formatting and lookup tables (Code_name and Code_value) round-trip
assert(code.Code_INVALID_ARGUMENT.String() == "INVALID_ARGUMENT", "Code_INVALID_ARGUMENT.String() must be INVALID_ARGUMENT")
assert(code.Code_name[int32(code.Code_INVALID_ARGUMENT)] == "INVALID_ARGUMENT", "Code_name[3] must be INVALID_ARGUMENT")
assert(code.Code_value["INVALID_ARGUMENT"] == int32(code.Code_INVALID_ARGUMENT), "Code_value[INVALID_ARGUMENT] must be 3")
// 3. status.Status with Code_INVALID_ARGUMENT marshals and unmarshals via protobuf preserving code and message
st := &status.Status{
Code: int32(code.Code_INVALID_ARGUMENT),
Message: "invalid argument: request_id must be non-empty",
}
assert(st.GetCode() == int32(code.Code_INVALID_ARGUMENT), "status code must equal Code_INVALID_ARGUMENT")
wire, err := proto.Marshal(st)
assert(err == nil && len(wire) > 0, "proto.Marshal(status) must succeed")
var decoded status.Status
err = proto.Unmarshal(wire, &decoded)
assert(err == nil, "proto.Unmarshal(status) must succeed")
assert(code.Code(decoded.GetCode()) == code.Code_INVALID_ARGUMENT, "decoded status code must match Code_INVALID_ARGUMENT")
assert(decoded.GetMessage() == "invalid argument: request_id must be non-empty", "decoded status message must match")
// 4. status.Status with Code_INVALID_ARGUMENT attaches and unpacks errdetails.BadRequest field violations
badReq := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{
{
Field: "request_id",
Description: "request_id must be a non-empty string",
},
},
}
detailAny, err := anypb.New(badReq)
assert(err == nil, "anypb.New(BadRequest) must succeed")
st.Details = []*anypb.Any{detailAny}
var unpacked errdetails.BadRequest
err = st.GetDetails()[0].UnmarshalTo(&unpacked)
assert(err == nil, "UnmarshalTo(BadRequest) must succeed")
assert(len(unpacked.GetFieldViolations()) == 1, "expected 1 field violation")
assert(unpacked.GetFieldViolations()[0].GetField() == "request_id", "field violation name must match")
fmt.Println("contract passed")
}
Seeder de origen
anónimo