Пример
scheduler 0.23.2
Проверенный пример — npm scheduler 0.23.2. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: unstable_ImmediatePriority…
sha256:c93bfdd89d6ac77cda751369b06fcfa380f8f975cd705c95f911cd619f8b7957
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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-27 |
Кейс
HOW- Цель
- verify pkg:npm/scheduler@0.23.2
- Пакеты
- Окружение
- node 22.23.2
- Создан
- 2026-08-27T15:46:22Z
Контракт
- unstable_ImmediatePriority, unstable_UserBlockingPriority, unstable_NormalPriority, unstable_LowPriority, and unstable_IdlePriority are exported priority constants
- unstable_getCurrentPriorityLevel returns active priority level defaulting to unstable_NormalPriority
- unstable_runWithPriority executes callback at specified priority level and restores previous priority
- unstable_wrapCallback binds a callback to current priority level
- unstable_now returns monotonic non-negative millisecond timestamp
- unstable_shouldYield returns boolean indicating whether execution should yield to host
- unstable_scheduleCallback schedules and executes tasks in order of priority
- unstable_cancelCallback cancels a scheduled task by setting callback to null
- unstable_scheduleCallback supports delayed scheduling via options.delay
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.js
Исходный код
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/scheduler@0.23.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/scheduler@0.23.2
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.
{"case":{"caseId":"case:sha256:d3f87e0cfd539710405a606905c97194f1bef4fbeedcc5e7436980cbfe4952ca","constraints":{"executionContext":"node"},"contract":["unstable_ImmediatePriority, unstable_UserBlockingPriority, unstable_NormalPriority, unstable_LowPriority, and unstable_IdlePriority are exported priority constants","unstable_getCurrentPriorityLevel returns active priority level defaulting to unstable_NormalPriority","unstable_runWithPriority executes callback at specified priority level and restores previous priority","unstable_wrapCallback binds a callback to current priority level","unstable_now returns monotonic non-negative millisecond timestamp","unstable_shouldYield returns boolean indicating whether execution should yield to host","unstable_scheduleCallback schedules and executes tasks in order of priority","unstable_cancelCallback cancels a scheduled task by setting callback to null","unstable_scheduleCallback supports delayed scheduling via options.delay"],"goal":"verify pkg:npm/scheduler@0.23.2","kind":"HOW","packages":["pkg:npm/scheduler@0.23.2"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/scheduler@0.23.2"],"schemaVersion":1,"subject":"pkg:npm/scheduler@0.23.2","verifierAdapter":"node-typescript@1"}
{
"name": "sample-scheduler",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-scheduler",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"scheduler": "0.23.2"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"license": "MIT"
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"license": "MIT",
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
"bin": {
"loose-envify": "cli.js"
}
},
"node_modules/scheduler": {
"version": "0.23.2",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
"integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==",
"license": "MIT",
"dependencies": {
"loose-envify": "^1.1.0"
}
}
}
}
{
"name": "sample-scheduler",
"version": "1.0.0",
"description": "Clean-room verification sample for scheduler",
"main": "test/contract.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"scheduler": "0.23.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/scheduler@0.23.2",
"kind": "HOW",
"packages": [
"pkg:npm/scheduler@0.23.2"
]
}
const assert = require('assert');
const Scheduler = require('scheduler');
const {
unstable_ImmediatePriority,
unstable_UserBlockingPriority,
unstable_NormalPriority,
unstable_LowPriority,
unstable_IdlePriority,
unstable_scheduleCallback,
unstable_cancelCallback,
unstable_getCurrentPriorityLevel,
unstable_runWithPriority,
unstable_wrapCallback,
unstable_now,
unstable_shouldYield,
} = Scheduler;
async function runContractTests() {
// 1. Exported priority constants
assert.strictEqual(unstable_ImmediatePriority, 1, 'unstable_ImmediatePriority should be 1');
assert.strictEqual(unstable_UserBlockingPriority, 2, 'unstable_UserBlockingPriority should be 2');
assert.strictEqual(unstable_NormalPriority, 3, 'unstable_NormalPriority should be 3');
assert.strictEqual(unstable_LowPriority, 4, 'unstable_LowPriority should be 4');
assert.strictEqual(unstable_IdlePriority, 5, 'unstable_IdlePriority should be 5');
// 2. Default and scoped priority level management
assert.strictEqual(unstable_getCurrentPriorityLevel(), unstable_NormalPriority, 'Default priority must be NormalPriority');
const scopedResult = unstable_runWithPriority(unstable_UserBlockingPriority, () => {
assert.strictEqual(unstable_getCurrentPriorityLevel(), unstable_UserBlockingPriority, 'Priority inside runWithPriority must match set priority');
return 'priority-result';
});
assert.strictEqual(scopedResult, 'priority-result', 'runWithPriority must return callback return value');
assert.strictEqual(unstable_getCurrentPriorityLevel(), unstable_NormalPriority, 'Priority must restore after runWithPriority');
// 3. wrapCallback binds a callback to current priority level
const wrapped = unstable_runWithPriority(unstable_LowPriority, () => {
return unstable_wrapCallback(() => unstable_getCurrentPriorityLevel());
});
assert.strictEqual(unstable_getCurrentPriorityLevel(), unstable_NormalPriority, 'Current priority remains normal after wrapCallback definition');
assert.strictEqual(wrapped(), unstable_LowPriority, 'wrapped callback should execute with bound priority');
// 4. Time and yielding utilities
const now = unstable_now();
assert.strictEqual(typeof now, 'number', 'unstable_now must return a number');
assert(now >= 0, 'unstable_now must return a non-negative timestamp');
const shouldYield = unstable_shouldYield();
assert.strictEqual(typeof shouldYield, 'boolean', 'unstable_shouldYield must return a boolean');
// 5. scheduleCallback executes tasks in priority order
const executionLog = [];
await new Promise((resolve) => {
unstable_scheduleCallback(unstable_LowPriority, () => {
executionLog.push('low');
if (executionLog.length === 3) resolve();
});
unstable_scheduleCallback(unstable_ImmediatePriority, () => {
executionLog.push('immediate');
if (executionLog.length === 3) resolve();
});
unstable_scheduleCallback(unstable_NormalPriority, () => {
executionLog.push('normal');
if (executionLog.length === 3) resolve();
});
});
assert.deepStrictEqual(executionLog, ['immediate', 'normal', 'low'], 'Tasks must execute in order of priority');
// 6. cancelCallback cancels scheduled task
const cancelLog = [];
await new Promise((resolve) => {
const taskToCancel = unstable_scheduleCallback(unstable_ImmediatePriority, () => {
cancelLog.push('cancelled');
});
unstable_cancelCallback(taskToCancel);
assert.strictEqual(taskToCancel.callback, null, 'cancelCallback sets task callback to null');
unstable_scheduleCallback(unstable_NormalPriority, () => {
cancelLog.push('executed');
resolve();
});
});
assert.deepStrictEqual(cancelLog, ['executed'], 'Cancelled task must not execute');
// 7. Delayed scheduling with options.delay
const delayLog = [];
await new Promise((resolve) => {
unstable_scheduleCallback(unstable_NormalPriority, () => {
delayLog.push('delayed');
resolve();
}, { delay: 20 });
unstable_scheduleCallback(unstable_NormalPriority, () => {
delayLog.push('immediate');
});
});
assert.deepStrictEqual(delayLog, ['immediate', 'delayed'], 'Delayed task must execute after immediate task');
console.log('All scheduler contract assertions passed successfully.');
}
runContractTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Исходный сидер
аноним