示例
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.QuotaFailure_Violation
已验证示例 — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.QuotaFailure_Violation. contract 在 go 1.26 · linux…
sha256:bc0f630b22058cd45c82fec8dbda1058e64cdd23af7235cfb9fe6ab7c8896355
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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.QuotaFailure_Violation in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
- 符号
-
- google.golang.org/genproto/googleapis/rpc/errdetails.QuotaFailure_Violation
- 环境
- go 1.26.6
- 创建时间
- 2026-08-27T11:51:37Z
契约
- QuotaFailure_Violation struct initialized with Subject and Description retains field values
- GetSubject returns the configured subject string on valid instance and empty string on nil
- GetDescription returns the configured description string on valid instance and empty string on nil
- QuotaFailure aggregates QuotaFailure_Violation instances in its Violations slice
- QuotaFailure containing QuotaFailure_Violation instances roundtrips through protobuf wire format
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- quotafailure.go
- spec.json
- test/contract_test.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.QuotaFailure_Violation 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.QuotaFailure_Violation
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: esm
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:b247889a762175df77e0d60b8ab729a7bdca20fbffc61e729067e12f0b3fdbb0","contract":["QuotaFailure_Violation struct initialized with Subject and Description retains field values","GetSubject returns the configured subject string on valid instance and empty string on nil","GetDescription returns the configured description string on valid instance and empty string on nil","QuotaFailure aggregates QuotaFailure_Violation instances in its Violations slice","QuotaFailure containing QuotaFailure_Violation instances roundtrips through protobuf wire format"],"goal":"verify google.golang.org/genproto/googleapis/rpc/errdetails.QuotaFailure_Violation 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.QuotaFailure_Violation"]},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","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.QuotaFailure_Violation"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.36.5
)
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.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
package sample
import (
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/protobuf/proto"
)
// NewQuotaViolation creates a new QuotaFailure_Violation with the given subject and description.
func NewQuotaViolation(subject, description string) *errdetails.QuotaFailure_Violation {
return &errdetails.QuotaFailure_Violation{
Subject: subject,
Description: description,
}
}
// NewQuotaFailure wraps multiple violations into a QuotaFailure error detail.
func NewQuotaFailure(violations ...*errdetails.QuotaFailure_Violation) *errdetails.QuotaFailure {
return &errdetails.QuotaFailure{
Violations: violations,
}
}
// SerializeQuotaFailure marshals a QuotaFailure into protobuf wire bytes.
func SerializeQuotaFailure(qf *errdetails.QuotaFailure) ([]byte, error) {
return proto.Marshal(qf)
}
// DeserializeQuotaFailure unmarshals protobuf wire bytes into a QuotaFailure.
func DeserializeQuotaFailure(data []byte) (*errdetails.QuotaFailure, error) {
var qf errdetails.QuotaFailure
if err := proto.Unmarshal(data, &qf); err != nil {
return nil, err
}
return &qf, nil
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/errdetails.QuotaFailure_Violation 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.QuotaFailure_Violation"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "esm",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package test
import (
"testing"
"example.com/sample"
"google.golang.org/genproto/googleapis/rpc/errdetails"
)
func TestQuotaFailureViolationContract(t *testing.T) {
// Direct struct initialization
v := &errdetails.QuotaFailure_Violation{
Subject: "project:test-project-123",
Description: "Daily API call quota exceeded for standard tier",
}
// Field access and getters
if got := v.GetSubject(); got != "project:test-project-123" {
t.Fatalf("unexpected Subject: got %q, want %q", got, "project:test-project-123")
}
if got := v.GetDescription(); got != "Daily API call quota exceeded for standard tier" {
t.Fatalf("unexpected Description: got %q, want %q", got, "Daily API call quota exceeded for standard tier")
}
// Nil-safe getters
var nilViolation *errdetails.QuotaFailure_Violation
if nilViolation.GetSubject() != "" {
t.Fatalf("nil violation GetSubject should return empty string")
}
if nilViolation.GetDescription() != "" {
t.Fatalf("nil violation GetDescription should return empty string")
}
// Helper constructors
helperViolation := sample.NewQuotaViolation("clientip:127.0.0.1", "Rate limit exceeded")
if helperViolation.GetSubject() != "clientip:127.0.0.1" {
t.Fatalf("unexpected helper Subject: got %q", helperViolation.GetSubject())
}
if helperViolation.GetDescription() != "Rate limit exceeded" {
t.Fatalf("unexpected helper Description: got %q", helperViolation.GetDescription())
}
// Envelope aggregation
qf := sample.NewQuotaFailure(v, helperViolation)
if len(qf.GetViolations()) != 2 {
t.Fatalf("expected 2 violations, got %d", len(qf.GetViolations()))
}
if qf.GetViolations()[0].GetSubject() != "project:test-project-123" {
t.Fatalf("unexpected violation 0 subject: %s", qf.GetViolations()[0].GetSubject())
}
if qf.GetViolations()[1].GetSubject() != "clientip:127.0.0.1" {
t.Fatalf("unexpected violation 1 subject: %s", qf.GetViolations()[1].GetSubject())
}
// Protobuf serialization round-trip
bytes, err := sample.SerializeQuotaFailure(qf)
if err != nil {
t.Fatalf("SerializeQuotaFailure failed: %v", err)
}
restored, err := sample.DeserializeQuotaFailure(bytes)
if err != nil {
t.Fatalf("DeserializeQuotaFailure failed: %v", err)
}
if len(restored.GetViolations()) != 2 {
t.Fatalf("expected 2 restored violations, got %d", len(restored.GetViolations()))
}
if restored.GetViolations()[0].GetDescription() != "Daily API call quota exceeded for standard tier" {
t.Fatalf("unexpected restored violation 0 description: %s", restored.GetViolations()[0].GetDescription())
}
if restored.GetViolations()[1].GetDescription() != "Rate limit exceeded" {
t.Fatalf("unexpected restored violation 1 description: %s", restored.GetViolations()[1].GetDescription())
}
}
原始种子者
匿名