Ejemplo
bare-posix 1.0.1: geteuid
Muestra verificada para npm bare-posix 1.0.1: geteuid. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: declares geteuid returning…
sha256:8e311052ef07a8e2e6519bf53ee60d340d7620402949cc4d8391799ce7e254b9
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
linux 24 · ubuntu · glibc 2.39 x64 npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify bare-posix.geteuid in pkg:npm/bare-posix@1.0.1
- Paquetes
- Símbolos
-
- bare-posix.geteuid
- Creado
- 2026-09-07T02:42:26Z
Contrato
- declares geteuid returning number and seteuid accepting number or string in TypeScript definition index.d.ts
- unsupported platform fallback implements geteuid returning -1 and seteuid throwing platform not supported error
- native C binding implements bare_posix_geteuid invoking POSIX geteuid and bare_posix_seteuid invoking seteuid
- module wrapper exports geteuid delegating to native binding returning effective user ID
- module wrapper seteuid accepts numeric user ID and forwards directly to native binding
- module wrapper seteuid resolves string username to UID via getpwnam before calling native binding
Archivos
- PROMPT.md
- csx.json
- 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 bare-posix.geteuid 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.geteuid
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:a2aa3d417fb61c1bc578ea4ddc71ceb2d85ad61677cfce7140400caeb88ea4d8","contract":["declares geteuid returning number and seteuid accepting number or string in TypeScript definition index.d.ts","unsupported platform fallback implements geteuid returning -1 and seteuid throwing platform not supported error","native C binding implements bare_posix_geteuid invoking POSIX geteuid and bare_posix_seteuid invoking seteuid","module wrapper exports geteuid delegating to native binding returning effective user ID","module wrapper seteuid accepts numeric user ID and forwards directly to native binding","module wrapper seteuid resolves string username to UID via getpwnam before calling native binding"],"goal":"verify bare-posix.geteuid in pkg:npm/bare-posix@1.0.1","kind":"HOW","packages":["pkg:npm/bare-posix@1.0.1"],"schemaVersion":1,"symbols":["bare-posix.geteuid"]},"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.geteuid"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-posix-geteuid",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-posix-geteuid",
"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-geteuid",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"bare-posix": "1.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-posix.geteuid in pkg:npm/bare-posix@1.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-posix@1.0.1"
],
"symbols": [
"bare-posix.geteuid"
]
}
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 and verify manifest
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.addon, true, 'Package must be marked as Bare addon');
const pkgDir = path.dirname(pkgPath);
// 2. Verify TypeScript declarations for bare-posix.geteuid and bare-posix.seteuid
const indexDtsPath = path.join(pkgDir, 'index.d.ts');
assert.ok(fs.existsSync(indexDtsPath), 'index.d.ts must exist');
const indexDts = fs.readFileSync(indexDtsPath, 'utf8');
assert.ok(indexDts.includes('export function geteuid(): number'), 'index.d.ts must declare geteuid');
assert.ok(indexDts.includes('export function seteuid(id: number | string): void'), 'index.d.ts must declare seteuid');
// 3. Verify unsupported platform fallback implementation in unsupported.js
const unsupportedPath = path.join(pkgDir, 'unsupported.js');
assert.ok(fs.existsSync(unsupportedPath), 'unsupported.js must exist');
const unsupported = require(unsupportedPath);
assert.equal(typeof unsupported.geteuid, 'function', 'unsupported.geteuid must be a function');
assert.equal(unsupported.geteuid(), -1, 'unsupported.geteuid() must return -1');
assert.throws(() => unsupported.seteuid(0), /Platform not supported/, 'unsupported.seteuid must throw Platform not supported');
// 4. Verify C native addon source in binding.c
const bindingCPath = path.join(pkgDir, 'binding.c');
assert.ok(fs.existsSync(bindingCPath), 'binding.c must exist');
const bindingC = fs.readFileSync(bindingCPath, 'utf8');
assert.ok(bindingC.includes('bare_posix_geteuid'), 'binding.c must implement bare_posix_geteuid');
assert.ok(bindingC.includes('geteuid()'), 'binding.c must call POSIX geteuid()');
assert.ok(bindingC.includes('bare_posix_seteuid'), 'binding.c must implement bare_posix_seteuid');
assert.ok(bindingC.includes('seteuid('), 'binding.c must call POSIX seteuid()');
assert.ok(bindingC.includes('BARE_MODULE(bare_posix, bare_posix_exports)'), 'binding.c must export BARE_MODULE');
// 5. Verify index.js wrapper logic with mock native binding
const bindingJsPath = path.join(pkgDir, 'binding.js');
const indexJsPath = path.join(pkgDir, 'index.js');
assert.ok(fs.existsSync(bindingJsPath), 'binding.js must exist');
assert.ok(fs.existsSync(indexJsPath), 'index.js must exist');
const mockCalls = [];
const mockBinding = {
geteuid: () => 1000,
seteuid: (id) => { mockCalls.push(['seteuid', id]); },
getpwnam: (name) => {
if (name === 'root') return { username: 'root', passwd: 'x', uid: 0, gid: 0, gecos: 'root', homedir: '/root', shell: '/bin/bash' };
if (name === 'nobody') return { username: 'nobody', passwd: 'x', uid: 65534, gid: 65534, gecos: 'nobody', homedir: '/nonexistent', shell: '/usr/sbin/nologin' };
return null;
}
};
require.cache[bindingJsPath] = {
id: bindingJsPath,
filename: bindingJsPath,
loaded: true,
exports: mockBinding
};
delete require.cache[indexJsPath];
const posix = require(indexJsPath);
assert.equal(typeof posix.geteuid, 'function', 'posix.geteuid must be exported as a function');
assert.equal(posix.geteuid(), 1000, 'posix.geteuid() must delegate to binding.geteuid');
// Test seteuid with numeric ID
posix.seteuid(500);
assert.deepEqual(mockCalls[mockCalls.length - 1], ['seteuid', 500], 'posix.seteuid with numeric ID must pass integer directly to binding');
// Test seteuid with string username (delegating to getpwnam)
posix.seteuid('root');
assert.deepEqual(mockCalls[mockCalls.length - 1], ['seteuid', 0], 'posix.seteuid with root must resolve to uid 0');
posix.seteuid('nobody');
assert.deepEqual(mockCalls[mockCalls.length - 1], ['seteuid', 65534], 'posix.seteuid with nobody must resolve to uid 65534');
console.log('Contract tests passed successfully.');
Seeder de origen
anónimo