示例
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5: code.Code_OUT_OF_RANGE
已验证示例 — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5: code.Code_OUT_OF_RANGE. contract 在 go 1.26 · linux debian/x64 …
sha256:5820316aa2e0cd56982c321fe552447e00d7dd3a9e767fc63d0e77e8489a0b8d
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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-09-07 |
案例
HOW- 目标
- verify google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
- 符号
-
- google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE
- 创建时间
- 2026-09-07T02:38:54Z
契约
- code.Code_OUT_OF_RANGE represents client operation past valid range with enum value 11
- code.Code_OUT_OF_RANGE enum converts to string representation OUT_OF_RANGE and maps in Code_name and Code_value
- status.Status represents an RPC error status with code.Code_OUT_OF_RANGE and unmarshals successfully
- status.Status with code.Code_OUT_OF_RANGE encapsulates BadRequest error details describing range violation
文件
- 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/code.Code_OUT_OF_RANGE in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE
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:332e55c9d292666ad46d5e307e1a0a2799729dc5eb8a4779ea0cdc422301f58e","contract":["code.Code_OUT_OF_RANGE represents client operation past valid range with enum value 11","code.Code_OUT_OF_RANGE enum converts to string representation OUT_OF_RANGE and maps in Code_name and Code_value","status.Status represents an RPC error status with code.Code_OUT_OF_RANGE and unmarshals successfully","status.Status with code.Code_OUT_OF_RANGE encapsulates BadRequest error details describing range violation"],"goal":"verify google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE"]},"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-20260825221802-da73d73af1c5"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5","symbols":["google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE"],"verifierAdapter":"golang@1"}
module example.com/codeofrange
go 1.26.6
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5
google.golang.org/protobuf v1.36.12
)
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-20260825221802-da73d73af1c5 h1:1VUiZAXyC+zmiFYi+WLtBzr68Cj8wOofHjjrA/kkizc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/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() {
// Create a BadRequest detail representing an out-of-range field violation
badRequest := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{
{
Field: "offset",
Description: "offset 1050 is past valid range [0, 1000]",
},
},
}
anyDetail, err := anypb.New(badRequest)
if err != nil {
log.Fatalf("failed to pack error detail: %v", err)
}
// Create RPC status with Code_OUT_OF_RANGE
st := &status.Status{
Code: int32(code.Code_OUT_OF_RANGE),
Message: "requested range exceeds boundary limits",
Details: []*anypb.Any{anyDetail},
}
data, err := proto.Marshal(st)
if err != nil {
log.Fatalf("failed to marshal status: %v", err)
}
var decoded status.Status
if err := proto.Unmarshal(data, &decoded); err != nil {
log.Fatalf("failed to unmarshal status: %v", err)
}
fmt.Printf("Status Code: %d (%s)\n", decoded.GetCode(), code.Code_name[decoded.GetCode()])
fmt.Printf("Status Message: %s\n", decoded.GetMessage())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/code.Code_OUT_OF_RANGE"
]
}
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(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "Assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// 1. code.Code_OUT_OF_RANGE represents client operation past valid range with enum value 11
assert(code.Code_OUT_OF_RANGE == 11, "code.Code_OUT_OF_RANGE must have value 11")
assert(int32(code.Code_OUT_OF_RANGE) == 11, "int32(code.Code_OUT_OF_RANGE) must be 11")
// 2. code.Code_OUT_OF_RANGE enum converts to string representation OUT_OF_RANGE and maps in Code_name and Code_value
assert(code.Code_OUT_OF_RANGE.String() == "OUT_OF_RANGE", "code.Code_OUT_OF_RANGE.String() must be OUT_OF_RANGE")
assert(code.Code_name[int32(code.Code_OUT_OF_RANGE)] == "OUT_OF_RANGE", "code.Code_name[11] must be OUT_OF_RANGE")
assert(code.Code_value["OUT_OF_RANGE"] == int32(code.Code_OUT_OF_RANGE), "code.Code_value[OUT_OF_RANGE] must match Code_OUT_OF_RANGE")
// 3. status.Status represents an RPC error status with code.Code_OUT_OF_RANGE and unmarshals successfully
st := &status.Status{
Code: int32(code.Code_OUT_OF_RANGE),
Message: "request offset is past the end of the available collection",
}
assert(st.GetCode() == int32(code.Code_OUT_OF_RANGE), "status code must match Code_OUT_OF_RANGE")
assert(st.GetMessage() == "request offset is past the end of the available collection", "status message must match")
data, err := proto.Marshal(st)
assert(err == nil, "proto.Marshal(st) must succeed")
assert(len(data) > 0, "marshaled payload must not be empty")
var decoded status.Status
err = proto.Unmarshal(data, &decoded)
assert(err == nil, "proto.Unmarshal(data) must succeed")
assert(decoded.GetCode() == int32(code.Code_OUT_OF_RANGE), "decoded status code must match Code_OUT_OF_RANGE")
assert(decoded.GetMessage() == "request offset is past the end of the available collection", "decoded message must match")
// 4. status.Status with code.Code_OUT_OF_RANGE encapsulates BadRequest error details describing range violation
badRequest := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{
{
Field: "offset",
Description: "offset 1050 is past valid range [0, 1000]",
},
},
}
anyDetail, err := anypb.New(badRequest)
assert(err == nil, "anypb.New(badRequest) must succeed")
st.Details = append(st.Details, anyDetail)
assert(len(st.GetDetails()) == 1, "details count must be 1")
unpackedBadRequest := &errdetails.BadRequest{}
err = anypb.UnmarshalTo(st.GetDetails()[0], unpackedBadRequest, proto.UnmarshalOptions{})
assert(err == nil, "anypb.UnmarshalTo must succeed")
assert(len(unpackedBadRequest.GetFieldViolations()) == 1, "expected 1 field violation")
assert(unpackedBadRequest.GetFieldViolations()[0].GetField() == "offset", "violation field must be offset")
assert(unpackedBadRequest.GetFieldViolations()[0].GetDescription() == "offset 1050 is past valid range [0, 1000]", "violation description must match")
fmt.Println("All contract assertions for Code_OUT_OF_RANGE passed successfully.")
}
原始种子者
匿名