サンプル
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc: profile.Profile
検証済みサンプル — golang github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc: profile.Profile. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.
sha256:24f183e41dc418afa346e171cc4ebdb8dc740c72d21acc22d4e372fcf68d2de1
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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)
}
}
オリジンシーダー
匿名