Exemplo
compare-version 0.1.2: compareVersion
Amostra verificada para npm compare-version 0.1.2: compareVersion. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.
sha256:9285b52384dd5381b558f40aea27f544ffc21c67ee1cb4c9c4ff5a16154c2eb9
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
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
| 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 compareVersion in pkg:npm/compare-version@0.1.2
- Pacotes
- Símbolos
-
- compareVersion
- Criado
- 2026-08-26T11:04:17Z
Contrato
- compareVersion returns 1 when the first version string is greater than the second
- compareVersion returns -1 when the first version string is less than the second
- compareVersion returns 0 when version strings are equal
- compareVersion returns false when either argument is not a string
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
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 compareVersion in pkg:npm/compare-version@0.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/compare-version@0.1.2
Demonstrate these symbols/APIs:
- compareVersion
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:8c9184cfdbbd4ad7da5ce6b1f960e0739e7c672765aeac5ad5df67c143c494ae","contract":["compareVersion returns 1 when the first version string is greater than the second","compareVersion returns -1 when the first version string is less than the second","compareVersion returns 0 when version strings are equal","compareVersion returns false when either argument is not a string"],"goal":"verify compareVersion in pkg:npm/compare-version@0.1.2","kind":"HOW","packages":["pkg:npm/compare-version@0.1.2"],"schemaVersion":1,"symbols":["compareVersion"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/compare-version@0.1.2"],"schemaVersion":1,"subject":"pkg:npm/compare-version@0.1.2","symbols":["compareVersion"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-compare-version",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-compare-version",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"compare-version": "0.1.2"
}
},
"node_modules/compare-version": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/compare-version/-/compare-version-0.1.2.tgz",
"integrity": "sha512-pJDh5/4wrEnXX/VWRZvruAGHkzKdr46z11OlTPN+VrATlWWhSKewNCJ1futCO5C7eJB3nPMFZA1LeYtcFboZ2A==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
}
}
}
{
"name": "sample-compare-version",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for compare-version",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"compare-version": "0.1.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify compareVersion in pkg:npm/compare-version@0.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/compare-version@0.1.2"
],
"symbols": [
"compareVersion"
]
}
const compareVersion = require('compare-version');
function checkCompareVersion(a, b) {
return compareVersion(a, b);
}
module.exports = {
compareVersion,
checkCompareVersion
};
const assert = require('node:assert');
const compareVersion = require('compare-version');
const { checkCompareVersion } = require('../src/index.js');
// 1. compareVersion returns 1 when the first version string is greater than the second
assert.strictEqual(compareVersion('1.11.0', '1.10.0'), 1, '1.11.0 > 1.10.0 should return 1');
assert.strictEqual(compareVersion('2.0.0', '1.9.9'), 1, '2.0.0 > 1.9.9 should return 1');
assert.strictEqual(compareVersion('1.0.1', '1.0'), 1, '1.0.1 > 1.0 should return 1');
assert.strictEqual(checkCompareVersion('1.1.0', '1.0.9'), 1, 'checkCompareVersion 1.1.0 > 1.0.9 should return 1');
// 2. compareVersion returns -1 when the first version string is less than the second
assert.strictEqual(compareVersion('1.10.0', '1.11.0'), -1, '1.10.0 < 1.11.0 should return -1');
assert.strictEqual(compareVersion('1.9.9', '2.0.0'), -1, '1.9.9 < 2.0.0 should return -1');
assert.strictEqual(compareVersion('1.0', '1.0.1'), -1, '1.0 < 1.0.1 should return -1');
assert.strictEqual(checkCompareVersion('1.0.9', '1.1.0'), -1, 'checkCompareVersion 1.0.9 < 1.1.0 should return -1');
// 3. compareVersion returns 0 when version strings are equal
assert.strictEqual(compareVersion('1.0.0', '1.0.0'), 0, '1.0.0 === 1.0.0 should return 0');
assert.strictEqual(compareVersion('0.1.2', '0.1.2'), 0, '0.1.2 === 0.1.2 should return 0');
assert.strictEqual(compareVersion('1.0.0', '1.0'), 0, '1.0.0 and 1.0 are considered equal (0)');
assert.strictEqual(checkCompareVersion('2.1.0', '2.1.0'), 0, 'checkCompareVersion 2.1.0 === 2.1.0 should return 0');
// 4. compareVersion returns false when either argument is not a string
assert.strictEqual(compareVersion(1, '1.0.0'), false, 'non-string first argument should return false');
assert.strictEqual(compareVersion('1.0.0', 1), false, 'non-string second argument should return false');
assert.strictEqual(compareVersion(null, '1.0.0'), false, 'null argument should return false');
assert.strictEqual(compareVersion('1.0.0', undefined), false, 'undefined argument should return false');
assert.strictEqual(compareVersion({}, {}), false, 'object arguments should return false');
assert.strictEqual(checkCompareVersion(null, null), false, 'checkCompareVersion non-string arguments should return false');
console.log('Contract tests passed successfully.');
Seeder de origem
anônimo