CodeSampleX

Пример

@types/node 24.13.5

Проверенный пример — npm @types/node 24.13.5. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: @types/node package.json declares version…

sha256:877e1164737d7d4f1e5c81cf79413fb8ec83dfcfc6f1f38ba2366796ba852986

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-11-28

Кейс

HOW
Цель
verify pkg:npm/%40types/node@24.13.5
Пакеты
Окружение
node 22.23.2
Создан
2026-11-28T23:33:59Z

Контракт

  1. @types/node package.json declares version 24.13.5, empty main, types entry index.d.ts, typeScriptVersion 5.6, and typesVersions mappings for <=5.6 (ts5.6/*) and <=5.7 (ts5.7/*)
  2. @types/node declares dependency undici-types ~7.18.0 and undici-types resolves with a 7.18.x manifest and index.d.ts entry point
  3. Every triple-slash reference path in index.d.ts, ts5.6/index.d.ts, and ts5.7/index.d.ts resolves to an existing non-empty declaration file; index.d.ts references es2020, esnext.disposable, and esnext.float16 while ts5.6 and ts5.7 include ./compatibility/float16array.d.ts
  4. sqlite.d.ts declares module node:sqlite with class DatabaseSync and Node 24 options timeout, readBigInts, returnArrays, allowBareNamedParameters, and allowUnknownNamedParameters
  5. web-globals/fetch.d.ts imports undici-types and declares global fetch, Headers, Request, Response, FormData, WebSocket, and EventSource
  6. Core declaration files (fs.d.ts, crypto.d.ts, buffer.d.ts, events.d.ts, path.d.ts, stream.d.ts, worker_threads.d.ts) declare both bare and node:-prefixed modules

Файлы

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/inspect.cjs
  • test/contract.cjs

Скачать артефакт с исходным кодом (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 pkg:npm/%40types/node@24.13.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/node@24.13.5
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.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:6d1c8ebb3a384164d63b572eb4337c3f3814629b76d37f4ae781ac6fb121dc90","constraints":{"executionContext":"node"},"contract":["@types/node package.json declares version 24.13.5, empty main, types entry index.d.ts, typeScriptVersion 5.6, and typesVersions mappings for \u003c=5.6 (ts5.6/*) and \u003c=5.7 (ts5.7/*)","@types/node declares dependency undici-types ~7.18.0 and undici-types resolves with a 7.18.x manifest and index.d.ts entry point","Every triple-slash reference path in index.d.ts, ts5.6/index.d.ts, and ts5.7/index.d.ts resolves to an existing non-empty declaration file; index.d.ts references es2020, esnext.disposable, and esnext.float16 while ts5.6 and ts5.7 include ./compatibility/float16array.d.ts","sqlite.d.ts declares module node:sqlite with class DatabaseSync and Node 24 options timeout, readBigInts, returnArrays, allowBareNamedParameters, and allowUnknownNamedParameters","web-globals/fetch.d.ts imports undici-types and declares global fetch, Headers, Request, Response, FormData, WebSocket, and EventSource","Core declaration files (fs.d.ts, crypto.d.ts, buffer.d.ts, events.d.ts, path.d.ts, stream.d.ts, worker_threads.d.ts) declare both bare and node:-prefixed modules"],"goal":"verify pkg:npm/%40types/node@24.13.5","kind":"HOW","packages":["pkg:npm/%40types/node@24.13.5"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/%40types/node@24.13.5"],"schemaVersion":1,"subject":"pkg:npm/%40types/node@24.13.5","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-types-node-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-types-node-sample",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/node": "24.13.5"
      }
    },
    "node_modules/@types/node": {
      "version": "24.13.5",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.5.tgz",
      "integrity": "sha512-TXyindR+lBr22aJIdMQzCFHPHR6cR4js838mRDCSz5hOKWZvZwsXSSiXDmjRj4iJmgl+sR9O+1mkoVBSMadNug==",
      "license": "MIT",
      "dependencies": {
        "undici-types": "~7.18.0"
      }
    },
    "node_modules/undici-types": {
      "version": "7.18.2",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
      "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "verify-types-node-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for @types/node@24.13.5",
  "license": "MIT-0",
  "main": "src/inspect.cjs",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@types/node": "24.13.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/node@24.13.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/node@24.13.5"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/inspect.cjs
"use strict";

const fs = require("node:fs");
const path = require("node:path");

function loadTypesNodePackage() {
  const pkgPath = require.resolve("@types/node/package.json");
  const rootDir = path.dirname(pkgPath);
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
  return { rootDir, pkg };
}

function loadUndiciTypesPackage(fromDir) {
  const pkgPath = require.resolve("undici-types/package.json", {
    paths: [fromDir],
  });
  const rootDir = path.dirname(pkgPath);
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
  return { rootDir, pkg };
}

function readDeclaration(rootDir, relPath) {
  const target = path.resolve(rootDir, relPath);
  return fs.readFileSync(target, "utf8");
}

function extractReferencePaths(content) {
  const results = [];
  const pattern = /\/\/\/\s*<reference\s+path="([^"]+)"\s*\/>/g;
  let match;
  while ((match = pattern.exec(content)) !== null) {
    results.push(match[1]);
  }
  return results;
}

function extractReferenceLibs(content) {
  const results = [];
  const pattern = /\/\/\/\s*<reference\s+lib="([^"]+)"\s*\/>/g;
  let match;
  while ((match = pattern.exec(content)) !== null) {
    results.push(match[1]);
  }
  return results;
}

function verifyReferenceGraph(rootDir, entryRelPath) {
  const entryPath = path.resolve(rootDir, entryRelPath);
  const entryDir = path.dirname(entryPath);
  const content = fs.readFileSync(entryPath, "utf8");
  const refPaths = extractReferencePaths(content);
  const missing = [];
  const empty = [];

  for (const rel of refPaths) {
    const resolved = path.resolve(entryDir, rel);
    if (!fs.existsSync(resolved)) {
      missing.push(rel);
      continue;
    }
    const stat = fs.statSync(resolved);
    if (!stat.isFile() || stat.size === 0) {
      empty.push(rel);
    }
  }

  return {
    entryRelPath,
    referenceCount: refPaths.length,
    refPaths,
    libs: extractReferenceLibs(content),
    missing,
    empty,
  };
}

function extractDeclaredModules(content) {
  const modules = [];
  const pattern = /declare\s+module\s+["']([^"']+)["']/g;
  let match;
  while ((match = pattern.exec(content)) !== null) {
    modules.push(match[1]);
  }
  return modules;
}

module.exports = {
  loadTypesNodePackage,
  loadUndiciTypesPackage,
  readDeclaration,
  extractReferencePaths,
  extractReferenceLibs,
  verifyReferenceGraph,
  extractDeclaredModules,
};
test/contract.cjs
"use strict";

const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const {
  loadTypesNodePackage,
  loadUndiciTypesPackage,
  readDeclaration,
  verifyReferenceGraph,
  extractDeclaredModules,
} = require("../src/inspect.cjs");

// 1. Package manifest and version checks
const { rootDir, pkg } = loadTypesNodePackage();
assert.equal(pkg.name, "@types/node");
assert.equal(pkg.version, "24.13.5");
assert.equal(pkg.main, "");
assert.equal(pkg.types, "index.d.ts");
assert.equal(pkg.typeScriptVersion, "5.6");
assert.deepEqual(pkg.typesVersions["<=5.6"], { "*": ["ts5.6/*"] });
assert.deepEqual(pkg.typesVersions["<=5.7"], { "*": ["ts5.7/*"] });
assert.equal(pkg.dependencies["undici-types"], "~7.18.0");

// 2. Transitive undici-types dependency resolves with a valid declaration entry point
const undici = loadUndiciTypesPackage(rootDir);
assert.equal(undici.pkg.name, "undici-types");
assert.match(undici.pkg.version, /^7\.18\.\d+$/);
assert.equal(undici.pkg.types, "index.d.ts");
assert.equal(
  fs.existsSync(path.resolve(undici.rootDir, undici.pkg.types)),
  true
);

// 3. Complete reference graph integrity across root, ts5.6, and ts5.7 entry points
const rootGraph = verifyReferenceGraph(rootDir, "index.d.ts");
assert.ok(rootGraph.referenceCount >= 60);
assert.deepEqual(rootGraph.missing, []);
assert.deepEqual(rootGraph.empty, []);
assert.deepEqual(rootGraph.libs, [
  "es2020",
  "esnext.disposable",
  "esnext.float16",
]);

const ts56Graph = verifyReferenceGraph(rootDir, "ts5.6/index.d.ts");
assert.ok(ts56Graph.referenceCount >= 60);
assert.deepEqual(ts56Graph.missing, []);
assert.deepEqual(ts56Graph.empty, []);
assert.ok(ts56Graph.refPaths.includes("./compatibility/float16array.d.ts"));

const ts57Graph = verifyReferenceGraph(rootDir, "ts5.7/index.d.ts");
assert.ok(ts57Graph.referenceCount >= 60);
assert.deepEqual(ts57Graph.missing, []);
assert.deepEqual(ts57Graph.empty, []);
assert.ok(ts57Graph.refPaths.includes("./compatibility/float16array.d.ts"));

// 4. Node 24 sqlite declaration coverage
const sqliteDecl = readDeclaration(rootDir, "sqlite.d.ts");
assert.deepEqual(extractDeclaredModules(sqliteDecl), ["node:sqlite"]);
assert.match(sqliteDecl, /\bclass\s+DatabaseSync\b/);
for (const optionName of [
  "timeout",
  "readBigInts",
  "returnArrays",
  "allowBareNamedParameters",
  "allowUnknownNamedParameters",
]) {
  assert.match(
    sqliteDecl,
    new RegExp(`\\b${optionName}\\?:\\s*`),
    `expected DatabaseSyncOptions.${optionName} in sqlite.d.ts`
  );
}

// 5. Web fetch globals backed by undici-types
const fetchDecl = readDeclaration(rootDir, "web-globals/fetch.d.ts");
assert.match(fetchDecl, /import\s+\*\s+as\s+undici\s+from\s+"undici-types"/);
assert.match(fetchDecl, /\bfunction\s+fetch\s*\(/);
for (const globalName of [
  "Headers",
  "Request",
  "Response",
  "FormData",
  "WebSocket",
  "EventSource",
]) {
  assert.match(
    fetchDecl,
    new RegExp(`\\bvar\\s+${globalName}:`),
    `expected global ${globalName} in web-globals/fetch.d.ts`
  );
}

// 6. Core built-in module declarations include both bare and node:-prefixed modules
const expectedModules = [
  ["fs.d.ts", ["fs", "node:fs"]],
  ["crypto.d.ts", ["crypto", "node:crypto"]],
  ["buffer.d.ts", ["buffer", "node:buffer"]],
  ["events.d.ts", ["events", "node:events"]],
  ["path.d.ts", ["path", "node:path", "path/posix", "node:path/posix", "path/win32", "node:path/win32"]],
  ["stream.d.ts", ["stream", "node:stream"]],
  ["worker_threads.d.ts", ["worker_threads", "node:worker_threads"]],
];

for (const [declFile, requiredModules] of expectedModules) {
  const declared = new Set(extractDeclaredModules(readDeclaration(rootDir, declFile)));
  for (const modName of requiredModules) {
    assert.ok(
      declared.has(modName),
      `expected ${declFile} to declare module "${modName}"`
    );
  }
}

console.log(
  `Verified @types/node@${pkg.version}: ${rootGraph.referenceCount} root references, ts5.6/ts5.7 compatibility graphs, undici-types@${undici.pkg.version}, node:sqlite, web-globals/fetch, and core module declarations.`
);

Исходный сидер

аноним