示例
github.com/lyft/protoc-gen-star/v2 v2.0.3: InitMockDebugger
已验证示例 — golang github.com/lyft/protoc-gen-star/v2 v2.0.3: InitMockDebugger. contract 在 go 1.26 · linux debian/x64 · docker 上运行并通过.
sha256:018731823e3a098ca7ae5b77b4423f7a0028fecd466b67d441787eac7ff6f75f
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 go
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify github.com/lyft/protoc-gen-star/v2.InitMockDebugger in pkg:golang/github.com/lyft/protoc-gen-star/v2@v2.0.3
- 符号
-
- github.com/lyft/protoc-gen-star/v2.InitMockDebugger
- 创建时间
- 2026-10-11T15:02:51Z
契约
- InitMockDebugger returns an initialized MockDebugger with clean initial state
- MockDebugger records Log messages to Output reader without setting Failed or Exited
- MockDebugger Fail records failure and simulated exit without terminating the process
- MockDebugger CheckErr captures error and marks Exited when error is non-nil
- MockDebugger Push propagates child failure back to root MockDebugger with prefix
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- mock_debugger.go
- spec.json
- test/contract.go
源代码
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 github.com/lyft/protoc-gen-star/v2.InitMockDebugger in 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
Demonstrate these symbols/APIs:
- github.com/lyft/protoc-gen-star/v2.InitMockDebugger
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:d8ff28bdadaf4aa852685ff2aee8c2e3dd36c50c89784b8537aa1608e67d3281","contract":["InitMockDebugger returns an initialized MockDebugger with clean initial state","MockDebugger records Log messages to Output reader without setting Failed or Exited","MockDebugger Fail records failure and simulated exit without terminating the process","MockDebugger CheckErr captures error and marks Exited when error is non-nil","MockDebugger Push propagates child failure back to root MockDebugger with prefix"],"goal":"verify github.com/lyft/protoc-gen-star/v2.InitMockDebugger in 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,"symbols":["github.com/lyft/protoc-gen-star/v2.InitMockDebugger"]},"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","symbols":["github.com/lyft/protoc-gen-star/v2.InitMockDebugger"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/lyft/protoc-gen-star/v2 v2.0.3
require (
github.com/spf13/afero v1.3.3 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.23.0 // 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 sample
import (
"errors"
"io"
"strings"
pgs "github.com/lyft/protoc-gen-star/v2"
)
// ErrSampleOperation indicates an intentional test error.
var ErrSampleOperation = errors.New("sample operation failed")
// NewMockDebugger creates a new MockDebugger for unit testing protoc-gen-star modules.
func NewMockDebugger() pgs.MockDebugger {
return pgs.InitMockDebugger()
}
// CaptureLog writes messages to the mock debugger and returns the accumulated output as a string.
func CaptureLog(d pgs.MockDebugger, messages ...string) (string, error) {
for _, msg := range messages {
d.Log(msg)
}
out, err := io.ReadAll(d.Output())
if err != nil {
return "", err
}
return strings.TrimSpace(string(out)), nil
}
// FailWithContext logs a failure on a nested child debugger with the given prefix.
func FailWithContext(d pgs.MockDebugger, prefix, message string) {
child := d.Push(prefix)
child.Fail(message)
}
// CheckOperation checks if err is non-nil and passes it to CheckErr.
func CheckOperation(d pgs.MockDebugger, err error, message string) {
d.CheckErr(err, message)
}
{
"schemaVersion": 1,
"goal": "verify github.com/lyft/protoc-gen-star/v2.InitMockDebugger in 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"
],
"symbols": [
"github.com/lyft/protoc-gen-star/v2.InitMockDebugger"
]
}
package main
import (
"fmt"
"io"
"os"
"strings"
pgs "github.com/lyft/protoc-gen-star/v2"
"sample"
)
func main() {
fmt.Println("Running contract tests for github.com/lyft/protoc-gen-star/v2.InitMockDebugger...")
// Assertion 1: InitMockDebugger returns an initialized MockDebugger with clean initial state
{
d := sample.NewMockDebugger()
if d == nil {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: InitMockDebugger returned nil\n")
os.Exit(1)
}
if d.Failed() {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: initial Failed() should be false\n")
os.Exit(1)
}
if d.Exited() {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: initial Exited() should be false\n")
os.Exit(1)
}
if d.Err() != nil {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: initial Err() should be nil\n")
os.Exit(1)
}
fmt.Println(" ✓ Assertion 1 passed: InitMockDebugger returns an initialized MockDebugger with clean initial state")
}
// Assertion 2: MockDebugger records Log messages to Output reader without setting Failed or Exited
{
d := pgs.InitMockDebugger()
d.Log("starting plugin execution")
d.Logf("processing message %s", "DescriptorProto")
out, err := io.ReadAll(d.Output())
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 2 failed reading output: %v\n", err)
os.Exit(1)
}
logText := string(out)
if !strings.Contains(logText, "starting plugin execution") {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: missing expected log text: %s\n", logText)
os.Exit(1)
}
if !strings.Contains(logText, "processing message DescriptorProto") {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: missing expected formatted log text: %s\n", logText)
os.Exit(1)
}
if d.Failed() {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: Failed() should be false after logging\n")
os.Exit(1)
}
if d.Exited() {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: Exited() should be false after logging\n")
os.Exit(1)
}
fmt.Println(" ✓ Assertion 2 passed: MockDebugger records Log messages to Output reader without setting Failed or Exited")
}
// Assertion 3: MockDebugger Fail records failure and simulated exit without terminating the process
{
d := pgs.InitMockDebugger()
d.Fail("unrecoverable generation error")
if !d.Failed() {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected Failed() to be true\n")
os.Exit(1)
}
if !d.Exited() {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected Exited() to be true\n")
os.Exit(1)
}
if d.ExitCode() != 1 {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected ExitCode() == 1, got %d\n", d.ExitCode())
os.Exit(1)
}
out, _ := io.ReadAll(d.Output())
if !strings.Contains(string(out), "unrecoverable generation error") {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: missing expected fail message in output: %s\n", string(out))
os.Exit(1)
}
fmt.Println(" ✓ Assertion 3 passed: MockDebugger Fail records failure and simulated exit without terminating the process")
}
// Assertion 4: MockDebugger CheckErr captures error and marks Exited when error is non-nil
{
d := pgs.InitMockDebugger()
sample.CheckOperation(d, sample.ErrSampleOperation, "validating proto AST")
if d.Err() != sample.ErrSampleOperation {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected Err() == ErrSampleOperation, got %v\n", d.Err())
os.Exit(1)
}
if !d.Exited() {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected Exited() to be true after CheckErr\n")
os.Exit(1)
}
if d.ExitCode() != 1 {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected ExitCode() == 1, got %d\n", d.ExitCode())
os.Exit(1)
}
out, _ := io.ReadAll(d.Output())
if !strings.Contains(string(out), "[error] validating proto AST: sample operation failed") {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: unexpected error message in output: %s\n", string(out))
os.Exit(1)
}
fmt.Println(" ✓ Assertion 4 passed: MockDebugger CheckErr captures error and marks Exited when error is non-nil")
}
// Assertion 5: MockDebugger Push propagates child failure back to root MockDebugger with prefix
{
d := pgs.InitMockDebugger()
sample.FailWithContext(d, "generator", "syntax violation")
if !d.Failed() {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected root MockDebugger to be marked Failed() via child\n")
os.Exit(1)
}
if !d.Exited() {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected root MockDebugger to be marked Exited() via child\n")
os.Exit(1)
}
out, _ := io.ReadAll(d.Output())
if !strings.Contains(string(out), "[generator]syntax violation") {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected prefixed message in output, got: %s\n", string(out))
os.Exit(1)
}
fmt.Println(" ✓ Assertion 5 passed: MockDebugger Push propagates child failure back to root MockDebugger with prefix")
}
fmt.Println("All contract assertions passed successfully.")
}
原始种子者
匿名