Exemplo
github.com/lyft/protoc-gen-star/v2 v2.0.3
Amostra verificada para golang github.com/lyft/protoc-gen-star/v2 v2.0.3. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:fd4ac1c62c5361f38b66df8bc7ce90ff3360e4a9d03e7171aaad711ea56308d9
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-11 |
Caso
HOW- Objetivo
- verify pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3
- Criado
- 2026-10-11T13:59:20Z
Contrato
- ParseParameters parses comma-separated key-value pairs and extracts string, integer, and boolean values
- Parameters methods return defaults when keys are absent and report errors for invalid type conversions
- FilePath methods manipulate paths, extract directory, base name, and extension, and allow extension replacement
- Name methods convert proto identifiers between UpperCamelCase, LowerCamelCase, SnakeCase, and ScreamingSnakeCase
- InitMockDebugger creates a mock debugger that tracks debug logs, errors, and exit codes without terminating the process
- ProcessFileDescriptorSet parses a FileDescriptorSet into an AST graph and supports entity Lookup by fully qualified name
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código-fonte
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/github.com/lyft/protoc-gen-star/v2@v2.0.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3
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:ad694462f3a03764be13ab7f3ad1f0b991304d595dd696386ff7d6effeccb9d3","contract":["ParseParameters parses comma-separated key-value pairs and extracts string, integer, and boolean values","Parameters methods return defaults when keys are absent and report errors for invalid type conversions","FilePath methods manipulate paths, extract directory, base name, and extension, and allow extension replacement","Name methods convert proto identifiers between UpperCamelCase, LowerCamelCase, SnakeCase, and ScreamingSnakeCase","InitMockDebugger creates a mock debugger that tracks debug logs, errors, and exit codes without terminating the process","ProcessFileDescriptorSet parses a FileDescriptorSet into an AST graph and supports entity Lookup by fully qualified name"],"goal":"verify pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3","kind":"HOW","packages":["pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3"],"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/github.com/lyft/protoc-gen-star/v2@v2.0.3"],"schemaVersion":1,"subject":"pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3","verifierAdapter":"golang@1"}
module sample
go 1.26.6
require (
github.com/lyft/protoc-gen-star/v2 v2.0.3
google.golang.org/protobuf v1.23.0
)
require (
github.com/spf13/afero v1.3.3 // indirect
golang.org/x/text v0.3.7 // indirect
)
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/lyft/protoc-gen-star/v2 v2.0.3 h1:/3+/2sWyXeMLzKd1bX+ixWKgEMsULrIivpDsuaF441o=
github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/afero v1.3.3 h1:p5gZEKLYoL7wh8VrJesMaYeNxdEd1v3cb4irOk9zB54=
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package main
import (
"fmt"
pgs "github.com/lyft/protoc-gen-star/v2"
"google.golang.org/protobuf/types/descriptorpb"
)
func main() {
// Parse parameters passed to a protoc plugin
params := pgs.ParseParameters("lang=go,plugins=grpc")
fmt.Printf("Parsed parameters: lang=%s, plugins=%s\n", params.Str("lang"), params.Str("plugins"))
// Format entity names
entityName := pgs.Name("order_service")
fmt.Printf("CamelCase name: %s\n", entityName.UpperCamelCase())
// Manage file paths
filePath := pgs.JoinPaths("proto", "service.proto")
fmt.Printf("Generated output path: %s\n", filePath.SetExt(".pb.go"))
// Create and inspect AST
fileName := "service.proto"
pkgName := "services.order"
msgName := "Order"
fdset := &descriptorpb.FileDescriptorSet{
File: []*descriptorpb.FileDescriptorProto{
{
Name: &fileName,
Package: &pkgName,
MessageType: []*descriptorpb.DescriptorProto{
{
Name: &msgName,
},
},
},
},
}
dbg := pgs.InitMockDebugger()
ast := pgs.ProcessFileDescriptorSet(dbg, fdset)
if ent, ok := ast.Lookup(".services.order.Order"); ok {
fmt.Printf("Found entity in AST: %s\n", ent.FullyQualifiedName())
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3"
]
}
package main
import (
"fmt"
"os"
pgs "github.com/lyft/protoc-gen-star/v2"
"google.golang.org/protobuf/types/descriptorpb"
)
func main() {
if err := runTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All contract tests passed successfully.")
}
func runTests() error {
// 1. ParseParameters parses comma-separated key-value pairs and extracts string, integer, and boolean values
{
params := pgs.ParseParameters("lang=go,count=42,optimize=true")
if val := params.Str("lang"); val != "go" {
return fmt.Errorf("expected lang=go, got %s", val)
}
count, err := params.Int("count")
if err != nil || count != 42 {
return fmt.Errorf("expected count=42, got %d (err: %v)", count, err)
}
opt, err := params.Bool("optimize")
if err != nil || !opt {
return fmt.Errorf("expected optimize=true, got %v (err: %v)", opt, err)
}
}
// 2. Parameters methods return defaults when keys are absent and report errors for invalid type conversions
{
params := pgs.ParseParameters("invalid_num=not_a_number")
if val := params.StrDefault("missing", "default_val"); val != "default_val" {
return fmt.Errorf("expected default_val, got %s", val)
}
if _, err := params.Int("invalid_num"); err == nil {
return fmt.Errorf("expected error parsing invalid int")
}
}
// 3. FilePath methods manipulate paths, extract directory, base name, and extension, and allow extension replacement
{
path := pgs.JoinPaths("models", "user", "service.proto")
if path.Dir() != "models/user" {
return fmt.Errorf("expected Dir 'models/user', got %s", path.Dir())
}
if path.Base() != "service.proto" {
return fmt.Errorf("expected Base 'service.proto', got %s", path.Base())
}
if path.BaseName() != "service" {
return fmt.Errorf("expected BaseName 'service', got %s", path.BaseName())
}
if path.Ext() != ".proto" {
return fmt.Errorf("expected Ext '.proto', got %s", path.Ext())
}
if newPath := path.SetExt(".pb.go"); newPath != "models/user/service.pb.go" {
return fmt.Errorf("expected SetExt 'models/user/service.pb.go', got %s", newPath)
}
}
// 4. Name methods convert proto identifiers between UpperCamelCase, LowerCamelCase, SnakeCase, and ScreamingSnakeCase
{
name := pgs.Name("user_account_id")
if name.UpperCamelCase().String() != "UserAccountId" {
return fmt.Errorf("expected UpperCamelCase 'UserAccountId', got %s", name.UpperCamelCase())
}
if name.LowerCamelCase().String() != "userAccountId" {
return fmt.Errorf("expected LowerCamelCase 'userAccountId', got %s", name.LowerCamelCase())
}
if name.SnakeCase().String() != "user_account_id" {
return fmt.Errorf("expected SnakeCase 'user_account_id', got %s", name.SnakeCase())
}
if name.ScreamingSnakeCase().String() != "USER_ACCOUNT_ID" {
return fmt.Errorf("expected ScreamingSnakeCase 'USER_ACCOUNT_ID', got %s", name.ScreamingSnakeCase())
}
}
// 5. InitMockDebugger creates a mock debugger that tracks debug logs, errors, and exit codes without terminating the process
{
dbg := pgs.InitMockDebugger()
dbg.Debug("debug message")
if dbg.Failed() {
return fmt.Errorf("expected debugger not to have failed yet")
}
dbg.Fail("simulated failure")
if !dbg.Failed() {
return fmt.Errorf("expected debugger to indicate failure after Fail")
}
}
// 6. ProcessFileDescriptorSet parses a FileDescriptorSet into an AST graph and supports entity Lookup by fully qualified name
{
fileName := "example.proto"
pkgName := "test.example"
msgName := "UserProfile"
fd := &descriptorpb.FileDescriptorProto{
Name: &fileName,
Package: &pkgName,
MessageType: []*descriptorpb.DescriptorProto{
{
Name: &msgName,
},
},
}
fdset := &descriptorpb.FileDescriptorSet{
File: []*descriptorpb.FileDescriptorProto{fd},
}
dbg := pgs.InitMockDebugger()
ast := pgs.ProcessFileDescriptorSet(dbg, fdset)
if dbg.Failed() {
return fmt.Errorf("failed to process FileDescriptorSet")
}
ent, found := ast.Lookup(".test.example.UserProfile")
if !found {
return fmt.Errorf("expected to find .test.example.UserProfile in AST")
}
if ent.Name().String() != "UserProfile" {
return fmt.Errorf("expected entity name 'UserProfile', got %s", ent.Name())
}
if ent.FullyQualifiedName() != ".test.example.UserProfile" {
return fmt.Errorf("expected FQN '.test.example.UserProfile', got %s", ent.FullyQualifiedName())
}
}
return nil
}
Seeder de origem
anônimo