Sample
scheduler 0.25.0: unstable_getCurrentPriorityLevel
Verified sample for npm scheduler 0.25.0: unstable_getCurrentPriorityLevel. The contract ran on node 22 · linux alpine/x64 · docker and passed.
sha256:b0e37aa578f1c2e268d21abfcb413e88ec337100b1b539eda0bcad6c604349a2
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@1 |
2026-08-21 |
Case
HOW- Goal
- verify scheduler.unstable_getCurrentPriorityLevel in pkg:npm/scheduler@0.25.0
- Packages
- Symbols
-
- scheduler.unstable_getCurrentPriorityLevel
- Created
- 2026-08-21T02:56:00Z
Contract
- unstable_getCurrentPriorityLevel is exported as a function from scheduler
- unstable_getCurrentPriorityLevel returns unstable_NormalPriority (3) as default ambient priority level
- unstable_getCurrentPriorityLevel reflects priority level passed to unstable_runWithPriority during callback execution
- unstable_getCurrentPriorityLevel tracks nested priority scopes and restores previous priority on exit
- unstable_getCurrentPriorityLevel restores previous priority level when a callback throws an error
- unstable_getCurrentPriorityLevel inside a callback wrapped by unstable_wrapCallback reflects captured priority
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Source
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_getCurrentPriorityLevel 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_getCurrentPriorityLevel
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:643b1f28a2a1b24fe138e052c57386c9ff6fb26d8a56d56c662efd750d0836ed","contract":["unstable_getCurrentPriorityLevel is exported as a function from scheduler","unstable_getCurrentPriorityLevel returns unstable_NormalPriority (3) as default ambient priority level","unstable_getCurrentPriorityLevel reflects priority level passed to unstable_runWithPriority during callback execution","unstable_getCurrentPriorityLevel tracks nested priority scopes and restores previous priority on exit","unstable_getCurrentPriorityLevel restores previous priority level when a callback throws an error","unstable_getCurrentPriorityLevel inside a callback wrapped by unstable_wrapCallback reflects captured priority"],"goal":"verify scheduler.unstable_getCurrentPriorityLevel in pkg:npm/scheduler@0.25.0","kind":"HOW","packages":["pkg:npm/scheduler@0.25.0"],"schemaVersion":1,"symbols":["scheduler.unstable_getCurrentPriorityLevel"]},"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_getCurrentPriorityLevel"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-scheduler-getcurrentprioritylevel",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-scheduler-getcurrentprioritylevel",
"version": "1.0.0",
"license": "MIT-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"
}
}
}
{
"name": "sample-scheduler-getcurrentprioritylevel",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for scheduler.unstable_getCurrentPriorityLevel in scheduler@0.25.0",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"scheduler": "0.25.0"
}
}
{
"schemaVersion": 1,
"goal": "verify scheduler.unstable_getCurrentPriorityLevel in pkg:npm/scheduler@0.25.0",
"kind": "HOW",
"packages": [
"pkg:npm/scheduler@0.25.0"
],
"symbols": [
"scheduler.unstable_getCurrentPriorityLevel"
]
}
const scheduler = require('scheduler');
const {
unstable_ImmediatePriority,
unstable_UserBlockingPriority,
unstable_NormalPriority,
unstable_LowPriority,
unstable_IdlePriority,
unstable_runWithPriority,
unstable_getCurrentPriorityLevel,
unstable_wrapCallback
} = scheduler;
/**
* Returns the currently active priority level from scheduler.
*
* @returns {number} Current priority level integer (e.g. 1 for Immediate, 3 for Normal).
*/
function getCurrentPriority() {
return unstable_getCurrentPriorityLevel();
}
/**
* Execute a callback within an explicit priority level context and query the current level.
*
* @param {number} priorityLevel - The priority level to apply.
* @param {Function} callback - Function executed within the specified priority scope.
* @returns {*} Result of the callback execution.
*/
function runWithPriorityScope(priorityLevel, callback) {
return unstable_runWithPriority(priorityLevel, callback);
}
/**
* Wrap a function to preserve the current priority level at time of creation.
*
* @param {Function} callback - Function to wrap.
* @returns {Function} Wrapped function that restores captured priority level when called.
*/
function captureCurrentPriority(callback) {
return unstable_wrapCallback(callback);
}
module.exports = {
scheduler,
unstable_ImmediatePriority,
unstable_UserBlockingPriority,
unstable_NormalPriority,
unstable_LowPriority,
unstable_IdlePriority,
unstable_runWithPriority,
unstable_getCurrentPriorityLevel,
unstable_wrapCallback,
getCurrentPriority,
runWithPriorityScope,
captureCurrentPriority
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
scheduler,
unstable_ImmediatePriority,
unstable_UserBlockingPriority,
unstable_NormalPriority,
unstable_LowPriority,
unstable_IdlePriority,
unstable_runWithPriority,
unstable_getCurrentPriorityLevel,
unstable_wrapCallback,
getCurrentPriority,
runWithPriorityScope,
captureCurrentPriority
} = require('../src/index.js');
async function runTests() {
// 1. unstable_getCurrentPriorityLevel is exported as a function from scheduler
assert.equal(typeof scheduler.unstable_getCurrentPriorityLevel, 'function', 'scheduler.unstable_getCurrentPriorityLevel must be a function');
assert.equal(typeof unstable_getCurrentPriorityLevel, 'function', 'unstable_getCurrentPriorityLevel must be a function');
assert.equal(typeof getCurrentPriority, 'function', 'getCurrentPriority helper must be a function');
// 2. unstable_getCurrentPriorityLevel returns unstable_NormalPriority (3) as default ambient priority level
const defaultPriority = getCurrentPriority();
assert.equal(defaultPriority, 3, 'Default priority level should be 3');
assert.equal(defaultPriority, unstable_NormalPriority, 'Default priority level should equal unstable_NormalPriority');
// 3. unstable_getCurrentPriorityLevel reflects priority level passed to unstable_runWithPriority during callback execution
const priorities = [
{ name: 'ImmediatePriority', value: unstable_ImmediatePriority },
{ name: 'UserBlockingPriority', value: unstable_UserBlockingPriority },
{ name: 'NormalPriority', value: unstable_NormalPriority },
{ name: 'LowPriority', value: unstable_LowPriority },
{ name: 'IdlePriority', value: unstable_IdlePriority }
];
for (const { name, value } of priorities) {
let observedLevel = null;
const result = runWithPriorityScope(value, () => {
observedLevel = getCurrentPriority();
return `result-${name}`;
});
assert.equal(observedLevel, value, `Observed priority inside runWithPriority(${name}) must be ${value}`);
assert.equal(result, `result-${name}`, 'runWithPriority must return callback return value');
}
// 4. unstable_getCurrentPriorityLevel tracks nested priority scopes and restores previous priority on exit
runWithPriorityScope(unstable_LowPriority, () => {
assert.equal(getCurrentPriority(), unstable_LowPriority, 'Outer level is LowPriority');
runWithPriorityScope(unstable_ImmediatePriority, () => {
assert.equal(getCurrentPriority(), unstable_ImmediatePriority, 'Inner level is ImmediatePriority');
runWithPriorityScope(unstable_UserBlockingPriority, () => {
assert.equal(getCurrentPriority(), unstable_UserBlockingPriority, 'Innermost level is UserBlockingPriority');
});
assert.equal(getCurrentPriority(), unstable_ImmediatePriority, 'Restored to ImmediatePriority after innermost scope');
});
assert.equal(getCurrentPriority(), unstable_LowPriority, 'Restored to LowPriority after middle scope');
});
assert.equal(getCurrentPriority(), unstable_NormalPriority, 'Restored to default NormalPriority after outer scope');
// 5. unstable_getCurrentPriorityLevel restores previous priority level when a callback throws an error
runWithPriorityScope(unstable_LowPriority, () => {
assert.equal(getCurrentPriority(), unstable_LowPriority, 'Ambient level before error is LowPriority');
assert.throws(
() => {
runWithPriorityScope(unstable_ImmediatePriority, () => {
assert.equal(getCurrentPriority(), unstable_ImmediatePriority, 'Priority inside throwing scope is ImmediatePriority');
throw new Error('test-failure-simulation');
});
},
/test-failure-simulation/
);
assert.equal(getCurrentPriority(), unstable_LowPriority, 'Priority level restored to LowPriority after thrown error');
});
// 6. unstable_getCurrentPriorityLevel inside a callback wrapped by unstable_wrapCallback reflects captured priority
let wrappedCallback;
runWithPriorityScope(unstable_UserBlockingPriority, () => {
wrappedCallback = captureCurrentPriority(() => {
return getCurrentPriority();
});
});
runWithPriorityScope(unstable_IdlePriority, () => {
assert.equal(getCurrentPriority(), unstable_IdlePriority, 'Caller ambient priority is IdlePriority');
const priorityInWrapped = wrappedCallback();
assert.equal(priorityInWrapped, unstable_UserBlockingPriority, 'Wrapped callback executed with captured UserBlockingPriority');
assert.equal(getCurrentPriority(), unstable_IdlePriority, 'Caller priority remains IdlePriority after wrapped callback invocation');
});
console.log('All contract assertions for scheduler.unstable_getCurrentPriorityLevel passed successfully.');
}
runTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Origin Seeder
anonymous