Exemplo
github.com/prometheus/client_model v0.6.2: go.Bucket, go.Histogram
Amostra verificada para golang github.com/prometheus/client_model v0.6.2: go.Bucket, go.Histogram. O contrato rodou em go 1.26 · linux alpine/x64 · docker e…
sha256:8f68364426c1d12920901aec1c03f8dd5689d1e25989d9fcb0b55124f6c6efc6
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 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-28 |
Caso
HOW- Objetivo
- verify github.com/prometheus/client_model/go.Histogram in pkg:golang/github.com/prometheus/client_model@v0.6.2
- Símbolos
-
- github.com/prometheus/client_model/go.Bucket
- github.com/prometheus/client_model/go.Histogram
- Criado
- 2026-08-28T00:30:34Z
Contrato
- dto.Histogram getters (GetSampleCount, GetSampleSum, GetBucket) return zero/nil values for nil and uninitialized instances.
- dto.Histogram stores and retrieves sample count, sample sum, and bucket slices.
- dto.Bucket getters (GetCumulativeCount, GetUpperBound, GetExemplar) return zero/nil values for nil instances and retrieve configured values.
- dto.Histogram.Reset clears all fields back to zero values.
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract_test.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 github.com/prometheus/client_model/go.Histogram in pkg:golang/github.com/prometheus/client_model@v0.6.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/client_model@v0.6.2
Demonstrate these symbols/APIs:
- github.com/prometheus/client_model/go.Bucket
- github.com/prometheus/client_model/go.Histogram
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:215275ca9b953e192a4ae909843f65402f5f5374cbb36b5ac3452b76ec587253","contract":["dto.Histogram getters (GetSampleCount, GetSampleSum, GetBucket) return zero/nil values for nil and uninitialized instances.","dto.Histogram stores and retrieves sample count, sample sum, and bucket slices.","dto.Bucket getters (GetCumulativeCount, GetUpperBound, GetExemplar) return zero/nil values for nil instances and retrieve configured values.","dto.Histogram.Reset clears all fields back to zero values."],"goal":"verify github.com/prometheus/client_model/go.Histogram in pkg:golang/github.com/prometheus/client_model@v0.6.2","kind":"HOW","packages":["pkg:golang/github.com/prometheus/client_model@v0.6.2"],"schemaVersion":1,"symbols":["github.com/prometheus/client_model/go.Bucket","github.com/prometheus/client_model/go.Histogram"]},"contractCommand":["go","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/github.com/prometheus/client_model@v0.6.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/client_model@v0.6.2","symbols":["github.com/prometheus/client_model/go.Bucket","github.com/prometheus/client_model/go.Histogram"],"verifierAdapter":"golang@1"}
module example.com/histogram
go 1.22.0
require (
github.com/prometheus/client_model v0.6.2
google.golang.org/protobuf v1.36.6
)
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
package main
import (
"fmt"
dto "github.com/prometheus/client_model/go"
"google.golang.org/protobuf/proto"
)
func main() {
h := &dto.Histogram{
SampleCount: proto.Uint64(10),
SampleSum: proto.Float64(25.5),
Bucket: []*dto.Bucket{
{
CumulativeCount: proto.Uint64(4),
UpperBound: proto.Float64(2.5),
},
{
CumulativeCount: proto.Uint64(10),
UpperBound: proto.Float64(10.0),
},
},
}
fmt.Printf("Sample count: %d\n", h.GetSampleCount())
fmt.Printf("Sample sum: %f\n", h.GetSampleSum())
fmt.Printf("Buckets count: %d\n", len(h.GetBucket()))
for _, b := range h.GetBucket() {
fmt.Printf(" le %f: %d\n", b.GetUpperBound(), b.GetCumulativeCount())
}
}
{
"schemaVersion": 1,
"goal": "verify github.com/prometheus/client_model/go.Histogram in pkg:golang/github.com/prometheus/client_model@v0.6.2",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/client_model@v0.6.2"
],
"symbols": [
"github.com/prometheus/client_model/go.Bucket",
"github.com/prometheus/client_model/go.Histogram"
]
}
package test
import (
"testing"
dto "github.com/prometheus/client_model/go"
"google.golang.org/protobuf/proto"
)
func TestHistogramNilAndDefaultGetters(t *testing.T) {
var nilHistogram *dto.Histogram
if got := nilHistogram.GetSampleCount(); got != 0 {
t.Errorf("nilHistogram.GetSampleCount() = %v, want 0", got)
}
if got := nilHistogram.GetSampleSum(); got != 0 {
t.Errorf("nilHistogram.GetSampleSum() = %v, want 0", got)
}
if got := nilHistogram.GetBucket(); got != nil {
t.Errorf("nilHistogram.GetBucket() = %v, want nil", got)
}
emptyHistogram := &dto.Histogram{}
if got := emptyHistogram.GetSampleCount(); got != 0 {
t.Errorf("emptyHistogram.GetSampleCount() = %v, want 0", got)
}
if got := emptyHistogram.GetSampleSum(); got != 0 {
t.Errorf("emptyHistogram.GetSampleSum() = %v, want 0", got)
}
if got := emptyHistogram.GetBucket(); got != nil {
t.Errorf("emptyHistogram.GetBucket() = %v, want nil", got)
}
}
func TestHistogramValuesAndBuckets(t *testing.T) {
b1 := &dto.Bucket{
CumulativeCount: proto.Uint64(5),
UpperBound: proto.Float64(1.0),
}
b2 := &dto.Bucket{
CumulativeCount: proto.Uint64(12),
UpperBound: proto.Float64(5.0),
}
h := &dto.Histogram{
SampleCount: proto.Uint64(12),
SampleSum: proto.Float64(34.5),
Bucket: []*dto.Bucket{b1, b2},
}
if got := h.GetSampleCount(); got != 12 {
t.Errorf("h.GetSampleCount() = %v, want 12", got)
}
if got := h.GetSampleSum(); got != 34.5 {
t.Errorf("h.GetSampleSum() = %v, want 34.5", got)
}
buckets := h.GetBucket()
if len(buckets) != 2 {
t.Fatalf("len(h.GetBucket()) = %v, want 2", len(buckets))
}
if buckets[0].GetCumulativeCount() != 5 || buckets[0].GetUpperBound() != 1.0 {
t.Errorf("bucket 0 mismatch: count=%v, upper=%v", buckets[0].GetCumulativeCount(), buckets[0].GetUpperBound())
}
if buckets[1].GetCumulativeCount() != 12 || buckets[1].GetUpperBound() != 5.0 {
t.Errorf("bucket 1 mismatch: count=%v, upper=%v", buckets[1].GetCumulativeCount(), buckets[1].GetUpperBound())
}
}
func TestBucketGetters(t *testing.T) {
var nilBucket *dto.Bucket
if got := nilBucket.GetCumulativeCount(); got != 0 {
t.Errorf("nilBucket.GetCumulativeCount() = %v, want 0", got)
}
if got := nilBucket.GetUpperBound(); got != 0 {
t.Errorf("nilBucket.GetUpperBound() = %v, want 0", got)
}
if got := nilBucket.GetExemplar(); got != nil {
t.Errorf("nilBucket.GetExemplar() = %v, want nil", got)
}
b := &dto.Bucket{
CumulativeCount: proto.Uint64(42),
UpperBound: proto.Float64(100.5),
}
if got := b.GetCumulativeCount(); got != 42 {
t.Errorf("b.GetCumulativeCount() = %v, want 42", got)
}
if got := b.GetUpperBound(); got != 100.5 {
t.Errorf("b.GetUpperBound() = %v, want 100.5", got)
}
}
func TestHistogramReset(t *testing.T) {
h := &dto.Histogram{
SampleCount: proto.Uint64(10),
SampleSum: proto.Float64(50.0),
Bucket: []*dto.Bucket{
{CumulativeCount: proto.Uint64(10), UpperBound: proto.Float64(5.0)},
},
}
h.Reset()
if got := h.GetSampleCount(); got != 0 {
t.Errorf("h.GetSampleCount() after Reset() = %v, want 0", got)
}
if got := h.GetSampleSum(); got != 0 {
t.Errorf("h.GetSampleSum() after Reset() = %v, want 0", got)
}
if got := h.GetBucket(); got != nil {
t.Errorf("h.GetBucket() after Reset() = %v, want nil", got)
}
}
Seeder de origem
anônimo