Sample
github.com/prometheus/client_model v0.6.1: go.Histogram
Verified sample for golang github.com/prometheus/client_model v0.6.1: go.Histogram. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:4d8914a1da812d3dcf42ecc8c568464f4741f6e00f3a0b9a87de33f121e10cff
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify github.com/prometheus/client_model/go.Histogram in pkg:golang/github.com/prometheus/client_model@v0.6.1
- Symbols
-
- github.com/prometheus/client_model/go.Histogram
- Environment
- go 1.26.6
- Created
- 2026-09-05T14:10:19Z
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.
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract_test.go
Source
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.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/client_model@v0.6.1
Demonstrate these symbols/APIs:
- github.com/prometheus/client_model/go.Histogram
Required runtime conditions:
- ecosystem: golang
- language: go
- packageManager: go@1.26.6
- runtime: go@1.26.6
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:2384306a0711c581c5347a5aeba6191533e6010e5de51e522db7deb5bb6bcb9d","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.1","kind":"HOW","packages":["pkg:golang/github.com/prometheus/client_model@v0.6.1"],"schemaVersion":1,"symbols":["github.com/prometheus/client_model/go.Histogram"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","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/github.com/prometheus/client_model@v0.6.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/client_model@v0.6.1","symbols":["github.com/prometheus/client_model/go.Histogram"],"verifierAdapter":"golang@1"}
module example.com/histogram
go 1.26.6
require (
github.com/prometheus/client_model v0.6.1
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=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
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"
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.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/client_model@v0.6.1"
],
"symbols": [
"github.com/prometheus/client_model/go.Histogram"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.6",
"runtime": "go@1.26.6"
}
}
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)
}
}
Origin Seeder
anonymous