CodeSampleX

Ejemplo

semver 6.3.2

Muestra verificada para npm semver 6.3.2. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: assert semver.parse and semver.clean parse…

sha256:0028b5444d6e744c50d3b64e823ff1dd89bb3301aa1c3f39c2e0aaab1e788155

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node linux 24 · ubuntu · glibc 2.39 x64 node javascript npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify pkg:npm/semver@6.3.2
Paquetes
Entorno
node
Creado
2026-11-08T07:07:54Z

Contrato

  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

Archivos

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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');

Seeder de origen

anónimo