CodeSampleX

Beispiel

bare-os 3.9.3

Verifiziertes Beispiel für npm bare-os 3.9.3. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: package manifest specifies Bare addon…

sha256:f41393293ba3be6937b4e7c221f2fdb00778ff703be943be6fa046945688d1cd

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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-26

Fall

HOW
Ziel
verify pkg:npm/bare-os@3.9.3
Pakete
Erstellt
2026-08-26T13:47:39Z

Contract

  1. package manifest specifies Bare addon configuration, Bare engine requirement, and exports for root, constants, errors, and package subpaths
  2. bare-os/errors exports OSError class extending Error with UNKNOWN_SIGNAL and TITLE_OVERFLOW static constructors
  3. declares system info, process management, user/group info, CPU/memory diagnostics, and environment variable manipulation functions in index.d.ts
  4. declares signals, errnos, and priority constant maps in lib/constants.d.ts and lib/errors.d.ts
  5. ships native Bare C addon binding, CMakeLists build configuration, and multi-platform prebuild artifacts

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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/bare-os@3.9.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bare-os@3.9.3

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.
csx.json
{"case":{"caseId":"case:sha256:57bb09226ed1949dc07c3dbfe3539761a3e679b4ed34a1a145d7826e8932043a","contract":["package manifest specifies Bare addon configuration, Bare engine requirement, and exports for root, constants, errors, and package subpaths","bare-os/errors exports OSError class extending Error with UNKNOWN_SIGNAL and TITLE_OVERFLOW static constructors","declares system info, process management, user/group info, CPU/memory diagnostics, and environment variable manipulation functions in index.d.ts","declares signals, errnos, and priority constant maps in lib/constants.d.ts and lib/errors.d.ts","ships native Bare C addon binding, CMakeLists build configuration, and multi-platform prebuild artifacts"],"goal":"verify pkg:npm/bare-os@3.9.3","kind":"HOW","packages":["pkg:npm/bare-os@3.9.3"],"schemaVersion":1},"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-os@3.9.3"],"schemaVersion":1,"subject":"pkg:npm/bare-os@3.9.3","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-bare-os",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-bare-os",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "bare-os": "3.9.3"
      }
    },
    "node_modules/bare-os": {
      "version": "3.9.3",
      "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.9.3.tgz",
      "integrity": "sha512-fF4Q7QsyKVF5Rj0qvI8BgUNjqzC2JvQlpTaPLjVJVxYVUX5Zr9un+y3w1HmA4nNKdFmRBT8z/WmrjvXzXVerKQ==",
      "license": "Apache-2.0",
      "engines": {
        "bare": ">=1.14.0"
      }
    }
  }
}
package.json
{
  "name": "sample-bare-os",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "bare-os": "3.9.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/bare-os@3.9.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bare-os@3.9.3"
  ]
}
test/contract.mjs
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-os package manifest and verify exports and metadata
const pkgPath = require.resolve('bare-os/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, 'bare-os', 'Package name must be bare-os');
assert.equal(pkg.version, '3.9.3', 'Package version must be 3.9.3');
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.equal(pkg.engines?.bare, '>=1.14.0', 'Package must specify Bare engine >=1.14.0');

assert.ok(pkg.exports, 'Package must define exports');
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['./constants'].types, './lib/constants.d.ts', 'Constants export must have constants.d.ts types');
assert.equal(pkg.exports['./constants'].default, './lib/constants.js', 'Constants export must have constants.js default');
assert.equal(pkg.exports['./errors'].types, './lib/errors.d.ts', 'Errors export must have errors.d.ts types');
assert.equal(pkg.exports['./errors'].default, './lib/errors.js', 'Errors export must have errors.js default');
assert.equal(pkg.exports['./package'], './package.json', 'Package export must point to package.json');

const pkgDir = path.dirname(pkgPath);
const indexDts = fs.readFileSync(path.join(pkgDir, 'index.d.ts'), 'utf8');
const constantsDts = fs.readFileSync(path.join(pkgDir, 'lib', 'constants.d.ts'), 'utf8');
const errorsDts = fs.readFileSync(path.join(pkgDir, 'lib', 'errors.d.ts'), 'utf8');

// 2. Verify errors submodule functionality (pure JS OSError)
const OSError = require('bare-os/errors');
assert.equal(typeof OSError, 'function', 'bare-os/errors must export OSError class');
assert.ok(OSError.prototype instanceof Error, 'OSError must extend Error');

const unknownSignalErr = OSError.UNKNOWN_SIGNAL('Invalid signal 999');
assert.ok(unknownSignalErr instanceof OSError, 'UNKNOWN_SIGNAL must return OSError instance');
assert.equal(unknownSignalErr.name, 'OSError', 'Error name must be OSError');
assert.equal(unknownSignalErr.code, 'UNKNOWN_SIGNAL', 'Error code must be UNKNOWN_SIGNAL');
assert.equal(unknownSignalErr.message, 'UNKNOWN_SIGNAL: Invalid signal 999');

const titleOverflowErr = OSError.TITLE_OVERFLOW('Title exceeds 255 chars');
assert.ok(titleOverflowErr instanceof OSError, 'TITLE_OVERFLOW must return OSError instance');
assert.equal(titleOverflowErr.name, 'OSError', 'Error name must be OSError');
assert.equal(titleOverflowErr.code, 'TITLE_OVERFLOW', 'Error code must be TITLE_OVERFLOW');
assert.equal(titleOverflowErr.message, 'TITLE_OVERFLOW: Title exceeds 255 chars');

// 3. Verify index.d.ts type definitions and API surface
assert.ok(indexDts.includes('export { constants, errors }'), 'index.d.ts must export constants and errors');
assert.ok(indexDts.includes("export const EOL: '\\r\\n' | '\\n'"), 'index.d.ts must declare EOL');
assert.ok(indexDts.includes("export const devNull: '\\\\\\\\.\\\\nul' | '/dev/null'"), 'index.d.ts must declare devNull');

// System info declarations
assert.ok(indexDts.includes('export function platform()'), 'index.d.ts must declare platform');
assert.ok(indexDts.includes('export function arch()'), 'index.d.ts must declare arch');
assert.ok(indexDts.includes('export function type(): string'), 'index.d.ts must declare type');
assert.ok(indexDts.includes('export function version(): string'), 'index.d.ts must declare version');
assert.ok(indexDts.includes('export function release(): string'), 'index.d.ts must declare release');
assert.ok(indexDts.includes('export function machine(): string'), 'index.d.ts must declare machine');
assert.ok(indexDts.includes('export function execPath(): string'), 'index.d.ts must declare execPath');
assert.ok(indexDts.includes('export function pid(): number'), 'index.d.ts must declare pid');
assert.ok(indexDts.includes('export function ppid(): number'), 'index.d.ts must declare ppid');
assert.ok(indexDts.includes('export function cwd(): string'), 'index.d.ts must declare cwd');
assert.ok(indexDts.includes('export function chdir(dir: string): void'), 'index.d.ts must declare chdir');
assert.ok(indexDts.includes('export function tmpdir(): string'), 'index.d.ts must declare tmpdir');
assert.ok(indexDts.includes('export function homedir(): string'), 'index.d.ts must declare homedir');
assert.ok(indexDts.includes('export function hostname(): string'), 'index.d.ts must declare hostname');

// Network interfaces, UserInfo, GroupInfo
assert.ok(indexDts.includes('export interface NetworkInterface'), 'index.d.ts must declare NetworkInterface');
assert.ok(indexDts.includes('export function networkInterfaces(): Record<string, NetworkInterface[]>'), 'index.d.ts must declare networkInterfaces');
assert.ok(indexDts.includes('export function kill(pid: number, signal?: string | number): void'), 'index.d.ts must declare kill');
assert.ok(indexDts.includes('export interface UserInfo'), 'index.d.ts must declare UserInfo');
assert.ok(indexDts.includes('export function userInfo(uid?: number): UserInfo'), 'index.d.ts must declare userInfo');
assert.ok(indexDts.includes('export interface GroupInfo'), 'index.d.ts must declare GroupInfo');
assert.ok(indexDts.includes('export function groupInfo(gid?: number): GroupInfo | null'), 'index.d.ts must declare groupInfo');

// Resource, CPU, memory metrics
assert.ok(indexDts.includes("export function endianness(): 'LE' | 'BE'"), 'index.d.ts must declare endianness');
assert.ok(indexDts.includes('export function availableParallelism(): number'), 'index.d.ts must declare availableParallelism');
assert.ok(indexDts.includes('export interface CpuUsage'), 'index.d.ts must declare CpuUsage');
assert.ok(indexDts.includes('export function cpuUsage(previous?: CpuUsage): CpuUsage'), 'index.d.ts must declare cpuUsage');
assert.ok(indexDts.includes('export function threadCpuUsage(previous?: CpuUsage): CpuUsage'), 'index.d.ts must declare threadCpuUsage');
assert.ok(indexDts.includes('export function resourceUsage():'), 'index.d.ts must declare resourceUsage');
assert.ok(indexDts.includes('export function memoryUsage():'), 'index.d.ts must declare memoryUsage');
assert.ok(indexDts.includes('export function freemem(): number'), 'index.d.ts must declare freemem');
assert.ok(indexDts.includes('export function totalmem(): number'), 'index.d.ts must declare totalmem');
assert.ok(indexDts.includes('export function availableMemory(): number'), 'index.d.ts must declare availableMemory');
assert.ok(indexDts.includes('export function constrainedMemory(): number'), 'index.d.ts must declare constrainedMemory');
assert.ok(indexDts.includes('export function uptime(): number'), 'index.d.ts must declare uptime');
assert.ok(indexDts.includes('export function loadavg(): ArrayLike<number>'), 'index.d.ts must declare loadavg');
assert.ok(indexDts.includes('export function cpus():'), 'index.d.ts must declare cpus');

// Process title and priority
assert.ok(indexDts.includes('export function getProcessTitle(): string'), 'index.d.ts must declare getProcessTitle');
assert.ok(indexDts.includes('export function setProcessTitle(title: unknown): void'), 'index.d.ts must declare setProcessTitle');
assert.ok(indexDts.includes('export function getPriority(pid?: number): number'), 'index.d.ts must declare getPriority');
assert.ok(indexDts.includes('export function setPriority(priority: number): void'), 'index.d.ts must declare setPriority');

// Environment variable helpers
assert.ok(indexDts.includes('export function getEnvKeys(): string[]'), 'index.d.ts must declare getEnvKeys');
assert.ok(indexDts.includes('export function getEnv(name: string): string | undefined'), 'index.d.ts must declare getEnv');
assert.ok(indexDts.includes('export function hasEnv(name: string): boolean'), 'index.d.ts must declare hasEnv');
assert.ok(indexDts.includes('export function setEnv(name: string, value: string): void'), 'index.d.ts must declare setEnv');
assert.ok(indexDts.includes('export function unsetEnv(name: string): void'), 'index.d.ts must declare unsetEnv');

// 4. Verify constants.d.ts and errors.d.ts definitions
assert.ok(constantsDts.includes('signals: Record<string, number>'), 'constants.d.ts must declare signals');
assert.ok(constantsDts.includes('errnos: Record<string, number>'), 'constants.d.ts must declare errnos');
assert.ok(constantsDts.includes('priority: Record<string, number>'), 'constants.d.ts must declare priority');
assert.ok(errorsDts.includes('declare class OSError extends Error'), 'errors.d.ts must declare OSError class');

// 5. Verify C binding and prebuild artifacts exist
assert.ok(fs.existsSync(path.join(pkgDir, 'binding.c')), 'binding.c must exist for native Bare addon');
assert.ok(fs.existsSync(path.join(pkgDir, 'binding.js')), 'binding.js must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'CMakeLists.txt')), 'CMakeLists.txt must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'prebuilds', 'linux-x64', 'bare-os.bare')), 'linux-x64 prebuild must exist');

console.log('Contract tests passed successfully.');

Ursprungs-Seeder

anonym