CodeSampleX

Sample

ci-info 3.9.0

Verified sample for npm ci-info 3.9.0. The contract ran on node 22 · linux alpine/x64 · docker and passed: getCISummary returns boolean isCI and nullable…

sha256:8fcad04686492d95ef5e0445083f61f1ed1856fa532683134e2e570d7633e279

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
2
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

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-23
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-09-08

Case

HOW
Goal
verify pkg:npm/ci-info@3.9.0
Packages
Created
2026-08-23T07:22:27Z

Contract

  1. getCISummary returns boolean isCI and nullable isPR and name properties
  2. getVendorConstants returns list of supported vendor constants including GITHUB_ACTIONS and GITLAB
  3. isVendorCI returns boolean indicating whether specific vendor flag is active
  4. detectEnvironment identifies GitHub Actions environment and pull request status
  5. detectEnvironment identifies GitLab CI environment and merge request status
  6. detectEnvironment identifies Travis CI environment and pull request status
  7. detectEnvironment identifies CircleCI environment and pull request status
  8. detectEnvironment respects CI=false environment override to disable isCI

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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 pkg:npm/ci-info@3.9.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ci-info@3.9.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:ab0657e80d94d4ff9901ac330ecda923cb65cd755ff75c5751998250c4b67f7d","contract":["getCISummary returns boolean isCI and nullable isPR and name properties","getVendorConstants returns list of supported vendor constants including GITHUB_ACTIONS and GITLAB","isVendorCI returns boolean indicating whether specific vendor flag is active","detectEnvironment identifies GitHub Actions environment and pull request status","detectEnvironment identifies GitLab CI environment and merge request status","detectEnvironment identifies Travis CI environment and pull request status","detectEnvironment identifies CircleCI environment and pull request status","detectEnvironment respects CI=false environment override to disable isCI"],"goal":"verify pkg:npm/ci-info@3.9.0","kind":"HOW","packages":["pkg:npm/ci-info@3.9.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/ci-info@3.9.0"],"schemaVersion":1,"subject":"pkg:npm/ci-info@3.9.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-ci-info",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-ci-info",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "ci-info": "3.9.0"
      }
    },
    "node_modules/ci-info": {
      "version": "3.9.0",
      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",
      "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/sibiraj-s"
        }
      ],
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    }
  }
}
package.json
{
  "name": "sample-ci-info",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for ci-info@3.9.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "ci-info": "3.9.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ci-info@3.9.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ci-info@3.9.0"
  ]
}
src/index.js
'use strict';

const ci = require('ci-info');

/**
 * Returns summary of CI environment flags.
 *
 * @returns {{ isCI: boolean, isPR: boolean | null, name: string | null }}
 */
function getCISummary() {
  return {
    isCI: ci.isCI,
    isPR: ci.isPR,
    name: ci.name
  };
}

/**
 * Returns all supported vendor constant names declared by ci-info.
 *
 * @returns {string[]} List of vendor constants.
 */
function getVendorConstants() {
  return Array.isArray(ci._vendors) ? [...ci._vendors] : [];
}

/**
 * Checks if a specific CI vendor flag is set to true.
 *
 * @param {string} vendorConstant - The vendor constant name.
 * @returns {boolean} Whether the vendor flag is true.
 */
function isVendorCI(vendorConstant) {
  return Boolean(ci[vendorConstant]);
}

/**
 * Evaluates CI detection under a simulated environment map.
 * Isolates process.env modifications and reloads ci-info module.
 *
 * @param {Record<string, string>} envOverrides - Environment variables to set.
 * @returns {{ isCI: boolean, isPR: boolean | null, name: string | null, vendorFlags: Record<string, boolean> }}
 */
function detectEnvironment(envOverrides) {
  const previousEnv = {};
  for (const key of Object.keys(envOverrides)) {
    previousEnv[key] = process.env[key];
    process.env[key] = envOverrides[key];
  }

  let freshCi;
  try {
    delete require.cache[require.resolve('ci-info')];
    freshCi = require('ci-info');
  } finally {
    for (const key of Object.keys(envOverrides)) {
      if (previousEnv[key] === undefined) {
        delete process.env[key];
      } else {
        process.env[key] = previousEnv[key];
      }
    }
    delete require.cache[require.resolve('ci-info')];
  }

  const vendorFlags = {};
  if (Array.isArray(freshCi._vendors)) {
    for (const vendor of freshCi._vendors) {
      if (freshCi[vendor]) {
        vendorFlags[vendor] = true;
      }
    }
  }

  return {
    isCI: freshCi.isCI,
    isPR: freshCi.isPR,
    name: freshCi.name,
    vendorFlags
  };
}

module.exports = {
  ci,
  getCISummary,
  getVendorConstants,
  isVendorCI,
  detectEnvironment
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  ci,
  getCISummary,
  getVendorConstants,
  isVendorCI,
  detectEnvironment
} = require('../src/index.js');

async function runContractTests() {
  // 1. Module export verification
  assert.ok(ci !== null && typeof ci === 'object', 'ci must be exported as an object');
  assert.equal(typeof getCISummary, 'function', 'getCISummary must be a function');
  assert.equal(typeof getVendorConstants, 'function', 'getVendorConstants must be a function');
  assert.equal(typeof isVendorCI, 'function', 'isVendorCI must be a function');
  assert.equal(typeof detectEnvironment, 'function', 'detectEnvironment must be a function');

  // 2. getCISummary returns boolean isCI and nullable isPR and name properties
  const summary = getCISummary();
  assert.equal(typeof summary.isCI, 'boolean', 'summary.isCI must be boolean');
  assert.ok(typeof summary.isPR === 'boolean' || summary.isPR === null, 'summary.isPR must be boolean or null');
  assert.ok(typeof summary.name === 'string' || summary.name === null, 'summary.name must be string or null');

  // 3. getVendorConstants returns list of supported vendor constants including GITHUB_ACTIONS and GITLAB
  const vendorConstants = getVendorConstants();
  assert.ok(Array.isArray(vendorConstants), 'vendorConstants must be an array');
  assert.ok(vendorConstants.length > 20, 'vendorConstants must declare known vendors');
  assert.ok(vendorConstants.includes('GITHUB_ACTIONS'), 'vendorConstants must include GITHUB_ACTIONS');
  assert.ok(vendorConstants.includes('GITLAB'), 'vendorConstants must include GITLAB');
  assert.ok(vendorConstants.includes('TRAVIS'), 'vendorConstants must include TRAVIS');
  assert.ok(vendorConstants.includes('CIRCLE'), 'vendorConstants must include CIRCLE');

  // 4. isVendorCI returns boolean indicating whether specific vendor flag is active
  const isGithub = isVendorCI('GITHUB_ACTIONS');
  assert.equal(typeof isGithub, 'boolean', 'isVendorCI must return boolean');
  const isUnknown = isVendorCI('NON_EXISTENT_VENDOR');
  assert.equal(isUnknown, false, 'isVendorCI for unknown vendor must return false');

  // 5. detectEnvironment identifies GitHub Actions environment and pull request status
  const githubPrEnv = detectEnvironment({
    GITHUB_ACTIONS: 'true',
    GITHUB_EVENT_NAME: 'pull_request'
  });
  assert.equal(githubPrEnv.isCI, true, 'GitHub Actions should be detected as CI');
  assert.equal(githubPrEnv.name, 'GitHub Actions', 'CI name should be GitHub Actions');
  assert.equal(githubPrEnv.isPR, true, 'GitHub PR event should be detected as PR');
  assert.equal(githubPrEnv.vendorFlags.GITHUB_ACTIONS, true, 'GITHUB_ACTIONS vendor flag must be true');

  // 6. detectEnvironment identifies GitLab CI environment and merge request status
  const gitlabMrEnv = detectEnvironment({
    GITLAB_CI: 'true',
    CI_MERGE_REQUEST_ID: '42'
  });
  assert.equal(gitlabMrEnv.isCI, true, 'GitLab CI should be detected as CI');
  assert.equal(gitlabMrEnv.name, 'GitLab CI', 'CI name should be GitLab CI');
  assert.equal(gitlabMrEnv.isPR, true, 'GitLab MR should be detected as PR');
  assert.equal(gitlabMrEnv.vendorFlags.GITLAB, true, 'GITLAB vendor flag must be true');

  // 7. detectEnvironment identifies Travis CI environment and pull request status
  const travisPrEnv = detectEnvironment({
    TRAVIS: 'true',
    TRAVIS_PULL_REQUEST: '100'
  });
  assert.equal(travisPrEnv.isCI, true, 'Travis CI should be detected as CI');
  assert.equal(travisPrEnv.name, 'Travis CI', 'CI name should be Travis CI');
  assert.equal(travisPrEnv.isPR, true, 'Travis PR should be detected as PR');
  assert.equal(travisPrEnv.vendorFlags.TRAVIS, true, 'TRAVIS vendor flag must be true');

  // 8. detectEnvironment identifies CircleCI environment and pull request status
  const circlePrEnv = detectEnvironment({
    CIRCLECI: 'true',
    CIRCLE_PULL_REQUEST: 'https://example.com/org/repo/pull/1'
  });
  assert.equal(circlePrEnv.isCI, true, 'CircleCI should be detected as CI');
  assert.equal(circlePrEnv.name, 'CircleCI', 'CI name should be CircleCI');
  assert.equal(circlePrEnv.isPR, true, 'CircleCI PR should be detected as PR');
  assert.equal(circlePrEnv.vendorFlags.CIRCLE, true, 'CIRCLE vendor flag must be true');

  // 9. detectEnvironment respects CI=false environment override to disable isCI
  const disabledEnv = detectEnvironment({
    CI: 'false',
    GITHUB_ACTIONS: 'true'
  });
  assert.equal(disabledEnv.isCI, false, 'CI=false must override CI detection to false');

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

runContractTests().catch((err) => {
  console.error('Contract test failure:', err);
  process.exit(1);
});

Origin Seeder

anonymous