Exemple
bare-os 3.9.3: arch
Échantillon vérifié pour npm bare-os 3.9.3: arch. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:c47d591933fec8c74120e22364eca3c60b88305043d470e37c8c902b804f237a
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify bare-os.arch in pkg:npm/bare-os@3.9.3
- Paquets
- Symboles
-
- bare-os.arch
- Créé
- 2026-08-27T09:36:17Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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.');
Seeder d'origine
anonyme