Exemplo
golang.org/x/tools v0.6.0
Amostra verificada para golang golang.org/x/tools v0.6.0. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou: imports.Process formats Go source…
sha256:3d5ad545846bb4b8f607dc0728ee38d58aace64345948fc49e6db75b445809d2
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-16 |
Caso
HOW- Objetivo
- verify pkg:golang/golang.org/x/tools@v0.6.0
- Pacotes
- Criado
- 2026-09-16T01:50:13Z
Contrato
- imports.Process formats Go source code and automatically resolves required standard package imports
- imports.VendorlessPath returns the un-vendored package import path
- cfg.New constructs a control flow graph containing entry, exit, and branch blocks for a function AST
- typeutil.Map associates arbitrary values with go/types Type keys using type identity
- cover.ParseProfilesFromReader parses Go coverage profile data into structured Profile and ProfileBlock entries
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código-fonte
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.6.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.6.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:646a5b39761db188bfc344ebca6237c5df8342ad993eeb9e428a3569c0ef15f7","contract":["imports.Process formats Go source code and automatically resolves required standard package imports","imports.VendorlessPath returns the un-vendored package import path","cfg.New constructs a control flow graph containing entry, exit, and branch blocks for a function AST","typeutil.Map associates arbitrary values with go/types Type keys using type identity","cover.ParseProfilesFromReader parses Go coverage profile data into structured Profile and ProfileBlock entries"],"goal":"verify pkg:golang/golang.org/x/tools@v0.6.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.6.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.6.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.6.0","verifierAdapter":"golang@1"}
module sample-golang-tools
go 1.23.0
require golang.org/x/tools v0.6.0
require (
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.5.0 // indirect
)
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"go/types"
"strings"
"golang.org/x/tools/cover"
"golang.org/x/tools/go/cfg"
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/imports"
)
func main() {
// Demonstrate imports.Process
src := []byte("package main\n\nfunc run() {\n\tfmt.Println(\"CodeSampleX\")\n}\n")
opt := &imports.Options{
TabWidth: 8,
TabIndent: true,
Comments: true,
}
formatted, err := imports.Process("example.go", src, opt)
if err == nil {
fmt.Printf("Formatted source with imports:\n%s\n", string(formatted))
}
// Demonstrate cfg.New
code := `package main
func calculate(a, b int) int {
if a > b {
return a - b
}
return b - a
}`
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "calc.go", code, 0)
if err == nil && len(f.Decls) > 0 {
if fn, ok := f.Decls[0].(*ast.FuncDecl); ok {
controlFlow := cfg.New(fn.Body, func(call *ast.CallExpr) bool { return true })
fmt.Printf("Control-flow graph blocks count: %d\n", len(controlFlow.Blocks))
}
}
// Demonstrate typeutil.Map
var typeMap typeutil.Map
intType := types.Typ[types.Int]
typeMap.Set(intType, "builtin-int")
fmt.Printf("typeutil.Map contains %d types, intType description: %v\n", typeMap.Len(), typeMap.At(intType))
// Demonstrate cover.ParseProfilesFromReader
covData := "mode: set\nexample.com/mod/pkg/file.go:10.14,12.2 1 1\nexample.com/mod/pkg/file.go:14.5,18.10 2 0\n"
profiles, err := cover.ParseProfilesFromReader(strings.NewReader(covData))
if err == nil {
fmt.Printf("Parsed coverage profiles: %d\n", len(profiles))
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/tools@v0.6.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.6.0"
]
}
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"go/types"
"os"
"strings"
"golang.org/x/tools/cover"
"golang.org/x/tools/go/cfg"
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/imports"
)
func main() {
// Assertion 1: imports.Process formats Go source code and automatically resolves required standard package imports
{
unformattedSrc := []byte("package main\n\nfunc hello() {\n\tstrings.ToUpper(\"test\")\n}\n")
opts := &imports.Options{
TabWidth: 8,
TabIndent: true,
Comments: true,
}
formatted, err := imports.Process("main.go", unformattedSrc, opts)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: imports.Process returned error: %v\n", err)
os.Exit(1)
}
formattedStr := string(formatted)
if !strings.Contains(formattedStr, "\"strings\"") {
fmt.Fprintf(os.Stderr, "FAIL: imports.Process did not insert strings import: %s\n", formattedStr)
os.Exit(1)
}
if !strings.Contains(formattedStr, "func hello()") {
fmt.Fprintf(os.Stderr, "FAIL: imports.Process corrupted function declaration: %s\n", formattedStr)
os.Exit(1)
}
}
// Assertion 2: imports.VendorlessPath returns the un-vendored package import path
{
vendoredPath := "github.com/example/repo/vendor/golang.org/x/tools"
vendorless := imports.VendorlessPath(vendoredPath)
if vendorless != "golang.org/x/tools" {
fmt.Fprintf(os.Stderr, "FAIL: imports.VendorlessPath expected 'golang.org/x/tools', got %q\n", vendorless)
os.Exit(1)
}
plainPath := "net/http"
if imports.VendorlessPath(plainPath) != "net/http" {
fmt.Fprintf(os.Stderr, "FAIL: imports.VendorlessPath modified non-vendored path: %q\n", imports.VendorlessPath(plainPath))
os.Exit(1)
}
}
// Assertion 3: cfg.New constructs a control flow graph containing entry, exit, and branch blocks for a function AST
{
src := `package main
func check(val int) string {
if val > 0 {
return "positive"
}
return "non-positive"
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "check.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile failed: %v\n", err)
os.Exit(1)
}
if len(file.Decls) == 0 {
fmt.Fprintln(os.Stderr, "FAIL: no declarations parsed")
os.Exit(1)
}
fn, ok := file.Decls[0].(*ast.FuncDecl)
if !ok || fn.Body == nil {
fmt.Fprintln(os.Stderr, "FAIL: expected FuncDecl with body")
os.Exit(1)
}
c := cfg.New(fn.Body, func(call *ast.CallExpr) bool { return true })
if c == nil {
fmt.Fprintln(os.Stderr, "FAIL: cfg.New returned nil CFG")
os.Exit(1)
}
if len(c.Blocks) < 3 {
fmt.Fprintf(os.Stderr, "FAIL: cfg.New expected at least 3 blocks for if-return, got %d\n", len(c.Blocks))
os.Exit(1)
}
entryBlock := c.Blocks[0]
if len(entryBlock.Succs) == 0 && len(c.Blocks) > 1 {
fmt.Fprintln(os.Stderr, "FAIL: entry block has no successors in multi-block CFG")
os.Exit(1)
}
}
// Assertion 4: typeutil.Map associates arbitrary values with go/types Type keys using type identity
{
var m typeutil.Map
intType := types.Typ[types.Int]
stringType := types.Typ[types.String]
boolType := types.Typ[types.Bool]
m.Set(intType, "integer-type")
m.Set(stringType, "string-type")
if m.Len() != 2 {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Map Len expected 2, got %d\n", m.Len())
os.Exit(1)
}
valInt := m.At(intType)
if valInt != "integer-type" {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Map At(intType) expected 'integer-type', got %v\n", valInt)
os.Exit(1)
}
valStr := m.At(stringType)
if valStr != "string-type" {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Map At(stringType) expected 'string-type', got %v\n", valStr)
os.Exit(1)
}
valBool := m.At(boolType)
if valBool != nil {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Map At(boolType) expected nil, got %v\n", valBool)
os.Exit(1)
}
deleted := m.Delete(intType)
if !deleted || m.Len() != 1 || m.At(intType) != nil {
fmt.Fprintf(os.Stderr, "FAIL: typeutil.Map Delete failed: deleted=%v, len=%d\n", deleted, m.Len())
os.Exit(1)
}
}
// Assertion 5: cover.ParseProfilesFromReader parses Go coverage profile data into structured Profile and ProfileBlock entries
{
coverageData := "mode: set\nexample.com/mod/pkg/file.go:10.14,12.2 1 1\nexample.com/mod/pkg/file.go:14.5,18.10 2 0\n"
profiles, err := cover.ParseProfilesFromReader(strings.NewReader(coverageData))
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: cover.ParseProfilesFromReader failed: %v\n", err)
os.Exit(1)
}
if len(profiles) != 1 {
fmt.Fprintf(os.Stderr, "FAIL: expected 1 Profile, got %d\n", len(profiles))
os.Exit(1)
}
p := profiles[0]
if p.FileName != "example.com/mod/pkg/file.go" {
fmt.Fprintf(os.Stderr, "FAIL: unexpected profile FileName: %q\n", p.FileName)
os.Exit(1)
}
if p.Mode != "set" {
fmt.Fprintf(os.Stderr, "FAIL: unexpected profile Mode: %q\n", p.Mode)
os.Exit(1)
}
if len(p.Blocks) != 2 {
fmt.Fprintf(os.Stderr, "FAIL: expected 2 blocks, got %d\n", len(p.Blocks))
os.Exit(1)
}
b0 := p.Blocks[0]
if b0.StartLine != 10 || b0.StartCol != 14 || b0.EndLine != 12 || b0.EndCol != 2 || b0.NumStmt != 1 || b0.Count != 1 {
fmt.Fprintf(os.Stderr, "FAIL: unexpected block 0: %+v\n", b0)
os.Exit(1)
}
b1 := p.Blocks[1]
if b1.StartLine != 14 || b1.StartCol != 5 || b1.EndLine != 18 || b1.EndCol != 10 || b1.NumStmt != 2 || b1.Count != 0 {
fmt.Fprintf(os.Stderr, "FAIL: unexpected block 1: %+v\n", b1)
os.Exit(1)
}
}
fmt.Println("PASS: golang.org/x/tools@v0.6.0 contract passed")
}
Seeder de origem
anônimo