CodeSampleX

サンプル

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

検証済みサンプル — golang github.com/Masterminds/semver/v3 v3.2.0: semver.IncMajor. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.

sha256:72b37f3d6158b15d79ee76ae522d3e0710cd88e85bd1c0e9d0bf9643dae054d4

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 go

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
verify semver.IncMajor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
パッケージ
シンボル
  • semver.IncMajor
作成日
2026-09-01T01:22:03Z

コントラクト

  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

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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.")
}

オリジンシーダー

匿名