Sample
semver 7.8.5: valid, clean, satisfies
Verified sample for npm semver 7.8.5: valid, clean, satisfies. The contract ran on node 22 · linux alpine/x64 · docker and passed.
sha256:adbe1add479d1091d09e81176fc5caa12a8e23b90878d82ab0895993251df6d8
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
- 2
- Signing keys that built it
- 2
Declared environment
windows 11 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
| 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-09-07 |
Case
HOW- Goal
- verify pkg:npm/semver@7.8.5
- Packages
- Symbols
-
- valid
- clean
- satisfies
- compare
- inc
- coerce
- minVersion
- Created
- 2026-08-18T19:31:10Z
Contract
- valid and clean parse and sanitize semantic version strings
- satisfies checks whether version satisfies a range specification
- compare, gt, and lt correctly order versions according to precedence
- inc increments versions across major, minor, patch, and prerelease types
- coerce extracts valid semver strings from loose version input
- minVersion determines the lowest version that satisfies a range
Files
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
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 pkg:npm/semver@7.8.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/semver@7.8.5
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:caa4994804a5cc6f998bb34b7d2a972a8b0a1117c878a7baf242a9e2a45ccb7c","constraints":{"executionContext":"node"},"contract":["valid and clean parse and sanitize semantic version strings","satisfies checks whether version satisfies a range specification","compare, gt, and lt correctly order versions according to precedence","inc increments versions across major, minor, patch, and prerelease types","coerce extracts valid semver strings from loose version input","minVersion determines the lowest version that satisfies a range"],"goal":"verify pkg:npm/semver@7.8.5","kind":"HOW","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["valid","clean","satisfies","compare","inc","coerce","minVersion"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["valid","clean","satisfies","compare","inc","coerce","minVersion"],"verifierAdapter":"node-typescript@1"}
const semver = require('semver');
/**
* Validates and cleans a semantic version string.
* @param {string} version
* @returns {string | null}
*/
function cleanVersion(version) {
return semver.clean(version);
}
/**
* Increments a version by the given release type.
* @param {string} version
* @param {semver.ReleaseType} release
* @param {string} [identifier]
* @returns {string | null}
*/
function incrementVersion(version, release, identifier) {
return semver.inc(version, release, identifier);
}
/**
* Coerces a loose string to a semver string.
* @param {string | number} value
* @returns {string | null}
*/
function coerceVersion(value) {
const result = semver.coerce(value);
return result ? result.version : null;
}
/**
* Compares two semantic versions.
* @param {string} v1
* @param {string} v2
* @returns {1 | 0 | -1}
*/
function compareVersions(v1, v2) {
return semver.compare(v1, v2);
}
module.exports = {
cleanVersion,
incrementVersion,
coerceVersion,
compareVersions
};
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"semver": "7.8.5"
}
},
"node_modules/semver": {
"version": "7.8.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"dependencies": {
"semver": "7.8.5"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/semver@7.8.5",
"kind": "HOW",
"packages": [
"pkg:npm/semver@7.8.5"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
const assert = require('node:assert/strict');
const semver = require('semver');
const {
cleanVersion,
incrementVersion,
coerceVersion,
compareVersions
} = require('../index.js');
assert.equal(typeof semver.valid, 'function', 'semver.valid must be a function');
assert.equal(typeof semver.clean, 'function', 'semver.clean must be a function');
assert.equal(typeof semver.inc, 'function', 'semver.inc must be a function');
assert.equal(typeof semver.coerce, 'function', 'semver.coerce must be a function');
assert.equal(typeof semver.compare, 'function', 'semver.compare must be a function');
assert.equal(typeof semver.satisfies, 'function', 'semver.satisfies must be a function');
// Contract 1: valid and clean parse and sanitize semantic version strings
{
assert.equal(semver.valid('1.2.3'), '1.2.3');
assert.equal(semver.valid('v1.2.3'), '1.2.3');
assert.equal(semver.valid('2.0.0-beta.1+build.123'), '2.0.0-beta.1');
assert.equal(semver.valid('not-a-version'), null);
assert.equal(semver.clean(' =v1.2.3 '), '1.2.3');
assert.equal(semver.clean(' ~1.2.3 '), null);
assert.equal(cleanVersion(' =v1.2.3 '), '1.2.3');
assert.equal(cleanVersion('invalid'), null);
}
// Contract 2: satisfies checks whether version satisfies a range specification
{
assert.equal(semver.satisfies('1.2.3', '^1.2.0'), true);
assert.equal(semver.satisfies('1.3.0', '~1.2.0'), false);
assert.equal(semver.satisfies('2.0.0', '>=1.0.0 <3.0.0'), true);
assert.equal(semver.satisfies('3.0.0', '>=1.0.0 <3.0.0'), false);
assert.equal(semver.satisfies('1.2.3-alpha.1', '^1.2.0', { includePrerelease: true }), true);
}
// Contract 3: compare, gt, and lt correctly order versions according to precedence
{
assert.equal(semver.compare('1.2.3', '1.2.4'), -1);
assert.equal(semver.compare('1.2.4', '1.2.3'), 1);
assert.equal(semver.compare('1.2.3', '1.2.3'), 0);
assert.equal(compareVersions('1.2.3', '1.2.4'), -1);
assert.equal(semver.gt('1.10.0', '1.9.0'), true);
assert.equal(semver.lt('1.2.3', '1.2.4'), true);
assert.equal(semver.eq('1.2.3', '1.2.3'), true);
assert.equal(semver.gt('1.2.3', '1.2.3-beta'), true);
}
// Contract 4: inc increments versions across major, minor, patch, and prerelease types
{
assert.equal(semver.inc('1.2.3', 'major'), '2.0.0');
assert.equal(semver.inc('1.2.3', 'minor'), '1.3.0');
assert.equal(semver.inc('1.2.3', 'patch'), '1.2.4');
assert.equal(incrementVersion('1.2.3', 'patch'), '1.2.4');
assert.equal(semver.inc('1.2.3', 'prerelease', 'alpha'), '1.2.4-alpha.0');
assert.equal(semver.inc('1.2.4-alpha.0', 'prerelease'), '1.2.4-alpha.1');
assert.equal(semver.inc('1.2.3', 'premajor', 'beta'), '2.0.0-beta.0');
assert.equal(semver.inc('invalid-version', 'patch'), null);
}
// Contract 5: coerce extracts valid semver strings from loose version input
{
assert.equal(coerceVersion('v4'), '4.0.0');
assert.equal(coerceVersion('version 1.2'), '1.2.0');
assert.equal(coerceVersion('release-4.5.6.7'), '4.5.6');
assert.equal(coerceVersion('unrelated text'), null);
const coerced = semver.coerce('package-3.14.15');
assert.notEqual(coerced, null);
assert.equal(coerced.version, '3.14.15');
assert.equal(coerced.major, 3);
assert.equal(coerced.minor, 14);
assert.equal(coerced.patch, 15);
}
// Contract 6: minVersion determines the lowest version that satisfies a range
{
assert.equal(semver.minVersion('>=1.2.0')?.version, '1.2.0');
assert.equal(semver.minVersion('^2.1.0')?.version, '2.1.0');
assert.equal(semver.minVersion('~3.0.0')?.version, '3.0.0');
assert.throws(
() => semver.minVersion('invalid-range'),
(err) => err instanceof TypeError
);
}
console.log('All semver contract assertions passed successfully.');
Origin Seeder
anonymous