Exemplo
semver 7.8.5: eq, gt, gte
Amostra verificada para npm semver 7.8.5: eq, gt, gte. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: assert semver.parse parses semantic…
sha256:e967d95665fc65c5fec60271dc3d2fb09ff9aef0d80670e69c955424413e5ffa
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 2
- Chaves de assinatura que o compilaram
- 2
Ambiente declarado
node 22.22 linux 24 · ubuntu · glibc 2.39 x64 node 22.22 javascript npm 11 wsl
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:npm/semver@7.8.5
- Pacotes
- Símbolos
-
- eq
- gt
- gte
- lt
- lte
- neq
- parse
- rsort
- sort
- Ambiente
- node 22.22.2
- Criado
- 2026-08-19T12:36:03Z
Contrato
- 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
Arquivos
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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.
{"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"}
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);
}
{
"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": "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"
}
}
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');
Seeder de origem
anônimo