CodeSampleX

Sample

read-binary-file-arch 1.0.6: readBinaryFileArch

Verified sample for npm read-binary-file-arch 1.0.6: readBinaryFileArch. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:73ed359a17b0e4fdb833fb4988a4788a73e3e75677c9130b438b468640979599

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
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-06

Case

HOW
Goal
verify read-binary-file-arch.readBinaryFileArch in pkg:npm/read-binary-file-arch@1.0.6
Packages
Symbols
  • read-binary-file-arch.readBinaryFileArch
Created
2026-09-06T09:43:15Z

Contract

  1. readBinaryFileArch detects x64 architecture for Node.js executable binary
  2. readBinaryFileArch identifies x64 architecture from synthetic PE binary header
  3. readBinaryFileArch identifies ia32 architecture from synthetic PE binary header
  4. readBinaryFileArch returns null for non-binary plain text files
  5. readBinaryFileArch rejects directory paths with an error indicating target is not a file
  6. readBinaryFileArch rejects non-existent file paths with ENOENT error

Files

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

Download the source artifact (tar.gz)

Source

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 read-binary-file-arch.readBinaryFileArch in pkg:npm/read-binary-file-arch@1.0.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/read-binary-file-arch@1.0.6
Demonstrate these symbols/APIs:
  - read-binary-file-arch.readBinaryFileArch

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:9f49fa3325d0ead5083d7fd0df57de16d5e83552e549b7200aede06900869929","contract":["readBinaryFileArch detects x64 architecture for Node.js executable binary","readBinaryFileArch identifies x64 architecture from synthetic PE binary header","readBinaryFileArch identifies ia32 architecture from synthetic PE binary header","readBinaryFileArch returns null for non-binary plain text files","readBinaryFileArch rejects directory paths with an error indicating target is not a file","readBinaryFileArch rejects non-existent file paths with ENOENT error"],"goal":"verify read-binary-file-arch.readBinaryFileArch in pkg:npm/read-binary-file-arch@1.0.6","kind":"HOW","packages":["pkg:npm/read-binary-file-arch@1.0.6"],"schemaVersion":1,"symbols":["read-binary-file-arch.readBinaryFileArch"]},"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/read-binary-file-arch@1.0.6"],"schemaVersion":1,"subject":"pkg:npm/read-binary-file-arch@1.0.6","symbols":["read-binary-file-arch.readBinaryFileArch"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { readBinaryFileArch } from 'read-binary-file-arch';

export { readBinaryFileArch };

export async function detectBinaryArch(filePath) {
  return readBinaryFileArch(filePath);
}
package-lock.json
{
  "name": "sample-read-binary-file-arch",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-read-binary-file-arch",
      "version": "1.0.0",
      "dependencies": {
        "read-binary-file-arch": "1.0.6"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/read-binary-file-arch": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/read-binary-file-arch/-/read-binary-file-arch-1.0.6.tgz",
      "integrity": "sha512-BNg9EN3DD3GsDXX7Aa8O4p92sryjkmzYYgmgTAc6CA4uGLEDzFfxOxugu21akOxpcXHiEgsYkC6nPsQvLLLmEg==",
      "license": "MIT",
      "dependencies": {
        "debug": "^4.3.4"
      },
      "bin": {
        "read-binary-file-arch": "cli.js"
      }
    }
  }
}
package.json
{
  "name": "sample-read-binary-file-arch",
  "version": "1.0.0",
  "type": "module",
  "main": "index.mjs",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "read-binary-file-arch": "1.0.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify read-binary-file-arch.readBinaryFileArch in pkg:npm/read-binary-file-arch@1.0.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/read-binary-file-arch@1.0.6"
  ],
  "symbols": [
    "read-binary-file-arch.readBinaryFileArch"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { readBinaryFileArch } from 'read-binary-file-arch';
import { detectBinaryArch } from '../index.mjs';

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-contract-'));

try {
  function createSyntheticPE(machineType) {
    const buf = Buffer.alloc(1024);
    buf.write('MZ', 0, 'ascii');
    buf.writeUInt32LE(0x80, 0x3c);
    buf.write('PE\0\0', 0x80, 'ascii');
    buf.writeUInt16LE(machineType, 0x84);
    return buf;
  }

  // 1. readBinaryFileArch detects x64 architecture for Node.js executable binary
  {
    const arch = await readBinaryFileArch(process.execPath);
    assert.equal(arch, 'x64');
    const helperArch = await detectBinaryArch(process.execPath);
    assert.equal(helperArch, 'x64');
  }

  // 2. readBinaryFileArch identifies x64 architecture from synthetic PE binary header
  {
    const pePath = path.join(tempDir, 'dummy_x64.exe');
    fs.writeFileSync(pePath, createSyntheticPE(0x8664));
    const arch = await readBinaryFileArch(pePath);
    assert.equal(arch, 'x64');
    const helperArch = await detectBinaryArch(pePath);
    assert.equal(helperArch, 'x64');
  }

  // 3. readBinaryFileArch identifies ia32 architecture from synthetic PE binary header
  {
    const pePath = path.join(tempDir, 'dummy_ia32.exe');
    fs.writeFileSync(pePath, createSyntheticPE(0x014c));
    const arch = await readBinaryFileArch(pePath);
    assert.equal(arch, 'ia32');
    const helperArch = await detectBinaryArch(pePath);
    assert.equal(helperArch, 'ia32');
  }

  // 4. readBinaryFileArch returns null for non-binary plain text files
  {
    const textPath = path.join(tempDir, 'sample.txt');
    fs.writeFileSync(textPath, 'This is a plain text file without binary headers.');
    const arch = await readBinaryFileArch(textPath);
    assert.equal(arch, null);
    const helperArch = await detectBinaryArch(textPath);
    assert.equal(helperArch, null);
  }

  // 5. readBinaryFileArch rejects directory paths with an error indicating target is not a file
  {
    await assert.rejects(
      async () => {
        await readBinaryFileArch(tempDir);
      },
      {
        name: 'Error',
        message: `${tempDir} is not a file.`,
      }
    );
  }

  // 6. readBinaryFileArch rejects non-existent file paths with ENOENT error
  {
    const missingPath = path.join(tempDir, 'missing_file.bin');
    await assert.rejects(
      async () => {
        await readBinaryFileArch(missingPath);
      },
      (err) => {
        assert.equal(err.code, 'ENOENT');
        return true;
      }
    );
  }

  console.log('All readBinaryFileArch contract assertions passed.');
} finally {
  fs.rmSync(tempDir, { recursive: true, force: true });
}

Origin Seeder

anonymous