샘플
bare-posix 1.0.1: getegid
검증된 샘플 — npm bare-posix 1.0.1: getegid. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: package manifest specifies bare-posix 1.0.1 with Bare…
sha256:a283c9d87fcbd0408385ec21740b95b061f3d354583861b6b151278f6f378d49
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
케이스
HOW- 목표
- verify bare-posix.getegid in pkg:npm/bare-posix@1.0.1
- 패키지
- 심벌
-
- bare-posix.getegid
- 생성일
- 2026-09-07T01:48:33Z
컨트랙트
- package manifest specifies bare-posix 1.0.1 with Bare addon flag and subpath exports
- declares getegid() returning number and setegid in TypeScript definitions (index.d.ts)
- exports getegid function from binding and setegid wrapper in JavaScript interface
- native binding registers bare_posix_getegid returning POSIX getegid() as 32-bit unsigned integer
- unsupported platform fallback implements getegid() returning -1
- prebuilt native addon binaries exist across linux and darwin platforms
- posix.getegid() returns non-negative integer matching process effective group ID
- posix.setegid restores numeric effective group ID and resolves group name
파일
- PROMPT.md
- csx.json
- 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 bare-posix.getegid in pkg:npm/bare-posix@1.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-posix@1.0.1
Demonstrate these symbols/APIs:
- bare-posix.getegid
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:fd74837688cc3aa3cf7c5451d5d7546e793655e07391439ff52c79a9a6fed2ef","contract":["package manifest specifies bare-posix 1.0.1 with Bare addon flag and subpath exports","declares getegid() returning number and setegid in TypeScript definitions (index.d.ts)","exports getegid function from binding and setegid wrapper in JavaScript interface","native binding registers bare_posix_getegid returning POSIX getegid() as 32-bit unsigned integer","unsupported platform fallback implements getegid() returning -1","prebuilt native addon binaries exist across linux and darwin platforms","posix.getegid() returns non-negative integer matching process effective group ID","posix.setegid restores numeric effective group ID and resolves group name"],"goal":"verify bare-posix.getegid in pkg:npm/bare-posix@1.0.1","kind":"HOW","packages":["pkg:npm/bare-posix@1.0.1"],"schemaVersion":1,"symbols":["bare-posix.getegid"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bare-posix@1.0.1"],"schemaVersion":1,"subject":"pkg:npm/bare-posix@1.0.1","symbols":["bare-posix.getegid"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-posix-getegid",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-posix-getegid",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"bare-posix": "1.0.1"
}
},
"node_modules/bare-posix": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/bare-posix/-/bare-posix-1.0.1.tgz",
"integrity": "sha512-b4quA8dyRVvX0aFIAIiev5zFATHwIUGr42Gmt+CqiBNg/bdsNkrj4bbkeotMOMiljJS4DCME5kywJO/TFwKo1A==",
"license": "Apache-2.0"
}
}
}
{
"name": "sample-bare-posix-getegid",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"bare-posix": "1.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-posix.getegid in pkg:npm/bare-posix@1.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-posix@1.0.1"
],
"symbols": [
"bare-posix.getegid"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
const require = createRequire(import.meta.url);
// 1. Resolve bare-posix package manifest and verify exports and metadata
const pkgPath = require.resolve('bare-posix/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
assert.equal(pkg.name, 'bare-posix', 'Package name must be bare-posix');
assert.equal(pkg.version, '1.0.1', 'Package version must be 1.0.1');
assert.equal(pkg.license, 'Apache-2.0', 'Package license must be Apache-2.0');
assert.equal(pkg.addon, true, 'Package must be marked as addon');
assert.ok(pkg.exports, 'Package must define exports map');
assert.equal(pkg.exports['.'].types, './index.d.ts', 'Root export must have index.d.ts types');
assert.equal(pkg.exports['.'].default, './index.js', 'Root export must have index.js default');
assert.equal(pkg.exports['.'].android, './unsupported.js', 'Android export must point to unsupported.js');
assert.equal(pkg.exports['.'].win32, './unsupported.js', 'Win32 export must point to unsupported.js');
assert.equal(pkg.exports['./package'], './package.json', 'Package export must point to package.json');
const pkgDir = path.dirname(pkgPath);
// 2. Verify TypeScript declarations (index.d.ts) for getegid and setegid
const indexDts = fs.readFileSync(path.join(pkgDir, 'index.d.ts'), 'utf8');
assert.ok(
indexDts.includes('export function getegid(): number'),
'index.d.ts must declare export function getegid(): number'
);
assert.ok(
indexDts.includes('export function setegid(id: number | string): void'),
'index.d.ts must declare export function setegid(id: number | string): void'
);
// 3. Verify JavaScript implementation exports getegid and setegid wrapper logic
const indexJs = fs.readFileSync(path.join(pkgDir, 'index.js'), 'utf8');
assert.ok(
indexJs.includes('exports.getegid = binding.getegid'),
'index.js must export getegid from native binding'
);
assert.ok(
indexJs.includes('exports.setegid = function setegid(id)'),
'index.js must export setegid wrapper function'
);
// 4. Verify C native addon binding (binding.c) for bare_posix_getegid
const bindingC = fs.readFileSync(path.join(pkgDir, 'binding.c'), 'utf8');
assert.ok(
bindingC.includes('bare_posix_getegid(js_env_t *env, js_callback_info_t *info)'),
'binding.c must implement bare_posix_getegid'
);
assert.ok(
bindingC.includes('err = js_create_uint32(env, getegid(), &result);'),
'binding.c must create uint32 from POSIX getegid()'
);
assert.ok(
bindingC.includes('V("getegid", bare_posix_getegid)'),
'binding.c must export getegid symbol in bare_posix_exports'
);
assert.ok(
bindingC.includes('BARE_MODULE(bare_posix, bare_posix_exports)'),
'binding.c must register bare_posix module'
);
// 5. Verify unsupported platform fallback behavior (unsupported.js)
const unsupportedJs = fs.readFileSync(path.join(pkgDir, 'unsupported.js'), 'utf8');
assert.ok(
unsupportedJs.includes('exports.getegid = function getegid() {\n return -1\n}'),
'unsupported.js must return -1 for getegid on unsupported platforms'
);
// 6. Verify prebuilt native addon artifacts exist for supported platforms
const prebuildsDir = path.join(pkgDir, 'prebuilds');
const expectedTargets = [
'linux-x64',
'linux-arm64',
'darwin-x64',
'darwin-arm64'
];
for (const target of expectedTargets) {
const prebuildPath = path.join(prebuildsDir, target, 'bare-posix.bare');
assert.ok(fs.existsSync(prebuildPath), `Prebuild binary for ${target} must exist`);
const stats = fs.statSync(prebuildPath);
assert.ok(stats.size > 0, `Prebuild binary for ${target} must not be empty`);
}
// 7. Verify runtime behavior of getegid and setegid using simulated native binding
const bindingPath = path.join(pkgDir, 'binding.js');
let currentEgid = typeof process.getegid === 'function' ? process.getegid() : 1000;
let lastSetEgid = null;
require.cache[bindingPath] = {
id: bindingPath,
filename: bindingPath,
loaded: true,
exports: {
getegid: () => currentEgid,
setegid: (id) => {
if (typeof id !== 'number' || id < 0) {
throw new Error('invalid gid');
}
lastSetEgid = id;
},
getgrnam: (name) => {
if (name === 'currentgroup') {
return { groupname: 'currentgroup', passwd: 'x', gid: currentEgid, members: [] };
}
return null;
}
}
};
const posix = require('bare-posix');
assert.equal(typeof posix.getegid, 'function', 'bare-posix must export getegid function');
// Verify getegid returns non-negative number
const egid = posix.getegid();
assert.equal(typeof egid, 'number', 'getegid() must return a number');
assert.ok(Number.isInteger(egid), 'getegid() must return an integer');
assert.ok(egid >= 0, 'getegid() must return a non-negative integer');
assert.equal(egid, currentEgid, 'getegid() must match current effective group ID');
// Verify setegid with current numeric egid
posix.setegid(egid);
assert.equal(lastSetEgid, egid, 'setegid must successfully set current numeric egid');
// Verify setegid resolving group name via getgrnam
posix.setegid('currentgroup');
assert.equal(lastSetEgid, currentEgid, 'setegid must resolve group name to gid and set it');
// Verify setegid with unknown group name throws TypeError
assert.throws(
() => posix.setegid('nonexistent_group_test'),
(err) => err instanceof TypeError,
'setegid with unknown group name should throw TypeError accessing null.gid'
);
console.log('Contract tests passed successfully.');
오리진 시더
익명