Ejemplo
p-limit 2.3.0
Muestra verificada para npm p-limit 2.3.0. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: pLimit creates a limiter that restricts…
sha256:216d91d91e968222fd88085bfbc9d41ef2424cfeac222cad6936d625e0e8bcd0
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
windows 10 x64 npm vm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:npm/p-limit@2.3.0
- Paquetes
- Creado
- 2026-08-19T22:57:03Z
Contrato
- 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
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- sample.mjs
- spec.json
- test/contract.mjs
Código fuente
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 de origen
anónimo