サンプル
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe: profile.Parse
検証済みサンプル — golang github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe: profile.Parse. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.
sha256:62a46c29acf108bfebbc4f6ae422d6ee29df447dfc662f37554b9df2363f13ac
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify github.com/google/pprof/profile.Parse in pkg:golang/github.com/google/pprof@v0.0.0-20260906184651-6331bc6350fe
- シンボル
-
- github.com/google/pprof/profile.Parse
- 環境
- go 1.26.6
- 作成日
- 2026-10-10T00:39:42Z
コントラクト
- profile.Profile creates and validates a structured cpu/memory profile with CheckValid
- profile.Profile.Write serializes the profile into gzip-compressed protobuf format
- profile.Parse parses serialized profile data and restores samples, locations, and functions
ファイル
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.go
- 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 github.com/google/pprof/profile.Parse 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.Parse
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:051ae67caf96d3d367f667baebcba46f325e981addbed53f8e65b8289a8207eb","contract":["profile.Profile creates and validates a structured cpu/memory profile with CheckValid","profile.Profile.Write serializes the profile into gzip-compressed protobuf format","profile.Parse parses serialized profile data and restores samples, locations, and functions"],"goal":"verify github.com/google/pprof/profile.Parse 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.Parse"]},"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.Parse"],"verifierAdapter":"golang@1"}
module sample
go 1.25.0
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=
package sample
import (
"bytes"
"io"
"github.com/google/pprof/profile"
)
// BuildSampleProfile constructs a valid profile with sample type, functions, locations, and samples.
func BuildSampleProfile(functionName, filename string, line int64, sampleCount, cpuNanos int64) (*profile.Profile, error) {
p := &profile.Profile{
SampleType: []*profile.ValueType{
{Type: "samples", Unit: "count"},
{Type: "cpu", Unit: "nanoseconds"},
},
PeriodType: &profile.ValueType{Type: "cpu", Unit: "nanoseconds"},
Period: 10000000,
}
fn := &profile.Function{
ID: 1,
Name: functionName,
SystemName: functionName,
Filename: filename,
StartLine: line,
}
p.Function = []*profile.Function{fn}
loc := &profile.Location{
ID: 1,
Line: []profile.Line{
{
Function: fn,
Line: line + 5,
},
},
}
p.Location = []*profile.Location{loc}
s := &profile.Sample{
Location: []*profile.Location{loc},
Value: []int64{sampleCount, cpuNanos},
}
p.Sample = []*profile.Sample{s}
if err := p.CheckValid(); err != nil {
return nil, err
}
return p, nil
}
// SerializeProfile writes a Profile to an io.Writer in standard pprof format.
func SerializeProfile(p *profile.Profile, w io.Writer) error {
return p.Write(w)
}
// ParseProfile parses a serialized pprof stream from an io.Reader.
func ParseProfile(r io.Reader) (*profile.Profile, error) {
return profile.Parse(r)
}
// EncodeAndDecode serializes and re-parses a profile, returning the decoded profile.
func EncodeAndDecode(p *profile.Profile) (*profile.Profile, error) {
var buf bytes.Buffer
if err := p.Write(&buf); err != nil {
return nil, err
}
return profile.Parse(&buf)
}
{
"schemaVersion": 1,
"goal": "verify github.com/google/pprof/profile.Parse 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.Parse"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.6",
"runtime": "go@1.26.6"
}
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/google/pprof/profile"
"sample"
)
func main() {
// Assertion 1: profile.Profile creates and validates a structured cpu/memory profile with CheckValid
p, err := sample.BuildSampleProfile("worker.processTask", "worker.go", 10, 5, 50000000)
if err != nil {
fmt.Fprintf(os.Stderr, "BuildSampleProfile failed: %v\n", err)
os.Exit(1)
}
var _ *profile.Profile = p
if err := p.CheckValid(); err != nil {
fmt.Fprintf(os.Stderr, "p.CheckValid failed: %v\n", err)
os.Exit(1)
}
if len(p.Sample) != 1 {
fmt.Fprintf(os.Stderr, "expected 1 sample, got %d\n", len(p.Sample))
os.Exit(1)
}
// Assertion 2: profile.Profile.Write serializes the profile into gzip-compressed protobuf format
var buf bytes.Buffer
if err := p.Write(&buf); err != nil {
fmt.Fprintf(os.Stderr, "p.Write failed: %v\n", err)
os.Exit(1)
}
if buf.Len() == 0 {
fmt.Fprintf(os.Stderr, "serialized buffer is empty\n")
os.Exit(1)
}
// Assertion 3: profile.Parse parses serialized profile data and restores samples, locations, and functions
parsed, err := profile.Parse(&buf)
if err != nil {
fmt.Fprintf(os.Stderr, "profile.Parse failed: %v\n", err)
os.Exit(1)
}
if err := parsed.CheckValid(); err != nil {
fmt.Fprintf(os.Stderr, "parsed profile CheckValid failed: %v\n", err)
os.Exit(1)
}
if len(parsed.Sample) != 1 {
fmt.Fprintf(os.Stderr, "expected 1 sample in parsed profile, got %d\n", len(parsed.Sample))
os.Exit(1)
}
if parsed.Sample[0].Value[0] != 5 || parsed.Sample[0].Value[1] != 50000000 {
fmt.Fprintf(os.Stderr, "parsed sample values mismatch: got %v, expected [5, 50000000]\n", parsed.Sample[0].Value)
os.Exit(1)
}
if len(parsed.Function) != 1 || parsed.Function[0].Name != "worker.processTask" {
fmt.Fprintf(os.Stderr, "parsed function mismatch\n")
os.Exit(1)
}
if len(parsed.Location) != 1 || len(parsed.Location[0].Line) != 1 || parsed.Location[0].Line[0].Line != 15 {
fmt.Fprintf(os.Stderr, "parsed location line mismatch\n")
os.Exit(1)
}
fmt.Println("All pprof profile contract assertions passed.")
}
オリジンシーダー
匿名