CodeSampleX

Exemplo

bare-pipe 4.2.3

Amostra verificada para npm bare-pipe 4.2.3. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: package manifest specifies bare-pipe 4.2.3…

sha256:f01f661c60496db2553efba8b32c0e29a382ef2e124f6a9a42c81de948c6f9c5

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify pkg:npm/bare-pipe@4.2.3
Pacotes
Criado
2026-08-27T13:03:03Z

Contrato

  1. package manifest specifies bare-pipe 4.2.3 with Bare addon configuration, peer dependencies, and subpath exports
  2. exports PipeError class supporting static error factories for already connected, already listening, closed server, and invalid IPC target
  3. declares Pipe and PipeServer classes, factory functions createServer and createConnection, and pipe file descriptor pair utility in index.d.ts
  4. defines constants for connection lifecycle states (CONNECTING, CONNECTED, BINDING, BOUND, READING, CLOSING, READABLE, WRITABLE, UNREFED) and libuv handle types
  5. ships native Bare C addon binding with uv_pipe integration, handle passing protocol, and multi-platform prebuild artifacts

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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-pipe@4.2.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bare-pipe@4.2.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:a5b68a7f39cd8a0e74bdf672c3858999b15bf0515628efb5bf4d486fa59bd6b3","contract":["package manifest specifies bare-pipe 4.2.3 with Bare addon configuration, peer dependencies, and subpath exports","exports PipeError class supporting static error factories for already connected, already listening, closed server, and invalid IPC target","declares Pipe and PipeServer classes, factory functions createServer and createConnection, and pipe file descriptor pair utility in index.d.ts","defines constants for connection lifecycle states (CONNECTING, CONNECTED, BINDING, BOUND, READING, CLOSING, READABLE, WRITABLE, UNREFED) and libuv handle types","ships native Bare C addon binding with uv_pipe integration, handle passing protocol, and multi-platform prebuild artifacts"],"goal":"verify pkg:npm/bare-pipe@4.2.3","kind":"HOW","packages":["pkg:npm/bare-pipe@4.2.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-pipe@4.2.3"],"schemaVersion":1,"subject":"pkg:npm/bare-pipe@4.2.3","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-bare-pipe",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-bare-pipe",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "bare-pipe": "4.2.3"
      }
    },
    "node_modules/b4a": {
      "version": "1.8.1",
      "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
      "integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
      "license": "Apache-2.0",
      "peerDependencies": {
        "react-native-b4a": "*"
      },
      "peerDependenciesMeta": {
        "react-native-b4a": {
          "optional": true
        }
      }
    },
    "node_modules/bare-events": {
      "version": "2.9.2",
      "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz",
      "integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==",
      "license": "Apache-2.0",
      "peerDependencies": {
        "bare-abort-controller": "*"
      },
      "peerDependenciesMeta": {
        "bare-abort-controller": {
          "optional": true
        }
      }
    },
    "node_modules/bare-pipe": {
      "version": "4.2.3",
      "resolved": "https://registry.npmjs.org/bare-pipe/-/bare-pipe-4.2.3.tgz",
      "integrity": "sha512-MJYji+Vy8cNMAB2fwg1WQAm1hFIOe5ojw5V9EhEa/wEEYpKT8c36WjHBDwgkgAZfUSX6wQcEFX+Q7wN09SgRow==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-events": "^2.0.0",
        "bare-stream": "^2.0.0"
      },
      "engines": {
        "bare": ">=1.16.0"
      }
    },
    "node_modules/bare-stream": {
      "version": "2.13.4",
      "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.4.tgz",
      "integrity": "sha512-PcrQ8lVLbiJscNm1Kez+Yp4Gy4AHGcN1lzwjvf5NybWen7VvEgUfyfnXYJ2zNqWnzOfCb1Abq6lH8ti0syQszA==",
      "license": "Apache-2.0",
      "dependencies": {
        "b4a": "^1.8.1",
        "streamx": "^2.25.0",
        "teex": "^1.0.1"
      },
      "peerDependencies": {
        "bare-abort-controller": "*",
        "bare-buffer": "*",
        "bare-events": "*"
      },
      "peerDependenciesMeta": {
        "bare-abort-controller": {
          "optional": true
        },
        "bare-buffer": {
          "optional": true
        },
        "bare-events": {
          "optional": true
        }
      }
    },
    "node_modules/events-universal": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
      "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-events": "^2.7.0"
      }
    },
    "node_modules/fast-fifo": {
      "version": "1.3.2",
      "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
      "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==",
      "license": "MIT"
    },
    "node_modules/streamx": {
      "version": "2.28.1",
      "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz",
      "integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==",
      "license": "MIT",
      "dependencies": {
        "events-universal": "^1.0.0",
        "fast-fifo": "^1.3.2",
        "text-decoder": "^1.1.0"
      }
    },
    "node_modules/teex": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz",
      "integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==",
      "license": "MIT",
      "dependencies": {
        "streamx": "^2.12.5"
      }
    },
    "node_modules/text-decoder": {
      "version": "1.2.7",
      "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz",
      "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==",
      "license": "Apache-2.0",
      "dependencies": {
        "b4a": "^1.6.4"
      }
    }
  }
}
package.json
{
  "name": "sample-bare-pipe",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "bare-pipe": "4.2.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/bare-pipe@4.2.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bare-pipe@4.2.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. Verify package manifest and exports
const pkgPath = require.resolve('bare-pipe/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, 'bare-pipe', 'Package name must be bare-pipe');
assert.equal(pkg.version, '4.2.3', 'Package version must be 4.2.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.ok(pkg.exports, 'Package exports must exist');
assert.equal(pkg.exports['.'].types, './index.d.ts', 'Root export must specify types ./index.d.ts');
assert.equal(pkg.exports['.'].default, './index.js', 'Root export must specify default ./index.js');
assert.equal(pkg.exports['./constants'].types, './lib/constants.d.ts', 'Constants export must specify types');
assert.equal(pkg.exports['./constants'].default, './lib/constants.js', 'Constants export must specify default');
assert.equal(pkg.exports['./errors'].types, './lib/errors.d.ts', 'Errors export must specify types');
assert.equal(pkg.exports['./errors'].default, './lib/errors.js', 'Errors export must specify 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 PipeError)
const PipeError = require('bare-pipe/errors');
assert.equal(typeof PipeError, 'function', 'bare-pipe/errors must export PipeError class');
assert.ok(PipeError.prototype instanceof Error, 'PipeError must extend Error');

const connectedErr = PipeError.PIPE_ALREADY_CONNECTED('Pipe is already connected');
assert.ok(connectedErr instanceof PipeError, 'PIPE_ALREADY_CONNECTED must return PipeError instance');
assert.equal(connectedErr.name, 'PipeError', 'Error name must be PipeError');
assert.equal(connectedErr.code, 'PIPE_ALREADY_CONNECTED', 'Error code must be PIPE_ALREADY_CONNECTED');
assert.equal(connectedErr.message, 'PIPE_ALREADY_CONNECTED: Pipe is already connected');

const listeningErr = PipeError.SERVER_ALREADY_LISTENING('Server is already listening');
assert.ok(listeningErr instanceof PipeError, 'SERVER_ALREADY_LISTENING must return PipeError instance');
assert.equal(listeningErr.name, 'PipeError', 'Error name must be PipeError');
assert.equal(listeningErr.code, 'SERVER_ALREADY_LISTENING', 'Error code must be SERVER_ALREADY_LISTENING');
assert.equal(listeningErr.message, 'SERVER_ALREADY_LISTENING: Server is already listening');

const closedErr = PipeError.SERVER_IS_CLOSED('Server is closed');
assert.ok(closedErr instanceof PipeError, 'SERVER_IS_CLOSED must return PipeError instance');
assert.equal(closedErr.name, 'PipeError', 'Error name must be PipeError');
assert.equal(closedErr.code, 'SERVER_IS_CLOSED', 'Error code must be SERVER_IS_CLOSED');
assert.equal(closedErr.message, 'SERVER_IS_CLOSED: Server is closed');

const targetErr = PipeError.INVALID_IPC_TARGET('Target does not implement IPC handle protocol');
assert.ok(targetErr instanceof PipeError, 'INVALID_IPC_TARGET must return PipeError instance');
assert.equal(targetErr.name, 'PipeError', 'Error name must be PipeError');
assert.equal(targetErr.code, 'INVALID_IPC_TARGET', 'Error code must be INVALID_IPC_TARGET');
assert.equal(targetErr.message, 'INVALID_IPC_TARGET: Target does not implement IPC handle protocol');

// 3. Verify TypeScript declarations (index.d.ts, constants.d.ts, errors.d.ts)
assert.ok(indexDts.includes('interface Pipe<M extends PipeEvents = PipeEvents> extends Duplex<M>, IPCAcceptable'), 'index.d.ts must declare Pipe interface');
assert.ok(indexDts.includes('interface PipeServer<M extends PipeServerEvents = PipeServerEvents> extends EventEmitter<M>'), 'index.d.ts must declare PipeServer interface');
assert.ok(indexDts.includes('export function pipe(): [read: number, write: number]'), 'index.d.ts must declare pipe() function');
assert.ok(indexDts.includes('export function createConnection('), 'index.d.ts must declare createConnection');
assert.ok(indexDts.includes('export function createServer('), 'index.d.ts must declare createServer');
assert.ok(indexDts.includes('interface IPCAcceptable'), 'index.d.ts must declare IPCAcceptable interface');
assert.ok(indexDts.includes('type IPCAcceptable'), 'index.d.ts must export type IPCAcceptable');
assert.ok(indexDts.includes('interface PipeOptions'), 'index.d.ts must declare PipeOptions interface');

// Verify constants type definitions
assert.ok(constantsDts.includes('CONNECTING: number'), 'constants.d.ts must declare state.CONNECTING');
assert.ok(constantsDts.includes('CONNECTED: number'), 'constants.d.ts must declare state.CONNECTED');
assert.ok(constantsDts.includes('READABLE: number'), 'constants.d.ts must declare state.READABLE');
assert.ok(constantsDts.includes('WRITABLE: number'), 'constants.d.ts must declare state.WRITABLE');
assert.ok(constantsDts.includes('NAMED_PIPE: number'), 'constants.d.ts must declare handle.NAMED_PIPE');
assert.ok(constantsDts.includes('TCP: number'), 'constants.d.ts must declare handle.TCP');
assert.ok(constantsDts.includes('UDP: number'), 'constants.d.ts must declare handle.UDP');

// Verify errors type definitions
assert.ok(errorsDts.includes('declare class PipeError extends Error'), 'errors.d.ts must declare PipeError class');

// 4. Verify IPC well-known symbols
const ipcHandleSym = Symbol.for('bare.ipc.handle');
const ipcAcceptSym = Symbol.for('bare.ipc.accept');
assert.equal(typeof ipcHandleSym, 'symbol', 'Symbol.for("bare.ipc.handle") must be a symbol');
assert.equal(typeof ipcAcceptSym, 'symbol', 'Symbol.for("bare.ipc.accept") must be a symbol');

// 5. Verify C native addon binding and multi-platform prebuilt binaries
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_MODULE(bare_pipe, bare_pipe_exports)'), 'binding.c must register bare_pipe module');
assert.ok(bindingC.includes('bare_pipe_init'), 'binding.c must implement bare_pipe_init');
assert.ok(bindingC.includes('bare_pipe_connect'), 'binding.c must implement bare_pipe_connect');
assert.ok(bindingC.includes('bare_pipe_open'), 'binding.c must implement bare_pipe_open');
assert.ok(bindingC.includes('bare_pipe_bind'), 'binding.c must implement bare_pipe_bind');
assert.ok(bindingC.includes('bare_pipe_accept'), 'binding.c must implement bare_pipe_accept');
assert.ok(bindingC.includes('bare_pipe_writev'), 'binding.c must implement bare_pipe_writev');
assert.ok(bindingC.includes('bare_pipe_pipe'), 'binding.c must implement bare_pipe_pipe');
assert.ok(bindingC.includes('uv_pipe_init'), 'binding.c must use uv_pipe_init');
assert.ok(bindingC.includes('uv_pipe_open'), 'binding.c must use uv_pipe_open');
assert.ok(bindingC.includes('uv_pipe_connect2'), 'binding.c must use uv_pipe_connect2');
assert.ok(bindingC.includes('uv_pipe_bind2'), 'binding.c must use uv_pipe_bind2');
assert.ok(bindingC.includes('uv_write2'), 'binding.c must support handle transfer with uv_write2');

assert.ok(fs.existsSync(path.join(pkgDir, 'CMakeLists.txt')), 'CMakeLists.txt must exist');

const prebuildsDir = path.join(pkgDir, 'prebuilds');
const expectedTargets = [
  'linux-x64',
  'linux-arm64',
  'darwin-x64',
  'darwin-arm64',
  'win32-x64',
  'win32-arm64',
  'android-arm64',
  'ios-arm64'
];

for (const target of expectedTargets) {
  const prebuildPath = path.join(prebuildsDir, target, 'bare-pipe.bare');
  assert.ok(fs.existsSync(prebuildPath), `Prebuild binary for ${target} must exist at ${prebuildPath}`);
  const stats = fs.statSync(prebuildPath);
  assert.ok(stats.size > 0, `Prebuild binary for ${target} must not be empty`);
}

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

Seeder de origem

anônimo