CodeSampleX

Exemplo

globals 14.0.0: nodeBuiltin

Amostra verificada para npm globals 14.0.0: nodeBuiltin. O contrato rodou em node 22 · linux debian/x64 · docker e passou: globals.nodeBuiltin is a…

sha256:9b369e06b48a5c6057e0be848901f587ba21bcdb03f295976694f1734d7dae5a

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 debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-05

Caso

HOW
Objetivo
verify globals.nodeBuiltin in pkg:npm/globals@14.0.0
Pacotes
Símbolos
  • globals.nodeBuiltin
Ambiente
node 22.23.2
Criado
2026-09-05T23:40:23Z

Contrato

  1. globals.nodeBuiltin is a dictionary mapping Node.js built-in identifiers to boolean writeability flags
  2. globals.nodeBuiltin contains exactly 65 built-in identifier entries
  3. globals.nodeBuiltin marks all built-in identifiers as read-only with value false
  4. globals.nodeBuiltin includes core Node.js process and execution identifiers process, Buffer, and global as read-only
  5. globals.nodeBuiltin includes timer functions setTimeout, setInterval, setImmediate, clearTimeout, and clearInterval as read-only
  6. globals.nodeBuiltin includes standard Web APIs fetch, Request, Response, Headers, URL, and AbortController as read-only
  7. globals.nodeBuiltin includes streams and encoding APIs ReadableStream, WritableStream, TextEncoder, and TextDecoder as read-only

Arquivos

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

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 globals.nodeBuiltin in pkg:npm/globals@14.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/globals@14.0.0
Demonstrate these symbols/APIs:
  - globals.nodeBuiltin

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:fe180275487e907681544a5fbcd2ea6c4e4fcc9c508764284c2485ce697fc5ab","contract":["globals.nodeBuiltin is a dictionary mapping Node.js built-in identifiers to boolean writeability flags","globals.nodeBuiltin contains exactly 65 built-in identifier entries","globals.nodeBuiltin marks all built-in identifiers as read-only with value false","globals.nodeBuiltin includes core Node.js process and execution identifiers process, Buffer, and global as read-only","globals.nodeBuiltin includes timer functions setTimeout, setInterval, setImmediate, clearTimeout, and clearInterval as read-only","globals.nodeBuiltin includes standard Web APIs fetch, Request, Response, Headers, URL, and AbortController as read-only","globals.nodeBuiltin includes streams and encoding APIs ReadableStream, WritableStream, TextEncoder, and TextDecoder as read-only"],"goal":"verify globals.nodeBuiltin in pkg:npm/globals@14.0.0","kind":"HOW","packages":["pkg:npm/globals@14.0.0"],"schemaVersion":1,"symbols":["globals.nodeBuiltin"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/globals@14.0.0"],"schemaVersion":1,"subject":"pkg:npm/globals@14.0.0","symbols":["globals.nodeBuiltin"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-globals-node-builtin",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-globals-node-builtin",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "globals": "14.0.0"
      }
    },
    "node_modules/globals": {
      "version": "14.0.0",
      "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
      "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    }
  }
}
package.json
{
  "name": "sample-globals-node-builtin",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of globals.nodeBuiltin in globals@14.0.0",
  "type": "module",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "globals": "14.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify globals.nodeBuiltin in pkg:npm/globals@14.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/globals@14.0.0"
  ],
  "symbols": [
    "globals.nodeBuiltin"
  ]
}
src/index.js
import globals from 'globals';

/**
 * Returns the dictionary of Node.js built-in global identifiers and their writeability status.
 *
 * @returns {Record<string, boolean>} Object mapping identifier names to boolean writeability flags.
 */
export function getNodeBuiltinGlobals() {
  return globals.nodeBuiltin;
}

/**
 * Checks whether a given identifier name is recognized as a Node.js built-in global.
 *
 * @param {string} identifier - Identifier name to check.
 * @returns {boolean} True if the identifier exists in globals.nodeBuiltin.
 */
export function isNodeBuiltin(identifier) {
  return Object.hasOwn(globals.nodeBuiltin, identifier);
}

/**
 * Checks whether a recognized Node.js built-in global is writable (can be reassigned).
 *
 * @param {string} identifier - Identifier name to check.
 * @returns {boolean} True if writable, false if read-only or not present.
 */
export function isNodeBuiltinWritable(identifier) {
  return globals.nodeBuiltin[identifier] === true;
}

export { globals };
export default globals.nodeBuiltin;
test/contract.mjs
import assert from 'node:assert/strict';
import globals, { getNodeBuiltinGlobals, isNodeBuiltin, isNodeBuiltinWritable } from '../src/index.js';

// 1. globals.nodeBuiltin is a dictionary mapping Node.js built-in identifiers to boolean writeability flags
assert.equal(typeof globals, 'object', 'globals should be an object');
assert.notEqual(globals, null, 'globals should not be null');
const builtins = getNodeBuiltinGlobals();
assert.equal(typeof builtins, 'object', 'globals.nodeBuiltin should be an object');
assert.notEqual(builtins, null, 'globals.nodeBuiltin should not be null');
for (const [identifier, isWritable] of Object.entries(builtins)) {
  assert.equal(typeof identifier, 'string', `identifier ${identifier} must be a string`);
  assert.equal(typeof isWritable, 'boolean', `writeability for ${identifier} must be a boolean`);
}

// 2. globals.nodeBuiltin contains exactly 65 built-in identifier entries
assert.equal(Object.keys(builtins).length, 65, 'globals.nodeBuiltin should contain exactly 65 identifiers');

// 3. globals.nodeBuiltin marks all built-in identifiers as read-only with value false
for (const [identifier, isWritable] of Object.entries(builtins)) {
  assert.equal(isWritable, false, `identifier ${identifier} should be read-only (false)`);
  assert.equal(isNodeBuiltinWritable(identifier), false, `${identifier} should not be writable`);
}

// 4. globals.nodeBuiltin includes core Node.js process and execution identifiers process, Buffer, and global as read-only
const coreIdentifiers = ['process', 'Buffer', 'global'];
for (const id of coreIdentifiers) {
  assert.equal(isNodeBuiltin(id), true, `${id} must be recognized as a Node.js built-in`);
  assert.equal(builtins[id], false, `globals.nodeBuiltin.${id} should be false`);
  assert.equal(isNodeBuiltinWritable(id), false, `${id} must not be writable`);
}

// 5. globals.nodeBuiltin includes timer functions setTimeout, setInterval, setImmediate, clearTimeout, and clearInterval as read-only
const timerIdentifiers = ['setTimeout', 'setInterval', 'setImmediate', 'clearTimeout', 'clearInterval'];
for (const id of timerIdentifiers) {
  assert.equal(isNodeBuiltin(id), true, `${id} must be recognized as a Node.js built-in`);
  assert.equal(builtins[id], false, `globals.nodeBuiltin.${id} should be false`);
  assert.equal(isNodeBuiltinWritable(id), false, `${id} must not be writable`);
}

// 6. globals.nodeBuiltin includes standard Web APIs fetch, Request, Response, Headers, URL, and AbortController as read-only
const webApiIdentifiers = ['fetch', 'Request', 'Response', 'Headers', 'URL', 'AbortController'];
for (const id of webApiIdentifiers) {
  assert.equal(isNodeBuiltin(id), true, `${id} must be recognized as a Node.js built-in`);
  assert.equal(builtins[id], false, `globals.nodeBuiltin.${id} should be false`);
  assert.equal(isNodeBuiltinWritable(id), false, `${id} must not be writable`);
}

// 7. globals.nodeBuiltin includes streams and encoding APIs ReadableStream, WritableStream, TextEncoder, and TextDecoder as read-only
const streamAndEncodingIdentifiers = ['ReadableStream', 'WritableStream', 'TextEncoder', 'TextDecoder'];
for (const id of streamAndEncodingIdentifiers) {
  assert.equal(isNodeBuiltin(id), true, `${id} must be recognized as a Node.js built-in`);
  assert.equal(builtins[id], false, `globals.nodeBuiltin.${id} should be false`);
  assert.equal(isNodeBuiltinWritable(id), false, `${id} must not be writable`);
}

// Ensure unknown non-builtin identifiers return false
assert.equal(isNodeBuiltin('window'), false, 'window is not a nodeBuiltin global');
assert.equal(isNodeBuiltinWritable('window'), false, 'window is not writable');
assert.equal(isNodeBuiltin('nonExistentGlobalXYZ'), false, 'non-existent identifier should return false');

console.log('Contract test passed.');

Seeder de origem

anônimo