Exemple
p-limit 2.3.0
Échantillon vérifié pour npm p-limit 2.3.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : pLimit creates a limiter that…
sha256:216d91d91e968222fd88085bfbc9d41ef2424cfeac222cad6936d625e0e8bcd0
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é
windows 10 x64 npm vm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Cas
HOW- Objectif
- verify pkg:npm/p-limit@2.3.0
- Paquets
- Créé
- 2026-08-19T22:57:03Z
Contrat
- pLimit creates a limiter that restricts concurrency to the specified limit
- runWithLimit executes tasks concurrently up to the specified limit
- activeCount and pendingCount track running and queued tasks
- clearQueue discards pending tasks that have not started execution
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- sample.mjs
- 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 pkg:npm/p-limit@2.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/p-limit@2.3.0
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:d52bdca73158231e4015007d106f0ae588771e0fd89505c6ceffdb94dfe2b81d","contract":["pLimit creates a limiter that restricts concurrency to the specified limit","runWithLimit executes tasks concurrently up to the specified limit","activeCount and pendingCount track running and queued tasks","clearQueue discards pending tasks that have not started execution"],"goal":"verify pkg:npm/p-limit@2.3.0","kind":"HOW","packages":["pkg:npm/p-limit@2.3.0"],"schemaVersion":1,"symbols":["p-limit","p-limit.activeCount","p-limit.pendingCount","p-limit.clearQueue"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"10","packageManager":"npm","schemaVersion":1,"virtualization":"vm"},"license":"MIT-0","packages":["pkg:npm/p-limit@2.3.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"p-limit": "2.3.0"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"engines": {
"node": ">=6"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"p-limit": "2.3.0"
}
}
import pLimit from 'p-limit';
/**
* Creates a concurrency limiter with the specified limit.
* @param {number} concurrency
* @returns {Function}
*/
export function createLimiter(concurrency) {
return pLimit(concurrency);
}
/**
* Runs a list of tasks with a concurrency limit.
* @param {Array<() => Promise<any>>} tasks
* @param {number} concurrency
* @returns {Promise<any[]>}
*/
export async function runWithLimit(tasks, concurrency) {
const limit = pLimit(concurrency);
return Promise.all(tasks.map((task) => limit(task)));
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/p-limit@2.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/p-limit@2.3.0"
]
}
import assert from 'node:assert/strict';
import pLimit from 'p-limit';
import { createLimiter, runWithLimit } from '../sample.mjs';
async function testConcurrencyLimit() {
const limit = createLimiter(2);
let active = 0;
let maxActive = 0;
const tasks = Array.from({ length: 6 }, (_, i) => async () => {
active++;
if (active > maxActive) {
maxActive = active;
}
await new Promise((resolve) => setTimeout(resolve, 30));
active--;
return i;
});
const results = await Promise.all(tasks.map((t) => limit(t)));
assert.deepEqual(results, [0, 1, 2, 3, 4, 5], 'all tasks should complete in order');
assert(maxActive <= 2, `max concurrent tasks (${maxActive}) should not exceed limit (2)`);
console.log('Contract 1 passed: concurrency limit respected');
}
async function testRunWithLimit() {
const tasks = [
async () => 10,
async () => 20,
async () => 30
];
const results = await runWithLimit(tasks, 2);
assert.deepEqual(results, [10, 20, 30], 'runWithLimit should return mapped task results');
console.log('Contract 2 passed: runWithLimit works');
}
async function testCountsAndQueue() {
const limit = pLimit(1);
let resolveFirst;
const firstPromise = new Promise((resolve) => {
resolveFirst = resolve;
});
const p1 = limit(() => firstPromise);
const p2 = limit(() => Promise.resolve('second'));
const p3 = limit(() => Promise.resolve('third'));
assert.equal(limit.activeCount, 1, 'activeCount should be 1');
assert.equal(limit.pendingCount, 2, 'pendingCount should be 2');
limit.clearQueue();
assert.equal(limit.pendingCount, 0, 'pendingCount should be 0 after clearQueue');
resolveFirst('first');
const res1 = await p1;
assert.equal(res1, 'first', 'first task should complete');
console.log('Contract 3 & 4 passed: activeCount, pendingCount, and clearQueue verified');
}
async function main() {
await testConcurrencyLimit();
await testRunWithLimit();
await testCountsAndQueue();
console.log('All contracts passed successfully.');
}
main().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Seeder d'origine
anonyme