CodeSampleX

Sample

compare-version 0.1.2: compareVersion

Verified sample for npm compare-version 0.1.2: compareVersion. The contract ran on node 22 · linux alpine/x64 · docker and passed.

sha256:9285b52384dd5381b558f40aea27f544ffc21c67ee1cb4c9c4ff5a16154c2eb9

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

Case

HOW
Goal
verify compareVersion in pkg:npm/compare-version@0.1.2
Packages
Symbols
  • compareVersion
Created
2026-08-26T11:04:17Z

Contract

  1. compareVersion returns 1 when the first version string is greater than the second
  2. compareVersion returns -1 when the first version string is less than the second
  3. compareVersion returns 0 when version strings are equal
  4. compareVersion returns false when either argument is not a string

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 compareVersion in pkg:npm/compare-version@0.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/compare-version@0.1.2
Demonstrate these symbols/APIs:
  - compareVersion

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:8c9184cfdbbd4ad7da5ce6b1f960e0739e7c672765aeac5ad5df67c143c494ae","contract":["compareVersion returns 1 when the first version string is greater than the second","compareVersion returns -1 when the first version string is less than the second","compareVersion returns 0 when version strings are equal","compareVersion returns false when either argument is not a string"],"goal":"verify compareVersion in pkg:npm/compare-version@0.1.2","kind":"HOW","packages":["pkg:npm/compare-version@0.1.2"],"schemaVersion":1,"symbols":["compareVersion"]},"contractCommand":["node","test/contract.js"],"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/compare-version@0.1.2"],"schemaVersion":1,"subject":"pkg:npm/compare-version@0.1.2","symbols":["compareVersion"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-compare-version",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-compare-version",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "compare-version": "0.1.2"
      }
    },
    "node_modules/compare-version": {
      "version": "0.1.2",
      "resolved": "https://registry.npmjs.org/compare-version/-/compare-version-0.1.2.tgz",
      "integrity": "sha512-pJDh5/4wrEnXX/VWRZvruAGHkzKdr46z11OlTPN+VrATlWWhSKewNCJ1futCO5C7eJB3nPMFZA1LeYtcFboZ2A==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-compare-version",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for compare-version",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "compare-version": "0.1.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify compareVersion in pkg:npm/compare-version@0.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/compare-version@0.1.2"
  ],
  "symbols": [
    "compareVersion"
  ]
}
src/index.js
const compareVersion = require('compare-version');

function checkCompareVersion(a, b) {
  return compareVersion(a, b);
}

module.exports = {
  compareVersion,
  checkCompareVersion
};
test/contract.js
const assert = require('node:assert');
const compareVersion = require('compare-version');
const { checkCompareVersion } = require('../src/index.js');

// 1. compareVersion returns 1 when the first version string is greater than the second
assert.strictEqual(compareVersion('1.11.0', '1.10.0'), 1, '1.11.0 > 1.10.0 should return 1');
assert.strictEqual(compareVersion('2.0.0', '1.9.9'), 1, '2.0.0 > 1.9.9 should return 1');
assert.strictEqual(compareVersion('1.0.1', '1.0'), 1, '1.0.1 > 1.0 should return 1');
assert.strictEqual(checkCompareVersion('1.1.0', '1.0.9'), 1, 'checkCompareVersion 1.1.0 > 1.0.9 should return 1');

// 2. compareVersion returns -1 when the first version string is less than the second
assert.strictEqual(compareVersion('1.10.0', '1.11.0'), -1, '1.10.0 < 1.11.0 should return -1');
assert.strictEqual(compareVersion('1.9.9', '2.0.0'), -1, '1.9.9 < 2.0.0 should return -1');
assert.strictEqual(compareVersion('1.0', '1.0.1'), -1, '1.0 < 1.0.1 should return -1');
assert.strictEqual(checkCompareVersion('1.0.9', '1.1.0'), -1, 'checkCompareVersion 1.0.9 < 1.1.0 should return -1');

// 3. compareVersion returns 0 when version strings are equal
assert.strictEqual(compareVersion('1.0.0', '1.0.0'), 0, '1.0.0 === 1.0.0 should return 0');
assert.strictEqual(compareVersion('0.1.2', '0.1.2'), 0, '0.1.2 === 0.1.2 should return 0');
assert.strictEqual(compareVersion('1.0.0', '1.0'), 0, '1.0.0 and 1.0 are considered equal (0)');
assert.strictEqual(checkCompareVersion('2.1.0', '2.1.0'), 0, 'checkCompareVersion 2.1.0 === 2.1.0 should return 0');

// 4. compareVersion returns false when either argument is not a string
assert.strictEqual(compareVersion(1, '1.0.0'), false, 'non-string first argument should return false');
assert.strictEqual(compareVersion('1.0.0', 1), false, 'non-string second argument should return false');
assert.strictEqual(compareVersion(null, '1.0.0'), false, 'null argument should return false');
assert.strictEqual(compareVersion('1.0.0', undefined), false, 'undefined argument should return false');
assert.strictEqual(compareVersion({}, {}), false, 'object arguments should return false');
assert.strictEqual(checkCompareVersion(null, null), false, 'checkCompareVersion non-string arguments should return false');

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

Origin Seeder

anonymous