Exemple
github.com/Masterminds/semver/v3 v3.3.0: ErrInvalidSemVer
Échantillon vérifié pour golang github.com/Masterminds/semver/v3 v3.3.0: ErrInvalidSemVer. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker…
sha256:e56962c9910edf517595ca175e9171c3fb2e8ce9648d6403f8883fbceca84a3b
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-06 |
Cas
HOW- Objectif
- verify github.com/Masterminds/semver/v3.ErrInvalidSemVer in pkg:golang/github.com/Masterminds/semver/v3@v3.3.0
- Symboles
-
- github.com/Masterminds/semver/v3.ErrInvalidSemVer
- Créé
- 2026-09-06T13:12:19Z
Contrat
- semver.NewVersion returns semver.ErrInvalidSemVer when given an invalid semantic version string
- errors.Is(err, semver.ErrInvalidSemVer) evaluates to true for errors returned by semver.NewVersion on invalid semantic version strings
- semver.ErrInvalidSemVer.Error() returns "Invalid Semantic Version"
- semver.NewVersion parses valid semantic versions without returning semver.ErrInvalidSemVer
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code 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 github.com/Masterminds/semver/v3.ErrInvalidSemVer in pkg:golang/github.com/Masterminds/semver/v3@v3.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/Masterminds/semver/v3@v3.3.0
Demonstrate these symbols/APIs:
- github.com/Masterminds/semver/v3.ErrInvalidSemVer
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:2e7fa501d8b5c4613e3dd8e193219b7b9ddcdab7b322a7714d59f8103016d5ef","contract":["semver.NewVersion returns semver.ErrInvalidSemVer when given an invalid semantic version string","errors.Is(err, semver.ErrInvalidSemVer) evaluates to true for errors returned by semver.NewVersion on invalid semantic version strings","semver.ErrInvalidSemVer.Error() returns \"Invalid Semantic Version\"","semver.NewVersion parses valid semantic versions without returning semver.ErrInvalidSemVer"],"goal":"verify github.com/Masterminds/semver/v3.ErrInvalidSemVer in pkg:golang/github.com/Masterminds/semver/v3@v3.3.0","kind":"HOW","packages":["pkg:golang/github.com/Masterminds/semver/v3@v3.3.0"],"schemaVersion":1,"symbols":["github.com/Masterminds/semver/v3.ErrInvalidSemVer"]},"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/github.com/Masterminds/semver/v3@v3.3.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/Masterminds/semver/v3@v3.3.0","symbols":["github.com/Masterminds/semver/v3.ErrInvalidSemVer"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/Masterminds/semver/v3 v3.3.0
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
package main
import (
"errors"
"fmt"
"github.com/Masterminds/semver/v3"
)
// ValidateVersion attempts to parse a version string and returns true if valid,
// or false along with the error if it fails.
func ValidateVersion(v string) (*semver.Version, error) {
ver, err := semver.NewVersion(v)
if err != nil {
if errors.Is(err, semver.ErrInvalidSemVer) {
return nil, fmt.Errorf("invalid semantic version format: %w", err)
}
return nil, err
}
return ver, nil
}
func main() {
validInput := "1.2.3"
ver, err := ValidateVersion(validInput)
if err != nil {
fmt.Printf("Failed to parse %q: %v\n", validInput, err)
return
}
fmt.Printf("Parsed valid version: %s (major=%d, minor=%d, patch=%d)\n",
ver.String(), ver.Major(), ver.Minor(), ver.Patch())
invalidInput := "not-a-semver"
_, err = ValidateVersion(invalidInput)
if errors.Is(err, semver.ErrInvalidSemVer) {
fmt.Printf("Successfully caught ErrInvalidSemVer for input %q: %v\n", invalidInput, err)
}
}
{
"schemaVersion": 1,
"goal": "verify github.com/Masterminds/semver/v3.ErrInvalidSemVer in pkg:golang/github.com/Masterminds/semver/v3@v3.3.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/Masterminds/semver/v3@v3.3.0"
],
"symbols": [
"github.com/Masterminds/semver/v3.ErrInvalidSemVer"
]
}
package main
import (
"errors"
"fmt"
"os"
"github.com/Masterminds/semver/v3"
)
func main() {
// Assertion 1: semver.NewVersion returns semver.ErrInvalidSemVer when given an invalid semantic version string
{
invalidCases := []string{"not-a-semver", "abc.def", "1.2.3.4.5"}
for _, raw := range invalidCases {
_, err := semver.NewVersion(raw)
if err == nil {
fmt.Fprintf(os.Stderr, "contract violation: expected error for invalid semver string %q, got nil\n", raw)
os.Exit(1)
}
if !errors.Is(err, semver.ErrInvalidSemVer) {
fmt.Fprintf(os.Stderr, "contract violation: expected errors.Is(err, semver.ErrInvalidSemVer) for %q, got %v\n", raw, err)
os.Exit(1)
}
}
}
// Assertion 2: errors.Is(err, semver.ErrInvalidSemVer) evaluates to true for errors returned by semver.NewVersion on invalid semantic version strings
{
_, err := semver.NewVersion("invalid-format")
if !errors.Is(err, semver.ErrInvalidSemVer) {
fmt.Fprintf(os.Stderr, "contract violation: errors.Is(err, semver.ErrInvalidSemVer) must be true, got %v\n", err)
os.Exit(1)
}
}
// Assertion 3: semver.ErrInvalidSemVer.Error() returns "Invalid Semantic Version"
{
expectedMsg := "Invalid Semantic Version"
actualMsg := semver.ErrInvalidSemVer.Error()
if actualMsg != expectedMsg {
fmt.Fprintf(os.Stderr, "contract violation: expected ErrInvalidSemVer.Error() to be %q, got %q\n", expectedMsg, actualMsg)
os.Exit(1)
}
}
// Assertion 4: semver.NewVersion parses valid semantic versions without returning semver.ErrInvalidSemVer
{
validCases := []string{"1.2.3", "v2.0.1", "0.1.0-alpha.1", "3.4.5+build.100"}
for _, raw := range validCases {
ver, err := semver.NewVersion(raw)
if err != nil {
fmt.Fprintf(os.Stderr, "contract violation: valid semver string %q returned unexpected error: %v\n", raw, err)
os.Exit(1)
}
if ver == nil {
fmt.Fprintf(os.Stderr, "contract violation: parsed version is nil for %q\n", raw)
os.Exit(1)
}
}
}
fmt.Println("CONTRACT_PASS")
}
Seeder d'origine
anonyme