CodeSampleX

Exemplo

glob 8.1.0

Amostra verificada para npm glob 8.1.0. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: glob.sync finds matching files by glob pattern

sha256:73c76d5b644c2bf0cf242376348d6a3a6af7ba57e563cb1df6c5d8f39babbaaf

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@1
2026-08-21

Caso

HOW
Objetivo
verify pkg:npm/glob@8.1.0
Pacotes
Criado
2026-08-21T14:30:10Z

Contrato

  1. glob.sync finds matching files by glob pattern
  2. glob.sync respects options such as ignore and nodir
  3. glob async callback finds matching files by glob pattern

Arquivos

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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/glob@8.1.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/glob@8.1.0

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:9789b78ffdfc0b4f4f4188031e20c9acb16e7d3963b66049837a2165bfabf859","contract":["glob.sync finds matching files by glob pattern","glob.sync respects options such as ignore and nodir","glob async callback finds matching files by glob pattern"],"goal":"verify pkg:npm/glob@8.1.0","kind":"HOW","packages":["pkg:npm/glob@8.1.0"],"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/glob@8.1.0"],"schemaVersion":1,"subject":"pkg:npm/glob@8.1.0","verifierAdapter":"node-typescript@1"}
index.mjs
import glob from 'glob';

export function findFilesSync(pattern, options = {}) {
  return glob.sync(pattern, options);
}

export function findFilesAsync(pattern, options = {}) {
  return new Promise((resolve, reject) => {
    glob(pattern, options, (err, matches) => {
      if (err) return reject(err);
      resolve(matches);
    });
  });
}
package-lock.json
{
  "name": "sample-glob",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-glob",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
        "glob": "8.1.0"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "2.1.4",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
      "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0"
      }
    },
    "node_modules/fs.realpath": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
      "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
      "license": "ISC"
    },
    "node_modules/glob": {
      "version": "8.1.0",
      "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
      "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
      "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
      "license": "ISC",
      "dependencies": {
        "fs.realpath": "^1.0.0",
        "inflight": "^1.0.4",
        "inherits": "2",
        "minimatch": "^5.0.1",
        "once": "^1.3.0"
      },
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/inflight": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
      "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
      "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
      "license": "ISC",
      "dependencies": {
        "once": "^1.3.0",
        "wrappy": "1"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/minimatch": {
      "version": "5.1.9",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",
      "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^2.0.1"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/once": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
      "license": "ISC",
      "dependencies": {
        "wrappy": "1"
      }
    },
    "node_modules/wrappy": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
      "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-glob",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "glob": "8.1.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/glob@8.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/glob@8.1.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import glob from 'glob';

const testDir = path.join(process.cwd(), '.tmp_test_fixture');
if (fs.existsSync(testDir)) {
  fs.rmSync(testDir, { recursive: true, force: true });
}
fs.mkdirSync(testDir, { recursive: true });
fs.mkdirSync(path.join(testDir, 'src'), { recursive: true });
fs.mkdirSync(path.join(testDir, 'test'), { recursive: true });

fs.writeFileSync(path.join(testDir, 'src', 'index.js'), 'console.log("hello");');
fs.writeFileSync(path.join(testDir, 'src', 'utils.js'), 'export const a = 1;');
fs.writeFileSync(path.join(testDir, 'src', 'data.json'), '{"key":"val"}');
fs.writeFileSync(path.join(testDir, 'test', 'index.test.js'), 'assert(true);');
fs.writeFileSync(path.join(testDir, 'README.md'), '# Test');

try {
  // 1. glob.sync finds matching files by glob pattern
  const jsFiles = glob.sync('**/*.js', { cwd: testDir });
  assert.equal(jsFiles.length, 3, 'Should find exactly 3 .js files');
  assert.deepEqual(jsFiles.sort(), ['src/index.js', 'src/utils.js', 'test/index.test.js'].sort());

  // 2. glob.sync respects options such as ignore and nodir
  const nonTestJsFiles = glob.sync('**/*.js', { cwd: testDir, ignore: 'test/**' });
  assert.equal(nonTestJsFiles.length, 2, 'Should find 2 .js files when ignoring test/**');
  assert.deepEqual(nonTestJsFiles.sort(), ['src/index.js', 'src/utils.js'].sort());

  // 3. glob async callback finds matching files by glob pattern
  await new Promise((resolve, reject) => {
    glob('**/*.json', { cwd: testDir }, (err, files) => {
      if (err) return reject(err);
      try {
        assert.equal(files.length, 1);
        assert.equal(files[0], 'src/data.json');
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });

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

Seeder de origem

anônimo