CodeSampleX

샘플

scheduler 0.25.0: unstable_IdlePriority

검증된 샘플 — npm scheduler 0.25.0: unstable_IdlePriority. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: unstable_IdlePriority is exported as a…

sha256:623a47f538c4f6a455275461066decf9816582f9870298eca8c0b5d4bf2cba1e

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify unstable_IdlePriority in pkg:npm/scheduler@0.25.0
패키지
심벌
  • unstable_IdlePriority
생성일
2026-09-02T14:19:15Z

컨트랙트

  1. unstable_IdlePriority is exported as a numeric constant with value 5
  2. unstable_IdlePriority has the lowest priority level relative to Immediate, UserBlocking, Normal, and Low priorities
  3. unstable_runWithPriority executes callbacks with current priority set to unstable_IdlePriority
  4. unstable_scheduleCallback schedules tasks assigned with unstable_IdlePriority level

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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 unstable_IdlePriority 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:
  - unstable_IdlePriority

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:3451599b82e307f7f0553405a66755a18a39481fe5524910cd7868b76b442176","contract":["unstable_IdlePriority is exported as a numeric constant with value 5","unstable_IdlePriority has the lowest priority level relative to Immediate, UserBlocking, Normal, and Low priorities","unstable_runWithPriority executes callbacks with current priority set to unstable_IdlePriority","unstable_scheduleCallback schedules tasks assigned with unstable_IdlePriority level"],"goal":"verify unstable_IdlePriority in pkg:npm/scheduler@0.25.0","kind":"HOW","packages":["pkg:npm/scheduler@0.25.0"],"schemaVersion":1,"symbols":["unstable_IdlePriority"]},"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":["unstable_IdlePriority"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-scheduler-unstable-idle-priority",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-scheduler-unstable-idle-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-unstable-idle-priority",
  "version": "1.0.0",
  "private": true,
  "description": "Verification of unstable_IdlePriority in scheduler",
  "main": "src/index.js",
  "dependencies": {
    "scheduler": "0.25.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify unstable_IdlePriority in pkg:npm/scheduler@0.25.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/scheduler@0.25.0"
  ],
  "symbols": [
    "unstable_IdlePriority"
  ]
}
src/index.js
const scheduler = require('scheduler');

/**
 * Returns the numeric priority constant for idle priority.
 * @returns {number} The unstable_IdlePriority value.
 */
function getIdlePriority() {
  return scheduler.unstable_IdlePriority;
}

/**
 * Executes a callback within the context of idle priority level.
 * @param {Function} action - The action to execute under idle priority.
 * @returns {{ priority: number, result: any }} The observed priority level and execution result.
 */
function runWithIdlePriority(action) {
  return scheduler.unstable_runWithPriority(scheduler.unstable_IdlePriority, () => {
    const priority = scheduler.unstable_getCurrentPriorityLevel();
    const result = action ? action() : undefined;
    return { priority, result };
  });
}

/**
 * Schedules a callback task with idle priority.
 * @param {Function} callback - The task callback.
 * @param {object} [options] - Optional task options.
 * @returns {object} The scheduled task node.
 */
function scheduleIdleTask(callback, options) {
  return scheduler.unstable_scheduleCallback(
    scheduler.unstable_IdlePriority,
    callback,
    options
  );
}

module.exports = {
  getIdlePriority,
  runWithIdlePriority,
  scheduleIdleTask,
  scheduler
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  getIdlePriority,
  runWithIdlePriority,
  scheduleIdleTask,
  scheduler
} = require('../src/index.js');

// 1. Symbol export and value verification
assert.strictEqual(typeof scheduler.unstable_IdlePriority, 'number', 'unstable_IdlePriority must be exported as a number');
assert.strictEqual(scheduler.unstable_IdlePriority, 5, 'unstable_IdlePriority must have value 5');
assert.strictEqual(getIdlePriority(), 5, 'getIdlePriority helper must return 5');

// 2. Relative priority level ordering (lower numeric value means higher urgency)
assert.strictEqual(scheduler.unstable_ImmediatePriority, 1, 'unstable_ImmediatePriority is 1');
assert.strictEqual(scheduler.unstable_UserBlockingPriority, 2, 'unstable_UserBlockingPriority is 2');
assert.strictEqual(scheduler.unstable_NormalPriority, 3, 'unstable_NormalPriority is 3');
assert.strictEqual(scheduler.unstable_LowPriority, 4, 'unstable_LowPriority is 4');
assert.strictEqual(scheduler.unstable_IdlePriority, 5, 'unstable_IdlePriority is 5');
assert.ok(
  scheduler.unstable_ImmediatePriority < scheduler.unstable_UserBlockingPriority &&
  scheduler.unstable_UserBlockingPriority < scheduler.unstable_NormalPriority &&
  scheduler.unstable_NormalPriority < scheduler.unstable_LowPriority &&
  scheduler.unstable_LowPriority < scheduler.unstable_IdlePriority,
  'unstable_IdlePriority has the lowest priority level'
);

// 3. Execution under idle priority with unstable_runWithPriority
const executed = runWithIdlePriority(() => 'idle-task-result');
assert.strictEqual(executed.priority, scheduler.unstable_IdlePriority, 'Observed current priority during execution is unstable_IdlePriority (5)');
assert.strictEqual(executed.result, 'idle-task-result', 'Action returns the expected result');

// 4. Scheduling tasks with unstable_scheduleCallback using unstable_IdlePriority
const task = scheduleIdleTask(() => 'queued-result');
assert.strictEqual(typeof task, 'object', 'scheduleIdleTask returns a valid task object');
assert.strictEqual(task.priorityLevel, scheduler.unstable_IdlePriority, 'Task priorityLevel matches unstable_IdlePriority (5)');
assert.strictEqual(typeof task.callback, 'function', 'Task callback is attached');
assert.ok(typeof task.expirationTime === 'number' && task.expirationTime > 0, 'Task has a positive numeric expirationTime');

console.log('Contract assertions for scheduler.unstable_IdlePriority passed.');

오리진 시더

익명