Beispiel
exit 0.1.2: exit
Verifiziertes Beispiel für npm exit 0.1.2: exit. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: assert exit is a function accepting…
sha256:6411e70962709c59faba8e022aecae68ba674f2d4bd1c7d04d1eb64049a2448f
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify pkg:npm/exit@0.1.2
- Pakete
- Symbole
-
- exit
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-27T12:41:36Z
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
Dateien
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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.');
Ursprungs-Seeder
anonym