CodeSampleX

Ejemplo

github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2

Muestra verificada para golang github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y…

sha256:25208857f48e4234607d821c1f984df9ddb1e4882bb431bdaedd5e4477f153a5

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 go

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-29

Caso

HOW
Objetivo
verify pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2
Paquetes
Creado
2026-10-29T16:10:14Z

Contrato

  1. profile.Profile.CheckValid returns nil when SampleType, Sample, Location, and Function references are consistent
  2. profile.Profile.WriteUncompressed serializes a valid Profile into wire format that profile.ParseData round-trips without data loss
  3. profile.Profile.Copy produces an independent deep copy and Scale multiplies Sample.Value entries without mutating the source Profile
  4. profile.Merge combines compatible Profile instances and sums Sample.Value slices for matching sample locations

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2

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:668fd334cb365762c49d8ddf47b143e44ff0eb0de440a8f37fe0b2d886e72051","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 pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2","kind":"HOW","packages":["pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2"],"schemaVersion":1},"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-20201203190320-1bf35d6f28c2"],"schemaVersion":1,"subject":"pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2","verifierAdapter":"golang@1"}
go.mod
module sample

go 1.21

require github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2
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-20201203190320-1bf35d6f28c2 h1:HyOHhUtuB/Ruw/L5s5pG2D0kckkN2/IzBs9OClGHnHI=
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/google/pprof@v0.0.0-20201203190320-1bf35d6f28c2"
  ]
}
test/contract.go
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)
	}
}

Seeder de origen

anónimo