Exemple
semver 6.3.1: maxSatisfying
Échantillon vérifié pour npm semver 6.3.1: maxSatisfying. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:8807006571f3989d88d5ca75d838b8b00f8fced177bd0e2c2795c8c8e86403b6
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
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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-28 |
Cas
HOW- Objectif
- verify semver.maxSatisfying in pkg:npm/semver@6.3.1
- Paquets
- Symboles
-
- semver.maxSatisfying
- Environnement
- node 22.23.2
- Créé
- 2026-08-28T02:31:54Z
Contrat
- assert semver.maxSatisfying returns the highest version in an array satisfying a caret range
- assert semver.maxSatisfying returns the highest version matching a bounded comparison range
- assert semver.maxSatisfying returns null when no version satisfies the specified range
- assert semver.maxSatisfying returns null for an empty array of versions
- assert semver.maxSatisfying respects the includePrerelease option to match prerelease versions
- assert semver.maxSatisfying respects the loose option for loose version string formats
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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 semver.maxSatisfying in pkg:npm/semver@6.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/semver@6.3.1
Demonstrate these symbols/APIs:
- semver.maxSatisfying
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.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:96c0f1a505fbad0f8b71e44a6ea7d669004518616050c09ddf89b98a28568844","constraints":{"executionContext":"node"},"contract":["assert semver.maxSatisfying returns the highest version in an array satisfying a caret range","assert semver.maxSatisfying returns the highest version matching a bounded comparison range","assert semver.maxSatisfying returns null when no version satisfies the specified range","assert semver.maxSatisfying returns null for an empty array of versions","assert semver.maxSatisfying respects the includePrerelease option to match prerelease versions","assert semver.maxSatisfying respects the loose option for loose version string formats"],"goal":"verify semver.maxSatisfying in pkg:npm/semver@6.3.1","kind":"HOW","packages":["pkg:npm/semver@6.3.1"],"schemaVersion":1,"symbols":["semver.maxSatisfying"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@6.3.1"],"schemaVersion":1,"subject":"pkg:npm/semver@6.3.1","symbols":["semver.maxSatisfying"],"verifierAdapter":"node-typescript@1"}
const semver = require('semver');
/**
* Finds the maximum satisfying version from a list of versions against a range.
*
* @param {string[]} versions - Array of version strings.
* @param {string} range - Semver range string.
* @param {object} [options] - Options object (e.g., includePrerelease, loose).
* @returns {string|null} The highest satisfying version string, or null if none match.
*/
function findMaxSatisfying(versions, range, options) {
return semver.maxSatisfying(versions, range, options);
}
module.exports = {
findMaxSatisfying,
semver,
};
{
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"semver": "6.3.1"
}
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
}
}
}
}
{
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"description": "Clean-room sample verifying semver.maxSatisfying functionality",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"semver": "6.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify semver.maxSatisfying in pkg:npm/semver@6.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/semver@6.3.1"
],
"symbols": [
"semver.maxSatisfying"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import semver from 'semver';
import { findMaxSatisfying } from '../index.js';
// 1. Returns the highest version in an array satisfying a caret range
const versions1 = ['1.2.0', '1.2.3', '1.3.0', '2.0.0', '1.2.9'];
const max1 = findMaxSatisfying(versions1, '^1.2.0');
assert.strictEqual(max1, '1.3.0', 'semver.maxSatisfying must return the highest version satisfying ^1.2.0');
const directMax1 = semver.maxSatisfying(versions1, '^1.2.0');
assert.strictEqual(directMax1, '1.3.0', 'semver.maxSatisfying direct call must return 1.3.0');
// 2. Returns the highest version matching a bounded comparison range
const versions2 = ['1.0.0', '1.4.9', '1.5.0', '1.8.2', '2.0.1'];
const max2 = findMaxSatisfying(versions2, '>=1.0.0 <1.5.0');
assert.strictEqual(max2, '1.4.9', 'semver.maxSatisfying must return highest within range >=1.0.0 <1.5.0');
// 3. Returns null when no version satisfies the specified range
const versions3 = ['1.0.0', '1.2.0', '1.3.0'];
const max3 = findMaxSatisfying(versions3, '^2.0.0');
assert.strictEqual(max3, null, 'semver.maxSatisfying must return null when no version matches');
// 4. Returns null for an empty array of versions
const max4 = findMaxSatisfying([], '^1.0.0');
assert.strictEqual(max4, null, 'semver.maxSatisfying must return null for an empty versions array');
// 5. Respects the includePrerelease option to match prerelease versions
const versions5 = ['1.2.0', '1.2.4-alpha.1', '1.2.4-beta.0'];
const maxNoPrerelease = findMaxSatisfying(versions5, '^1.2.3');
assert.strictEqual(maxNoPrerelease, null, 'semver.maxSatisfying without includePrerelease must return null for prereleases');
const maxWithPrerelease = findMaxSatisfying(versions5, '^1.2.3', { includePrerelease: true });
assert.strictEqual(maxWithPrerelease, '1.2.4-beta.0', 'semver.maxSatisfying with includePrerelease must return the highest matching prerelease');
// 6. Respects the loose option for loose version string formats
const looseVersions = ['v1.2.0', 'v1.3.0', '2.0.0'];
const maxLoose = findMaxSatisfying(looseVersions, '^1.0.0', { loose: true });
assert.strictEqual(maxLoose, 'v1.3.0', 'semver.maxSatisfying with loose option must parse loose version strings');
console.log('All contract assertions passed.');
Seeder d'origine
anonyme