CodeSampleX

Sample

tinypool 1.1.1: Tinypool

Verified sample for npm tinypool 1.1.1: Tinypool. The contract ran on node 22 · linux debian/x64 · docker and passed: Tinypool constructor initializes worker…

sha256:05501ac79e07765a19d967db34a974c7f20758cdc2ad42fbe9376d05118a345f

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-02

Case

HOW
Goal
verify Tinypool in pkg:npm/tinypool@1.1.1
Packages
Symbols
  • Tinypool
Environment
node 22.23.2
Created
2026-09-02T13:07:21Z

Contract

  1. Tinypool constructor initializes worker pool with specified thread limits and worker script
  2. run executes default worker handler and returns processed payload
  3. run with name option executes specific named export function in worker script
  4. run with AbortSignal rejects with AbortError when cancellation is triggered
  5. recycleWorkers refreshes worker threads without interrupting subsequent task processing
  6. completed tracks total finished tasks across worker pool execution
  7. destroy terminates active worker threads and shuts down pool

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • src/worker.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 Tinypool in pkg:npm/tinypool@1.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/tinypool@1.1.1
Demonstrate these symbols/APIs:
  - Tinypool

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:e9e58d0ab1f2448f8eb2fedd9508d448f8465155ed7ab5349a66c916e8b537d3","contract":["Tinypool constructor initializes worker pool with specified thread limits and worker script","run executes default worker handler and returns processed payload","run with name option executes specific named export function in worker script","run with AbortSignal rejects with AbortError when cancellation is triggered","recycleWorkers refreshes worker threads without interrupting subsequent task processing","completed tracks total finished tasks across worker pool execution","destroy terminates active worker threads and shuts down pool"],"goal":"verify Tinypool in pkg:npm/tinypool@1.1.1","kind":"HOW","packages":["pkg:npm/tinypool@1.1.1"],"schemaVersion":1,"symbols":["Tinypool"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/tinypool@1.1.1"],"schemaVersion":1,"subject":"pkg:npm/tinypool@1.1.1","symbols":["Tinypool"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-tinypool",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-tinypool",
      "version": "1.0.0",
      "dependencies": {
        "tinypool": "1.1.1"
      }
    },
    "node_modules/tinypool": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz",
      "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==",
      "license": "MIT",
      "engines": {
        "node": "^18.0.0 || >=20.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-tinypool",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "description": "Clean-room verification of tinypool worker pool operations",
  "main": "src/index.js",
  "dependencies": {
    "tinypool": "1.1.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify Tinypool in pkg:npm/tinypool@1.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/tinypool@1.1.1"
  ],
  "symbols": [
    "Tinypool"
  ]
}
src/index.js
import { Tinypool } from 'tinypool';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

/**
 * Creates and initializes a Tinypool worker pool instance.
 * @param {object} [options] - Options passed to Tinypool constructor
 * @returns {Tinypool} Initialized worker pool
 */
export function createWorkerPool(options = {}) {
  const defaultWorker = path.resolve(__dirname, 'worker.js');
  return new Tinypool({
    filename: defaultWorker,
    minThreads: 1,
    maxThreads: 2,
    ...options
  });
}

/**
 * Executes default task handler on the worker pool.
 * @param {Tinypool} pool - Worker pool instance
 * @param {any} payload - Task payload
 * @returns {Promise<any>}
 */
export async function runTask(pool, payload) {
  return pool.run(payload);
}

/**
 * Executes a named export function in the worker.
 * @param {Tinypool} pool - Worker pool instance
 * @param {string} name - Export name
 * @param {any} payload - Task payload
 * @returns {Promise<any>}
 */
export async function runNamedTask(pool, name, payload) {
  return pool.run(payload, { name });
}

/**
 * Executes a cancellable task on the worker pool.
 * @param {Tinypool} pool - Worker pool instance
 * @param {string} name - Export name
 * @param {any} payload - Task payload
 * @param {AbortSignal} signal - AbortSignal instance
 * @returns {Promise<any>}
 */
export async function runCancellableTask(pool, name, payload, signal) {
  return pool.run(payload, { name, signal });
}

export { Tinypool };
src/worker.js
export function sum({ numbers }) {
  if (!Array.isArray(numbers)) {
    throw new TypeError('numbers must be an array');
  }
  return numbers.reduce((acc, val) => acc + val, 0);
}

export function formatUpper({ text }) {
  if (typeof text !== 'string') {
    throw new TypeError('text must be a string');
  }
  return text.toUpperCase();
}

export async function delayedTask({ value, delayMs = 200 }) {
  await new Promise((resolve) => setTimeout(resolve, delayMs));
  return value;
}

export default function defaultHandler(task) {
  return { handled: true, payload: task };
}
test/contract.mjs
import assert from 'node:assert';
import {
  Tinypool,
  createWorkerPool,
  runTask,
  runNamedTask,
  runCancellableTask
} from '../src/index.js';

// 1. Tinypool constructor initializes worker pool with specified thread limits and worker script
const pool = createWorkerPool();
assert.ok(pool instanceof Tinypool, 'pool should be an instance of Tinypool');
assert.strictEqual(typeof pool.run, 'function', 'pool should have a run method');

try {
  // 2. run executes default worker handler and returns processed payload
  const defaultResult = await runTask(pool, { message: 'hello tinypool' });
  assert.deepStrictEqual(
    defaultResult,
    { handled: true, payload: { message: 'hello tinypool' } },
    'default task handler should return processed payload'
  );

  // 3. run with name option executes specific named export function in worker script
  const sumResult = await runNamedTask(pool, 'sum', { numbers: [10, 20, 30] });
  assert.strictEqual(sumResult, 60, 'named task sum should return 60');

  const upperResult = await runNamedTask(pool, 'formatUpper', { text: 'tinypool' });
  assert.strictEqual(upperResult, 'TINYPOOL', 'named task formatUpper should return TINYPOOL');

  // 4. run with AbortSignal rejects with AbortError when cancellation is triggered
  const controller = new AbortController();
  const cancelPromise = runCancellableTask(
    pool,
    'delayedTask',
    { value: 'aborted-result', delayMs: 400 },
    controller.signal
  );
  setTimeout(() => controller.abort(), 30);

  await assert.rejects(
    async () => {
      await cancelPromise;
    },
    (err) => {
      return err.name === 'AbortError' || (err.message && err.message.includes('aborted'));
    },
    'Task should reject with AbortError when AbortSignal is aborted'
  );

  // 5. recycleWorkers refreshes worker threads without interrupting subsequent task processing
  await pool.recycleWorkers();
  const postRecycleResult = await runNamedTask(pool, 'formatUpper', { text: 'after-recycle' });
  assert.strictEqual(
    postRecycleResult,
    'AFTER-RECYCLE',
    'worker pool should process tasks normally after recycling'
  );

  // 6. completed tracks total finished tasks across worker pool execution
  assert.ok(
    pool.completed >= 4,
    'pool.completed should track total completed tasks'
  );

  // 7. destroy terminates active worker threads and shuts down pool
  assert.ok(pool.threads.length >= 1, 'pool should have active worker threads');
  await pool.destroy();
  assert.strictEqual(pool.threads.length, 0, 'pool threads should be empty after destroy');

  console.log('Contract tests passed successfully.');
} finally {
  if (pool.threads.length > 0) {
    await pool.destroy();
  }
}

Origin Seeder

anonymous