CodeSampleX

Sample

jake 10.9.4: verify task execution

Verified sample for npm jake 10.9.4: verify task execution. The contract ran on node 22 · linux alpine/x64 · docker and passed.

sha256:4cf81ae7c17e8d943a5af1709511482bf9cac3db21d96c566beae3a4725a0298

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

Case

HOW
Goal
verify pkg:npm/jake@10.9.4 task execution
Packages
Symbols
  • jake.Task
  • jake.task
Created
2026-08-28T05:48:16Z

Contract

  1. jake exports Task class and task definition function
  2. task creates a Task instance registered in global and namespace registry
  3. runTask invokes a task and resolves with its return value
  4. runTask executes prerequisites in order before running the dependent task
  5. runTask passes positional arguments to task action handlers
  6. runTask handles asynchronous promise-returning task actions
  7. executeTask forces re-execution of a previously completed task
  8. namespace groups tasks under a colon-separated namespace prefix

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.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 pkg:npm/jake@10.9.4 task execution
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/jake@10.9.4
Demonstrate these symbols/APIs:
  - jake.Task
  - jake.task

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:0c99e8e37e1345d61978e6743fcfc9d9b2b317c783162df237c95c685ccc5f7d","contract":["jake exports Task class and task definition function","task creates a Task instance registered in global and namespace registry","runTask invokes a task and resolves with its return value","runTask executes prerequisites in order before running the dependent task","runTask passes positional arguments to task action handlers","runTask handles asynchronous promise-returning task actions","executeTask forces re-execution of a previously completed task","namespace groups tasks under a colon-separated namespace prefix"],"goal":"verify pkg:npm/jake@10.9.4 task execution","kind":"HOW","packages":["pkg:npm/jake@10.9.4"],"schemaVersion":1,"symbols":["jake.Task","jake.task"]},"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/jake@10.9.4"],"schemaVersion":1,"subject":"pkg:npm/jake@10.9.4","symbols":["jake.Task","jake.task"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-jake",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-jake",
      "version": "1.0.0",
      "dependencies": {
        "jake": "10.9.4"
      }
    },
    "node_modules/async": {
      "version": "3.2.6",
      "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
      "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
      "license": "MIT"
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "2.1.4",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
      "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0"
      }
    },
    "node_modules/filelist": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz",
      "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==",
      "license": "Apache-2.0",
      "dependencies": {
        "minimatch": "^5.0.1"
      }
    },
    "node_modules/jake": {
      "version": "10.9.4",
      "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz",
      "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==",
      "license": "Apache-2.0",
      "dependencies": {
        "async": "^3.2.6",
        "filelist": "^1.0.4",
        "picocolors": "^1.1.1"
      },
      "bin": {
        "jake": "bin/cli.js"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/minimatch": {
      "version": "5.1.9",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",
      "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^2.0.1"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "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"
    }
  }
}
package.json
{
  "name": "sample-jake",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of jake task execution",
  "main": "src/index.js",
  "dependencies": {
    "jake": "10.9.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/jake@10.9.4 task execution",
  "kind": "HOW",
  "packages": [
    "pkg:npm/jake@10.9.4"
  ],
  "symbols": [
    "jake.Task",
    "jake.task"
  ]
}
src/index.js
const jakeModule = require('jake');

// Ensure quiet mode for programmatic execution
if (jakeModule && jakeModule.program && jakeModule.program.opts) {
  jakeModule.program.opts.quiet = true;
}

/**
 * Define a task in Jake.
 * @param {string} name - Task name.
 * @param {string[]|Function} [prereqs] - Prerequisite task names or action.
 * @param {Function} [action] - Action callback to execute.
 * @param {object} [opts] - Additional options.
 * @returns {object} The created Task instance.
 */
function defineTask(name, prereqs, action, opts) {
  return jakeModule.task(name, prereqs, action, opts);
}

/**
 * Retrieve an existing task by name.
 * @param {string} name - Task name or namespaced name (e.g. 'ns:task').
 * @returns {object|undefined} The task instance if found.
 */
function getTask(name) {
  return jakeModule.Task[name];
}

/**
 * Run a task and return a promise resolving with its result.
 * @param {object|string} taskOrName - Task instance or task name.
 * @param {...any} args - Arguments to pass to the task action.
 * @returns {Promise<any>}
 */
function runTask(taskOrName, ...args) {
  const taskInstance = typeof taskOrName === 'string' ? getTask(taskOrName) : taskOrName;
  if (!taskInstance) {
    return Promise.reject(new Error(`Task not found: ${taskOrName}`));
  }
  return new Promise((resolve, reject) => {
    taskInstance.once('complete', (val) => resolve(val));
    taskInstance.once('error', (err) => reject(err));
    taskInstance.invoke(...args);
  });
}

/**
 * Execute a task directly (forcing re-run) and return a promise resolving with its result.
 * @param {object|string} taskOrName - Task instance or task name.
 * @param {...any} args - Arguments to pass to the task action.
 * @returns {Promise<any>}
 */
function executeTask(taskOrName, ...args) {
  const taskInstance = typeof taskOrName === 'string' ? getTask(taskOrName) : taskOrName;
  if (!taskInstance) {
    return Promise.reject(new Error(`Task not found: ${taskOrName}`));
  }
  return new Promise((resolve, reject) => {
    taskInstance.once('complete', (val) => resolve(val));
    taskInstance.once('error', (err) => reject(err));
    taskInstance.execute(...args);
  });
}

/**
 * Define a namespace containing tasks.
 * @param {string} name - Namespace name.
 * @param {Function} closure - Function inside which tasks are declared.
 * @returns {object} The namespace object.
 */
function defineNamespace(name, closure) {
  return jakeModule.namespace(name, closure);
}

module.exports = {
  jake: jakeModule,
  Task: jakeModule.Task,
  task: jakeModule.task,
  defineTask,
  getTask,
  runTask,
  executeTask,
  defineNamespace
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  jake,
  Task,
  task,
  defineTask,
  getTask,
  runTask,
  executeTask,
  defineNamespace
} = require('../src/index.js');

// 1. jake exports Task class and task definition function
assert.strictEqual(typeof Task, 'function', 'Task should be exported as a class / constructor');
assert.strictEqual(typeof task, 'function', 'task should be exported as a function');
assert.strictEqual(typeof defineTask, 'function', 'defineTask should be a helper function');
assert.strictEqual(typeof runTask, 'function', 'runTask should be a helper function');
assert.strictEqual(typeof executeTask, 'function', 'executeTask should be a helper function');

// 2. task creates a Task instance registered in global and namespace registry
const sampleTask = defineTask('contract-sample-task', () => 'sample-output');
assert.ok(sampleTask instanceof Task, 'defineTask should return an instance of Task');
assert.strictEqual(sampleTask.name, 'contract-sample-task');
assert.strictEqual(getTask('contract-sample-task'), sampleTask);
assert.strictEqual(jake.Task['contract-sample-task'], sampleTask);

// 3. runTask invokes a task and resolves with its return value
const basicResult = await runTask(sampleTask);
assert.strictEqual(basicResult, 'sample-output');
assert.strictEqual(sampleTask.value, 'sample-output');
assert.strictEqual(sampleTask.taskStatus, 'done');

// 4. runTask executes prerequisites in order before running the dependent task
const sequence = [];
defineTask('prereq-alpha', () => {
  sequence.push('alpha');
});
defineTask('prereq-beta', ['prereq-alpha'], () => {
  sequence.push('beta');
});
defineTask('prereq-main', ['prereq-beta'], () => {
  sequence.push('main');
  return 'chain-complete';
});

const chainResult = await runTask('prereq-main');
assert.strictEqual(chainResult, 'chain-complete');
assert.deepStrictEqual(sequence, ['alpha', 'beta', 'main']);

// 5. runTask passes positional arguments to task action handlers
let capturedArgs = [];
defineTask('args-task', (first, second, multiplier) => {
  capturedArgs = [first, second, multiplier];
  return (first + second) * multiplier;
});

const computation = await runTask('args-task', 10, 5, 3);
assert.strictEqual(computation, 45);
assert.deepStrictEqual(capturedArgs, [10, 5, 3]);

// 6. runTask handles asynchronous promise-returning task actions
defineTask('async-delay-task', async () => {
  return new Promise((resolve) => {
    setTimeout(() => resolve({ status: 'ready', code: 200 }), 15);
  });
});

const asyncResult = await runTask('async-delay-task');
assert.deepStrictEqual(asyncResult, { status: 'ready', code: 200 });

// 7. executeTask forces re-execution of a previously completed task
let executionCount = 0;
defineTask('rerun-task', () => {
  executionCount++;
  return executionCount;
});

const firstRun = await runTask('rerun-task');
assert.strictEqual(firstRun, 1);
assert.strictEqual(executionCount, 1);

const secondRun = await executeTask('rerun-task');
assert.strictEqual(secondRun, 2);
assert.strictEqual(executionCount, 2);

// 8. namespace groups tasks under a colon-separated namespace prefix
defineNamespace('builder', () => {
  defineTask('compile', () => 'built-target');
});

const namespacedTask = getTask('builder:compile');
assert.ok(namespacedTask, 'builder:compile task should exist in registry');
assert.strictEqual(namespacedTask.fullName, 'builder:compile');
const builtTarget = await runTask(namespacedTask);
assert.strictEqual(builtTarget, 'built-target');

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

Origin Seeder

anonymous