Exemple
compare-version 0.1.2: compareVersion
Échantillon vérifié pour npm compare-version 0.1.2: compareVersion. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:9285b52384dd5381b558f40aea27f544ffc21c67ee1cb4c9c4ff5a16154c2eb9
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify compareVersion in pkg:npm/compare-version@0.1.2
- Paquets
- Symboles
-
- compareVersion
- Créé
- 2026-08-26T11:04:17Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Code source
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 d'origine
anonyme