샘플
bare-os 3.9.3: arch
검증된 샘플 — npm bare-os 3.9.3: arch. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: package manifest specifies Bare addon configuration, Bare…
sha256:c47d591933fec8c74120e22364eca3c60b88305043d470e37c8c902b804f237a
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 bare-os.arch in pkg:npm/bare-os@3.9.3
- 패키지
- 심벌
-
- bare-os.arch
- 생성일
- 2026-08-27T09:36:17Z
컨트랙트
- package manifest specifies Bare addon configuration, Bare engine requirement, and exports for root, constants, errors, and package subpaths
- index.d.ts declares export function arch(): 'arm' | 'arm64' | 'ia32' | 'x64' for retrieving CPU architecture
- index.js exports arch function that delegates to binding.arch
- bare-os.arch returns the CPU architecture string provided by the addon binding
- getArch, isX64, and isArm64 helpers correctly reflect bare-os.arch status
- bare-os.arch returns expected values across arm, arm64, ia32, and x64 architectures
- bare-os.arch executes deterministically and idempotently across multiple invocations
- binding.c sets arch constant from BARE_ARCH macro and registers the symbol in exports table
파일
- 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 bare-os.arch in pkg:npm/bare-os@3.9.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-os@3.9.3
Demonstrate these symbols/APIs:
- bare-os.arch
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:32e0ed249d962e26f01c0683d7f91488c854fafcb9cd8057934071e498252bbb","contract":["package manifest specifies Bare addon configuration, Bare engine requirement, and exports for root, constants, errors, and package subpaths","index.d.ts declares export function arch(): 'arm' | 'arm64' | 'ia32' | 'x64' for retrieving CPU architecture","index.js exports arch function that delegates to binding.arch","bare-os.arch returns the CPU architecture string provided by the addon binding","getArch, isX64, and isArm64 helpers correctly reflect bare-os.arch status","bare-os.arch returns expected values across arm, arm64, ia32, and x64 architectures","bare-os.arch executes deterministically and idempotently across multiple invocations","binding.c sets arch constant from BARE_ARCH macro and registers the symbol in exports table"],"goal":"verify bare-os.arch in pkg:npm/bare-os@3.9.3","kind":"HOW","packages":["pkg:npm/bare-os@3.9.3"],"schemaVersion":1,"symbols":["bare-os.arch"]},"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","symbols":["bare-os.arch"],"verifierAdapter":"node-typescript@1"}
import { createRequire } from 'node:module';
import path from 'node:path';
import nodeOS from 'node:os';
const require = createRequire(import.meta.url);
// Ensure native binding is provided in Node.js environments where require.addon is absent
if (typeof Bare === 'undefined') {
const mockBinding = {
platform: process.platform,
arch: process.arch,
type() { return nodeOS.type(); },
version() { return nodeOS.version ? nodeOS.version() : nodeOS.release(); },
release() { return nodeOS.release(); },
machine() { return nodeOS.machine ? nodeOS.machine() : process.arch; },
execPath() { return process.execPath; },
pid() { return process.pid; },
ppid() { return process.ppid; },
cwd() { return process.cwd(); },
chdir(dir) { process.chdir(dir); },
tmpdir() { return nodeOS.tmpdir(); },
homedir() { return nodeOS.homedir(); },
hostname() { return nodeOS.hostname(); },
userInfo(uid) { return nodeOS.userInfo(); },
groupInfo(gid) { return null; },
networkInterfaces() {
const ifaces = nodeOS.networkInterfaces();
const result = [];
for (const [name, addrs] of Object.entries(ifaces)) {
if (addrs) {
for (const addr of addrs) {
result.push({ name, ...addr });
}
}
}
return result;
},
kill(pid, sig) { process.kill(pid, sig); },
isLittleEndian: nodeOS.endianness() === 'LE',
availableParallelism() { return nodeOS.availableParallelism ? nodeOS.availableParallelism() : nodeOS.cpus().length; },
cpuUsage() { return process.cpuUsage(); },
threadCpuUsage() { return process.cpuUsage(); },
resourceUsage() { return process.resourceUsage ? process.resourceUsage() : {}; },
memoryUsage() { return process.memoryUsage(); },
freemem() { return nodeOS.freemem(); },
totalmem() { return nodeOS.totalmem(); },
availableMemory() { return typeof nodeOS.freemem === 'function' ? nodeOS.freemem() : 0; },
constrainedMemory() { return 0; },
uptime() { return nodeOS.uptime(); },
loadavg() { return nodeOS.loadavg(); },
cpus() { return nodeOS.cpus(); },
getProcessTitle() { return process.title; },
setProcessTitle(t) { process.title = t; },
getPriority(pid) { return nodeOS.getPriority ? nodeOS.getPriority(pid) : 0; },
setPriority(pid, p) { if (nodeOS.setPriority) nodeOS.setPriority(pid, p); },
getEnvKeys() { return Object.keys(process.env); },
getEnv(n) { return process.env[n]; },
hasEnv(n) { return Object.prototype.hasOwnProperty.call(process.env, n); },
setEnv(n, v) { process.env[n] = v; },
unsetEnv(n) { delete process.env[n]; }
};
try {
const mainPath = require.resolve('bare-os');
const bindingPath = path.join(path.dirname(mainPath), 'binding.js');
require.cache[bindingPath] = {
id: bindingPath,
filename: bindingPath,
loaded: true,
exports: mockBinding
};
} catch (err) {
// node_modules might not be resolved if uninstalled
}
}
const os = require('bare-os');
/**
* Returns the operating system CPU architecture.
* @returns {string}
*/
export function getArch() {
return os.arch();
}
/**
* Checks whether the platform CPU architecture is x64.
* @returns {boolean}
*/
export function isX64() {
return os.arch() === 'x64';
}
/**
* Checks whether the platform CPU architecture is arm64.
* @returns {boolean}
*/
export function isArm64() {
return os.arch() === 'arm64';
}
export default os;
{
"name": "sample-bare-os-arch",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-os-arch",
"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"
}
}
}
}
{
"name": "sample-bare-os-arch",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"bare-os": "3.9.3"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-os.arch in pkg:npm/bare-os@3.9.3",
"kind": "HOW",
"packages": [
"pkg:npm/bare-os@3.9.3"
],
"symbols": [
"bare-os.arch"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
import os, { getArch, isX64, isArm64 } from '../index.js';
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 indexJs = fs.readFileSync(path.join(pkgDir, 'index.js'), 'utf8');
const bindingC = fs.readFileSync(path.join(pkgDir, 'binding.c'), 'utf8');
// 2. Verify arch symbol declarations in TypeScript definition
assert.ok(
indexDts.includes("export function arch(): 'arm' | 'arm64' | 'ia32' | 'x64'"),
'index.d.ts must declare export function arch(): "arm" | "arm64" | "ia32" | "x64"'
);
// 3. Verify arch implementation in JavaScript module
assert.ok(indexJs.includes('exports.arch = function arch()'), 'index.js must export arch function');
assert.ok(indexJs.includes('return binding.arch'), 'arch function must delegate to binding.arch');
// 4. Verify arch invocation behavior on bare-os
assert.equal(typeof os.arch, 'function', 'bare-os must export arch function');
const archVal = os.arch();
assert.equal(typeof archVal, 'string', 'bare-os.arch() must return a string');
assert.equal(archVal, process.arch, 'bare-os.arch() should match current architecture in mock binding');
// Helper function tests
assert.equal(getArch(), archVal, 'getArch() must match os.arch()');
assert.equal(isX64(), archVal === 'x64', 'isX64() must match arch === "x64"');
assert.equal(isArm64(), archVal === 'arm64', 'isArm64() must match arch === "arm64"');
// 5. Verify arch returns expected values for different architectures
const bindingFilePath = path.join(pkgDir, 'binding.js');
const validArchitectures = ['arm', 'arm64', 'ia32', 'x64'];
for (const targetArch of validArchitectures) {
require.cache[bindingFilePath].exports.arch = targetArch;
assert.equal(os.arch(), targetArch, `bare-os.arch() must return '${targetArch}' when binding.arch is '${targetArch}'`);
}
// 6. Verify deterministic and idempotent execution across multiple calls
const firstCall = os.arch();
const secondCall = os.arch();
const thirdCall = os.arch();
assert.equal(firstCall, secondCall, 'repeated calls to arch must return identical values');
assert.equal(secondCall, thirdCall, 'repeated calls to arch must remain stable');
// 7. Verify C binding implementation and symbol registration
assert.ok(bindingC.includes('V("arch", BARE_ARCH)'), 'binding.c must register arch with BARE_ARCH macro');
console.log('Contract verification finished successfully.');
오리진 시더
익명