Sample
github.com/prometheus/common v0.71.0: version
Verified sample for golang github.com/prometheus/common v0.71.0: version. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:73197198b04bc5e97ba82284aa32aa272188fc8c0018a6670372ec4a1e543a5c
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
linux 24 · ubuntu · glibc 2.39 x64 go
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/common/version in pkg:golang/github.com/prometheus/common@v0.71.0
- Packages
- Symbols
-
- github.com/prometheus/common/version
- Created
- 2026-09-05T08:35:10Z
Contract
- version.Print, version.Info, and version.BuildContext format build and runtime version strings including program name, Go version, and platform
- version.ComponentUserAgent and version.PrometheusUserAgent construct formatted user-agent headers combining component names and version numbers
- version.Slog generates structured key-value attributes for slog logging including version, revision, branch, build date, and runtime system fields
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
- version_info.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/common/version in pkg:golang/github.com/prometheus/common@v0.71.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/common@v0.71.0
Demonstrate these symbols/APIs:
- github.com/prometheus/common/version
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:6a59e262f374996609941ba7c0c3f99e6947d9ac260f0615cc3716a6fc0550d2","contract":["version.Print, version.Info, and version.BuildContext format build and runtime version strings including program name, Go version, and platform","version.ComponentUserAgent and version.PrometheusUserAgent construct formatted user-agent headers combining component names and version numbers","version.Slog generates structured key-value attributes for slog logging including version, revision, branch, build date, and runtime system fields"],"goal":"verify github.com/prometheus/common/version in pkg:golang/github.com/prometheus/common@v0.71.0","kind":"HOW","packages":["pkg:golang/github.com/prometheus/common@v0.71.0"],"schemaVersion":1,"symbols":["github.com/prometheus/common/version"]},"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/github.com/prometheus/common@v0.71.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/common@v0.71.0","symbols":["github.com/prometheus/common/version"],"verifierAdapter":"golang@1"}
module example.com/version-sample
go 1.25.0
require github.com/prometheus/common v0.71.0
github.com/prometheus/common v0.71.0 h1:9KDAKb7Mj3HEVKyFCK6Dc/HIwlBzZIN2l7/lrHl3KK8=
github.com/prometheus/common v0.71.0/go.mod h1:CLJ5H8TEsGX8bl31BdMkfhIZ+QmZ9tBPPotUxUbfcmk=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
{
"schemaVersion": 1,
"goal": "verify github.com/prometheus/common/version in pkg:golang/github.com/prometheus/common@v0.71.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/common@v0.71.0"
],
"symbols": [
"github.com/prometheus/common/version"
]
}
package main
import (
"fmt"
"os"
"strings"
versionsample "example.com/version-sample"
"github.com/prometheus/common/version"
)
func main() {
// Assertion 1: Verify default runtime information
if version.GoVersion == "" {
fmt.Fprintf(os.Stderr, "FAIL: expected non-empty version.GoVersion\n")
os.Exit(1)
}
if version.GoOS == "" || version.GoArch == "" {
fmt.Fprintf(os.Stderr, "FAIL: expected non-empty GoOS and GoArch\n")
os.Exit(1)
}
defaultCtx := version.BuildContext()
if !strings.Contains(defaultCtx, "go=") || !strings.Contains(defaultCtx, "platform=") {
fmt.Fprintf(os.Stderr, "FAIL: BuildContext missing expected default fields: %s\n", defaultCtx)
os.Exit(1)
}
// Assertion 2: Configure build variables and verify Print, Info, BuildContext
version.Version = "2.1.0"
version.Revision = "1a2b3c4d"
version.Branch = "release-2.1"
version.BuildUser = "ci-builder"
version.BuildDate = "2026-09-05T00:00:00Z"
expectedInfo := "(version=2.1.0, branch=release-2.1, revision=1a2b3c4d)"
if info := version.Info(); info != expectedInfo {
fmt.Fprintf(os.Stderr, "FAIL: Info() mismatch: got %q, want %q\n", info, expectedInfo)
os.Exit(1)
}
expectedCtx := fmt.Sprintf("(go=%s, platform=%s/%s, user=ci-builder, date=2026-09-05T00:00:00Z, tags=%s)",
version.GoVersion, version.GoOS, version.GoArch, version.GetTags())
if ctx := version.BuildContext(); ctx != expectedCtx {
fmt.Fprintf(os.Stderr, "FAIL: BuildContext() mismatch: got %q, want %q\n", ctx, expectedCtx)
os.Exit(1)
}
printOut := version.Print("test-service")
if !strings.Contains(printOut, "test-service, version 2.1.0 (branch: release-2.1, revision: 1a2b3c4d)") {
fmt.Fprintf(os.Stderr, "FAIL: Print() missing header line: %s\n", printOut)
os.Exit(1)
}
if !strings.Contains(printOut, "build user: ci-builder") || !strings.Contains(printOut, "build date: 2026-09-05T00:00:00Z") {
fmt.Fprintf(os.Stderr, "FAIL: Print() missing build user or build date: %s\n", printOut)
os.Exit(1)
}
// Assertion 3: Verify UserAgent generation
if ua := version.PrometheusUserAgent(); ua != "Prometheus/2.1.0" {
fmt.Fprintf(os.Stderr, "FAIL: PrometheusUserAgent mismatch: got %q, want %q\n", ua, "Prometheus/2.1.0")
os.Exit(1)
}
if ua := version.ComponentUserAgent("Alertmanager"); ua != "Alertmanager/2.1.0" {
fmt.Fprintf(os.Stderr, "FAIL: ComponentUserAgent mismatch: got %q, want %q\n", ua, "Alertmanager/2.1.0")
os.Exit(1)
}
if ua := versionsample.FormatUserAgent("Pushgateway"); ua != "Pushgateway/2.1.0" {
fmt.Fprintf(os.Stderr, "FAIL: versionsample.FormatUserAgent mismatch: got %q, want %q\n", ua, "Pushgateway/2.1.0")
os.Exit(1)
}
// Assertion 4: Verify Slog structured logging key-values
attrs := version.Slog()
if len(attrs)%2 != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected even number of slog key-value pairs, got %d\n", len(attrs))
os.Exit(1)
}
attrMap := make(map[string]any)
for i := 0; i < len(attrs); i += 2 {
key, ok := attrs[i].(string)
if !ok {
fmt.Fprintf(os.Stderr, "FAIL: slog attribute key at index %d is not a string\n", i)
os.Exit(1)
}
attrMap[key] = attrs[i+1]
}
if attrMap["version"] != "2.1.0" || attrMap["revision"] != "1a2b3c4d" || attrMap["branch"] != "release-2.1" {
fmt.Fprintf(os.Stderr, "FAIL: slog attributes mismatch on version/revision/branch: %+v\n", attrMap)
os.Exit(1)
}
if attrMap["builduser"] != "ci-builder" || attrMap["builddate"] != "2026-09-05T00:00:00Z" {
fmt.Fprintf(os.Stderr, "FAIL: slog attributes mismatch on builduser/builddate: %+v\n", attrMap)
os.Exit(1)
}
if attrMap["goversion"] != version.GoVersion || attrMap["goos"] != version.GoOS || attrMap["goarch"] != version.GoArch {
fmt.Fprintf(os.Stderr, "FAIL: slog attributes mismatch on runtime fields: %+v\n", attrMap)
os.Exit(1)
}
// Assertion 5: Verify BuildSummary wrapper
summary := versionsample.GetBuildSummary("test-daemon")
if summary.Program != "test-daemon" || summary.UserAgent != "Prometheus/2.1.0" || summary.Info != expectedInfo {
fmt.Fprintf(os.Stderr, "FAIL: BuildSummary mismatch: %+v\n", summary)
os.Exit(1)
}
fmt.Println("PASS: version contract passed")
}
package versionsample
import (
"github.com/prometheus/common/version"
)
// BuildSummary aggregates application identity and version context.
type BuildSummary struct {
Program string
Info string
Context string
UserAgent string
SlogAttrs []any
}
// GetBuildSummary returns formatted version details for the given program name.
func GetBuildSummary(program string) BuildSummary {
return BuildSummary{
Program: program,
Info: version.Info(),
Context: version.BuildContext(),
UserAgent: version.PrometheusUserAgent(),
SlogAttrs: version.Slog(),
}
}
// FormatUserAgent returns a component-specific user agent string.
func FormatUserAgent(component string) string {
return version.ComponentUserAgent(component)
}
Origin Seeder
anonymous