Sample
semver 7.8.5: Compare and sort semver versions, extract major minor patch and prerelease components, and filter candidate version lists using maxSatisfying and minSatisfying in semver
Verified sample for npm semver 7.8.5: Compare and sort semver versions, extract major minor patch and prerelease components, and filter candidate version…
sha256:056f8192bde2d768cf29d522ab467f85314aecda61193fe6575f36482c806b87
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
linux 24 · ubuntu · glibc 2.39 x64 npm wsl
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
Case
HOW- Goal
- Compare and sort semver versions, extract major minor patch and prerelease components, and filter candidate version lists using maxSatisfying and minSatisfying in semver
- Packages
- Symbols
-
- semver.gt
- semver.compare
- semver.compareBuild
- semver.sort
- semver.major
- semver.minor
- semver.patch
- semver.prerelease
- semver.maxSatisfying
- semver.minSatisfying
- semver.valid
- semver.validRange
- Created
- 2026-08-19T00:38:15Z
Contract
- assert semver.gt and semver.lt perform relational comparisons between version strings adhering to semver precedence
- assert semver.compare and semver.rcompare compare two versions and return integer sorting order
- assert semver.compareBuild evaluates build metadata differences where semver.compare treats them as equal
- assert semver.sort and semver.rsort sort arrays of version strings in ascending and descending precedence order
- assert semver.major, semver.minor, and semver.patch extract numeric version components from parsed version strings
- assert semver.prerelease extracts an array of prerelease components or returns null when no prerelease tag is present
- assert semver.maxSatisfying and semver.minSatisfying filter version arrays and return highest and lowest matching versions for a range
- assert semver.valid sanitizes and returns canonical version strings or null for invalid semver input and semver.validRange validates range strings
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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: Compare and sort semver versions, extract major minor patch and prerelease components, and filter candidate version lists using maxSatisfying and minSatisfying in semver
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/semver@7.8.5
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:2e49fa514ac2f6621e703ce73b6e9b0419c46b8fa43839ee156b5d0951e4d0c0","contract":["assert semver.gt and semver.lt perform relational comparisons between version strings adhering to semver precedence","assert semver.compare and semver.rcompare compare two versions and return integer sorting order","assert semver.compareBuild evaluates build metadata differences where semver.compare treats them as equal","assert semver.sort and semver.rsort sort arrays of version strings in ascending and descending precedence order","assert semver.major, semver.minor, and semver.patch extract numeric version components from parsed version strings","assert semver.prerelease extracts an array of prerelease components or returns null when no prerelease tag is present","assert semver.maxSatisfying and semver.minSatisfying filter version arrays and return highest and lowest matching versions for a range","assert semver.valid sanitizes and returns canonical version strings or null for invalid semver input and semver.validRange validates range strings"],"goal":"Compare and sort semver versions, extract major minor patch and prerelease components, and filter candidate version lists using maxSatisfying and minSatisfying in semver","kind":"HOW","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["semver.gt","semver.compare","semver.compareBuild","semver.sort","semver.major","semver.minor","semver.patch","semver.prerelease","semver.maxSatisfying","semver.minSatisfying","semver.valid","semver.validRange"]},"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,"virtualization":"wsl"},"license":"MIT-0","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["semver.gt","semver.compare","semver.compareBuild","semver.sort","semver.major","semver.minor","semver.patch","semver.prerelease","semver.maxSatisfying","semver.minSatisfying","semver.valid","semver.validRange"],"verifierAdapter":"node-typescript@1"}
{
"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=="
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"semver": "7.8.5"
}
}
{
"schemaVersion": 1,
"goal": "Compare and sort semver versions, extract major minor patch and prerelease components, and filter candidate version lists using maxSatisfying and minSatisfying in semver",
"kind": "HOW",
"packages": [
"pkg:npm/semver@7.8.5"
]
}
import assert from 'node:assert/strict';
import semver from 'semver';
// 1. semver.gt and semver.lt perform relational comparisons between version strings adhering to semver precedence
assert.strictEqual(semver.gt('2.1.0', '2.0.9'), true);
assert.strictEqual(semver.gt('1.0.0-alpha', '1.0.0'), false);
assert.strictEqual(semver.lt('1.0.0-alpha', '1.0.0'), true);
assert.strictEqual(semver.gte('1.2.3', '1.2.3'), true);
assert.strictEqual(semver.lte('1.2.3', '1.2.4'), true);
assert.strictEqual(semver.eq('1.2.3', 'v1.2.3'), true);
assert.strictEqual(semver.neq('1.2.3', '1.2.4'), true);
// 2. semver.compare and semver.rcompare compare two versions and return integer sorting order
assert.strictEqual(semver.compare('1.2.3', '1.2.4'), -1);
assert.strictEqual(semver.compare('1.2.4', '1.2.3'), 1);
assert.strictEqual(semver.compare('1.2.3', '1.2.3'), 0);
assert.strictEqual(semver.rcompare('1.2.3', '1.2.4'), 1);
assert.strictEqual(semver.rcompare('1.2.4', '1.2.3'), -1);
// 3. semver.compareBuild evaluates build metadata differences where semver.compare treats them as equal
assert.strictEqual(semver.compare('1.2.3+build.1', '1.2.3+build.2'), 0);
assert.strictEqual(semver.compareBuild('1.2.3+build.1', '1.2.3+build.2'), -1);
assert.strictEqual(semver.compareBuild('1.2.3+build.2', '1.2.3+build.1'), 1);
assert.strictEqual(semver.compareBuild('1.2.3+build.1', '1.2.3+build.1'), 0);
// 4. semver.sort and semver.rsort sort arrays of version strings in ascending and descending precedence order
const unsorted = ['1.2.4', '1.0.0', '1.2.3-beta', '1.2.3', '2.0.0'];
assert.deepStrictEqual(semver.sort([...unsorted]), ['1.0.0', '1.2.3-beta', '1.2.3', '1.2.4', '2.0.0']);
assert.deepStrictEqual(semver.rsort([...unsorted]), ['2.0.0', '1.2.4', '1.2.3', '1.2.3-beta', '1.0.0']);
// 5. semver.major, semver.minor, and semver.patch extract numeric version components from parsed version strings
const versionString = '3.14.15-beta.2+build.42';
assert.strictEqual(semver.major(versionString), 3);
assert.strictEqual(semver.minor(versionString), 14);
assert.strictEqual(semver.patch(versionString), 15);
// 6. semver.prerelease extracts an array of prerelease components or returns null when no prerelease tag is present
assert.deepStrictEqual(semver.prerelease('3.14.15-beta.2+build.42'), ['beta', 2]);
assert.deepStrictEqual(semver.prerelease('1.0.0-rc.1.alpha.0'), ['rc', 1, 'alpha', 0]);
assert.strictEqual(semver.prerelease('1.0.0'), null);
assert.strictEqual(semver.prerelease('1.0.0+build.123'), null);
// 7. semver.maxSatisfying and semver.minSatisfying filter version arrays and return highest and lowest matching versions for a range
const candidateVersions = ['1.0.0', '1.1.0', '1.2.3', '2.0.0', '2.1.0-alpha.1'];
assert.strictEqual(semver.maxSatisfying(candidateVersions, '^1.0.0'), '1.2.3');
assert.strictEqual(semver.minSatisfying(candidateVersions, '^1.0.0'), '1.0.0');
assert.strictEqual(semver.maxSatisfying(candidateVersions, '~1.1.0'), '1.1.0');
assert.strictEqual(semver.maxSatisfying(candidateVersions, '>=2.0.0 <3.0.0', { includePrerelease: true }), '2.1.0-alpha.1');
assert.strictEqual(semver.maxSatisfying(candidateVersions, '>=3.0.0'), null);
assert.strictEqual(semver.minSatisfying(candidateVersions, '>=3.0.0'), null);
// 8. semver.valid sanitizes and returns canonical version strings or null for invalid semver input and semver.validRange validates range strings
assert.strictEqual(semver.valid(' v1.2.3 '), '1.2.3');
assert.strictEqual(semver.valid('1.2.3-alpha.1'), '1.2.3-alpha.1');
assert.strictEqual(semver.valid('not-a-version'), null);
assert.strictEqual(semver.valid('1.2'), null);
assert.strictEqual(typeof semver.validRange('1.x || >=2.5.0 || 5.0.0 - 7.2.3'), 'string');
assert.strictEqual(semver.validRange('invalid-range-###'), null);
console.log('Contract passed');
Origin Seeder
anonymous