Ejemplo
golang.org/x/tools v0.14.0
Muestra verificada para golang golang.org/x/tools v0.14.0. El contrato se ejecutó en go 1.26 · linux alpine/x64 · docker y pasó.
sha256:443da86d1dcb258ef2be41587345fe68dec823a88187042d6c0b6a7df3ebd1eb
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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Caso
HOW- Objetivo
- verify pkg:golang/golang.org/x/tools@v0.14.0
- Paquetes
- Creado
- 2026-08-28T09:13:18Z
Contrato
- astutil.UsesImport determines whether an AST file contains references to an imported package
- astutil.PathEnclosingInterval identifies the AST node stack enclosing a token position range
- typeutil.IntuitiveMethodSet returns the method set of a type including promoted methods
- typeutil.MakeHasher creates a type hasher for consistent identity hashing across types
- typeutil.Dependencies computes the transitive dependencies of a set of packages
Archivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código fuente
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/golang.org/x/tools@v0.14.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.14.0
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:87f31270e00d90fe31a84dd3ff730b58d7f09b302fe890c58e42d6939a178ffe","contract":["astutil.UsesImport determines whether an AST file contains references to an imported package","astutil.PathEnclosingInterval identifies the AST node stack enclosing a token position range","typeutil.IntuitiveMethodSet returns the method set of a type including promoted methods","typeutil.MakeHasher creates a type hasher for consistent identity hashing across types","typeutil.Dependencies computes the transitive dependencies of a set of packages"],"goal":"verify pkg:golang/golang.org/x/tools@v0.14.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.14.0"],"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/golang.org/x/tools@v0.14.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.14.0","verifierAdapter":"golang@1"}
module sample-golang-tools
go 1.25.0
require golang.org/x/tools v0.14.0
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
package main
import (
"fmt"
"go/parser"
"go/token"
"go/types"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/types/typeutil"
)
func main() {
src := `package main
import "fmt"
func hello() {
fmt.Println("hello world")
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "hello.go", src, 0)
if err != nil {
panic(err)
}
// 1. astutil.UsesImport
usesFmt := astutil.UsesImport(file, "fmt")
fmt.Printf("Uses import fmt: %v\n", usesFmt)
// 2. astutil.PathEnclosingInterval
path, exact := astutil.PathEnclosingInterval(file, file.Pos(), file.End())
fmt.Printf("Enclosing nodes: %d, exact: %v\n", len(path), exact)
// 3. typeutil.MakeHasher
hasher := typeutil.MakeHasher()
intType := types.Typ[types.Int]
hashVal := hasher.Hash(intType)
fmt.Printf("Int type hash: %d\n", hashVal)
// 4. typeutil.IntuitiveMethodSet
mset := typeutil.IntuitiveMethodSet(intType, nil)
fmt.Printf("Int method count: %d\n", len(mset))
// 5. typeutil.Dependencies
pkg := types.NewPackage("example/pkg", "pkg")
deps := typeutil.Dependencies(pkg)
fmt.Printf("Dependencies count: %d\n", len(deps))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/tools@v0.14.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.14.0"
]
}
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"go/types"
"os"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/types/typeutil"
)
func main() {
// Assertion 1: astutil.UsesImport determines whether an AST file contains references to an imported package
{
src := `package main
import "fmt"
func hello() {
fmt.Println("test")
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile error: %v\n", err)
os.Exit(1)
}
if !astutil.UsesImport(file, "fmt") {
fmt.Fprintln(os.Stderr, "FAIL: astutil.UsesImport returned false for used import 'fmt'")
os.Exit(1)
}
if astutil.UsesImport(file, "os") {
fmt.Fprintln(os.Stderr, "FAIL: astutil.UsesImport returned true for unused package 'os'")
os.Exit(1)
}
}
// Assertion 2: astutil.PathEnclosingInterval identifies the AST node stack enclosing a token position range
{
src := `package main
func targetFunc() int {
return 42
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "target.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile error: %v\n", err)
os.Exit(1)
}
// Find position of FuncDecl
var targetPos token.Pos
ast.Inspect(file, func(n ast.Node) bool {
if fd, ok := n.(*ast.FuncDecl); ok && fd.Name.Name == "targetFunc" {
targetPos = fd.Name.Pos()
return false
}
return true
})
if !targetPos.IsValid() {
fmt.Fprintln(os.Stderr, "FAIL: targetFunc position not found")
os.Exit(1)
}
path, exact := astutil.PathEnclosingInterval(file, targetPos, targetPos)
if !exact || len(path) == 0 {
fmt.Fprintf(os.Stderr, "FAIL: astutil.PathEnclosingInterval exact=%v, len(path)=%d\n", exact, len(path))
os.Exit(1)
}
ident, ok := path[0].(*ast.Ident)
if !ok || ident.Name != "targetFunc" {
fmt.Fprintf(os.Stderr, "FAIL: innermost node expected *ast.Ident 'targetFunc', got %T\n", path[0])
os.Exit(1)
}
_, isFile := path[len(path)-1].(*ast.File)
if !isFile {
fmt.Fprintf(os.Stderr, "FAIL: outermost node expected *ast.File, got %T\n", path[len(path)-1])
os.Exit(1)
}
}
// Assertion 3: typeutil.IntuitiveMethodSet returns the method set of a type including promoted methods
{
pkg := types.NewPackage("example/types", "types")
innerStruct := types.NewStruct(nil, nil)
innerNamed := types.NewNamed(types.NewTypeName(token.NoPos, pkg, "Inner", nil), innerStruct, nil)
recvVar := types.NewVar(token.NoPos, pkg, "recv", innerNamed)
sig := types.NewSignatureType(recvVar, nil, nil, nil, nil, false)
innerMethod := types.NewFunc(token.NoPos, pkg, "DoWork", sig)
innerNamed.AddMethod(innerMethod)
outerField := types.NewField(token.NoPos, pkg, "Inner", innerNamed, true) // embedded field
outerStruct := types.NewStruct([]*types.Var{outerField}, nil)
outerNamed := types.NewNamed(types.NewTypeName(token.NoPos, pkg, "Outer", nil), outerStruct, nil)
mset := typeutil.IntuitiveMethodSet(outerNamed, nil)
found := false
for _, sel := range mset {
if sel.Obj().Name() == "DoWork" {
found = true
break
}
}
if !found {
fmt.Fprintln(os.Stderr, "FAIL: typeutil.IntuitiveMethodSet did not find promoted method 'DoWork'")
os.Exit(1)
}
}
// Assertion 4: typeutil.MakeHasher creates a type hasher for consistent identity hashing across types
{
hasher := typeutil.MakeHasher()
slice1 := types.NewSlice(types.Typ[types.Int])
slice2 := types.NewSlice(types.Typ[types.Int])
slice3 := types.NewSlice(types.Typ[types.String])
h1 := hasher.Hash(slice1)
h2 := hasher.Hash(slice2)
h3 := hasher.Hash(slice3)
if h1 != h2 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.MakeHasher expected identical hashes for identical slice types: %d != %d\n", h1, h2)
os.Exit(1)
}
if h1 == h3 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.MakeHasher expected different hashes for distinct types: %d == %d\n", h1, h3)
os.Exit(1)
}
}
// Assertion 5: typeutil.Dependencies computes the transitive dependencies of a set of packages
{
pkgC := types.NewPackage("example/pkgC", "pkgC")
pkgB := types.NewPackage("example/pkgB", "pkgB")
pkgB.SetImports([]*types.Package{pkgC})
pkgA := types.NewPackage("example/pkgA", "pkgA")
pkgA.SetImports([]*types.Package{pkgB})
deps := typeutil.Dependencies(pkgA)
if len(deps) != 3 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Dependencies expected 3 packages, got %d\n", len(deps))
os.Exit(1)
}
paths := make([]string, len(deps))
for i, p := range deps {
paths[i] = p.Path()
}
// Topological order: pkgC, pkgB, pkgA
if paths[0] != "example/pkgC" || paths[1] != "example/pkgB" || paths[2] != "example/pkgA" {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Dependencies topological order mismatch: %v\n", paths)
os.Exit(1)
}
}
fmt.Println("PASS: golang.org/x/tools contract passed")
}
Seeder de origen
anónimo