CodeSampleX

Exemplo

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

Amostra verificada para golang github.com/Masterminds/semver/v3 v3.2.0: semver.IncMajor. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:72b37f3d6158b15d79ee76ae522d3e0710cd88e85bd1c0e9d0bf9643dae054d4

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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
Pacotes
Símbolos
  • semver.IncMajor
Criado
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

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 origem

anônimo