Sample
golang.org/x/tools v0.31.0: imports.Process
Verified sample for golang golang.org/x/tools v0.31.0: imports.Process. The contract ran on go 1.26 · linux alpine/x64 · docker and passed.
sha256:302d85999ce103fcbb6e32c4bee070682a78b03c3d66314a416094f6a824751e
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
- 1
- 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 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-30 |
Case
HOW- Goal
- verify golang.org/x/tools/imports.Process in pkg:golang/golang.org/x/tools@v0.31.0
- Packages
- Symbols
-
- golang.org/x/tools/imports.Process
- Environment
- go 1.26.6
- Created
- 2026-08-30T08:40:55Z
Contract
- Process formats Go source code and automatically adds missing imports
- Process removes unused imports from Go source code
- Process accepts Options to preserve comments and format source
- Process returns an error when given invalid Go syntax
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- imports_demo.go
- spec.json
- test/contract.go
Source
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 golang.org/x/tools/imports.Process in pkg:golang/golang.org/x/tools@v0.31.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/tools@v0.31.0
Demonstrate these symbols/APIs:
- golang.org/x/tools/imports.Process
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.
{"case":{"caseId":"case:sha256:dfd5171df8c3234596c4bcbac8c4d11b78a7b9e7ed151e4900875c1d3a8d4d6f","contract":["Process formats Go source code and automatically adds missing imports","Process removes unused imports from Go source code","Process accepts Options to preserve comments and format source","Process returns an error when given invalid Go syntax"],"goal":"verify golang.org/x/tools/imports.Process in pkg:golang/golang.org/x/tools@v0.31.0","kind":"HOW","packages":["pkg:golang/golang.org/x/tools@v0.31.0"],"schemaVersion":1,"symbols":["golang.org/x/tools/imports.Process"]},"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/golang.org/x/tools@v0.31.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/tools@v0.31.0","symbols":["golang.org/x/tools/imports.Process"],"verifierAdapter":"golang@1"}
module example.com/importsdemo
go 1.24.0
require golang.org/x/tools v0.31.0
require (
golang.org/x/mod v0.24.0 // indirect
golang.org/x/sync v0.12.0 // indirect
)
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
package importsdemo
import (
"golang.org/x/tools/imports"
)
// ProcessSource formats and resolves imports for Go source code.
func ProcessSource(filename string, src []byte, opt *imports.Options) ([]byte, error) {
return imports.Process(filename, src, opt)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/tools/imports.Process in pkg:golang/golang.org/x/tools@v0.31.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/tools@v0.31.0"
],
"symbols": [
"golang.org/x/tools/imports.Process"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.6",
"runtime": "go@1.26.6"
}
}
package main
import (
"fmt"
"os"
"strings"
"example.com/importsdemo"
"golang.org/x/tools/imports"
)
func main() {
// 1. Missing imports
unformatted := []byte("package main\n\nfunc main() {\n\tfmt.Println(\"hello\")\n}\n")
res, err := importsdemo.ProcessSource("main.go", unformatted, nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: %v\n", err)
os.Exit(1)
}
if !strings.Contains(string(res), `"fmt"`) {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: missing 'fmt' import\n")
os.Exit(1)
}
// 2. Unused imports
withUnused := []byte("package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tfmt.Println(\"test\")\n}\n")
res, err = importsdemo.ProcessSource("main.go", withUnused, nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: %v\n", err)
os.Exit(1)
}
if strings.Contains(string(res), `"os"`) || !strings.Contains(string(res), `"fmt"`) {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: unused import not removed\n")
os.Exit(1)
}
// 3. Options
input := []byte("package main\n\n// Important comment\nfunc main() {\n\tstrings.ToUpper(\"abc\")\n}\n")
opt := &imports.Options{
Comments: true,
TabIndent: true,
TabWidth: 8,
}
res, err = importsdemo.ProcessSource("main.go", input, opt)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: %v\n", err)
os.Exit(1)
}
if !strings.Contains(string(res), "// Important comment") || !strings.Contains(string(res), `"strings"`) {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: options formatting error\n")
os.Exit(1)
}
// 4. Syntax error
invalid := []byte("package main\n\nfunc main( {\n")
_, err = importsdemo.ProcessSource("main.go", invalid, nil)
if err == nil {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected syntax error\n")
os.Exit(1)
}
fmt.Println("All contract assertions passed")
}
Origin Seeder
anonymous