CodeSampleX

Ejemplo

github.com/Masterminds/semver/v3 v3.2.0: semver.IncMajor

Muestra verificada para golang github.com/Masterminds/semver/v3 v3.2.0: semver.IncMajor. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.

sha256:72b37f3d6158b15d79ee76ae522d3e0710cd88e85bd1c0e9d0bf9643dae054d4

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 go

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify semver.IncMajor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
Paquetes
Símbolos
  • semver.IncMajor
Creado
2026-09-01T01:22:03Z

Contrato

  1. semver.Version.IncMajor increments the major version number by one and resets minor and patch numbers to zero
  2. semver.Version.IncMajor removes any prerelease and build metadata from the resulting version
  3. semver.Version.IncMajor returns a new Version instance without mutating the original Version

Archivos

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
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 semver.IncMajor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
Demonstrate these symbols/APIs:
  - semver.IncMajor

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.
csx.json
{"case":{"caseId":"case:sha256:df9f557b5c7c928f9f40f4e116f3caf8ab2e596ca5cddecb0d1028351829ad1a","contract":["semver.Version.IncMajor increments the major version number by one and resets minor and patch numbers to zero","semver.Version.IncMajor removes any prerelease and build metadata from the resulting version","semver.Version.IncMajor returns a new Version instance without mutating the original Version"],"goal":"verify semver.IncMajor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0","kind":"HOW","packages":["pkg:golang/github.com/Masterminds/semver/v3@v3.2.0"],"schemaVersion":1,"symbols":["semver.IncMajor"]},"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.2.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/Masterminds/semver/v3@v3.2.0","symbols":["semver.IncMajor"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26

require github.com/Masterminds/semver/v3 v3.2.0
go.sum
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
main.go
package main

import (
	"fmt"
	"os"

	"github.com/Masterminds/semver/v3"
)

func main() {
	v, err := semver.NewVersion("1.4.2-beta.1+exp.sha.5114f85")
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to parse version: %v\n", err)
		os.Exit(1)
	}

	nextMajor := v.IncMajor()
	fmt.Printf("Original version:   %s\n", v.String())
	fmt.Printf("Next major version: %s\n", nextMajor.String())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify semver.IncMajor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/Masterminds/semver/v3@v3.2.0"
  ],
  "symbols": [
    "semver.IncMajor"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/Masterminds/semver/v3"
)

func main() {
	// Assertion 1: semver.Version.IncMajor increments the major version number by one and resets minor and patch numbers to zero
	v1, err := semver.NewVersion("1.4.2")
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 1 failed to parse: %v\n", err)
		os.Exit(1)
	}
	inc1 := v1.IncMajor()
	if inc1.Major() != 2 || inc1.Minor() != 0 || inc1.Patch() != 0 {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: expected 2.0.0, got %s\n", inc1.String())
		os.Exit(1)
	}
	if inc1.String() != "2.0.0" {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: expected string '2.0.0', got %q\n", inc1.String())
		os.Exit(1)
	}

	// Assertion 2: semver.Version.IncMajor removes any prerelease and build metadata from the resulting version
	v2, err := semver.NewVersion("1.2.3-alpha.1+build.10")
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed to parse: %v\n", err)
		os.Exit(1)
	}
	inc2 := v2.IncMajor()
	if inc2.Prerelease() != "" {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: expected empty prerelease, got %q\n", inc2.Prerelease())
		os.Exit(1)
	}
	if inc2.Metadata() != "" {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: expected empty metadata, got %q\n", inc2.Metadata())
		os.Exit(1)
	}
	if inc2.String() != "2.0.0" {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: expected string '2.0.0', got %q\n", inc2.String())
		os.Exit(1)
	}

	// Assertion 3: semver.Version.IncMajor returns a new Version instance without mutating the original Version
	v3, err := semver.NewVersion("3.5.7-rc.2+sha.abcdef")
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed to parse: %v\n", err)
		os.Exit(1)
	}
	_ = v3.IncMajor()
	if v3.Major() != 3 || v3.Minor() != 5 || v3.Patch() != 7 || v3.Prerelease() != "rc.2" || v3.Metadata() != "sha.abcdef" {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: original version was mutated: %s\n", v3.String())
		os.Exit(1)
	}
	if v3.String() != "3.5.7-rc.2+sha.abcdef" {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: original version string changed: %s\n", v3.String())
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed.")
}

Seeder de origen

anónimo