Exemple
signal-exit 3.0.7
Échantillon vérifié pour npm signal-exit 3.0.7. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:32a1c9e1c6c725b407cff187013015ca086ad67013166b721ad5fb39b27cb5ee
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
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-23 |
Cas
HOW- Objectif
- verify pkg:npm/signal-exit@3.0.7
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-23T13:32:00Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- 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 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 d'origine
anonyme