示例
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc: profile.Profile
已验证示例 — golang github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc: profile.Profile. contract 在 go 1.26 · linux debian/x64 · docker 上运行并通过.
sha256:24f183e41dc418afa346e171cc4ebdb8dc740c72d21acc22d4e372fcf68d2de1
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 go
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-18 |
案例
HOW- 目标
- verify profile.Profile in pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc
- 符号
-
- profile.Profile
- 创建时间
- 2026-10-18T19:12:35Z
契约
- profile.Profile.CheckValid returns nil when SampleType, Sample, Location, and Function references are consistent
- profile.Profile.WriteUncompressed serializes a valid Profile into wire format that profile.ParseData round-trips without data loss
- profile.Profile.Copy produces an independent deep copy and Scale multiplies Sample.Value entries without mutating the source Profile
- profile.Merge combines compatible Profile instances and sums Sample.Value slices for matching sample locations
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
源代码
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 profile.Profile in pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc
Demonstrate these symbols/APIs:
- profile.Profile
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:b878b77e22ea1331197610898d0be6604951597e10ce673e7043a1b79220c055","contract":["profile.Profile.CheckValid returns nil when SampleType, Sample, Location, and Function references are consistent","profile.Profile.WriteUncompressed serializes a valid Profile into wire format that profile.ParseData round-trips without data loss","profile.Profile.Copy produces an independent deep copy and Scale multiplies Sample.Value entries without mutating the source Profile","profile.Merge combines compatible Profile instances and sums Sample.Value slices for matching sample locations"],"goal":"verify profile.Profile in pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc","kind":"HOW","packages":["pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc"],"schemaVersion":1,"symbols":["profile.Profile"]},"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/google/pprof@v0.0.0-20191218002539-d4f498aebedc"],"schemaVersion":1,"subject":"pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc","symbols":["profile.Profile"],"verifierAdapter":"golang@1"}
module sample
go 1.21
require github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc h1:DLpL8pWq0v4JYoRpEhDfsJhhJyGKCcQM2WPW2TJs31c=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
{
"schemaVersion": 1,
"goal": "verify profile.Profile in pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/google/pprof@v0.0.0-20191218002539-d4f498aebedc"
],
"symbols": [
"profile.Profile"
]
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/google/pprof/profile"
)
func main() {
fn := &profile.Function{
ID: 1,
Name: "main.compute",
SystemName: "main.compute",
Filename: "main.go",
StartLine: 10,
}
loc := &profile.Location{
ID: 1,
Address: 0x1000,
Line: []profile.Line{
{Function: fn, Line: 15},
},
}
prof := &profile.Profile{
SampleType: []*profile.ValueType{
{Type: "samples", Unit: "count"},
{Type: "cpu", Unit: "nanoseconds"},
},
DefaultSampleType: "cpu",
Sample: []*profile.Sample{
{
Location: []*profile.Location{loc},
Value: []int64{10, 5000000},
Label: map[string][]string{
"tag": {"worker"},
},
},
},
Location: []*profile.Location{loc},
Function: []*profile.Function{fn},
DurationNanos: 10000000,
PeriodType: &profile.ValueType{Type: "cpu", Unit: "nanoseconds"},
Period: 100000,
}
if err := prof.CheckValid(); err != nil {
fmt.Fprintf(os.Stderr, "initial CheckValid failed: %v\n", err)
os.Exit(1)
}
var buf bytes.Buffer
if err := prof.WriteUncompressed(&buf); err != nil {
fmt.Fprintf(os.Stderr, "WriteUncompressed failed: %v\n", err)
os.Exit(1)
}
parsed, err := profile.ParseData(buf.Bytes())
if err != nil {
fmt.Fprintf(os.Stderr, "ParseData failed: %v\n", err)
os.Exit(1)
}
if err := parsed.CheckValid(); err != nil {
fmt.Fprintf(os.Stderr, "parsed CheckValid failed: %v\n", err)
os.Exit(1)
}
if len(parsed.Sample) != 1 || len(parsed.Sample[0].Value) != 2 || parsed.Sample[0].Value[1] != 5000000 {
fmt.Fprintf(os.Stderr, "unexpected parsed sample values: %+v\n", parsed.Sample)
os.Exit(1)
}
if parsed.Sample[0].Location[0].Line[0].Function.Name != "main.compute" {
fmt.Fprintf(os.Stderr, "unexpected function name: %s\n", parsed.Sample[0].Location[0].Line[0].Function.Name)
os.Exit(1)
}
copied := parsed.Copy()
copied.Scale(2.0)
if copied.Sample[0].Value[0] != 20 || copied.Sample[0].Value[1] != 10000000 {
fmt.Fprintf(os.Stderr, "unexpected scaled values: %v\n", copied.Sample[0].Value)
os.Exit(1)
}
if parsed.Sample[0].Value[0] != 10 {
fmt.Fprintf(os.Stderr, "original mutated on scaled copy: %v\n", parsed.Sample[0].Value)
os.Exit(1)
}
merged, err := profile.Merge([]*profile.Profile{parsed, copied})
if err != nil {
fmt.Fprintf(os.Stderr, "Merge failed: %v\n", err)
os.Exit(1)
}
if err := merged.CheckValid(); err != nil {
fmt.Fprintf(os.Stderr, "merged CheckValid failed: %v\n", err)
os.Exit(1)
}
if len(merged.Sample) != 1 || merged.Sample[0].Value[0] != 30 || merged.Sample[0].Value[1] != 15000000 {
fmt.Fprintf(os.Stderr, "unexpected merged sample values: %+v\n", merged.Sample[0].Value)
os.Exit(1)
}
}
原始种子者
匿名