示例
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.RetryInfo
已验证示例 — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.RetryInfo. contract 在 go 1.26 · linux alpine/x64 …
sha256:d43d71899d406ff6170b741f3ccd4cb3ff0b900221e87667c30a1e0d34b0d25b
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 go
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-27 |
案例
HOW- 目标
- verify google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
- 符号
-
- google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo
- 创建时间
- 2026-08-27T11:57:22Z
契约
- RetryInfo initializes with durationpb RetryDelay and retrieves duration accurately
- RetryInfo packs into anypb.Any and unpacks back successfully
- RetryInfo integrates into status.Status details and roundtrips through proto serialization
- RetryInfo handles nil RetryDelay safely returning nil
- RetryInfo message matches anypb.MessageIs type check
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.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 google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo
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:8e2350702b52e0b6768d46e683a56bd82424abb19c113991a3a0cf6af0b4f4ab","contract":["RetryInfo initializes with durationpb RetryDelay and retrieves duration accurately","RetryInfo packs into anypb.Any and unpacks back successfully","RetryInfo integrates into status.Status details and roundtrips through proto serialization","RetryInfo handles nil RetryDelay safely returning nil","RetryInfo message matches anypb.MessageIs type check"],"goal":"verify google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo"]},"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-20241007155032-5fefd90f89a9"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9","symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.35.1
)
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
package main
import (
"fmt"
"log"
"time"
"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"
"google.golang.org/protobuf/types/known/durationpb"
)
func main() {
// 1. Create a RetryInfo detail indicating a retry backoff duration
retryInfo := &errdetails.RetryInfo{
RetryDelay: durationpb.New(15 * time.Second),
}
// 2. Pack RetryInfo into Any protobuf message
anyRetryInfo, err := anypb.New(retryInfo)
if err != nil {
log.Fatalf("failed to pack retry info: %v", err)
}
// 3. Attach RetryInfo Any message into standard RPC status
rpcStatus := &status.Status{
Code: int32(code.Code_UNAVAILABLE),
Message: "service temporarily unavailable, please retry later",
Details: []*anypb.Any{anyRetryInfo},
}
// 4. Serialize Status to binary protobuf
data, err := proto.Marshal(rpcStatus)
if err != nil {
log.Fatalf("failed to marshal status: %v", err)
}
// 5. Unmarshal and unpack RetryInfo
var decoded status.Status
if err := proto.Unmarshal(data, &decoded); err != nil {
log.Fatalf("failed to unmarshal status: %v", err)
}
for _, detail := range decoded.GetDetails() {
if detail.MessageIs(&errdetails.RetryInfo{}) {
unpacked := &errdetails.RetryInfo{}
if err := detail.UnmarshalTo(unpacked); err != nil {
log.Fatalf("failed to unpack detail: %v", err)
}
fmt.Printf("Retry delay: %v\n", unpacked.GetRetryDelay().AsDuration())
}
}
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/errdetails.RetryInfo"
]
}
package main
import (
"fmt"
"os"
"time"
"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"
"google.golang.org/protobuf/types/known/durationpb"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "Assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// 1. RetryInfo initializes with durationpb RetryDelay and retrieves duration accurately
expectedDuration := 10 * time.Second
retryInfo := &errdetails.RetryInfo{
RetryDelay: durationpb.New(expectedDuration),
}
assert(retryInfo.GetRetryDelay() != nil, "RetryDelay should not be nil")
assert(retryInfo.GetRetryDelay().GetSeconds() == 10, "RetryDelay seconds should be 10")
assert(retryInfo.GetRetryDelay().GetNanos() == 0, "RetryDelay nanos should be 0")
assert(retryInfo.GetRetryDelay().AsDuration() == expectedDuration, "RetryDelay AsDuration should match expectedDuration")
// 2. RetryInfo packs into anypb.Any and unpacks back successfully
anyMsg, err := anypb.New(retryInfo)
assert(err == nil, "anypb.New(retryInfo) should succeed")
assert(anyMsg != nil, "anyMsg should not be nil")
unpacked := &errdetails.RetryInfo{}
err = anypb.UnmarshalTo(anyMsg, unpacked, proto.UnmarshalOptions{})
assert(err == nil, "UnmarshalTo should succeed")
assert(unpacked.GetRetryDelay().AsDuration() == expectedDuration, "unpacked retry duration should match")
// 3. RetryInfo integrates into status.Status details and roundtrips through proto serialization
rpcStatus := &status.Status{
Code: int32(code.Code_UNAVAILABLE),
Message: "service overloaded, please back off",
Details: []*anypb.Any{anyMsg},
}
data, err := proto.Marshal(rpcStatus)
assert(err == nil, "proto.Marshal should succeed")
assert(len(data) > 0, "marshaled bytes should not be empty")
var decodedStatus status.Status
err = proto.Unmarshal(data, &decodedStatus)
assert(err == nil, "proto.Unmarshal should succeed")
assert(decodedStatus.GetCode() == int32(code.Code_UNAVAILABLE), "status code should match UNAVAILABLE")
assert(len(decodedStatus.GetDetails()) == 1, "details count should be 1")
// 4. RetryInfo handles nil RetryDelay safely returning nil
nilRetryInfo := &errdetails.RetryInfo{}
assert(nilRetryInfo.GetRetryDelay() == nil, "GetRetryDelay on empty RetryInfo should return nil")
var typedNil *errdetails.RetryInfo
assert(typedNil.GetRetryDelay() == nil, "GetRetryDelay on typed nil should return nil")
// 5. RetryInfo message matches anypb.MessageIs type check
assert(anyMsg.MessageIs(&errdetails.RetryInfo{}), "MessageIs should return true for RetryInfo")
assert(!anyMsg.MessageIs(&errdetails.BadRequest{}), "MessageIs should return false for BadRequest")
fmt.Println("All contract assertions passed successfully.")
}
原始种子者
匿名