샘플
golang.org/x/tools v0.22.0
검증된 샘플 — golang golang.org/x/tools v0.22.0. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: inspector.New constructs an Inspector from parsed AST…
sha256:d436e0d102090de9d505556e9f57045e39e286aeeef96fc18244e40e5d79d888
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:golang/golang.org/x/tools@v0.22.0
- 생성일
- 2026-08-28T09:02:21Z
컨트랙트
- inspector.New constructs an Inspector from parsed AST files for node filtering and traversal
- inspector.Preorder traverses AST nodes in preorder filtering by specific node types
- inspector.WithStack traverses AST nodes maintaining the ancestor stack and allowing branch control
- intsets.Sparse performs insertion, membership testing, union, and difference operations on sparse integer sets
- analysis.Analyzer defines a modular static analysis pass with metadata and execution function
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.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 pkg:golang/golang.org/x/tools@v0.22.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.22.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:1542a09e372d414dd865aeed54597d56499005bf6bde58693d9f7cd4d62b0591","contract":["inspector.New constructs an Inspector from parsed AST files for node filtering and traversal","inspector.Preorder traverses AST nodes in preorder filtering by specific node types","inspector.WithStack traverses AST nodes maintaining the ancestor stack and allowing branch control","intsets.Sparse performs insertion, membership testing, union, and difference operations on sparse integer sets","analysis.Analyzer defines a modular static analysis pass with metadata and execution function"],"goal":"verify pkg:golang/golang.org/x/tools@v0.22.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.22.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.22.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.22.0","verifierAdapter":"golang@1"}
module sample-golang-tools
go 1.23.0
require golang.org/x/tools v0.22.0
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"golang.org/x/tools/container/intsets"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/ast/inspector"
)
func main() {
// Demonstrate inspector.New and inspector.Preorder
src := `package main
func hello() {
println("hello")
}
func world() {
println("world")
}
`
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "example.go", src, 0)
if err == nil {
inspect := inspector.New([]*ast.File{f})
var funcs []string
inspect.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(n ast.Node) {
if fn, ok := n.(*ast.FuncDecl); ok && fn.Name != nil {
funcs = append(funcs, fn.Name.Name)
}
})
fmt.Printf("Inspector detected functions: %v\n", funcs)
}
// Demonstrate intsets.Sparse
var s intsets.Sparse
s.Insert(42)
s.Insert(100)
fmt.Printf("Sparse set length: %d, contains 42: %v\n", s.Len(), s.Has(42))
// Demonstrate analysis.Analyzer
analyzer := &analysis.Analyzer{
Name: "sampleanalyzer",
Doc: "verifies AST structure",
Run: func(pass *analysis.Pass) (interface{}, error) {
return nil, nil
},
}
fmt.Printf("Analyzer: %s (%s)\n", analyzer.Name, analyzer.Doc)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/tools@v0.22.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.22.0"
]
}
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"os"
"golang.org/x/tools/container/intsets"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/ast/inspector"
)
func main() {
// Assertion 1: inspector.New constructs an Inspector from parsed AST files for node filtering and traversal
src := `package sample
import "fmt"
func hello() {
fmt.Println("hello")
}
func world() {
fmt.Println("world")
}
`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "sample.go", src, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: parser.ParseFile failed: %v\n", err)
os.Exit(1)
}
inspect := inspector.New([]*ast.File{file})
if inspect == nil {
fmt.Fprintln(os.Stderr, "FAIL: inspector.New returned nil")
os.Exit(1)
}
// Assertion 2: inspector.Preorder traverses AST nodes in preorder filtering by specific node types
var funcNames []string
inspect.Preorder([]ast.Node{(*ast.FuncDecl)(nil)}, func(n ast.Node) {
fn, ok := n.(*ast.FuncDecl)
if ok && fn.Name != nil {
funcNames = append(funcNames, fn.Name.Name)
}
})
if len(funcNames) != 2 || funcNames[0] != "hello" || funcNames[1] != "world" {
fmt.Fprintf(os.Stderr, "FAIL: inspector.Preorder unexpected func names: %v\n", funcNames)
os.Exit(1)
}
// Assertion 3: inspector.WithStack traverses AST nodes maintaining the ancestor stack and allowing branch control
var stackDepthAtCall int
inspect.WithStack([]ast.Node{(*ast.CallExpr)(nil)}, func(n ast.Node, push bool, stack []ast.Node) bool {
if push {
stackDepthAtCall++
if len(stack) == 0 {
fmt.Fprintln(os.Stderr, "FAIL: inspector.WithStack stack is empty on push")
os.Exit(1)
}
}
return true
})
if stackDepthAtCall != 2 {
fmt.Fprintf(os.Stderr, "FAIL: inspector.WithStack expected 2 call expressions, got %d\n", stackDepthAtCall)
os.Exit(1)
}
// Assertion 4: intsets.Sparse performs insertion, membership testing, union, and difference operations on sparse integer sets
{
var a, b intsets.Sparse
a.Insert(1)
a.Insert(100)
a.Insert(10000)
if !a.Has(100) || a.Has(200) {
fmt.Fprintln(os.Stderr, "FAIL: intsets.Sparse Has failed")
os.Exit(1)
}
if a.Len() != 3 {
fmt.Fprintf(os.Stderr, "FAIL: intsets.Sparse Len expected 3, got %d\n", a.Len())
os.Exit(1)
}
b.Insert(100)
b.Insert(500)
var union intsets.Sparse
union.Copy(&a)
union.UnionWith(&b)
if union.Len() != 4 || !union.Has(500) || !union.Has(1) {
fmt.Fprintf(os.Stderr, "FAIL: intsets.Sparse UnionWith failed, len=%d\n", union.Len())
os.Exit(1)
}
var diff intsets.Sparse
diff.Copy(&a)
diff.DifferenceWith(&b)
if diff.Len() != 2 || diff.Has(100) || !diff.Has(10000) {
fmt.Fprintf(os.Stderr, "FAIL: intsets.Sparse DifferenceWith failed, len=%d\n", diff.Len())
os.Exit(1)
}
}
// Assertion 5: analysis.Analyzer defines a modular static analysis pass with metadata and execution function
{
ran := false
analyzer := &analysis.Analyzer{
Name: "testanalyzer",
Doc: "verifies test analyzer contract",
Run: func(pass *analysis.Pass) (interface{}, error) {
ran = true
return "ok", nil
},
}
if analyzer.Name != "testanalyzer" || analyzer.Doc != "verifies test analyzer contract" {
fmt.Fprintln(os.Stderr, "FAIL: analysis.Analyzer fields mismatch")
os.Exit(1)
}
res, err := analyzer.Run(nil)
if err != nil || !ran || res != "ok" {
fmt.Fprintf(os.Stderr, "FAIL: analysis.Analyzer Run failed: ran=%v, res=%v, err=%v\n", ran, res, err)
os.Exit(1)
}
}
fmt.Println("PASS: pkg:golang/golang.org/x/tools@v0.22.0 contract passed")
}
오리진 시더
익명