CodeSampleX

Sample

semver 7.8.5: eq, gt, gte

Verified sample for npm semver 7.8.5: eq, gt, gte. The contract ran on node 22 · linux alpine/x64 · docker and passed: assert semver.parse parses semantic…

sha256:e967d95665fc65c5fec60271dc3d2fb09ff9aef0d80670e69c955424413e5ffa

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 node 22.22 linux 24 · ubuntu · glibc 2.39 x64 node 22.22 javascript npm 11 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
verify pkg:npm/semver@7.8.5
Packages
Symbols
  • eq
  • gt
  • gte
  • lt
  • lte
  • neq
  • parse
  • rsort
  • sort
Environment
node 22.22.2
Created
2026-08-19T12:36:03Z

Contract

  1. assert semver.parse parses semantic version strings into SemVer objects with numerical components and prerelease tags or returns null for invalid input
  2. assert semver.sort and semver.rsort sort arrays of semantic versions in-place in ascending and descending order
  3. assert semver.gt and semver.gte evaluate strictly greater than and greater than or equal relations between versions
  4. assert semver.lt and semver.lte evaluate strictly less than and less than or equal relations between versions
  5. assert semver.eq and semver.neq evaluate semantic equality and inequality while ignoring build metadata

Files

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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 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@22.22.2

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:29236b20b6ad2be797f19fac25865895ce9bb698b03f898b270f32f1ef010e6b","constraints":{"executionContext":"node"},"contract":["assert semver.parse parses semantic version strings into SemVer objects with numerical components and prerelease tags or returns null for invalid input","assert semver.sort and semver.rsort sort arrays of semantic versions in-place in ascending and descending order","assert semver.gt and semver.gte evaluate strictly greater than and greater than or equal relations between versions","assert semver.lt and semver.lte evaluate strictly less than and less than or equal relations between versions","assert semver.eq and semver.neq evaluate semantic equality and inequality while ignoring build metadata"],"goal":"verify pkg:npm/semver@7.8.5","kind":"HOW","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["eq","gt","gte","lt","lte","neq","parse","rsort","sort"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"11.8.0","runtime":"node","runtimeVersion":"22.22.2","schemaVersion":1,"virtualization":"wsl"},"license":"MIT-0","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["eq","gt","gte","lt","lte","neq","parse","rsort","sort"],"verifierAdapter":"node-typescript@1"}
index.mjs
import semver from 'semver';

/**
 * Parse a semantic version string into a SemVer object.
 * Returns null if the version string is invalid.
 *
 * @param {string} version - The version string to parse.
 * @param {object} [options] - Parsing options.
 * @returns {semver.SemVer|null} Parsed SemVer object or null.
 */
export function parseSemver(version, options = {}) {
  return semver.parse(version, options);
}

/**
 * Sort an array of version strings in-place in ascending SemVer order.
 *
 * @param {string[]} versions - Array of version strings.
 * @param {object} [options] - Comparison options.
 * @returns {string[]} The sorted array.
 */
export function sortAsc(versions, options = {}) {
  return semver.sort(versions, options);
}

/**
 * Sort an array of version strings in-place in descending SemVer order.
 *
 * @param {string[]} versions - Array of version strings.
 * @param {object} [options] - Comparison options.
 * @returns {string[]} The sorted array.
 */
export function sortDesc(versions, options = {}) {
  return semver.rsort(versions, options);
}

/**
 * Check if version v1 is strictly greater than version v2.
 *
 * @param {string} v1 - First version string.
 * @param {string} v2 - Second version string.
 * @param {object} [options] - Comparison options.
 * @returns {boolean} True if v1 > v2.
 */
export function isGreaterThan(v1, v2, options = {}) {
  return semver.gt(v1, v2, options);
}

/**
 * Check if version v1 is greater than or equal to version v2.
 *
 * @param {string} v1 - First version string.
 * @param {string} v2 - Second version string.
 * @param {object} [options] - Comparison options.
 * @returns {boolean} True if v1 >= v2.
 */
export function isGreaterOrEqual(v1, v2, options = {}) {
  return semver.gte(v1, v2, options);
}

/**
 * Check if version v1 is strictly less than version v2.
 *
 * @param {string} v1 - First version string.
 * @param {string} v2 - Second version string.
 * @param {object} [options] - Comparison options.
 * @returns {boolean} True if v1 < v2.
 */
export function isLessThan(v1, v2, options = {}) {
  return semver.lt(v1, v2, options);
}

/**
 * Check if version v1 is less than or equal to version v2.
 *
 * @param {string} v1 - First version string.
 * @param {string} v2 - Second version string.
 * @param {object} [options] - Comparison options.
 * @returns {boolean} True if v1 <= v2.
 */
export function isLessOrEqual(v1, v2, options = {}) {
  return semver.lte(v1, v2, options);
}

/**
 * Check if version v1 is semantically equal to version v2 (ignoring build metadata).
 *
 * @param {string} v1 - First version string.
 * @param {string} v2 - Second version string.
 * @param {object} [options] - Comparison options.
 * @returns {boolean} True if v1 == v2.
 */
export function areEqual(v1, v2, options = {}) {
  return semver.eq(v1, v2, options);
}

/**
 * Check if version v1 is semantically not equal to version v2.
 *
 * @param {string} v1 - First version string.
 * @param {string} v2 - Second version string.
 * @param {object} [options] - Comparison options.
 * @returns {boolean} True if v1 != v2.
 */
export function areNotEqual(v1, v2, options = {}) {
  return semver.neq(v1, v2, options);
}
package-lock.json
{
  "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=="
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "semver": "7.8.5"
  }
}
spec.json
{
  "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@22.22.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import semver from 'semver';
import {
  parseSemver,
  sortAsc,
  sortDesc,
  isGreaterThan,
  isGreaterOrEqual,
  isLessThan,
  isLessOrEqual,
  areEqual,
  areNotEqual
} from '../index.mjs';

// 1. assert semver.parse parses semantic version strings into SemVer objects with numerical components and prerelease tags or returns null for invalid input
{
  const parsed = parseSemver('v1.2.3-alpha.1+build.42');
  assert.notEqual(parsed, null);
  assert.equal(parsed.major, 1);
  assert.equal(parsed.minor, 2);
  assert.equal(parsed.patch, 3);
  assert.deepEqual(parsed.prerelease, ['alpha', 1]);
  assert.deepEqual(parsed.build, ['build', '42']);
  assert.equal(parsed.version, '1.2.3-alpha.1');
  assert.equal(parsed.raw, 'v1.2.3-alpha.1+build.42');
  assert.equal(parsed instanceof semver.SemVer, true);

  assert.equal(parseSemver('not-a-version'), null);
  assert.equal(parseSemver(''), null);
}

// 2. assert semver.sort and semver.rsort sort arrays of semantic versions in-place in ascending and descending order
{
  const versionsAsc = ['1.10.0', '1.2.0', '1.2.0-beta.1', '2.0.0', '0.9.0'];
  const resAsc = sortAsc(versionsAsc);
  assert.equal(resAsc, versionsAsc);
  assert.deepEqual(versionsAsc, ['0.9.0', '1.2.0-beta.1', '1.2.0', '1.10.0', '2.0.0']);

  const versionsDesc = ['1.10.0', '1.2.0', '1.2.0-beta.1', '2.0.0', '0.9.0'];
  const resDesc = sortDesc(versionsDesc);
  assert.equal(resDesc, versionsDesc);
  assert.deepEqual(versionsDesc, ['2.0.0', '1.10.0', '1.2.0', '1.2.0-beta.1', '0.9.0']);
}

// 3. assert semver.gt and semver.gte evaluate strictly greater than and greater than or equal relations between versions
{
  assert.equal(isGreaterThan('1.2.3', '1.2.2'), true);
  assert.equal(isGreaterThan('1.2.3', '1.2.3'), false);
  assert.equal(isGreaterThan('1.2.3', '2.0.0'), false);
  assert.equal(isGreaterThan('1.2.3', '1.2.3-rc.1'), true);

  assert.equal(isGreaterOrEqual('1.2.3', '1.2.3'), true);
  assert.equal(isGreaterOrEqual('1.2.4', '1.2.3'), true);
  assert.equal(isGreaterOrEqual('1.2.2', '1.2.3'), false);
  assert.equal(isGreaterOrEqual('1.2.3+build1', '1.2.3+build2'), true);
}

// 4. assert semver.lt and semver.lte evaluate strictly less than and less than or equal relations between versions
{
  assert.equal(isLessThan('1.2.0', '1.2.3'), true);
  assert.equal(isLessThan('1.2.3', '1.2.3'), false);
  assert.equal(isLessThan('2.0.0', '1.2.3'), false);
  assert.equal(isLessThan('1.2.3-alpha', '1.2.3'), true);

  assert.equal(isLessOrEqual('1.2.3', '1.2.3'), true);
  assert.equal(isLessOrEqual('1.2.2', '1.2.3'), true);
  assert.equal(isLessOrEqual('1.2.4', '1.2.3'), false);
  assert.equal(isLessOrEqual('1.2.3+build1', '1.2.3+build2'), true);
}

// 5. assert semver.eq and semver.neq evaluate semantic equality and inequality while ignoring build metadata
{
  assert.equal(areEqual('1.2.3', '1.2.3'), true);
  assert.equal(areEqual('1.2.3+build1', '1.2.3+build2'), true);
  assert.equal(areEqual('v1.2.3', '1.2.3'), true);
  assert.equal(areEqual('1.2.3', '1.2.4'), false);

  assert.equal(areNotEqual('1.2.3', '1.2.4'), true);
  assert.equal(areNotEqual('1.2.3', '1.2.3'), false);
  assert.equal(areNotEqual('1.2.3+build1', '1.2.3+build2'), false);
}

console.log('PASS: all contract assertions satisfied');

Origin Seeder

anonymous