CodeSampleX

Sample

semver 5.7.2: minor

Verified sample for npm semver 5.7.2: minor. The contract ran on node 22 · linux alpine/x64 · docker and passed: semver.minor extracts the minor version…

sha256:204271f0af302abd38e7a088c42327b3520b970d579adeb536665c08bc760669

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

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-28

Case

HOW
Goal
verify semver.minor in pkg:npm/semver@5.7.2
Packages
Symbols
  • semver.minor
Created
2026-08-28T04:41:12Z

Contract

  1. semver.minor extracts the minor version number from a standard semantic version string
  2. semver.minor parses versions with leading 'v' prefix and extracts minor version
  3. semver.minor extracts minor version from prerelease and build metadata version strings
  4. semver.minor extracts minor version when passed a SemVer instance
  5. semver.minor parses loose version strings when loose option is enabled
  6. semver.minor throws TypeError for invalid version strings
  7. semver.minor throws TypeError for null or undefined input

Files

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • 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.minor 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.minor

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:1cf6de7318311efe6a6f615ab49fe15f948e28f94fd3102481ccc8939999ec65","contract":["semver.minor extracts the minor version number from a standard semantic version string","semver.minor parses versions with leading 'v' prefix and extracts minor version","semver.minor extracts minor version from prerelease and build metadata version strings","semver.minor extracts minor version when passed a SemVer instance","semver.minor parses loose version strings when loose option is enabled","semver.minor throws TypeError for invalid version strings","semver.minor throws TypeError for null or undefined input"],"goal":"verify semver.minor in pkg:npm/semver@5.7.2","kind":"HOW","packages":["pkg:npm/semver@5.7.2"],"schemaVersion":1,"symbols":["semver.minor"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@5.7.2"],"schemaVersion":1,"subject":"pkg:npm/semver@5.7.2","symbols":["semver.minor"],"verifierAdapter":"node-typescript@1"}
index.js
const semver = require('semver');

/**
 * Extracts the minor version number from a semver string or SemVer instance.
 *
 * @param {string|semver.SemVer} version - The version string or object to parse.
 * @param {boolean} [loose=false] - Whether to allow loose semver parsing.
 * @returns {number} The minor version number.
 */
function getMinorVersion(version, loose) {
  return semver.minor(version, loose);
}

module.exports = {
  getMinorVersion,
  semver,
};
package-lock.json
{
  "name": "sample-semver-minor",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-semver-minor",
      "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-minor",
  "version": "1.0.0",
  "description": "Clean-room sample verifying semver.minor in semver 5.7.2",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "semver": "5.7.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify semver.minor in pkg:npm/semver@5.7.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/semver@5.7.2"
  ],
  "symbols": [
    "semver.minor"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import semver from 'semver';
import { getMinorVersion } from '../index.js';

// 1. semver.minor extracts the minor version number from a standard semantic version string
assert.strictEqual(semver.minor('1.2.3'), 2);
assert.strictEqual(getMinorVersion('1.2.3'), 2);

// 2. semver.minor parses versions with leading 'v' prefix and extracts minor version
assert.strictEqual(semver.minor('v3.14.159'), 14);
assert.strictEqual(getMinorVersion('v3.14.159'), 14);

// 3. semver.minor extracts minor version from prerelease and build metadata version strings
assert.strictEqual(semver.minor('0.5.2-alpha.1+build.123'), 5);
assert.strictEqual(getMinorVersion('0.5.2-alpha.1+build.123'), 5);

// 4. semver.minor extracts minor version when passed a SemVer instance
const semVerObj = new semver.SemVer('10.20.30');
assert.strictEqual(semver.minor(semVerObj), 20);
assert.strictEqual(getMinorVersion(semVerObj), 20);

// 5. semver.minor parses loose version strings when loose option is enabled
assert.strictEqual(semver.minor('  =v4.8.12  ', true), 8);
assert.strictEqual(getMinorVersion('  =v4.8.12  ', true), 8);

// 6. semver.minor throws TypeError for invalid version strings
assert.throws(
  () => semver.minor('invalid-version'),
  (err) => err instanceof TypeError && err.message.includes('Invalid Version')
);
assert.throws(
  () => getMinorVersion('invalid-version'),
  (err) => err instanceof TypeError && err.message.includes('Invalid Version')
);

// 7. semver.minor throws TypeError for null or undefined input
assert.throws(
  () => semver.minor(null),
  (err) => err instanceof TypeError && err.message.includes('Invalid Version')
);
assert.throws(
  () => getMinorVersion(undefined),
  (err) => err instanceof TypeError && err.message.includes('Invalid Version')
);

console.log('All semver.minor contract assertions passed.');

Origin Seeder

anonymous