샘플
google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5: distribution.Distribution
검증된 샘플 — golang google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5: distribution.Distribution. go 1.26 · linux debian/x64 …
sha256:40cadfb768e0067dcd313aa207008330ba3604170e9cee70311e1b0e116e4f07
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-05 |
케이스
HOW- 목표
- verify distribution.Distribution in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5
- 심벌
-
- distribution.Distribution
- 생성일
- 2026-09-05T12:01:10Z
컨트랙트
- Distribution zero value has Count=0, Mean=0, and nil Range
- NewDistribution constructs a Distribution with specified count, mean, sum of squared deviations, and range
- GetRange returns min and max bounds for population values
- SetLinearBuckets configures linear bucket options with finite buckets, width, and offset
- TotalBucketCount calculates sum of bucket counts matching the total population count
- Distribution ProtoReflect returns non-nil protobuf Message descriptor
- Distribution String returns formatted text representation
파일
- PROMPT.md
- csx.json
- distribution.go
- go.mod
- go.sum
- 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 distribution.Distribution in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5
Demonstrate these symbols/APIs:
- distribution.Distribution
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:638fa94e6b2954145469cb8ac2e9b652bfdb7b2466e0cbf70bda67f5c11d4bdb","contract":["Distribution zero value has Count=0, Mean=0, and nil Range","NewDistribution constructs a Distribution with specified count, mean, sum of squared deviations, and range","GetRange returns min and max bounds for population values","SetLinearBuckets configures linear bucket options with finite buckets, width, and offset","TotalBucketCount calculates sum of bucket counts matching the total population count","Distribution ProtoReflect returns non-nil protobuf Message descriptor","Distribution String returns formatted text representation"],"goal":"verify distribution.Distribution in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5"],"schemaVersion":1,"symbols":["distribution.Distribution"]},"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/api@v0.0.0-20260825221802-da73d73af1c5"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5","symbols":["distribution.Distribution"],"verifierAdapter":"golang@1"}
package sample
import (
"google.golang.org/genproto/googleapis/api/distribution"
)
// NewDistribution creates a Distribution with basic population statistics and range.
func NewDistribution(count int64, mean, sumSqDev, min, max float64) *distribution.Distribution {
return &distribution.Distribution{
Count: count,
Mean: mean,
SumOfSquaredDeviation: sumSqDev,
Range: &distribution.Distribution_Range{
Min: min,
Max: max,
},
}
}
// SetLinearBuckets configures linear bucket options and bucket counts on a Distribution.
func SetLinearBuckets(d *distribution.Distribution, numFiniteBuckets int32, width, offset float64, counts []int64) {
d.BucketOptions = &distribution.Distribution_BucketOptions{
Options: &distribution.Distribution_BucketOptions_LinearBuckets{
LinearBuckets: &distribution.Distribution_BucketOptions_Linear{
NumFiniteBuckets: numFiniteBuckets,
Width: width,
Offset: offset,
},
},
}
d.BucketCounts = counts
}
// TotalBucketCount sums the counts across all histogram buckets.
func TotalBucketCount(d *distribution.Distribution) int64 {
var total int64
for _, c := range d.GetBucketCounts() {
total += c
}
return total
}
// HasHistogram returns true if bucket options and bucket counts are present.
func HasHistogram(d *distribution.Distribution) bool {
return d.GetBucketOptions() != nil && len(d.GetBucketCounts()) > 0
}
module sample
go 1.26.6
require google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5
require google.golang.org/protobuf v1.36.12 // indirect
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/api v0.0.0-20260825221802-da73d73af1c5 h1:izFU9hz7aeLI/Mi1J0991ae+xcwRLr7hTqWnB/9aIIU=
google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5/go.mod h1:3LhxRw4YYkf+ylAfgaY9JlVLFKhokkCV8duhLLe7+t0=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
{
"schemaVersion": 1,
"goal": "verify distribution.Distribution in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5"
],
"symbols": [
"distribution.Distribution"
]
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/api/distribution"
"sample"
)
func main() {
// Assertion 1: Distribution zero value has Count=0, Mean=0, and nil Range
var zeroDist distribution.Distribution
if zeroDist.GetCount() != 0 {
fmt.Fprintf(os.Stderr, "expected zeroDist.GetCount() == 0, got %d\n", zeroDist.GetCount())
os.Exit(1)
}
if zeroDist.GetMean() != 0 {
fmt.Fprintf(os.Stderr, "expected zeroDist.GetMean() == 0, got %f\n", zeroDist.GetMean())
os.Exit(1)
}
if zeroDist.GetRange() != nil {
fmt.Fprintf(os.Stderr, "expected zeroDist.GetRange() to be nil\n")
os.Exit(1)
}
// Assertion 2: NewDistribution constructs a Distribution with specified count, mean, sum of squared deviations, and range
d := sample.NewDistribution(10, 5.5, 12.25, 1.0, 10.0)
if d.GetCount() != 10 {
fmt.Fprintf(os.Stderr, "expected count 10, got %d\n", d.GetCount())
os.Exit(1)
}
if d.GetMean() != 5.5 {
fmt.Fprintf(os.Stderr, "expected mean 5.5, got %f\n", d.GetMean())
os.Exit(1)
}
if d.GetSumOfSquaredDeviation() != 12.25 {
fmt.Fprintf(os.Stderr, "expected sum of squared deviation 12.25, got %f\n", d.GetSumOfSquaredDeviation())
os.Exit(1)
}
// Assertion 3: GetRange returns min and max bounds for population values
r := d.GetRange()
if r == nil || r.GetMin() != 1.0 || r.GetMax() != 10.0 {
fmt.Fprintf(os.Stderr, "expected range min 1.0 and max 10.0, got %+v\n", r)
os.Exit(1)
}
// Assertion 4: SetLinearBuckets configures linear bucket options with finite buckets, width, and offset
counts := []int64{1, 3, 4, 2}
sample.SetLinearBuckets(d, 2, 5.0, 0.0, counts)
bo := d.GetBucketOptions()
if bo == nil {
fmt.Fprintf(os.Stderr, "expected non-nil BucketOptions\n")
os.Exit(1)
}
linear := bo.GetLinearBuckets()
if linear == nil || linear.NumFiniteBuckets != 2 || linear.Width != 5.0 || linear.Offset != 0.0 {
fmt.Fprintf(os.Stderr, "linear bucket mismatch: %+v\n", linear)
os.Exit(1)
}
// Assertion 5: TotalBucketCount calculates sum of bucket counts matching the total population count
if !sample.HasHistogram(d) {
fmt.Fprintf(os.Stderr, "expected HasHistogram(d) to be true\n")
os.Exit(1)
}
if total := sample.TotalBucketCount(d); total != 10 {
fmt.Fprintf(os.Stderr, "expected TotalBucketCount to equal 10, got %d\n", total)
os.Exit(1)
}
// Assertion 6: Distribution ProtoReflect returns non-nil protobuf Message descriptor
msg := d.ProtoReflect()
if msg == nil || msg.Descriptor() == nil || msg.Descriptor().FullName() != "google.api.Distribution" {
fmt.Fprintf(os.Stderr, "unexpected descriptor: %v\n", msg)
os.Exit(1)
}
// Assertion 7: Distribution String returns formatted text representation
str := d.String()
if len(str) == 0 {
fmt.Fprintf(os.Stderr, "expected non-empty string representation\n")
os.Exit(1)
}
fmt.Println("All distribution.Distribution contract assertions passed.")
}
오리진 시더
익명