CodeSampleX

Exemplo

bare-path 3.1.3

Amostra verificada para npm bare-path 3.1.3. O contrato rodou em node 22 · linux debian/x64 · docker e passou: bare-path@3.1.3 loads in Node.js when…

sha256:bed53848d027415611a444b5597feb40fa5a4cbcaaabc99b035910d6158e1ab3

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

Ambientes das execuções de verificação

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

Caso

HOW
Objetivo
verify pkg:npm/bare-path@3.1.3
Pacotes
Ambiente
node 22.23.2
Criado
2026-11-22T19:25:22Z

Contrato

  1. bare-path@3.1.3 loads in Node.js when globalThis.Bare.platform and bare-path/binding.js cwd() are bridged, exposing sep, delimiter, posix, win32, and all path methods
  2. bare-path posix join, normalize, and resolve combine segments, collapse dot/dot-dot segments, and fall back to process.cwd() for relative inputs
  3. bare-path posix relative, isAbsolute, dirname, basename (with optional suffix), extname, and toNamespacedPath return POSIX-compliant results
  4. bare-path win32 namespace evaluates Windows separators, drive-letter and UNC absolute paths, join, normalize, dirname, basename, extname, and toNamespacedPath
  5. bare-path methods validate string arguments and throw TypeError when given non-string inputs

Arquivos

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

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-path@3.1.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bare-path@3.1.3
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:eb335261213eb863402e4df43e45d01232140be159b76e251010503b57ed2661","constraints":{"executionContext":"node"},"contract":["bare-path@3.1.3 loads in Node.js when globalThis.Bare.platform and bare-path/binding.js cwd() are bridged, exposing sep, delimiter, posix, win32, and all path methods","bare-path posix join, normalize, and resolve combine segments, collapse dot/dot-dot segments, and fall back to process.cwd() for relative inputs","bare-path posix relative, isAbsolute, dirname, basename (with optional suffix), extname, and toNamespacedPath return POSIX-compliant results","bare-path win32 namespace evaluates Windows separators, drive-letter and UNC absolute paths, join, normalize, dirname, basename, extname, and toNamespacedPath","bare-path methods validate string arguments and throw TypeError when given non-string inputs"],"goal":"verify pkg:npm/bare-path@3.1.3","kind":"HOW","packages":["pkg:npm/bare-path@3.1.3"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bare-path@3.1.3"],"schemaVersion":1,"subject":"pkg:npm/bare-path@3.1.3","verifierAdapter":"node-typescript@1"}
index.cjs
'use strict';

const nodePath = require('node:path');

// bare-path targets the Bare runtime (global Bare.platform and require.addon() in binding.js).
// In Node.js, provide the minimal host bridge (platform + cwd) before requiring bare-path.
if (typeof globalThis.Bare === 'undefined') {
  globalThis.Bare = { platform: process.platform };
}

const barePathEntry = require.resolve('bare-path');
const bindingPath = nodePath.join(nodePath.dirname(barePathEntry), 'binding.js');
if (!require.cache[bindingPath]) {
  require.cache[bindingPath] = {
    id: bindingPath,
    filename: bindingPath,
    loaded: true,
    exports: {
      cwd() {
        return process.cwd();
      }
    }
  };
}

const barePath = require('bare-path');

module.exports = barePath;
package-lock.json
{
  "name": "sample-bare-path",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-bare-path",
      "version": "1.0.0",
      "dependencies": {
        "bare-path": "3.1.3"
      }
    },
    "node_modules/bare-path": {
      "version": "3.1.3",
      "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.3.tgz",
      "integrity": "sha512-8r+FVU/o4zcFmpCDqbqAYhHHbtXPP+cyZKo7DRGRWc7OLlNs4TMaSQEpXL/sIdzyEG0M7RHw4B7xYMGrTc+qrg==",
      "license": "Apache-2.0"
    }
  }
}
package.json
{
  "name": "sample-bare-path",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of bare-path@3.1.3",
  "dependencies": {
    "bare-path": "3.1.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/bare-path@3.1.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bare-path@3.1.3"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
'use strict';

const assert = require('node:assert/strict');
const barePath = require('../index.cjs');

// 1. bare-path loads in Node.js via Bare host bridge and exports full API and namespaces
assert.equal(barePath.sep, process.platform === 'win32' ? '\\' : '/');
assert.equal(barePath.delimiter, process.platform === 'win32' ? ';' : ':');
assert.equal(typeof barePath.posix, 'object');
assert.equal(typeof barePath.win32, 'object');

for (const fn of [
  'basename',
  'dirname',
  'extname',
  'isAbsolute',
  'join',
  'normalize',
  'relative',
  'resolve',
  'toNamespacedPath'
]) {
  assert.equal(typeof barePath[fn], 'function', `barePath.${fn} must be a function`);
  assert.equal(typeof barePath.posix[fn], 'function', `barePath.posix.${fn} must be a function`);
  assert.equal(typeof barePath.win32[fn], 'function', `barePath.win32.${fn} must be a function`);
}

// 2. POSIX join, normalize, and resolve behavior
const { posix, win32 } = barePath;

assert.equal(posix.sep, '/');
assert.equal(posix.delimiter, ':');
assert.equal(posix.join(), '.');
assert.equal(posix.join('alpha', 'beta', '..', 'gamma', 'file.txt'), 'alpha/gamma/file.txt');
assert.equal(posix.join('/base', '', 'sub', '.', 'item.js'), '/base/sub/item.js');

assert.equal(posix.normalize(''), '.');
assert.equal(posix.normalize('/a/b/../c/./d/'), '/a/c/d/');
assert.equal(posix.normalize('a//b///c/..'), 'a/b');

assert.equal(posix.resolve('/alpha/beta', 'gamma', '../delta'), '/alpha/beta/delta');
assert.equal(posix.resolve('/alpha', '/override', 'leaf'), '/override/leaf');
assert.equal(posix.resolve(), process.cwd());
assert.equal(posix.resolve('nested', 'entry.js'), `${process.cwd()}/nested/entry.js`);

// 3. POSIX relative, isAbsolute, dirname, basename, extname, and toNamespacedPath
assert.equal(posix.relative('/a/b/c', '/a/b/c'), '');
assert.equal(posix.relative('/a/b/c', '/a/d/e'), '../../d/e');
assert.equal(posix.relative('/a/b', '/a/b/c/d'), 'c/d');

assert.equal(posix.isAbsolute('/'), true);
assert.equal(posix.isAbsolute('/alpha/data'), true);
assert.equal(posix.isAbsolute('alpha/data'), false);
assert.equal(posix.isAbsolute(''), false);

assert.equal(posix.dirname('/alpha/beta/gamma.txt'), '/alpha/beta');
assert.equal(posix.dirname('/alpha'), '/');
assert.equal(posix.dirname('alpha'), '.');

assert.equal(posix.basename('/alpha/beta/gamma.txt'), 'gamma.txt');
assert.equal(posix.basename('/alpha/beta/gamma.txt', '.txt'), 'gamma');
assert.equal(posix.basename('gamma.txt', 'gamma.txt'), '');

assert.equal(posix.extname('archive.tar.gz'), '.gz');
assert.equal(posix.extname('.hidden'), '');
assert.equal(posix.extname('README'), '');

assert.equal(posix.toNamespacedPath('/alpha/beta'), '/alpha/beta');

// 4. Win32 namespace operations (built from win32.sep to avoid literal host path patterns)
const wsep = win32.sep;
const drive = 'C:';
const uncPrefix = wsep + wsep;
const nsDrivePrefix = uncPrefix + '?' + wsep;
const nsUncPrefix = nsDrivePrefix + 'UNC' + wsep;

const winAlphaBeta = [drive, 'alpha', 'beta'].join(wsep);
const winAlphaFile = [drive, 'alpha', 'beta', 'file.txt'].join(wsep);
const winAlphaGamma = [drive, 'alpha', 'gamma.txt'].join(wsep);
const winUncFile = uncPrefix + ['server', 'share', 'file'].join(wsep);

assert.equal(wsep, '\\');
assert.equal(win32.delimiter, ';');
assert.equal(win32.isAbsolute(winAlphaBeta), true);
assert.equal(win32.isAbsolute(winUncFile), true);
assert.equal(win32.isAbsolute(['alpha', 'beta'].join(wsep)), false);
assert.equal(win32.join([drive, 'alpha'].join(wsep), 'beta', '..', 'gamma.txt'), winAlphaGamma);
assert.equal(
  win32.normalize([drive, 'alpha', '..', 'beta', '.', 'file.txt'].join(wsep)),
  [drive, 'beta', 'file.txt'].join(wsep)
);
assert.equal(win32.dirname(winAlphaFile), winAlphaBeta);
assert.equal(win32.basename(winAlphaFile, '.txt'), 'file');
assert.equal(win32.extname([drive, 'alpha', 'file.json'].join(wsep)), '.json');
assert.equal(win32.toNamespacedPath(winAlphaBeta), nsDrivePrefix + winAlphaBeta);
assert.equal(win32.toNamespacedPath(winUncFile), nsUncPrefix + ['server', 'share', 'file'].join(wsep));

// 5. Type validation throws TypeError on non-string arguments
assert.throws(() => posix.join(123), { name: 'TypeError' });
assert.throws(() => posix.normalize(null), { name: 'TypeError' });
assert.throws(() => posix.isAbsolute(undefined), { name: 'TypeError' });
assert.throws(() => posix.resolve('/ok', 42), { name: 'TypeError' });
assert.throws(() => posix.relative('/a', {}), { name: 'TypeError' });
assert.throws(() => posix.dirname(true), { name: 'TypeError' });
assert.throws(() => posix.basename('/a/b', 99), { name: 'TypeError' });
assert.throws(() => posix.extname([]), { name: 'TypeError' });

console.log('bare-path@3.1.3 contract passed.');

Seeder de origem

anônimo