Sample
golang.org/x/mod v0.39.0: module.InvalidVersionError
Verified sample for golang golang.org/x/mod v0.39.0: module.InvalidVersionError. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:008f357a5fcbe5822b560e65fd8340606366bd64ce4e2c34bcf518aa00602302
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-09 |
Case
HOW- Goal
- verify golang.org/x/mod/module.InvalidVersionError in pkg:golang/golang.org/x/mod@v0.39.0
- Packages
- Symbols
-
- golang.org/x/mod/module.InvalidVersionError
- Environment
- go 1.26.6
- Created
- 2026-10-09T18:14:45Z
Contract
- module.CheckPathMajor returns *InvalidVersionError when version does not match path major
- module.EscapeVersion returns *InvalidVersionError for disallowed version string
- module.Check returns *ModuleError wrapping *InvalidVersionError for non-semantic version
- module.InvalidVersionError Error() formats message with noun, version and underlying error
- module.InvalidVersionError Unwrap() returns the underlying wrapped error
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.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/mod/module.InvalidVersionError in pkg:golang/golang.org/x/mod@v0.39.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/mod@v0.39.0
Demonstrate these symbols/APIs:
- golang.org/x/mod/module.InvalidVersionError
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:119dd6e526149a3bcccc80e896528b0ddd040b77f02e109e3b431a4353b71b94","contract":["module.CheckPathMajor returns *InvalidVersionError when version does not match path major","module.EscapeVersion returns *InvalidVersionError for disallowed version string","module.Check returns *ModuleError wrapping *InvalidVersionError for non-semantic version","module.InvalidVersionError Error() formats message with noun, version and underlying error","module.InvalidVersionError Unwrap() returns the underlying wrapped error"],"goal":"verify golang.org/x/mod/module.InvalidVersionError in pkg:golang/golang.org/x/mod@v0.39.0","kind":"HOW","packages":["pkg:golang/golang.org/x/mod@v0.39.0"],"schemaVersion":1,"symbols":["golang.org/x/mod/module.InvalidVersionError"]},"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/mod@v0.39.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/mod@v0.39.0","symbols":["golang.org/x/mod/module.InvalidVersionError"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require golang.org/x/mod v0.39.0
golang.org/x/mod v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74=
golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY=
package main
import (
"errors"
"fmt"
"golang.org/x/mod/module"
)
func main() {
err := module.Check("example.com/mod", "invalid-semver")
if err != nil {
var ive *module.InvalidVersionError
if errors.As(err, &ive) {
fmt.Printf("Invalid version detected: %s (pseudo: %t): %v\n", ive.Version, ive.Pseudo, ive.Err)
fmt.Printf("Formatted error: %s\n", ive.Error())
return
}
fmt.Printf("Unexpected error: %v\n", err)
return
}
fmt.Println("Version is valid.")
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/mod/module.InvalidVersionError in pkg:golang/golang.org/x/mod@v0.39.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/mod@v0.39.0"
],
"symbols": [
"golang.org/x/mod/module.InvalidVersionError"
]
}
package main
import (
"errors"
"fmt"
"os"
"golang.org/x/mod/module"
)
func main() {
// 1. module.CheckPathMajor returns *InvalidVersionError when version does not match path major
{
err := module.CheckPathMajor("v2.0.0", "")
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected error for mismatched path major\n")
os.Exit(1)
}
var ive *module.InvalidVersionError
if !errors.As(err, &ive) {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected *module.InvalidVersionError, got %T\n", err)
os.Exit(1)
}
if ive.Version != "v2.0.0" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected Version 'v2.0.0', got %q\n", ive.Version)
os.Exit(1)
}
if ive.Err == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected non-nil Err\n")
os.Exit(1)
}
}
// 2. module.EscapeVersion returns *InvalidVersionError for disallowed version string
{
_, err := module.EscapeVersion("v1.0.0!bad")
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected error for disallowed version string\n")
os.Exit(1)
}
var ive *module.InvalidVersionError
if !errors.As(err, &ive) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected *module.InvalidVersionError, got %T\n", err)
os.Exit(1)
}
if ive.Version != "v1.0.0!bad" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected Version 'v1.0.0!bad', got %q\n", ive.Version)
os.Exit(1)
}
if ive.Err == nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected non-nil Err\n")
os.Exit(1)
}
}
// 3. module.Check returns *ModuleError wrapping *InvalidVersionError for non-semantic version
{
err := module.Check("example.com/mod", "invalid-semver")
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected error for invalid semver\n")
os.Exit(1)
}
var mErr *module.ModuleError
if !errors.As(err, &mErr) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected *module.ModuleError, got %T\n", err)
os.Exit(1)
}
var ive *module.InvalidVersionError
if !errors.As(err, &ive) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected wrapped *module.InvalidVersionError, got %T\n", err)
os.Exit(1)
}
if ive.Version != "invalid-semver" {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected Version 'invalid-semver', got %q\n", ive.Version)
os.Exit(1)
}
}
// 4. module.InvalidVersionError Error() formats message with noun, version and underlying error
{
iveStandard := &module.InvalidVersionError{
Version: "v1.0",
Pseudo: false,
Err: errors.New("not canonical"),
}
msgStandard := iveStandard.Error()
expectedStandard := "version \"v1.0\" invalid: not canonical"
if msgStandard != expectedStandard {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected %q, got %q\n", expectedStandard, msgStandard)
os.Exit(1)
}
ivePseudo := &module.InvalidVersionError{
Version: "v0.0.0-bad",
Pseudo: true,
Err: errors.New("malformed time"),
}
msgPseudo := ivePseudo.Error()
expectedPseudo := "pseudo-version \"v0.0.0-bad\" invalid: malformed time"
if msgPseudo != expectedPseudo {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected %q, got %q\n", expectedPseudo, msgPseudo)
os.Exit(1)
}
}
// 5. module.InvalidVersionError Unwrap() returns the underlying wrapped error
{
underlying := errors.New("underlying cause")
ive := &module.InvalidVersionError{
Version: "v1.0.0",
Err: underlying,
}
if ive.Unwrap() != underlying {
fmt.Fprintf(os.Stderr, "assertion 5 failed: Unwrap() did not return underlying error\n")
os.Exit(1)
}
if !errors.Is(ive, underlying) {
fmt.Fprintf(os.Stderr, "assertion 5 failed: errors.Is did not match underlying error\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous