Sample
semver 5.7.2: SemVer
Verified sample for npm semver 5.7.2: SemVer. The contract ran on node 22 · linux debian/x64 · docker and passed: SemVer constructor parses valid semver…
sha256:0ba6a42f6f3b4e73737e487234221601b21911b588ed490a68977facdef7b1b6
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-03 |
Case
HOW- Goal
- verify semver.SemVer in pkg:npm/semver@5.7.2
- Packages
- Symbols
-
- semver.SemVer
- Environment
- node 22.23.2
- Created
- 2026-09-03T04:36:51Z
Contract
- SemVer constructor parses valid semver strings into major, minor, patch, prerelease, and build components
- SemVer can be called with or without the new keyword and returns an existing SemVer instance unchanged if options match
- SemVer supports loose mode parsing for prefixed versions and trims surrounding whitespace
- SemVer throws a TypeError when given an invalid version string in strict mode
- SemVer compare, compareMain, and comparePre correctly order versions according to semver precedence rules while ignoring build metadata in compare
- SemVer format and toString return the normalized version string excluding build metadata
- SemVer inc increments release versions in-place and updates version, major, minor, patch, and prerelease fields
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Source
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.SemVer 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.SemVer
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.
{"case":{"caseId":"case:sha256:faccb141fa9dfb561705b701a2bdd940894ebfbd3a1d76f0952e0d9cdfcca415","contract":["SemVer constructor parses valid semver strings into major, minor, patch, prerelease, and build components","SemVer can be called with or without the new keyword and returns an existing SemVer instance unchanged if options match","SemVer supports loose mode parsing for prefixed versions and trims surrounding whitespace","SemVer throws a TypeError when given an invalid version string in strict mode","SemVer compare, compareMain, and comparePre correctly order versions according to semver precedence rules while ignoring build metadata in compare","SemVer format and toString return the normalized version string excluding build metadata","SemVer inc increments release versions in-place and updates version, major, minor, patch, and prerelease fields"],"goal":"verify semver.SemVer in pkg:npm/semver@5.7.2","kind":"HOW","packages":["pkg:npm/semver@5.7.2"],"schemaVersion":1,"symbols":["semver.SemVer"]},"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.SemVer"],"verifierAdapter":"node-typescript@1"}
{
"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"
}
}
}
}
{
"name": "sample-semver",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of semver.SemVer class in pkg:npm/semver@5.7.2",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"semver": "5.7.2"
}
}
{
"schemaVersion": 1,
"goal": "verify semver.SemVer in pkg:npm/semver@5.7.2",
"kind": "HOW",
"packages": [
"pkg:npm/semver@5.7.2"
],
"symbols": [
"semver.SemVer"
]
}
const semver = require('semver');
/**
* Creates or normalizes a SemVer instance.
*
* @param {string|semver.SemVer} version - Version string or SemVer instance.
* @param {boolean|object} [loose] - Loose mode flag.
* @returns {semver.SemVer}
*/
function createSemVer(version, loose) {
return new semver.SemVer(version, loose);
}
module.exports = {
semver,
SemVer: semver.SemVer,
createSemVer
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { semver, SemVer, createSemVer } = require('../src/index.js');
// 1. Export verification
assert.ok(typeof semver === 'function' || typeof semver === 'object', 'semver module must be exported');
assert.equal(typeof SemVer, 'function', 'SemVer class constructor must be exported');
assert.equal(typeof createSemVer, 'function', 'createSemVer helper must be exported');
// 2. SemVer constructor parses valid semver strings into major, minor, patch, prerelease, and build components
{
const s = new SemVer('1.2.3-alpha.1+build.100');
assert.equal(s.major, 1);
assert.equal(s.minor, 2);
assert.equal(s.patch, 3);
assert.deepEqual(s.prerelease, ['alpha', 1]);
assert.deepEqual(s.build, ['build', '100']);
assert.equal(s.version, '1.2.3-alpha.1');
assert.equal(s.raw, '1.2.3-alpha.1+build.100');
}
// 3. SemVer can be called with or without the new keyword and returns an existing SemVer instance unchanged if options match
{
const s1 = new SemVer('2.0.0');
const s2 = SemVer('2.0.0');
assert.ok(s2 instanceof SemVer);
assert.equal(s2.version, '2.0.0');
const s3 = new SemVer(s1);
assert.equal(s1, s3);
const s4 = SemVer(s1);
assert.equal(s1, s4);
}
// 4. SemVer supports loose mode parsing for prefixed versions and trims surrounding whitespace
{
const loose1 = new SemVer(' =1.2.3 ', true);
assert.equal(loose1.version, '1.2.3');
const loose2 = new SemVer('v1.2.3', false);
assert.equal(loose2.version, '1.2.3');
const loose3 = new SemVer(' v1.2.3-rc.1 ', true);
assert.equal(loose3.version, '1.2.3-rc.1');
}
// 5. SemVer throws a TypeError when given an invalid version string in strict mode
{
assert.throws(() => new SemVer('invalid'), TypeError);
assert.throws(() => new SemVer('=1.2.3', false), TypeError);
assert.throws(() => new SemVer(null), TypeError);
assert.throws(() => new SemVer(undefined), TypeError);
}
// 6. SemVer compare, compareMain, and comparePre correctly order versions according to semver precedence rules while ignoring build metadata in compare
{
const a = new SemVer('1.2.3-alpha.1+build.1');
const b = new SemVer('1.2.3-alpha.1+build.2');
const c = new SemVer('1.2.3-alpha.2');
const d = new SemVer('1.2.3');
const e = new SemVer('1.3.0');
assert.equal(a.compare(b), 0);
assert.equal(a.compare(c), -1);
assert.equal(c.compare(a), 1);
assert.equal(c.compare(d), -1);
assert.equal(d.compare(e), -1);
assert.equal(a.compareMain(c), 0);
assert.equal(a.compareMain(e), -1);
assert.equal(a.comparePre(b), 0);
assert.equal(a.comparePre(c), -1);
}
// 7. SemVer format and toString return the normalized version string excluding build metadata
{
const vWithBuild = new SemVer('1.2.3-beta.1+sha.exp123');
assert.equal(vWithBuild.format(), '1.2.3-beta.1');
assert.equal(vWithBuild.toString(), '1.2.3-beta.1');
}
// 8. SemVer inc increments release versions in-place and updates version, major, minor, patch, and prerelease fields
{
const vInc = new SemVer('1.2.3');
vInc.inc('patch');
assert.equal(vInc.version, '1.2.4');
assert.equal(vInc.patch, 4);
vInc.inc('minor');
assert.equal(vInc.version, '1.3.0');
assert.equal(vInc.minor, 3);
vInc.inc('major');
assert.equal(vInc.version, '2.0.0');
assert.equal(vInc.major, 2);
vInc.inc('prerelease', 'beta');
assert.equal(vInc.version, '2.0.1-beta.0');
assert.deepEqual(vInc.prerelease, ['beta', 0]);
}
console.log('Contract assertions passed.');
Origin Seeder
anonymous