CodeSampleX

Beispiel

scheduler 0.25.0: unstable_LowPriority

Verifiziertes Beispiel für npm scheduler 0.25.0: unstable_LowPriority. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:bbd47e3311108bebaaefa699bac545e65e765b29b4048c45f3cc9c262863eb44

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

Fall

HOW
Ziel
verify scheduler.unstable_LowPriority in pkg:npm/scheduler@0.25.0
Pakete
Symbole
  • scheduler.unstable_LowPriority
Erstellt
2026-08-21T02:47:28Z

Contract

  1. unstable_LowPriority is exported as a numeric priority constant
  2. unstable_runWithPriority executes callback with unstable_LowPriority priority level
  3. unstable_scheduleCallback accepts unstable_LowPriority and creates scheduled task
  4. unstable_wrapCallback binds current priority level when running with unstable_LowPriority

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 scheduler.unstable_LowPriority in pkg:npm/scheduler@0.25.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/scheduler@0.25.0
Demonstrate these symbols/APIs:
  - scheduler.unstable_LowPriority

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:0e1f7d255ad6ad95911a124b0149f8bb8f6cdca01b863cc03cad12f319fbf993","contract":["unstable_LowPriority is exported as a numeric priority constant","unstable_runWithPriority executes callback with unstable_LowPriority priority level","unstable_scheduleCallback accepts unstable_LowPriority and creates scheduled task","unstable_wrapCallback binds current priority level when running with unstable_LowPriority"],"goal":"verify scheduler.unstable_LowPriority in pkg:npm/scheduler@0.25.0","kind":"HOW","packages":["pkg:npm/scheduler@0.25.0"],"schemaVersion":1,"symbols":["scheduler.unstable_LowPriority"]},"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/scheduler@0.25.0"],"schemaVersion":1,"subject":"pkg:npm/scheduler@0.25.0","symbols":["scheduler.unstable_LowPriority"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-scheduler-low-priority",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-scheduler-low-priority",
      "version": "1.0.0",
      "dependencies": {
        "scheduler": "0.25.0"
      }
    },
    "node_modules/scheduler": {
      "version": "0.25.0",
      "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz",
      "integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-scheduler-low-priority",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of scheduler.unstable_LowPriority",
  "main": "src/index.js",
  "dependencies": {
    "scheduler": "0.25.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify scheduler.unstable_LowPriority in pkg:npm/scheduler@0.25.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/scheduler@0.25.0"
  ],
  "symbols": [
    "scheduler.unstable_LowPriority"
  ]
}
src/index.js
const scheduler = require('scheduler');

const {
  unstable_LowPriority,
  unstable_NormalPriority,
  unstable_runWithPriority,
  unstable_scheduleCallback,
  unstable_cancelCallback,
  unstable_wrapCallback,
  unstable_getCurrentPriorityLevel
} = scheduler;

/**
 * Get the numeric value of Low Priority level in Scheduler.
 * @returns {number}
 */
function getLowPriorityLevel() {
  return unstable_LowPriority;
}

/**
 * Execute a function with low priority and return its result.
 * @param {Function} callback
 * @returns {*}
 */
function runAtLowPriority(callback) {
  return unstable_runWithPriority(unstable_LowPriority, callback);
}

/**
 * Schedule a task to be executed at low priority.
 * @param {Function} callback
 * @param {object} [options]
 * @returns {object} Scheduled task node
 */
function scheduleLowPriorityTask(callback, options) {
  return unstable_scheduleCallback(unstable_LowPriority, callback, options);
}

/**
 * Wrap a callback so that it always executes at low priority.
 * @param {Function} callback
 * @returns {Function}
 */
function createLowPriorityCallback(callback) {
  return unstable_runWithPriority(unstable_LowPriority, () => {
    return unstable_wrapCallback(callback);
  });
}

module.exports = {
  unstable_LowPriority,
  unstable_NormalPriority,
  getLowPriorityLevel,
  runAtLowPriority,
  scheduleLowPriorityTask,
  createLowPriorityCallback,
  unstable_getCurrentPriorityLevel,
  unstable_cancelCallback
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  unstable_LowPriority,
  unstable_NormalPriority,
  getLowPriorityLevel,
  runAtLowPriority,
  scheduleLowPriorityTask,
  createLowPriorityCallback,
  unstable_getCurrentPriorityLevel,
  unstable_cancelCallback
} = require('../src/index.js');

// 1. unstable_LowPriority is exported as a numeric priority constant
assert.equal(typeof unstable_LowPriority, 'number', 'unstable_LowPriority must be a number');
assert.equal(unstable_LowPriority, 4, 'unstable_LowPriority value should be 4');
assert.equal(getLowPriorityLevel(), 4, 'getLowPriorityLevel() should return 4');

// 2. unstable_runWithPriority executes callback with unstable_LowPriority priority level
const defaultPriority = unstable_getCurrentPriorityLevel();
let capturedPriority = null;
const result = runAtLowPriority(() => {
  capturedPriority = unstable_getCurrentPriorityLevel();
  return 'low-priority-result';
});
assert.equal(result, 'low-priority-result', 'runAtLowPriority should return callback result');
assert.equal(capturedPriority, unstable_LowPriority, 'Priority inside runAtLowPriority should be unstable_LowPriority');
assert.equal(unstable_getCurrentPriorityLevel(), defaultPriority, 'Priority outside runAtLowPriority should be restored');

// 3. unstable_scheduleCallback accepts unstable_LowPriority and creates scheduled task
let taskRan = false;
const task = scheduleLowPriorityTask(() => {
  taskRan = true;
  return 'task-complete';
});
assert.equal(typeof task, 'object', 'scheduleLowPriorityTask should return a task object');
assert.equal(task.priorityLevel, unstable_LowPriority, 'Task priorityLevel should match unstable_LowPriority');
assert.equal(typeof task.id, 'number', 'Task should have numeric id');

// Cancel task cleanly
unstable_cancelCallback(task);
assert.equal(task.callback, null, 'Cancelled task callback should be null');

// 4. unstable_wrapCallback binds current priority level when running with unstable_LowPriority
const lowPriorityCallback = createLowPriorityCallback(() => {
  return unstable_getCurrentPriorityLevel();
});
assert.equal(typeof lowPriorityCallback, 'function', 'createLowPriorityCallback should return a function');
const executionPriority = lowPriorityCallback();
assert.equal(executionPriority, unstable_LowPriority, 'Wrapped callback should run with unstable_LowPriority');

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

Ursprungs-Seeder

anonym