CodeSampleX

Exemplo

scheduler 0.23.2

Amostra verificada para npm scheduler 0.23.2. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: unstable_ImmediatePriority…

sha256:c93bfdd89d6ac77cda751369b06fcfa380f8f975cd705c95f911cd619f8b7957

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify pkg:npm/scheduler@0.23.2
Pacotes
Ambiente
node 22.23.2
Criado
2026-08-27T15:46:22Z

Contrato

  1. unstable_ImmediatePriority, unstable_UserBlockingPriority, unstable_NormalPriority, unstable_LowPriority, and unstable_IdlePriority are exported priority constants
  2. unstable_getCurrentPriorityLevel returns active priority level defaulting to unstable_NormalPriority
  3. unstable_runWithPriority executes callback at specified priority level and restores previous priority
  4. unstable_wrapCallback binds a callback to current priority level
  5. unstable_now returns monotonic non-negative millisecond timestamp
  6. unstable_shouldYield returns boolean indicating whether execution should yield to host
  7. unstable_scheduleCallback schedules and executes tasks in order of priority
  8. unstable_cancelCallback cancels a scheduled task by setting callback to null
  9. unstable_scheduleCallback supports delayed scheduling via options.delay

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 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.
csx.json
{"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"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "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"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/scheduler@0.23.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/scheduler@0.23.2"
  ]
}
test/contract.js
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);
});

Seeder de origem

anônimo