Sample
golang.org/x/mod v0.18.0: semver.Compare
Verified sample for golang golang.org/x/mod v0.18.0: semver.Compare. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:5b663c9c597bf23760ed261d7013dfd3f0befdb7b4d3395ae680fefa7df86383
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
linux 24 · ubuntu · glibc 2.39 x64 go
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-09-01 |
Case
HOW- Goal
- verify golang.org/x/mod/semver.Compare in pkg:golang/golang.org/x/mod@v0.18.0
- Packages
- Symbols
-
- golang.org/x/mod/semver.Compare
- Created
- 2026-09-01T11:25:01Z
Contract
- semver.Compare returns -1, 0, or 1 for standard semantic versions based on major, minor, and patch precedence
- semver.Compare orders prerelease versions below the corresponding release version
- semver.Compare ignores build metadata when evaluating version precedence
- semver.Compare orders invalid semantic version strings before any valid semantic version
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/semver.Compare in pkg:golang/golang.org/x/mod@v0.18.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/mod@v0.18.0
Demonstrate these symbols/APIs:
- golang.org/x/mod/semver.Compare
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:e70cfa67c5e972318cb6cc853a22f1ad0a0496a0f3cafc1aedd17654b04939f9","contract":["semver.Compare returns -1, 0, or 1 for standard semantic versions based on major, minor, and patch precedence","semver.Compare orders prerelease versions below the corresponding release version","semver.Compare ignores build metadata when evaluating version precedence","semver.Compare orders invalid semantic version strings before any valid semantic version"],"goal":"verify golang.org/x/mod/semver.Compare in pkg:golang/golang.org/x/mod@v0.18.0","kind":"HOW","packages":["pkg:golang/golang.org/x/mod@v0.18.0"],"schemaVersion":1,"symbols":["golang.org/x/mod/semver.Compare"]},"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/mod@v0.18.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/mod@v0.18.0","symbols":["golang.org/x/mod/semver.Compare"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/mod v0.18.0
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
package main
import (
"fmt"
"golang.org/x/mod/semver"
)
// CompareVersions compares two semantic versions using semver.Compare.
func CompareVersions(v1, v2 string) int {
return semver.Compare(v1, v2)
}
func main() {
v1 := "v1.2.3"
v2 := "v1.2.4"
v3 := "v1.2.3-alpha"
v4 := "v1.2.3+build.1"
fmt.Printf("Compare(%s, %s) = %d\n", v1, v2, CompareVersions(v1, v2))
fmt.Printf("Compare(%s, %s) = %d\n", v3, v1, CompareVersions(v3, v1))
fmt.Printf("Compare(%s, %s) = %d\n", v1, v4, CompareVersions(v1, v4))
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/mod/semver.Compare in pkg:golang/golang.org/x/mod@v0.18.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/mod@v0.18.0"
],
"symbols": [
"golang.org/x/mod/semver.Compare"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"fmt"
"os"
"golang.org/x/mod/semver"
)
func main() {
// Assertion 1: semver.Compare returns -1, 0, or 1 for standard semantic versions based on major, minor, and patch precedence
if res := semver.Compare("v1.2.3", "v1.2.4"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.2.3, v1.2.4) == -1, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("v2.0.0", "v1.9.9"); res != 1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v2.0.0, v1.9.9) == 1, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("v1.5.0", "v1.5.0"); res != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.5.0, v1.5.0) == 0, got %d\n", res)
os.Exit(1)
}
// Assertion 2: semver.Compare orders prerelease versions below the corresponding release version
if res := semver.Compare("v1.0.0-alpha", "v1.0.0"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.0.0-alpha, v1.0.0) == -1, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("v1.0.0-alpha", "v1.0.0-beta"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.0.0-alpha, v1.0.0-beta) == -1, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("v1.0.0-alpha.1", "v1.0.0-alpha.2"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.0.0-alpha.1, v1.0.0-alpha.2) == -1, got %d\n", res)
os.Exit(1)
}
// Assertion 3: semver.Compare ignores build metadata when evaluating version precedence
if res := semver.Compare("v1.0.0+build1", "v1.0.0+build2"); res != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.0.0+build1, v1.0.0+build2) == 0, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("v1.0.0-alpha+001", "v1.0.0-alpha+exp.sha.5114f85"); res != 0 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(v1.0.0-alpha+001, v1.0.0-alpha+exp.sha.5114f85) == 0, got %d\n", res)
os.Exit(1)
}
// Assertion 4: semver.Compare orders invalid semantic version strings before any valid semantic version
if res := semver.Compare("invalid", "v0.0.1"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(invalid, v0.0.1) == -1, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("1.0.0", "v1.0.0"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare(1.0.0, v1.0.0) == -1, got %d\n", res)
os.Exit(1)
}
if res := semver.Compare("", "v0.0.0"); res != -1 {
fmt.Fprintf(os.Stderr, "FAIL: expected Compare('', v0.0.0) == -1, got %d\n", res)
os.Exit(1)
}
fmt.Println("PASS: golang.org/x/mod/semver.Compare contract verified")
}
Origin Seeder
anonymous