샘플
exit 0.1.2: exit
검증된 샘플 — npm exit 0.1.2: exit. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert exit is a function accepting exit code and streams array
sha256:6411e70962709c59faba8e022aecae68ba674f2d4bd1c7d04d1eb64049a2448f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:npm/exit@0.1.2
- 패키지
- 심벌
-
- exit
- 환경
- node 22.23.2
- 생성일
- 2026-08-27T12:41:36Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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.');
오리진 시더
익명