CodeSampleX

Sample

github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99: profile.Line

Verified sample for golang github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99: profile.Line. The contract ran on go 1.26 · linux debian/x64 · docker…

sha256:82f0c1ca8e22ba8760b3e07dc81555a625f746f53076fbe812a2e5c7f2addaf8

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
2
Signing keys that built it
1
Declared environment go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

Verification-run environments

Environment Contract Stages Run
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-09-20
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-20

Case

HOW
Goal
verify github.com/google/pprof/profile.Line in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99
Packages
Symbols
  • github.com/google/pprof/profile.Line
Environment
go 1.26.6
Created
2026-09-20T07:55:47Z

Contract

  1. profile.Line associates a function with a specific source line number in a profile location
  2. Location supports multiple profile.Line entries representing inlined function call frames
  3. profile.CheckValid enforces that profile.Line references a non-nil function defined in the profile
  4. Profile serialization and parsing preserves profile.Line function associations and line numbers across round trips

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • line.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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.Line in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99
Demonstrate these symbols/APIs:
  - github.com/google/pprof/profile.Line
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.6
  - runtime: go@1.26.6

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.
csx.json
{"case":{"caseId":"case:sha256:92c712c922bb151e5d3658947f59f17ff2014186916e4f97f9d75568c961a700","contract":["profile.Line associates a function with a specific source line number in a profile location","Location supports multiple profile.Line entries representing inlined function call frames","profile.CheckValid enforces that profile.Line references a non-nil function defined in the profile","Profile serialization and parsing preserves profile.Line function associations and line numbers across round trips"],"goal":"verify github.com/google/pprof/profile.Line in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99","kind":"HOW","packages":["pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99"],"schemaVersion":1,"symbols":["github.com/google/pprof/profile.Line"]},"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-20200708004538-1a94d8640e99"],"schemaVersion":1,"subject":"pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99","symbols":["github.com/google/pprof/profile.Line"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.25.0

require github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99
go.sum
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-20200708004538-1a94d8640e99 h1:Ak8CrdlwwXwAZxzS66vgPt4U8yUZX7JwLvVR58FN5jM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/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=
line.go
package sample

import (
	"bytes"
	"fmt"

	"github.com/google/pprof/profile"
)

// NewLine creates a profile.Line associating a function with a source line number.
func NewLine(fn *profile.Function, line int64) profile.Line {
	return profile.Line{
		Function: fn,
		Line:     line,
	}
}

// NewInlinedLocation creates a profile.Location containing multiple inlined lines.
func NewInlinedLocation(id uint64, lines []profile.Line) *profile.Location {
	return &profile.Location{
		ID:   id,
		Line: lines,
	}
}

// CreateProfileWithLocation builds a valid minimal profile containing the provided location and functions.
func CreateProfileWithLocation(loc *profile.Location, fns []*profile.Function) *profile.Profile {
	return &profile.Profile{
		SampleType: []*profile.ValueType{
			{Type: "samples", Unit: "count"},
		},
		PeriodType: &profile.ValueType{Type: "cpu", Unit: "nanoseconds"},
		Period:     10000000,
		Function:   fns,
		Location:   []*profile.Location{loc},
		Sample: []*profile.Sample{
			{
				Location: []*profile.Location{loc},
				Value:    []int64{1},
			},
		},
	}
}

// RoundTripProfile serializes a profile to gzip protobuf bytes and parses it back.
func RoundTripProfile(p *profile.Profile) (*profile.Profile, error) {
	var buf bytes.Buffer
	if err := p.Write(&buf); err != nil {
		return nil, fmt.Errorf("failed to write profile: %w", err)
	}
	parsed, err := profile.Parse(&buf)
	if err != nil {
		return nil, fmt.Errorf("failed to parse profile: %w", err)
	}
	return parsed, nil
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/google/pprof/profile.Line in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99"
  ],
  "symbols": [
    "github.com/google/pprof/profile.Line"
  ],
  "runtimeConditions": {
    "ecosystem": "golang",
    "language": "go",
    "packageManager": "go@1.26.6",
    "runtime": "go@1.26.6"
  }
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/google/pprof/profile"
	"sample"
)

func main() {
	// Assertion 1: profile.Line associates a function with a specific source line number in a profile location
	fn := &profile.Function{
		ID:         1,
		Name:       "computeHash",
		SystemName: "computeHash",
		Filename:   "hash.go",
		StartLine:  10,
	}
	line := sample.NewLine(fn, 25)
	if line.Function != fn {
		fmt.Fprintf(os.Stderr, "line function mismatch: got %v, want %v\n", line.Function, fn)
		os.Exit(1)
	}
	if line.Line != 25 {
		fmt.Fprintf(os.Stderr, "line number mismatch: got %d, want 25\n", line.Line)
		os.Exit(1)
	}

	// Assertion 2: Location supports multiple profile.Line entries representing inlined function call frames
	callerFn := &profile.Function{
		ID:         2,
		Name:       "processRequest",
		SystemName: "processRequest",
		Filename:   "server.go",
		StartLine:  50,
	}
	lines := []profile.Line{
		sample.NewLine(fn, 25),       // innermost inlined frame
		sample.NewLine(callerFn, 72), // caller frame
	}
	loc := sample.NewInlinedLocation(1, lines)
	if len(loc.Line) != 2 {
		fmt.Fprintf(os.Stderr, "expected 2 lines in location, got %d\n", len(loc.Line))
		os.Exit(1)
	}
	if loc.Line[0].Function.Name != "computeHash" || loc.Line[0].Line != 25 {
		fmt.Fprintf(os.Stderr, "innermost frame mismatch: got func %s line %d\n", loc.Line[0].Function.Name, loc.Line[0].Line)
		os.Exit(1)
	}
	if loc.Line[1].Function.Name != "processRequest" || loc.Line[1].Line != 72 {
		fmt.Fprintf(os.Stderr, "caller frame mismatch: got func %s line %d\n", loc.Line[1].Function.Name, loc.Line[1].Line)
		os.Exit(1)
	}

	// Assertion 3: profile.CheckValid enforces that profile.Line references a non-nil function defined in the profile
	p := sample.CreateProfileWithLocation(loc, []*profile.Function{fn, callerFn})
	if err := p.CheckValid(); err != nil {
		fmt.Fprintf(os.Stderr, "valid profile CheckValid failed: %v\n", err)
		os.Exit(1)
	}

	invalidLocNilFn := &profile.Location{
		ID: 2,
		Line: []profile.Line{
			{Function: nil, Line: 10},
		},
	}
	pInvalidNil := sample.CreateProfileWithLocation(invalidLocNilFn, []*profile.Function{fn, callerFn})
	if err := pInvalidNil.CheckValid(); err == nil {
		fmt.Fprintf(os.Stderr, "expected CheckValid error for nil Line.Function, got nil\n")
		os.Exit(1)
	}

	unknownFn := &profile.Function{ID: 99, Name: "orphan", Filename: "orphan.go"}
	invalidLocUnlistedFn := &profile.Location{
		ID: 3,
		Line: []profile.Line{
			{Function: unknownFn, Line: 15},
		},
	}
	pInvalidUnlisted := sample.CreateProfileWithLocation(invalidLocUnlistedFn, []*profile.Function{fn, callerFn})
	if err := pInvalidUnlisted.CheckValid(); err == nil {
		fmt.Fprintf(os.Stderr, "expected CheckValid error for unlisted Line.Function, got nil\n")
		os.Exit(1)
	}

	// Assertion 4: Profile serialization and parsing preserves profile.Line function associations and line numbers across round trips
	rtProfile, err := sample.RoundTripProfile(p)
	if err != nil {
		fmt.Fprintf(os.Stderr, "round trip serialization failed: %v\n", err)
		os.Exit(1)
	}
	if err := rtProfile.CheckValid(); err != nil {
		fmt.Fprintf(os.Stderr, "round trip profile CheckValid failed: %v\n", err)
		os.Exit(1)
	}
	if len(rtProfile.Location) != 1 || len(rtProfile.Location[0].Line) != 2 {
		fmt.Fprintf(os.Stderr, "round trip line count mismatch: got %d locations\n", len(rtProfile.Location))
		os.Exit(1)
	}
	rtLines := rtProfile.Location[0].Line
	if rtLines[0].Function == nil || rtLines[0].Function.Name != "computeHash" || rtLines[0].Line != 25 {
		fmt.Fprintf(os.Stderr, "round trip innermost line mismatch\n")
		os.Exit(1)
	}
	if rtLines[1].Function == nil || rtLines[1].Function.Name != "processRequest" || rtLines[1].Line != 72 {
		fmt.Fprintf(os.Stderr, "round trip caller line mismatch\n")
		os.Exit(1)
	}

	fmt.Println("All profile.Line contract assertions passed.")
}

Origin Seeder

anonymous