CodeSampleX

Sample

node-releases 2.0.51: slice

Verified sample for npm node-releases 2.0.51: slice. The contract ran on node 22 · linux debian/x64 · docker and passed: slice extracts a subset of release…

sha256:c2dc9a59d353c85e42439d5f1f1ea410e85a59fc2681e56f77ec8cdfe2fd8b6c

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 node-releases.slice in pkg:npm/node-releases@2.0.51
Packages
Symbols
  • node-releases.slice
Environment
node 22.23.2
Created
2026-09-05T22:53:55Z

Contract

  1. slice extracts a subset of release records without mutating the source envs array
  2. slice with positive start and end extracts the exact range of release records
  3. slice with negative start extracts the most recent N releases from the end of the array
  4. slice with start index greater than or equal to array length returns an empty array
  5. slice without arguments creates a shallow copy of all release records with identical elements
  6. slice with negative start exceeding array length normalizes to index zero and returns elements from start

Files

  • PROMPT.md
  • csx.json
  • 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 node-releases.slice in pkg:npm/node-releases@2.0.51
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-releases@2.0.51
Demonstrate these symbols/APIs:
  - node-releases.slice

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:fd76e71f29f4c34221d40ff3c66978f452de3acba4352c331f0aac3d4e27d391","contract":["slice extracts a subset of release records without mutating the source envs array","slice with positive start and end extracts the exact range of release records","slice with negative start extracts the most recent N releases from the end of the array","slice with start index greater than or equal to array length returns an empty array","slice without arguments creates a shallow copy of all release records with identical elements","slice with negative start exceeding array length normalizes to index zero and returns elements from start"],"goal":"verify node-releases.slice in pkg:npm/node-releases@2.0.51","kind":"HOW","packages":["pkg:npm/node-releases@2.0.51"],"schemaVersion":1,"symbols":["node-releases.slice"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/node-releases@2.0.51"],"schemaVersion":1,"subject":"pkg:npm/node-releases@2.0.51","symbols":["node-releases.slice"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-releases-slice",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-releases-slice",
      "version": "1.0.0",
      "dependencies": {
        "node-releases": "2.0.51"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.51",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.51.tgz",
      "integrity": "sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    }
  }
}
package.json
{
  "name": "sample-node-releases-slice",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "node-releases": "2.0.51"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify node-releases.slice in pkg:npm/node-releases@2.0.51",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-releases@2.0.51"
  ],
  "symbols": [
    "node-releases.slice"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import envs from 'node-releases/data/processed/envs.json' with { type: 'json' };

// Ensure source data is valid array
assert.ok(Array.isArray(envs), 'envs must be an array');
const initialLength = envs.length;
assert.ok(initialLength > 0, 'envs must contain records');

// 1. slice extracts a subset of release records without mutating the source envs array
const firstTen = envs.slice(0, 10);
assert.equal(firstTen.length, 10, 'Sliced length should be 10');
assert.equal(envs.length, initialLength, 'Original envs length must remain unchanged');
assert.deepEqual(firstTen[0], envs[0], 'First element of slice must match original');
assert.deepEqual(firstTen[9], envs[9], 'Tenth element of slice must match original');

// 2. slice with positive start and end extracts the exact range of release records
const range = envs.slice(5, 15);
assert.equal(range.length, 10, 'Range slice length should be 10');
assert.deepEqual(range[0], envs[5], 'First element of range must equal envs[5]');
assert.deepEqual(range[9], envs[14], 'Last element of range must equal envs[14]');

// 3. slice with negative start extracts the most recent N releases from the end of the array
const recentFive = envs.slice(-5);
assert.equal(recentFive.length, 5, 'Negative start slice should have 5 items');
assert.deepEqual(recentFive[0], envs[initialLength - 5], 'First element of negative slice must match corresponding tail index');
assert.deepEqual(recentFive[4], envs[initialLength - 1], 'Last element of negative slice must match last release');

// 4. slice with start index greater than or equal to array length returns an empty array
const emptySlice = envs.slice(initialLength + 10);
assert.ok(Array.isArray(emptySlice), 'Empty slice must be an array');
assert.equal(emptySlice.length, 0, 'Empty slice length must be 0');

// 5. slice without arguments creates a shallow copy of all release records with identical elements
const fullCopy = envs.slice();
assert.notEqual(fullCopy, envs, 'Slice shallow copy must have different reference');
assert.equal(fullCopy.length, initialLength, 'Shallow copy must have same length as source');
assert.deepEqual(fullCopy[0], envs[0], 'First element of copy must match source');
assert.deepEqual(fullCopy[initialLength - 1], envs[initialLength - 1], 'Last element of copy must match source');

// 6. slice with negative start exceeding array length normalizes to index zero and returns elements from start
const clampedSlice = envs.slice(-1000, 3);
assert.equal(clampedSlice.length, 3, 'Slice with large negative start should start at index 0');
assert.deepEqual(clampedSlice[0], envs[0], 'Element at index 0 should match source[0]');

// CommonJS compatibility check
const require = createRequire(import.meta.url);
const cjsEnvs = require('node-releases/data/processed/envs.json');
assert.ok(Array.isArray(cjsEnvs), 'CJS envs must be an array');
const cjsSlice = cjsEnvs.slice(0, 5);
assert.equal(cjsSlice.length, 5, 'CJS slice should return 5 elements');
assert.deepEqual(cjsSlice[0], cjsEnvs[0], 'CJS slice first element must match');

Origin Seeder

anonymous