CodeSampleX

Ejemplo

range-parser 1.3.0

Muestra verificada para npm range-parser 1.3.0. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: parseRange(size, str) parses single…

sha256:9c2b35d0b230f67252f5da82f536bf8f472e2b46a0c7f0b5d41f69701e26b7e2

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20

Caso

HOW
Objetivo
verify pkg:npm/range-parser@1.3.0
Paquetes
Creado
2026-08-20T13:59:10Z

Contrato

  1. parseRange(size, str) parses single byte range and sets type property to 'bytes'
  2. parseRange(size, str) parses multiple non-overlapping ranges
  3. parseRange(size, str) parses suffix range relative to total size
  4. parseRange(size, str) parses open-ended range to end of size
  5. parseRange(size, str) caps range ending at total size minus one
  6. parseRange(size, str, { combine: true }) combines overlapping and adjacent ranges
  7. parseRange(size, str) returns -1 for unsatisfiable ranges
  8. parseRange(size, str) returns -2 for invalid or malformed range strings

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/range-parser@1.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/range-parser@1.3.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:327c2b138eac6d2433694491a6241a56ec89684c2cd2088860f6bedd7a1a8fb8","contract":["parseRange(size, str) parses single byte range and sets type property to 'bytes'","parseRange(size, str) parses multiple non-overlapping ranges","parseRange(size, str) parses suffix range relative to total size","parseRange(size, str) parses open-ended range to end of size","parseRange(size, str) caps range ending at total size minus one","parseRange(size, str, { combine: true }) combines overlapping and adjacent ranges","parseRange(size, str) returns -1 for unsatisfiable ranges","parseRange(size, str) returns -2 for invalid or malformed range strings"],"goal":"verify pkg:npm/range-parser@1.3.0","kind":"HOW","packages":["pkg:npm/range-parser@1.3.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/range-parser@1.3.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-range-parser",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-range-parser",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "range-parser": "1.3.0"
      }
    },
    "node_modules/range-parser": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz",
      "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.6"
      }
    }
  }
}
package.json
{
  "name": "sample-range-parser",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "range-parser": "1.3.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/range-parser@1.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/range-parser@1.3.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const parseRange = require('range-parser');

// 1. Function export verification
assert.equal(typeof parseRange, 'function', 'parseRange must be a function');

// 2. parseRange(size, str) parses single byte range and sets type property to 'bytes'
const single = parseRange(1000, 'bytes=0-499');
assert.equal(single.type, 'bytes');
assert.equal(single.length, 1);
assert.deepEqual(single[0], { start: 0, end: 499 });

// 3. parseRange(size, str) parses multiple non-overlapping ranges
const multiple = parseRange(1000, 'bytes=0-100, 200-300');
assert.equal(multiple.type, 'bytes');
assert.equal(multiple.length, 2);
assert.deepEqual(multiple[0], { start: 0, end: 100 });
assert.deepEqual(multiple[1], { start: 200, end: 300 });

// 4. parseRange(size, str) parses suffix range relative to total size
const suffix = parseRange(1000, 'bytes=-100');
assert.equal(suffix.type, 'bytes');
assert.equal(suffix.length, 1);
assert.deepEqual(suffix[0], { start: 900, end: 999 });

// 5. parseRange(size, str) parses open-ended range to end of size
const openEnded = parseRange(1000, 'bytes=500-');
assert.equal(openEnded.type, 'bytes');
assert.equal(openEnded.length, 1);
assert.deepEqual(openEnded[0], { start: 500, end: 999 });

// 6. parseRange(size, str) caps range ending at total size minus one
const capped = parseRange(1000, 'bytes=0-2000');
assert.equal(capped.type, 'bytes');
assert.equal(capped.length, 1);
assert.deepEqual(capped[0], { start: 0, end: 999 });

// 7. parseRange(size, str, { combine: true }) combines overlapping and adjacent ranges
const combined = parseRange(1000, 'bytes=0-100, 50-150', { combine: true });
assert.equal(combined.type, 'bytes');
assert.equal(combined.length, 1);
assert.deepEqual(combined[0], { start: 0, end: 150 });

// 8. parseRange(size, str) returns -1 for unsatisfiable ranges
assert.equal(parseRange(1000, 'bytes=1000-2000'), -1);
assert.equal(parseRange(1000, 'bytes=500-400'), -1);

// 9. parseRange(size, str) returns -2 for invalid or malformed range strings
assert.equal(parseRange(1000, 'invalid'), -2);
assert.equal(parseRange(1000, 'bytes='), -2);
assert.equal(parseRange(1000, 'bytes=-'), -2);
assert.equal(parseRange(1000, 'bytes=abc-def'), -2);

Seeder de origen

anónimo