CodeSampleX

Sample

bare-path 3.1.1: resolve

Verified sample for npm bare-path 3.1.1: resolve. The contract ran on node 22 · linux alpine/x64 · docker and passed: bare-path exports resolve function…

sha256:5d8194f07c7f92a55972ea610019005234b4c0bdb579867a8c0d3e0df18bae8f

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

Verification-run environments

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

Case

HOW
Goal
verify bare-path.resolve in pkg:npm/bare-path@3.1.1
Packages
Symbols
  • bare-path.resolve
Environment
node 22.23.2
Created
2026-08-27T16:13:55Z

Contract

  1. bare-path exports resolve function directly and via posix/win32 sub-namespaces
  2. resolve resolves absolute and relative path segments into a normalized absolute path
  3. resolve defaults to current working directory when given relative paths or no arguments
  4. resolve ignores empty path segments and normalizes dot and dot-dot segments correctly
  5. resolve validates argument types and throws TypeError when non-string arguments are provided

Files

  • PROMPT.md
  • csx.json
  • index.js
  • 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 bare-path.resolve in pkg:npm/bare-path@3.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bare-path@3.1.1
Demonstrate these symbols/APIs:
  - bare-path.resolve
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:d14e1baf8d2bf1606e2a62474d50739b2163fea2eb9603400c7d43891558a244","constraints":{"executionContext":"node"},"contract":["bare-path exports resolve function directly and via posix/win32 sub-namespaces","resolve resolves absolute and relative path segments into a normalized absolute path","resolve defaults to current working directory when given relative paths or no arguments","resolve ignores empty path segments and normalizes dot and dot-dot segments correctly","resolve validates argument types and throws TypeError when non-string arguments are provided"],"goal":"verify bare-path.resolve in pkg:npm/bare-path@3.1.1","kind":"HOW","packages":["pkg:npm/bare-path@3.1.1"],"schemaVersion":1,"symbols":["bare-path.resolve"]},"contractCommand":["node","test/contract.mjs"],"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.1"],"schemaVersion":1,"subject":"pkg:npm/bare-path@3.1.1","symbols":["bare-path.resolve"],"verifierAdapter":"node-typescript@1"}
index.js
import { createRequire } from 'node:module';
import path from 'node:path';

const require = createRequire(import.meta.url);

// Ensure native binding is provided in Node.js environments where Bare runtime is absent
if (typeof Bare === 'undefined') {
  globalThis.Bare = {
    platform: process.platform
  };

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

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

/**
 * Resolves a sequence of paths or path segments into an absolute path using bare-path.
 * @param {...string} paths
 * @returns {string}
 */
export function resolvePath(...paths) {
  return barePath.resolve(...paths);
}

/**
 * Resolves path segments specifically using bare-path posix resolver.
 * @param {...string} paths
 * @returns {string}
 */
export function resolvePosixPath(...paths) {
  return barePath.posix.resolve(...paths);
}

export default barePath;
package-lock.json
{
  "name": "sample-bare-path-resolve",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-bare-path-resolve",
      "version": "1.0.0",
      "dependencies": {
        "bare-path": "3.1.1"
      }
    },
    "node_modules/bare-path": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.1.tgz",
      "integrity": "sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==",
      "license": "Apache-2.0"
    }
  }
}
package.json
{
  "name": "sample-bare-path-resolve",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "bare-path": "3.1.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify bare-path.resolve in pkg:npm/bare-path@3.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bare-path@3.1.1"
  ],
  "symbols": [
    "bare-path.resolve"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import path from 'node:path';
import barePath, { resolvePath, resolvePosixPath } from '../index.js';

// 1. bare-path exports resolve function directly and via posix/win32 sub-namespaces
assert.strictEqual(typeof barePath.resolve, 'function', 'barePath.resolve must be a function');
assert.strictEqual(typeof barePath.posix.resolve, 'function', 'barePath.posix.resolve must be a function');
assert.strictEqual(typeof barePath.win32.resolve, 'function', 'barePath.win32.resolve must be a function');
assert.strictEqual(typeof resolvePath, 'function', 'resolvePath helper must be a function');
assert.strictEqual(typeof resolvePosixPath, 'function', 'resolvePosixPath helper must be a function');

// 2. resolve resolves absolute and relative path segments into a normalized absolute path
const posixAbs = barePath.posix.resolve('/a/b', 'c', 'd');
assert.strictEqual(posixAbs, '/a/b/c/d', 'posix.resolve must resolve segments into an absolute path');
const helperResolved = resolvePosixPath('/foo/bar', '../baz');
assert.strictEqual(helperResolved, '/foo/baz', 'resolvePosixPath helper must resolve relative path segments');

// 3. resolve defaults to current working directory when given relative paths or no arguments
const defaultCwd = barePath.posix.resolve();
assert.strictEqual(defaultCwd, process.cwd(), 'posix.resolve() with no arguments must return cwd');
const relResolved = barePath.posix.resolve('sample', 'test');
assert.strictEqual(relResolved, `${process.cwd()}/sample/test`, 'posix.resolve with relative path must prefix cwd');

// 4. resolve ignores empty path segments and normalizes dot and dot-dot segments correctly
const withEmpty = barePath.posix.resolve('/project', '', 'sub', '.', 'file.txt');
assert.strictEqual(withEmpty, '/project/sub/file.txt', 'posix.resolve must ignore empty segments and normalize dot');
const withParent = barePath.posix.resolve('/project/a/b/c', '../../d');
assert.strictEqual(withParent, '/project/a/d', 'posix.resolve must resolve parent directory dots');

// 5. resolve validates argument types and throws TypeError when non-string arguments are provided
assert.throws(
  () => barePath.posix.resolve(123),
  {
    name: 'TypeError',
    message: 'The "paths[0]" argument must be of type string. Received type number'
  },
  'posix.resolve must throw TypeError for non-string arguments'
);
assert.throws(
  () => barePath.posix.resolve('/valid', null),
  {
    name: 'TypeError',
    message: 'The "paths[1]" argument must be of type string. Received type object'
  },
  'posix.resolve must throw TypeError for null argument'
);

console.log('Contract verification finished successfully.');

Origin Seeder

anonymous