Ejemplo
exit 0.1.2: exit
Muestra verificada para npm exit 0.1.2: exit. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: assert exit is a function accepting exit…
sha256:6411e70962709c59faba8e022aecae68ba674f2d4bd1c7d04d1eb64049a2448f
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 10
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-27 |
Caso
HOW- Objetivo
- verify pkg:npm/exit@0.1.2
- Paquetes
- Símbolos
-
- exit
- Entorno
- node 22.23.2
- Creado
- 2026-08-27T12:41:36Z
Contrato
- assert exit is a function accepting exit code and streams array
- assert exit immediately terminates process with given code when all streams have bufferSize 0
- assert exit waits for non-empty streams to drain before calling process.exit
- assert exit replaces stream.write with noop function during termination
- assert exit synchronously flushes output and terminates child process with exit code
- assert exit registers process exit listener to ensure exit code propagation
Archivos
- PROMPT.md
- csx.json
- index.js
- 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/exit@0.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/exit@0.1.2
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:0caf1222df127738e39d1c9a83391bc54ae7a42c6548f3cb74a750581eaa5b5f","constraints":{"executionContext":"node"},"contract":["assert exit is a function accepting exit code and streams array","assert exit immediately terminates process with given code when all streams have bufferSize 0","assert exit waits for non-empty streams to drain before calling process.exit","assert exit replaces stream.write with noop function during termination","assert exit synchronously flushes output and terminates child process with exit code","assert exit registers process exit listener to ensure exit code propagation"],"goal":"verify pkg:npm/exit@0.1.2","kind":"HOW","packages":["pkg:npm/exit@0.1.2"],"schemaVersion":1,"symbols":["exit"]},"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/exit@0.1.2"],"schemaVersion":1,"subject":"pkg:npm/exit@0.1.2","symbols":["exit"],"verifierAdapter":"node-typescript@1"}
'use strict';
const exit = require('exit');
/**
* Invokes exit function to flush streams and terminate process.
*
* @param {number} [exitCode] - Process exit status code.
* @param {Array<object>} [streams] - Streams to drain before exit.
*/
function safeExit(exitCode, streams) {
return exit(exitCode, streams);
}
module.exports = {
exit,
safeExit,
};
{
"name": "sample-exit",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-exit",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"exit": "0.1.2"
}
},
"node_modules/exit": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",
"integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
}
}
}
{
"name": "sample-exit",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for exit",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"exit": "0.1.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/exit@0.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/exit@0.1.2"
],
"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 { spawnSync } from 'node:child_process';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { exit, safeExit } = require('../index.js');
// Contract 1: assert exit is a function accepting exit code and streams array
assert.strictEqual(typeof exit, 'function', 'exit must be a function');
assert.strictEqual(typeof safeExit, 'function', 'safeExit must be a function');
assert.strictEqual(exit.length, 2, 'exit should accept 2 formal parameters');
// Contract 2: assert exit immediately terminates process with given code when all streams have bufferSize 0
{
const origExit = process.exit;
const origListeners = process.rawListeners('exit');
let invokedCode = null;
process.exit = (code) => {
invokedCode = code;
};
try {
const mockStream1 = { bufferSize: 0, write: () => {} };
const mockStream2 = { bufferSize: 0, write: () => {} };
safeExit(42, [mockStream1, mockStream2]);
assert.strictEqual(invokedCode, 42, 'Expected process.exit to be called immediately with code 42');
} finally {
process.exit = origExit;
process.removeAllListeners('exit');
origListeners.forEach((fn) => process.on('exit', fn));
}
}
// Contract 3: assert exit waits for non-empty streams to drain before calling process.exit
{
const origExit = process.exit;
const origListeners = process.rawListeners('exit');
let invokedCode = null;
process.exit = (code) => {
invokedCode = code;
};
try {
let drainCallback1 = null;
let drainCallback2 = null;
const mockStream1 = {
bufferSize: 128,
write: (str, enc, cb) => {
drainCallback1 = cb;
},
};
const mockStream2 = {
bufferSize: 64,
write: (str, enc, cb) => {
drainCallback2 = cb;
},
};
safeExit(7, [mockStream1, mockStream2]);
assert.strictEqual(invokedCode, null, 'Process should not exit while streams are not drained');
assert.strictEqual(typeof drainCallback1, 'function', 'Write callback 1 should be set');
assert.strictEqual(typeof drainCallback2, 'function', 'Write callback 2 should be set');
drainCallback1();
assert.strictEqual(invokedCode, null, 'Process should not exit when only one stream drained');
drainCallback2();
assert.strictEqual(invokedCode, 7, 'Process should exit with code 7 after all streams drain');
} finally {
process.exit = origExit;
process.removeAllListeners('exit');
origListeners.forEach((fn) => process.on('exit', fn));
}
}
// Contract 4: assert exit replaces stream.write with noop function during termination
{
const origExit = process.exit;
const origListeners = process.rawListeners('exit');
let writeCalledAfterExit = false;
process.exit = () => {};
try {
const mockStream = {
bufferSize: 0,
write: () => {
writeCalledAfterExit = true;
},
};
safeExit(0, [mockStream]);
assert.strictEqual(typeof mockStream.write, 'function');
mockStream.write('should be ignored');
assert.strictEqual(writeCalledAfterExit, false, 'stream.write should be replaced with no-op');
} finally {
process.exit = origExit;
process.removeAllListeners('exit');
origListeners.forEach((fn) => process.on('exit', fn));
}
}
// Contract 5: assert exit synchronously flushes output and terminates child process with exit code
{
const testScript = `
const { exit } = require(${JSON.stringify(require.resolve('../index.js'))});
process.stdout.write('contract-stdout-payload\\n');
process.stderr.write('contract-stderr-payload\\n');
exit(13);
`;
const result = spawnSync(process.execPath, ['-e', testScript], { encoding: 'utf8' });
assert.strictEqual(result.status, 13, 'Child process must exit with code 13');
assert.strictEqual(result.stdout, 'contract-stdout-payload\n', 'Child process stdout must match written payload');
assert.strictEqual(result.stderr, 'contract-stderr-payload\n', 'Child process stderr must match written payload');
}
// Contract 6: assert exit registers process exit listener to ensure exit code propagation
{
const origExit = process.exit;
const origListeners = process.rawListeners('exit');
process.exit = () => {};
try {
const initialListenerCount = process.listenerCount('exit');
const mockStream = { bufferSize: 0, write: () => {} };
safeExit(9, [mockStream]);
const postListenerCount = process.listenerCount('exit');
assert.strictEqual(postListenerCount, initialListenerCount + 1, 'exit should attach an exit event listener');
} finally {
process.exit = origExit;
process.removeAllListeners('exit');
origListeners.forEach((fn) => process.on('exit', fn));
}
}
console.log('All contract assertions passed successfully.');
Seeder de origen
anónimo