CodeSampleX

Sample

semver 6.3.2

Verified sample for npm semver 6.3.2. The contract ran on node 22 · linux debian/x64 · docker and passed: assert semver.parse and semver.clean parse and…

sha256:0028b5444d6e744c50d3b64e823ff1dd89bb3301aa1c3f39c2e0aaab1e788155

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

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-11-08

Case

HOW
Goal
verify pkg:npm/semver@6.3.2
Packages
Environment
node
Created
2026-11-08T07:07:54Z

Contract

  1. assert semver.parse and semver.clean parse and normalize semantic version strings or return null on invalid input
  2. assert semver.inc increments major, minor, patch, and prerelease components
  3. assert semver.satisfies, semver.maxSatisfying, semver.minSatisfying, and semver.minVersion evaluate range constraints
  4. assert semver.coerce extracts valid SemVer instances from partial or dirty strings with standard and rtl options
  5. assert semver.intersects and semver.sort verify overlapping range sets and ascending version ordering

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@6.3.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/semver@6.3.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:d007ed7f025a680015c534fbc655fa4a70c32abdfc5d2750953fc98a1f903c9d","contract":["assert semver.parse and semver.clean parse and normalize semantic version strings or return null on invalid input","assert semver.inc increments major, minor, patch, and prerelease components","assert semver.satisfies, semver.maxSatisfying, semver.minSatisfying, and semver.minVersion evaluate range constraints","assert semver.coerce extracts valid SemVer instances from partial or dirty strings with standard and rtl options","assert semver.intersects and semver.sort verify overlapping range sets and ascending version ordering"],"goal":"verify pkg:npm/semver@6.3.2","kind":"HOW","packages":["pkg:npm/semver@6.3.2"],"schemaVersion":1},"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","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@6.3.2"],"schemaVersion":1,"subject":"pkg:npm/semver@6.3.2","verifierAdapter":"node-typescript@1"}
index.mjs
import semver from 'semver';

export function parseVersion(version, options = {}) {
  return semver.parse(version, options);
}

export function cleanVersion(version, options = {}) {
  return semver.clean(version, options);
}

export function incrementVersion(version, release, options = {}, identifier = undefined) {
  return semver.inc(version, release, options, identifier);
}

export function checkSatisfies(version, range, options = {}) {
  return semver.satisfies(version, range, options);
}

export function findMaxSatisfying(versions, range, options = {}) {
  return semver.maxSatisfying(versions, range, options);
}

export function findMinSatisfying(versions, range, options = {}) {
  return semver.minSatisfying(versions, range, options);
}

export function getMinVersion(range, loose = false) {
  return semver.minVersion(range, loose);
}

export function coerceVersion(version, options = {}) {
  return semver.coerce(version, options);
}

export function rangesIntersect(r1, r2, options = {}) {
  return semver.intersects(r1, r2, options);
}

export function sortVersions(versions, options = {}) {
  return semver.sort(versions, options);
}
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "dependencies": {
        "semver": "6.3.2"
      }
    },
    "node_modules/semver": {
      "version": "6.3.2",
      "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz",
      "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      }
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "semver": "6.3.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/semver@6.3.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/semver@6.3.2"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import semver from 'semver';
import {
  parseVersion,
  cleanVersion,
  incrementVersion,
  checkSatisfies,
  findMaxSatisfying,
  findMinSatisfying,
  getMinVersion,
  coerceVersion,
  rangesIntersect,
  sortVersions
} from '../index.mjs';

// 1. assert semver.parse and semver.clean parse and normalize semantic version strings or return null on invalid input
{
  const parsed = parseVersion('v2.4.6-beta.3+exp.sha.5114f85');
  assert.notEqual(parsed, null);
  assert.equal(parsed.major, 2);
  assert.equal(parsed.minor, 4);
  assert.equal(parsed.patch, 6);
  assert.deepEqual(parsed.prerelease, ['beta', 3]);
  assert.deepEqual(parsed.build, ['exp', 'sha', '5114f85']);
  assert.equal(parsed.version, '2.4.6-beta.3');
  assert.equal(parsed instanceof semver.SemVer, true);
  assert.equal(parseVersion('invalid-semver'), null);

  assert.equal(cleanVersion('  =v1.2.3   '), '1.2.3');
  assert.equal(cleanVersion('not-valid'), null);
}

// 2. assert semver.inc increments major, minor, patch, and prerelease components
{
  assert.equal(incrementVersion('1.2.3', 'major'), '2.0.0');
  assert.equal(incrementVersion('1.2.3', 'minor'), '1.3.0');
  assert.equal(incrementVersion('1.2.3', 'patch'), '1.2.4');
  assert.equal(incrementVersion('1.2.3', 'prerelease', {}, 'alpha'), '1.2.4-alpha.0');
  assert.equal(incrementVersion('1.2.4-alpha.0', 'prerelease', {}, 'alpha'), '1.2.4-alpha.1');
  assert.equal(incrementVersion('invalid', 'patch'), null);
}

// 3. assert semver.satisfies, semver.maxSatisfying, semver.minSatisfying, and semver.minVersion evaluate range constraints
{
  assert.equal(checkSatisfies('1.5.0', '^1.2.0 <1.6.0'), true);
  assert.equal(checkSatisfies('1.6.0', '^1.2.0 <1.6.0'), false);
  assert.equal(checkSatisfies('1.3.0-alpha.1', '^1.2.0', { includePrerelease: true }), true);
  assert.equal(checkSatisfies('1.3.0-alpha.1', '^1.2.0', { includePrerelease: false }), false);

  const candidates = ['1.0.0', '1.2.0', '1.2.5', '1.5.2', '2.0.0'];
  assert.equal(findMaxSatisfying(candidates, '~1.2.0'), '1.2.5');
  assert.equal(findMinSatisfying(candidates, '>=1.2.0 <2.0.0'), '1.2.0');
  assert.equal(findMaxSatisfying(candidates, '>=3.0.0'), null);

  const minVer = getMinVersion('^1.2.3');
  assert.notEqual(minVer, null);
  assert.equal(minVer.version, '1.2.3');
}

// 4. assert semver.coerce extracts valid SemVer instances from partial or dirty strings with standard and rtl options
{
  const std = coerceVersion('v42.6.7.9.3-alpha');
  assert.notEqual(std, null);
  assert.equal(std.version, '42.6.7');

  const rtl = coerceVersion('v42.6.7.9.3-alpha', { rtl: true });
  assert.notEqual(rtl, null);
  assert.equal(rtl.version, '7.9.3');

  assert.equal(coerceVersion('no-digits-here'), null);
}

// 5. assert semver.intersects and semver.sort verify overlapping range sets and ascending version ordering
{
  assert.equal(rangesIntersect('^1.2.0', '~1.5.0'), true);
  assert.equal(rangesIntersect('^1.2.0', '>=2.0.0'), false);

  const list = ['2.0.0', '1.0.0', '1.0.0-alpha.1', '1.10.0', '1.2.0'];
  const sorted = sortVersions(list);
  assert.deepEqual(sorted, ['1.0.0-alpha.1', '1.0.0', '1.2.0', '1.10.0', '2.0.0']);
}

console.log('PASS: all semver@6.3.2 contract assertions passed');

Origin Seeder

anonymous