CodeSampleX

Sample

glob 13.0.7: glob

Verified sample for npm glob 13.0.7: glob. The contract ran on node 22 · linux debian/x64 · docker and passed: require('glob') exports an async function glob…

sha256:5a4f08c724368cfb67c66f642f9b8aadcb204cf4e08eaf20c0caed1ced63ea21

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 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

Case

HOW
Goal
verify glob.glob in pkg:npm/glob@13.0.7
Packages
Symbols
  • glob.glob
Environment
node 22.23.2
Created
2026-11-22T15:48:28Z

Contract

  1. require('glob') exports an async function glob with self-referential alias glob.glob === glob, while the module namespace itself is an object rather than a function
  2. calling glob(pattern) without an options object resolves against process.cwd() and accepts a single pattern string or a string[] array with deduplicated matches
  3. cwd accepts both a directory path string and a file:// URL, and nodir, dot, ignore (glob array or IgnoreLike object), and maxDepth filter traversal results
  4. dotRelative:true prefixes relative paths with ./, mark:true appends / to matched directories, absolute:true returns absolute paths, and withFileTypes:true returns Path objects with name, isFile(), isDirectory(), and relative()
  5. includeChildMatches:false omits nested matches under already-matched directories
  6. passing an aborted AbortSignal rejects the returned Promise with signal.reason
  7. invalid option combinations (withFileTypes:true with absolute:true; matchBase:true with noglobstar:true) reject the returned Promise with Error and TypeError respectively rather than throwing synchronously

Files

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

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 glob.glob in pkg:npm/glob@13.0.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/glob@13.0.7
Demonstrate these symbols/APIs:
  - glob.glob
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:f69376412c9a5387e4583b190168035b93ae774a9f5f7a2fad935aacb3cd4cc9","constraints":{"executionContext":"node"},"contract":["require('glob') exports an async function glob with self-referential alias glob.glob === glob, while the module namespace itself is an object rather than a function","calling glob(pattern) without an options object resolves against process.cwd() and accepts a single pattern string or a string[] array with deduplicated matches","cwd accepts both a directory path string and a file:// URL, and nodir, dot, ignore (glob array or IgnoreLike object), and maxDepth filter traversal results","dotRelative:true prefixes relative paths with ./, mark:true appends / to matched directories, absolute:true returns absolute paths, and withFileTypes:true returns Path objects with name, isFile(), isDirectory(), and relative()","includeChildMatches:false omits nested matches under already-matched directories","passing an aborted AbortSignal rejects the returned Promise with signal.reason","invalid option combinations (withFileTypes:true with absolute:true; matchBase:true with noglobstar:true) reject the returned Promise with Error and TypeError respectively rather than throwing synchronously"],"goal":"verify glob.glob in pkg:npm/glob@13.0.7","kind":"HOW","packages":["pkg:npm/glob@13.0.7"],"schemaVersion":1,"symbols":["glob.glob"]},"contractCommand":["node","test/contract.js"],"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/glob@13.0.7"],"schemaVersion":1,"subject":"pkg:npm/glob@13.0.7","symbols":["glob.glob"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "glob-verify-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "glob-verify-sample",
      "version": "1.0.0",
      "dependencies": {
        "glob": "13.0.7"
      }
    },
    "node_modules/balanced-match": {
      "version": "4.0.4",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
      "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
      "license": "MIT",
      "engines": {
        "node": "18 || 20 || >=22"
      }
    },
    "node_modules/brace-expansion": {
      "version": "5.0.13",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz",
      "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^4.0.2"
      },
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/glob": {
      "version": "13.0.7",
      "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz",
      "integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==",
      "license": "BlueOak-1.0.0",
      "dependencies": {
        "minimatch": "^10.2.2",
        "minipass": "^7.1.3",
        "path-scurry": "^2.0.2"
      },
      "engines": {
        "node": "18 || 20 || >=22"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/lru-cache": {
      "version": "11.5.3",
      "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",
      "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/minimatch": {
      "version": "10.2.6",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
      "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
      "license": "BlueOak-1.0.0",
      "dependencies": {
        "brace-expansion": "^5.0.8"
      },
      "engines": {
        "node": "18 || 20 || >=22"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/minipass": {
      "version": "7.1.3",
      "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
      "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=16 || 14 >=14.17"
      }
    },
    "node_modules/path-scurry": {
      "version": "2.0.2",
      "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
      "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
      "license": "BlueOak-1.0.0",
      "dependencies": {
        "lru-cache": "^11.0.0",
        "minipass": "^7.1.2"
      },
      "engines": {
        "node": "18 || 20 || >=22"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    }
  }
}
package.json
{
  "name": "glob-verify-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for glob.glob in glob@13.0.7",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "glob": "13.0.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify glob.glob in pkg:npm/glob@13.0.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/glob@13.0.7"
  ],
  "symbols": [
    "glob.glob"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const { glob } = require('glob');

/**
 * Find matching paths asynchronously via `glob.glob`.
 *
 * @param {string | string[]} pattern
 * @param {import('glob').GlobOptions} [options]
 * @returns {Promise<Array<string | import('glob').Path>>}
 */
async function findMatches(pattern, options) {
  if (options === undefined) {
    return glob(pattern);
  }
  return glob.glob(pattern, options);
}

/**
 * Find only files (no directories) under `cwd`, excluding optional ignore patterns.
 *
 * @param {string | string[]} pattern
 * @param {string | URL} cwd
 * @param {string | string[] | import('glob').IgnoreLike} [ignore]
 * @returns {Promise<string[]>}
 */
async function findFiles(pattern, cwd, ignore) {
  const results = await glob.glob(pattern, {
    cwd,
    nodir: true,
    ignore,
  });
  return results.sort();
}

module.exports = {
  findMatches,
  findFiles,
};
test/contract.js
'use strict';

const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { pathToFileURL } = require('node:url');
const globPkg = require('glob');
const { glob } = globPkg;
const { findMatches, findFiles } = require('../src/index.js');

function writeFixtureTree(rootDir) {
  fs.mkdirSync(path.join(rootDir, 'a', 'b', 'c'), { recursive: true });
  fs.mkdirSync(path.join(rootDir, 'ignored'), { recursive: true });
  fs.mkdirSync(path.join(rootDir, 'pkg', 'sub', 'pkg'), { recursive: true });

  fs.writeFileSync(path.join(rootDir, 'root.txt'), 'root\n');
  fs.writeFileSync(path.join(rootDir, '.hidden'), 'secret\n');
  fs.writeFileSync(path.join(rootDir, 'a', 'one.txt'), 'one\n');
  fs.writeFileSync(path.join(rootDir, 'a', 'two.md'), 'two\n');
  fs.writeFileSync(path.join(rootDir, 'a', 'b', 'deep.txt'), 'deep\n');
  fs.writeFileSync(path.join(rootDir, 'a', 'b', 'c', 'too-deep.txt'), 'too-deep\n');
  fs.writeFileSync(path.join(rootDir, 'ignored', 'skip.txt'), 'skip\n');
  fs.writeFileSync(path.join(rootDir, 'pkg', 'marker.txt'), 'm1\n');
  fs.writeFileSync(path.join(rootDir, 'pkg', 'sub', 'pkg', 'marker.txt'), 'm2\n');
}

async function run() {
  // 1. Export shape: module namespace is an object; glob and glob.glob reference the same async function.
  assert.equal(typeof globPkg, 'object');
  assert.equal(typeof glob, 'function');
  assert.equal(glob.glob, glob);

  const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'glob-contract-'));
  const originalCwd = process.cwd();

  try {
    writeFixtureTree(tmpRoot);

    // 2. Omitting options defaults to process.cwd(); single pattern and string[] array patterns deduplicate.
    process.chdir(tmpRoot);
    const noOptsPromise = findMatches('*.txt');
    assert.equal(typeof noOptsPromise.then, 'function');
    const noOptsMatches = await noOptsPromise;
    assert.deepEqual(noOptsMatches, ['root.txt']);

    const arrayMatches = (await glob.glob(['a/*.txt', 'a/*.md', 'a/one.txt'])).sort();
    assert.deepEqual(arrayMatches, ['a/one.txt', 'a/two.md']);
    process.chdir(originalCwd);

    // 3. cwd accepts a string or file:// URL; nodir, dot, ignore, and maxDepth filter results.
    const filesViaUrl = await findFiles('**/*.txt', pathToFileURL(tmpRoot), ['ignored/**']);
    assert.deepEqual(filesViaUrl, [
      'a/b/c/too-deep.txt',
      'a/b/deep.txt',
      'a/one.txt',
      'pkg/marker.txt',
      'pkg/sub/pkg/marker.txt',
      'root.txt',
    ]);

    const withoutDot = (await glob('*', { cwd: tmpRoot, nodir: true })).sort();
    assert.deepEqual(withoutDot, ['root.txt']);

    const withDot = (await glob('*', { cwd: tmpRoot, nodir: true, dot: true })).sort();
    assert.deepEqual(withDot, ['.hidden', 'root.txt']);

    const customIgnore = (
      await glob('a/**', {
        cwd: tmpRoot,
        nodir: true,
        ignore: {
          ignored: (p) => p.name.endsWith('.md'),
          childrenIgnored: (p) => p.name === 'b',
        },
      })
    ).sort();
    assert.deepEqual(customIgnore, ['a/one.txt']);

    const shallow = (
      await glob('a/**/*.txt', { cwd: tmpRoot, nodir: true, maxDepth: 2 })
    ).sort();
    assert.deepEqual(shallow, ['a/one.txt']);

    // 4. Output formatting: dotRelative, mark, absolute, and withFileTypes.
    const dotRel = (await glob('a/*.txt', { cwd: tmpRoot, dotRelative: true })).sort();
    assert.deepEqual(dotRel, ['./a/one.txt']);

    const markedDirs = (await glob('a/*', { cwd: tmpRoot, mark: true })).sort();
    assert.deepEqual(markedDirs, ['a/b/', 'a/one.txt', 'a/two.md']);

    const absMatches = await glob('root.txt', { cwd: tmpRoot, absolute: true });
    assert.deepEqual(absMatches, [path.join(tmpRoot, 'root.txt')]);

    const fileTypes = await glob('a/*', { cwd: tmpRoot, withFileTypes: true });
    const byName = new Map(fileTypes.map((entry) => [entry.name, entry]));
    assert.equal(byName.size, 3);
    assert.equal(byName.get('b').isDirectory(), true);
    assert.equal(byName.get('one.txt').isFile(), true);
    assert.equal(byName.get('one.txt').relative(), path.join('a', 'one.txt'));

    // 5. includeChildMatches: false skips nested matches under already-matched directories.
    const topPkgOnly = await glob('**/pkg', {
      cwd: tmpRoot,
      includeChildMatches: false,
    });
    assert.deepEqual(topPkgOnly, ['pkg']);

    // 6. Aborted AbortSignal rejects with signal.reason.
    const controller = new AbortController();
    const abortReason = new Error('stopped-before-walk');
    controller.abort(abortReason);
    await assert.rejects(
      () => glob('**/*.txt', { cwd: tmpRoot, signal: controller.signal }),
      (err) => err === abortReason
    );

    // 7. Invalid option combinations reject asynchronously rather than throwing synchronously.
    const conflictPromise = glob('**', {
      cwd: tmpRoot,
      withFileTypes: true,
      absolute: true,
    });
    assert.equal(typeof conflictPromise.then, 'function');
    await assert.rejects(conflictPromise, {
      name: 'Error',
      message: 'cannot set absolute and withFileTypes:true',
    });

    const matchBasePromise = glob('*.txt', {
      cwd: tmpRoot,
      matchBase: true,
      noglobstar: true,
    });
    assert.equal(typeof matchBasePromise.then, 'function');
    await assert.rejects(matchBasePromise, {
      name: 'TypeError',
      message: 'base matching requires globstar',
    });
  } finally {
    process.chdir(originalCwd);
    fs.rmSync(tmpRoot, { recursive: true, force: true });
  }
}

run().catch((err) => {
  console.error(err);
  process.exit(1);
});

Origin Seeder

anonymous