Ejemplo
signal-exit 3.0.7
Muestra verificada para npm signal-exit 3.0.7. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: onExit registers an exit callback and…
sha256:32a1c9e1c6c725b407cff187013015ca086ad67013166b721ad5fb39b27cb5ee
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-23 |
Caso
HOW- Objetivo
- verify pkg:npm/signal-exit@3.0.7
- Paquetes
- Entorno
- node 22.23.2
- Creado
- 2026-08-23T13:32:00Z
Contrato
- onExit registers an exit callback and returns an unregister function
- calling the returned unregister function prevents the exit callback from firing
- onExit throws AssertionError when a non-function callback is passed
- onExit callback receives the numeric exit code when process.exit is called
- onExit callback receives exit code 0 when the Node.js event loop terminates naturally
- onExit callback receives the signal name when the process receives a termination signal
- onExit with alwaysLast option executes after standard exit listeners
- signals export provides an array of standard POSIX termination signal names
- load and unload functions control the lifecycle of process exit listeners
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- 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/signal-exit@3.0.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/signal-exit@3.0.7
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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:1c92273ec54f68150fc27d112b87417f352dffff5dcf9b01b339be09f4668bec","constraints":{"executionContext":"node"},"contract":["onExit registers an exit callback and returns an unregister function","calling the returned unregister function prevents the exit callback from firing","onExit throws AssertionError when a non-function callback is passed","onExit callback receives the numeric exit code when process.exit is called","onExit callback receives exit code 0 when the Node.js event loop terminates naturally","onExit callback receives the signal name when the process receives a termination signal","onExit with alwaysLast option executes after standard exit listeners","signals export provides an array of standard POSIX termination signal names","load and unload functions control the lifecycle of process exit listeners"],"goal":"verify pkg:npm/signal-exit@3.0.7","kind":"HOW","packages":["pkg:npm/signal-exit@3.0.7"],"schemaVersion":1},"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/signal-exit@3.0.7"],"schemaVersion":1,"subject":"pkg:npm/signal-exit@3.0.7","verifierAdapter":"node-typescript@1"}
{
"name": "sample-signal-exit",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-signal-exit",
"version": "1.0.0",
"dependencies": {
"signal-exit": "3.0.7"
}
},
"node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
"license": "ISC"
}
}
}
{
"name": "sample-signal-exit",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"signal-exit": "3.0.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/signal-exit@3.0.7",
"kind": "HOW",
"packages": [
"pkg:npm/signal-exit@3.0.7"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import { spawn, spawnSync } from 'node:child_process';
import onExit from 'signal-exit';
// 1. onExit registers an exit callback and returns an unregister function
{
const unregister = onExit(() => {});
assert.equal(typeof unregister, 'function');
unregister();
}
// 2. calling the returned unregister function prevents the exit callback from firing
{
const code = `
const onExit = require('signal-exit');
const remove = onExit(() => {
process.stdout.write('UNREGISTER_FAILED');
});
remove();
process.exit(0);
`;
const res = spawnSync(process.execPath, ['-e', code], { encoding: 'utf8' });
assert.equal(res.status, 0);
assert.ok(!res.stdout.includes('UNREGISTER_FAILED'));
}
// 3. onExit throws AssertionError when a non-function callback is passed
{
assert.throws(
() => {
onExit(null);
},
{
name: 'AssertionError',
}
);
}
// 4. onExit callback receives the numeric exit code when process.exit is called
{
const code = `
const fs = require('fs');
const onExit = require('signal-exit');
onExit((code, signal) => {
fs.writeSync(1, 'EXIT_CODE:' + code + ':' + signal);
});
process.exit(42);
`;
const res = spawnSync(process.execPath, ['-e', code], { encoding: 'utf8' });
assert.equal(res.status, 42);
assert.ok(res.stdout.includes('EXIT_CODE:42:null'));
}
// 5. onExit callback receives exit code 0 when the Node.js event loop terminates naturally
{
const code = `
const fs = require('fs');
const onExit = require('signal-exit');
onExit((code, signal) => {
fs.writeSync(1, 'NATURAL_EXIT:' + code + ':' + signal);
});
`;
const res = spawnSync(process.execPath, ['-e', code], { encoding: 'utf8' });
assert.equal(res.status, 0);
assert.ok(res.stdout.includes('NATURAL_EXIT:0:null'));
}
// 6. onExit callback receives the signal name when the process receives a termination signal
await new Promise((resolve, reject) => {
const code = `
const fs = require('fs');
const onExit = require('signal-exit');
onExit((code, signal) => {
fs.writeSync(1, 'SIGNAL:' + signal);
});
setInterval(() => {}, 1000);
`;
const child = spawn(process.execPath, ['-e', code], { stdio: ['pipe', 'pipe', 'inherit'] });
let out = '';
child.stdout.on('data', (d) => {
out += d.toString();
});
setTimeout(() => {
child.kill('SIGTERM');
}, 100);
child.on('close', () => {
try {
assert.ok(out.includes('SIGNAL:SIGTERM'));
resolve();
} catch (err) {
reject(err);
}
});
});
// 7. onExit with alwaysLast option executes after standard exit listeners
{
const code = `
const fs = require('fs');
const onExit = require('signal-exit');
onExit((code, signal) => {
fs.writeSync(1, 'LAST\\n');
}, { alwaysLast: true });
onExit((code, signal) => {
fs.writeSync(1, 'FIRST\\n');
});
process.exit(0);
`;
const res = spawnSync(process.execPath, ['-e', code], { encoding: 'utf8' });
assert.equal(res.status, 0);
assert.equal(res.stdout, 'FIRST\nLAST\n');
}
// 8. signals export provides an array of standard POSIX termination signal names
{
const sigs = onExit.signals();
assert.ok(Array.isArray(sigs));
assert.ok(sigs.includes('SIGINT'));
assert.ok(sigs.includes('SIGTERM'));
assert.ok(sigs.includes('SIGHUP'));
}
// 9. load and unload functions control the lifecycle of process exit listeners
{
assert.equal(typeof onExit.load, 'function');
assert.equal(typeof onExit.unload, 'function');
onExit.load();
onExit.unload();
}
Seeder de origen
anónimo