CodeSampleX

Sample

browserslist 4.28.9: parse

Verified sample for npm browserslist 4.28.9: parse. The contract ran on node 22 · linux debian/x64 · docker and passed: browserslist.parse decomposes query…

sha256:6bf8f6d8da671f82714744b26defbcad1bdf139d312bdd29ad26ed7e183b7f83

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

Case

HOW
Goal
verify pkg:npm/browserslist@4.28.9
Packages
Symbols
  • browserslist.parse
Environment
node 22.23.2
Created
2026-09-05T03:13:54Z

Contract

  1. browserslist.parse decomposes query strings into structured descriptor objects with query type and browser target
  2. browserslist.parse supports regional popularity queries with sign, popularity percentage, and place code
  3. browserslist.parse parses an array of queries and comma-separated query strings identically
  4. browserslist.parse identifies boolean compositions with compose and query negation with not flag
  5. browserslist.parse on empty string or empty array returns an empty descriptor list
  6. browserslist.parse with undefined defaults to parsing queries defined in browserslist.defaults
  7. browserslist.parse marks unclassified or unrecognized query syntax as type unknown rather than throwing
  8. browserslist.parse throws BrowserslistError when passed non-array and non-string argument types

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 pkg:npm/browserslist@4.28.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/browserslist@4.28.9
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:3e78590ccbf300318eb30c636e9e24977037fc50bd474d88db8b81d1f8329ac2","constraints":{"executionContext":"node"},"contract":["browserslist.parse decomposes query strings into structured descriptor objects with query type and browser target","browserslist.parse supports regional popularity queries with sign, popularity percentage, and place code","browserslist.parse parses an array of queries and comma-separated query strings identically","browserslist.parse identifies boolean compositions with compose and query negation with not flag","browserslist.parse on empty string or empty array returns an empty descriptor list","browserslist.parse with undefined defaults to parsing queries defined in browserslist.defaults","browserslist.parse marks unclassified or unrecognized query syntax as type unknown rather than throwing","browserslist.parse throws BrowserslistError when passed non-array and non-string argument types"],"goal":"verify pkg:npm/browserslist@4.28.9","kind":"HOW","packages":["pkg:npm/browserslist@4.28.9"],"schemaVersion":1,"symbols":["browserslist.parse"]},"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/browserslist@4.28.9"],"schemaVersion":1,"subject":"pkg:npm/browserslist@4.28.9","symbols":["browserslist.parse"],"verifierAdapter":"node-typescript@1"}
index.js
const browserslist = require('browserslist');

/**
 * Parses query strings or query arrays into structured AST descriptor objects.
 *
 * @param {string | string[]} queries - Browserslist query or array of queries.
 * @param {object} [opts] - Optional configuration options.
 * @returns {Array<object>} Array of parsed query descriptors.
 */
function parseQueries(queries, opts) {
  return browserslist.parse(queries, opts);
}

module.exports = {
  browserslist,
  parseQueries,
};
package-lock.json
{
  "name": "sample-browserslist-parse",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-browserslist-parse",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "browserslist": "4.28.9"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.21",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz",
      "integrity": "sha512-uh8vpY/1/YyFkunIDFH/12p7/7VdPKA1hejMVEbdkEaWnUz0Hesvx5EbiU6XxjyHZIOju+ZMbQJkRh+es3/spQ==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.28.9",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.9.tgz",
      "integrity": "sha512-EWazOblFYUvlGZcfGhPUPmYh3nikUxBVb+y9MJun5f3hBi812X+8MSQTujLBtgK3cf51fJWbWfOjyeO954d+Eg==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "baseline-browser-mapping": "^2.11.20",
        "caniuse-lite": "^1.0.30001810",
        "electron-to-chromium": "^1.5.420",
        "node-releases": "^2.0.54",
        "update-browserslist-db": "^1.3.2"
      },
      "bin": {
        "browserslist": "cli.js"
      },
      "engines": {
        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001810",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",
      "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0"
    },
    "node_modules/electron-to-chromium": {
      "version": "1.5.422",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.422.tgz",
      "integrity": "sha512-UvA/32XqrLDdZSn7Jllo1AYNcWji/G0d5M0GTViE7KoGBiMunw3a34Sb2KO4ZZyrSEhqsxFoVhWWJshdyfKqJA==",
      "license": "ISC"
    },
    "node_modules/escalade": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
      "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.54",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz",
      "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    },
    "node_modules/update-browserslist-db": {
      "version": "1.3.2",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz",
      "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "escalade": "^3.2.0",
        "picocolors": "^1.1.1"
      },
      "bin": {
        "update-browserslist-db": "cli.js"
      },
      "peerDependencies": {
        "browserslist": ">= 4.21.0"
      }
    }
  }
}
package.json
{
  "name": "sample-browserslist-parse",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room sample verifying browserslist.parse AST descriptor resolution",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "browserslist": "4.28.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/browserslist@4.28.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/browserslist@4.28.9"
  ],
  "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 browserslist from 'browserslist';
import { parseQueries } from '../index.js';

// 1. browserslist.parse decomposes query strings into structured descriptor objects with query type and browser target
const lastChrome = browserslist.parse('last 2 chrome versions');
assert.deepStrictEqual(lastChrome, [
  {
    query: 'last 2 chrome versions',
    type: 'last_browser_versions',
    versions: '2',
    browser: 'chrome',
    compose: 'or'
  }
]);
assert.deepStrictEqual(parseQueries('last 2 chrome versions'), lastChrome);

// 2. browserslist.parse supports regional popularity queries with sign, popularity percentage, and place code
const popularityUS = browserslist.parse('> 1% in US');
assert.deepStrictEqual(popularityUS, [
  {
    query: '> 1% in US',
    type: 'popularity_in_place',
    sign: '>',
    popularity: '1',
    place: 'US',
    compose: 'or'
  }
]);

// 3. browserslist.parse parses an array of queries and comma-separated query strings identically
const fromArray = browserslist.parse(['chrome > 100', 'ie 11']);
const fromString = browserslist.parse('chrome > 100, ie 11');
assert.deepStrictEqual(fromString, [
  {
    query: 'chrome > 100',
    type: 'browser_ray',
    browser: 'chrome',
    sign: '>',
    version: '100',
    compose: 'or'
  },
  {
    query: 'ie 11',
    type: 'browser_version',
    browser: 'ie',
    version: '11',
    compose: 'or'
  }
]);
assert.deepStrictEqual(fromArray, fromString);

// 4. browserslist.parse identifies boolean compositions with compose and query negation with not flag
const composed = browserslist.parse('dead and not chrome > 100');
assert.deepStrictEqual(composed, [
  { query: 'dead', type: 'dead', compose: 'or' },
  {
    query: 'not chrome > 100',
    not: true,
    type: 'browser_ray',
    browser: 'chrome',
    sign: '>',
    version: '100',
    compose: 'and'
  }
]);

// 5. browserslist.parse on empty string or empty array returns an empty descriptor list
assert.deepStrictEqual(browserslist.parse(''), []);
assert.deepStrictEqual(browserslist.parse([]), []);

// 6. browserslist.parse with undefined defaults to parsing queries defined in browserslist.defaults
const defaultDescriptors = browserslist.parse();
assert.ok(Array.isArray(defaultDescriptors) && defaultDescriptors.length === browserslist.defaults.length);
assert.strictEqual(defaultDescriptors[0].query, browserslist.defaults[0]);

// 7. browserslist.parse marks unclassified or unrecognized query syntax as type unknown rather than throwing
const unknownResult = browserslist.parse('unknown syntax @#$');
assert.deepStrictEqual(unknownResult, [
  {
    query: 'unknown syntax @#$',
    type: 'unknown',
    compose: 'or'
  }
]);

// 8. browserslist.parse throws BrowserslistError when passed non-array and non-string argument types
assert.throws(
  () => browserslist.parse(123),
  (err) => err.name === 'BrowserslistError' && err.message.includes('Browser queries must be an array or string. Got number.')
);

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

Origin Seeder

anonymous