CodeSampleX

Sample

semver 5.7.2: inc

Verified sample for npm semver 5.7.2: inc. The contract ran on node 22 · linux alpine/x64 · docker and passed: semver.inc increments major, minor, and patch…

sha256:018329565ec095cf3590f320f6394a35c346fcb28c8b1edb9855f92c2457100e

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

Case

HOW
Goal
verify semver.inc in pkg:npm/semver@5.7.2
Packages
Symbols
  • semver.inc
Environment
node 22.23.2
Created
2026-08-26T07:16:05Z

Contract

  1. semver.inc increments major, minor, and patch version numbers according to the specified release type
  2. semver.inc increments versions with prerelease identifiers for prepatch, preminor, and premajor release types
  3. semver.inc increments existing prerelease versions or appends a new identifier
  4. semver.inc supports loose mode parsing when incrementing non-standard version strings
  5. semver.inc returns null when given an invalid version string or invalid release type

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

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.inc in pkg:npm/semver@5.7.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/semver@5.7.2
Demonstrate these symbols/APIs:
  - semver.inc

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:0f728ca6ef5f2e411bb2481ca7c7366f5b3445e35c640cc67f5ad12eff3abdea","contract":["semver.inc increments major, minor, and patch version numbers according to the specified release type","semver.inc increments versions with prerelease identifiers for prepatch, preminor, and premajor release types","semver.inc increments existing prerelease versions or appends a new identifier","semver.inc supports loose mode parsing when incrementing non-standard version strings","semver.inc returns null when given an invalid version string or invalid release type"],"goal":"verify semver.inc in pkg:npm/semver@5.7.2","kind":"HOW","packages":["pkg:npm/semver@5.7.2"],"schemaVersion":1,"symbols":["semver.inc"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@5.7.2"],"schemaVersion":1,"subject":"pkg:npm/semver@5.7.2","symbols":["semver.inc"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-semver",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-semver",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "semver": "5.7.2"
      }
    },
    "node_modules/semver": {
      "version": "5.7.2",
      "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
      "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver"
      }
    }
  }
}
package.json
{
  "name": "sample-semver",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of semver.inc version incrementing",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "semver": "5.7.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify semver.inc in pkg:npm/semver@5.7.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/semver@5.7.2"
  ],
  "symbols": [
    "semver.inc"
  ]
}
src/index.js
const semver = require('semver');

/**
 * Increments a version string by the specified release type.
 *
 * @param {string} version - The version string to increment.
 * @param {string} release - Release type (e.g. 'major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease').
 * @param {boolean|string} [looseOrIdentifier] - Loose mode flag or prerelease identifier.
 * @param {string} [identifier] - Prerelease identifier if loose was provided as a boolean.
 * @returns {string|null} The incremented version string, or null if invalid.
 */
function incrementVersion(version, release, looseOrIdentifier, identifier) {
  return semver.inc(version, release, looseOrIdentifier, identifier);
}

module.exports = {
  semver,
  incrementVersion,
  inc: semver.inc
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { semver, incrementVersion, inc } = require('../src/index.js');

// 1. Export verification
assert.ok(typeof semver === 'function' || typeof semver === 'object', 'semver module must be exported');
assert.equal(typeof incrementVersion, 'function', 'incrementVersion helper must be exported');
assert.equal(typeof inc, 'function', 'inc method must be exported');

// 2. semver.inc increments major, minor, and patch version numbers according to the specified release type
{
  assert.equal(inc('1.2.3', 'major'), '2.0.0');
  assert.equal(incrementVersion('1.2.3', 'minor'), '1.3.0');
  assert.equal(inc('1.2.3', 'patch'), '1.2.4');
  assert.equal(inc('0.1.0', 'major'), '1.0.0');
  assert.equal(inc('0.1.0', 'minor'), '0.2.0');
  assert.equal(inc('0.1.0', 'patch'), '0.1.1');
}

// 3. semver.inc increments versions with prerelease identifiers for prepatch, preminor, and premajor release types
{
  assert.equal(inc('1.2.3', 'premajor', 'beta'), '2.0.0-beta.0');
  assert.equal(inc('1.2.3', 'preminor', 'rc'), '1.3.0-rc.0');
  assert.equal(incrementVersion('1.2.3', 'prepatch', 'alpha'), '1.2.4-alpha.0');
  assert.equal(inc('1.0.0', 'premajor'), '2.0.0-0');
  assert.equal(inc('1.0.0', 'preminor'), '1.1.0-0');
  assert.equal(inc('1.0.0', 'prepatch'), '1.0.1-0');
}

// 4. semver.inc increments existing prerelease versions or appends a new identifier
{
  assert.equal(inc('1.2.3-alpha.0', 'prerelease'), '1.2.3-alpha.1');
  assert.equal(inc('1.2.3-alpha.1', 'prerelease'), '1.2.3-alpha.2');
  assert.equal(inc('1.2.3-alpha.0', 'prerelease', 'beta'), '1.2.3-beta.0');
  assert.equal(incrementVersion('1.2.3', 'prerelease', 'rc'), '1.2.4-rc.0');
}

// 5. semver.inc supports loose mode parsing when incrementing non-standard version strings
{
  assert.equal(inc('=1.2.3', 'major', true), '2.0.0');
  assert.equal(inc('=1.2.3', 'major', false), null);
  assert.equal(inc('=1.2.3', 'premajor', true, 'beta'), '2.0.0-beta.0');
}

// 6. semver.inc returns null when given an invalid version string or invalid release type
{
  assert.equal(inc('invalid.version', 'patch'), null);
  assert.equal(inc('1.2.3', 'unknown-release-type'), null);
  assert.equal(incrementVersion(null, 'major'), null);
  assert.equal(incrementVersion(undefined, 'minor'), null);
}

console.log('Contract assertions passed.');

Origin Seeder

anonymous