CodeSampleX

Ejemplo

scheduler 0.25.0: unstable_UserBlockingPriority

Muestra verificada para npm scheduler 0.25.0: unstable_UserBlockingPriority. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.

sha256:15b3f0a868bc84dc8d30cc571ffdb98a149e00c811cc865d3570cdf706f796e9

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify scheduler.unstable_UserBlockingPriority in pkg:npm/scheduler@0.25.0
Paquetes
Símbolos
  • scheduler.unstable_UserBlockingPriority
Creado
2026-08-21T02:51:42Z

Contrato

  1. scheduler.unstable_UserBlockingPriority is exported as a numeric constant with value 2
  2. unstable_UserBlockingPriority is higher priority than Normal, Low, and Idle priorities and lower than Immediate priority
  3. scheduler.unstable_runWithPriority executes callbacks with current priority set to unstable_UserBlockingPriority
  4. scheduler.unstable_scheduleCallback schedules tasks assigned with unstable_UserBlockingPriority level

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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

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:c545289369d73cb0047374ac713fd8fd4aa11a284bc61923b7dfcc5d2b07b273","contract":["scheduler.unstable_UserBlockingPriority is exported as a numeric constant with value 2","unstable_UserBlockingPriority is higher priority than Normal, Low, and Idle priorities and lower than Immediate priority","scheduler.unstable_runWithPriority executes callbacks with current priority set to unstable_UserBlockingPriority","scheduler.unstable_scheduleCallback schedules tasks assigned with unstable_UserBlockingPriority level"],"goal":"verify scheduler.unstable_UserBlockingPriority in pkg:npm/scheduler@0.25.0","kind":"HOW","packages":["pkg:npm/scheduler@0.25.0"],"schemaVersion":1,"symbols":["scheduler.unstable_UserBlockingPriority"]},"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_UserBlockingPriority"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-scheduler-user-blocking-priority",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-scheduler-user-blocking-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-user-blocking-priority",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of scheduler unstable_UserBlockingPriority",
  "main": "src/index.js",
  "dependencies": {
    "scheduler": "0.25.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify scheduler.unstable_UserBlockingPriority in pkg:npm/scheduler@0.25.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/scheduler@0.25.0"
  ],
  "symbols": [
    "scheduler.unstable_UserBlockingPriority"
  ]
}
src/index.js
const scheduler = require('scheduler');

/**
 * Returns the numeric value representing the user-blocking priority level.
 * @returns {number} The user-blocking priority level constant.
 */
function getUserBlockingPriority() {
  return scheduler.unstable_UserBlockingPriority;
}

/**
 * Runs a synchronous action under the user-blocking priority level.
 * @param {Function} action - Function to execute under user-blocking priority.
 * @returns {*} The result of the action and the observed priority level.
 */
function runWithUserBlockingPriority(action) {
  return scheduler.unstable_runWithPriority(scheduler.unstable_UserBlockingPriority, () => {
    const currentPriority = scheduler.unstable_getCurrentPriorityLevel();
    const result = action ? action() : undefined;
    return {
      priority: currentPriority,
      result
    };
  });
}

/**
 * Schedules a callback task with user-blocking priority.
 * @param {Function} callback - Task callback.
 * @param {object} [options] - Scheduling options.
 * @returns {object} The scheduled task node.
 */
function scheduleUserBlockingTask(callback, options) {
  return scheduler.unstable_scheduleCallback(
    scheduler.unstable_UserBlockingPriority,
    callback,
    options
  );
}

module.exports = {
  getUserBlockingPriority,
  runWithUserBlockingPriority,
  scheduleUserBlockingTask,
  scheduler
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  getUserBlockingPriority,
  runWithUserBlockingPriority,
  scheduleUserBlockingTask,
  scheduler
} = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof scheduler.unstable_UserBlockingPriority, 'number', 'unstable_UserBlockingPriority should be exported as a number');
assert.strictEqual(scheduler.unstable_UserBlockingPriority, 2, 'unstable_UserBlockingPriority should equal 2');
assert.strictEqual(getUserBlockingPriority(), 2, 'getUserBlockingPriority should return 2');

// 2. Relative priority level ordering
assert.ok(scheduler.unstable_ImmediatePriority < scheduler.unstable_UserBlockingPriority, 'Immediate priority is higher than UserBlocking');
assert.ok(scheduler.unstable_UserBlockingPriority < scheduler.unstable_NormalPriority, 'UserBlocking priority is higher than Normal');
assert.ok(scheduler.unstable_NormalPriority < scheduler.unstable_LowPriority, 'Normal priority is higher than Low');
assert.ok(scheduler.unstable_LowPriority < scheduler.unstable_IdlePriority, 'Low priority is higher than Idle');

// 3. Execution under user-blocking priority with runWithUserBlockingPriority
const executed = runWithUserBlockingPriority(() => 'user-blocking-computed');
assert.strictEqual(executed.priority, scheduler.unstable_UserBlockingPriority, 'Observed execution priority is unstable_UserBlockingPriority');
assert.strictEqual(executed.result, 'user-blocking-computed', 'Action returns expected result under user-blocking priority');

// 4. Scheduling a task with unstable_UserBlockingPriority
const task = scheduleUserBlockingTask(() => 'task-result');
assert.strictEqual(typeof task, 'object', 'scheduleUserBlockingTask returns a task object');
assert.strictEqual(task.priorityLevel, scheduler.unstable_UserBlockingPriority, 'Task priorityLevel is unstable_UserBlockingPriority');
assert.strictEqual(typeof task.callback, 'function', 'Task callback is queued');
assert.ok(task.expirationTime > 0, 'Task expirationTime is computed');

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

Seeder de origen

anónimo