Exemplo
google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5: distribution.Distribution
Amostra verificada para golang google.golang.org/genproto/googleapis/api v0.0.0-20260825221802-da73d73af1c5: distribution.Distribution. O contrato rodou em…
sha256:40cadfb768e0067dcd313aa207008330ba3604170e9cee70311e1b0e116e4f07
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify distribution.Distribution in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20260825221802-da73d73af1c5
- Símbolos
-
- distribution.Distribution
- Criado
- 2026-09-05T12:01:10Z
Contrato
- 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
Arquivos
- PROMPT.md
- csx.json
- distribution.go
- go.mod
- go.sum
- spec.json
- test/contract.go
Código-fonte
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.")
}
Seeder de origem
anônimo