Beispiel
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe: profile.Sample
Verifiziertes Beispiel für golang github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe: profile.Sample. Der Vertrag lief auf go 1.26 · linux debian/x64…
sha256:1a037e1e4cf1e141cb4748546fc04a0e880dcc6c8a209f108f27618bd7f0960e
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-10-10 |
Fall
HOW- Ziel
- verify github.com/google/pprof/profile.Sample in pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe
- Symbole
-
- github.com/google/pprof/profile.Sample
- Umgebung
- go 1.26.6
- Erstellt
- 2026-10-10T01:32:28Z
Contract
- profile.Sample records stack locations and numeric sample values
- profile.Sample HasLabel verifies presence of string key-value tags
- profile.Sample NumLabel associates numeric measurements with unit tags
- profile.Sample DiffBaseSample identifies differential comparison base samples
- profile.Sample round-trips correctly through Profile serialization and parsing
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
Quelltext
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/google/pprof/profile.Sample in pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe
Demonstrate these symbols/APIs:
- github.com/google/pprof/profile.Sample
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:b6714dea6c6a25088467555f9a948d526ad36c763291e191e97dcfff2c2128c3","contract":["profile.Sample records stack locations and numeric sample values","profile.Sample HasLabel verifies presence of string key-value tags","profile.Sample NumLabel associates numeric measurements with unit tags","profile.Sample DiffBaseSample identifies differential comparison base samples","profile.Sample round-trips correctly through Profile serialization and parsing"],"goal":"verify github.com/google/pprof/profile.Sample in pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe","kind":"HOW","packages":["pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe"],"schemaVersion":1,"symbols":["github.com/google/pprof/profile.Sample"]},"contractCommand":["go","run","./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/google/pprof@v0.0.0-20260906184651-6331bc6350fe"],"schemaVersion":1,"subject":"pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe","symbols":["github.com/google/pprof/profile.Sample"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe h1:QAinXoAFJdGQYztXn3VpFey7KCwpedbZ/EkzbplQ0cY=
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
{
"schemaVersion": 1,
"goal": "verify github.com/google/pprof/profile.Sample in pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe"
],
"symbols": [
"github.com/google/pprof/profile.Sample"
]
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/google/pprof/profile"
)
func main() {
if err := runTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All contract tests passed successfully.")
}
func runTests() error {
// 1. profile.Sample records stack locations and numeric sample values
loc1 := &profile.Location{
ID: 1,
Address: 0x401000,
}
loc2 := &profile.Location{
ID: 2,
Address: 0x402000,
}
sample := &profile.Sample{
Location: []*profile.Location{loc1, loc2},
Value: []int64{10, 500000},
}
if len(sample.Location) != 2 {
return fmt.Errorf("expected 2 locations, got %d", len(sample.Location))
}
if sample.Location[0].ID != 1 || sample.Location[1].ID != 2 {
return fmt.Errorf("location IDs mismatch: got %d and %d", sample.Location[0].ID, sample.Location[1].ID)
}
if len(sample.Value) != 2 || sample.Value[0] != 10 || sample.Value[1] != 500000 {
return fmt.Errorf("unexpected sample values: %v", sample.Value)
}
// 2. profile.Sample HasLabel verifies presence of string key-value tags
sample.Label = map[string][]string{
"thread": {"worker-1"},
"request": {"GET /api/v1/items", "retry"},
}
if !sample.HasLabel("thread", "worker-1") {
return fmt.Errorf("expected HasLabel(\"thread\", \"worker-1\") to be true")
}
if !sample.HasLabel("request", "retry") {
return fmt.Errorf("expected HasLabel(\"request\", \"retry\") to be true")
}
if sample.HasLabel("thread", "worker-2") {
return fmt.Errorf("expected HasLabel(\"thread\", \"worker-2\") to be false")
}
if sample.HasLabel("nonexistent", "value") {
return fmt.Errorf("expected HasLabel on missing key to be false")
}
// 3. profile.Sample NumLabel associates numeric measurements with unit tags
sample.NumLabel = map[string][]int64{
"bytes": {1024, 2048},
"count": {42},
}
sample.NumUnit = map[string][]string{
"bytes": {"bytes", "bytes"},
"count": {"items"},
}
if len(sample.NumLabel["bytes"]) != 2 || sample.NumLabel["bytes"][0] != 1024 {
return fmt.Errorf("unexpected NumLabel[\"bytes\"]: %v", sample.NumLabel["bytes"])
}
if len(sample.NumUnit["bytes"]) != 2 || sample.NumUnit["bytes"][0] != "bytes" {
return fmt.Errorf("unexpected NumUnit[\"bytes\"]: %v", sample.NumUnit["bytes"])
}
// 4. profile.Sample DiffBaseSample identifies differential comparison base samples
baseSample := &profile.Sample{
Value: []int64{5, 250000},
Label: map[string][]string{
"pprof::base": {"true"},
},
}
if !baseSample.DiffBaseSample() {
return fmt.Errorf("expected DiffBaseSample() to return true for pprof::base=true")
}
if sample.DiffBaseSample() {
return fmt.Errorf("expected DiffBaseSample() to return false for sample without pprof::base")
}
// 5. profile.Sample round-trips correctly through Profile serialization and parsing
fn := &profile.Function{
ID: 1,
Name: "testFunc",
}
locWithFn := &profile.Location{
ID: 1,
Address: 0x401000,
Line: []profile.Line{
{
Function: fn,
Line: 42,
},
},
}
p := &profile.Profile{
SampleType: []*profile.ValueType{
{Type: "samples", Unit: "count"},
{Type: "cpu", Unit: "nanoseconds"},
},
Sample: []*profile.Sample{
{
Location: []*profile.Location{locWithFn},
Value: []int64{1, 1000},
Label: map[string][]string{
"env": {"prod"},
},
NumLabel: map[string][]int64{
"latency": {120},
},
NumUnit: map[string][]string{
"latency": {"ms"},
},
},
},
Location: []*profile.Location{locWithFn},
Function: []*profile.Function{fn},
}
if err := p.CheckValid(); err != nil {
return fmt.Errorf("profile CheckValid failed before serialization: %w", err)
}
var buf bytes.Buffer
if err := p.Write(&buf); err != nil {
return fmt.Errorf("profile Write failed: %w", err)
}
parsed, err := profile.Parse(&buf)
if err != nil {
return fmt.Errorf("profile Parse failed: %w", err)
}
if len(parsed.Sample) != 1 {
return fmt.Errorf("expected 1 sample after parse, got %d", len(parsed.Sample))
}
parsedSample := parsed.Sample[0]
if len(parsedSample.Value) != 2 || parsedSample.Value[0] != 1 || parsedSample.Value[1] != 1000 {
return fmt.Errorf("parsed sample values mismatch: %v", parsedSample.Value)
}
if !parsedSample.HasLabel("env", "prod") {
return fmt.Errorf("parsed sample missing label env=prod")
}
if len(parsedSample.NumLabel["latency"]) == 0 || parsedSample.NumLabel["latency"][0] != 120 {
return fmt.Errorf("parsed sample NumLabel latency mismatch: %v", parsedSample.NumLabel)
}
if len(parsedSample.NumUnit["latency"]) == 0 || parsedSample.NumUnit["latency"][0] != "ms" {
return fmt.Errorf("parsed sample NumUnit latency mismatch: %v", parsedSample.NumUnit)
}
return nil
}
Ursprungs-Seeder
anonym