Ejemplo
@types/js-yaml 4.0.9: load
Muestra verificada para npm @types/js-yaml 4.0.9: load. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: @types/js-yaml package.json…
sha256:525eba58d05c229ed197acc8fc9a82196bdf1dd161f870c347340add8f1d180a
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
- 2
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-23 |
| 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-07 |
Caso
HOW- Objetivo
- verify load in pkg:npm/%40types/js-yaml@4.0.9
- Paquetes
- Símbolos
-
- load
- Entorno
- node 22.23.2
- Creado
- 2026-08-23T17:41:19Z
Contrato
- @types/js-yaml package.json declares type definitions entry point index.d.ts and version 4.0.9
- @types/js-yaml index.d.ts declares load function taking string input and optional LoadOptions returning unknown
- @types/js-yaml index.d.ts declares LoadOptions interface with filename, onWarning, schema, json, and listener properties
- @types/js-yaml index.d.ts declares Schema class, YAMLException class, State interface, and EventType type
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Código fuente
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 load in pkg:npm/%40types/js-yaml@4.0.9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40types/js-yaml@4.0.9
Demonstrate these symbols/APIs:
- load
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.
{"case":{"caseId":"case:sha256:9886f034cb71903a282ddbfdb4af41d7d9906d4526d47146696d1ae3f60a0131","constraints":{"executionContext":"node"},"contract":["@types/js-yaml package.json declares type definitions entry point index.d.ts and version 4.0.9","@types/js-yaml index.d.ts declares load function taking string input and optional LoadOptions returning unknown","@types/js-yaml index.d.ts declares LoadOptions interface with filename, onWarning, schema, json, and listener properties","@types/js-yaml index.d.ts declares Schema class, YAMLException class, State interface, and EventType type"],"goal":"verify load in pkg:npm/%40types/js-yaml@4.0.9","kind":"HOW","packages":["pkg:npm/%40types/js-yaml@4.0.9"],"schemaVersion":1,"symbols":["load"]},"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/%40types/js-yaml@4.0.9"],"schemaVersion":1,"subject":"pkg:npm/%40types/js-yaml@4.0.9","symbols":["load"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-types-js-yaml-load",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-types-js-yaml-load",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@types/js-yaml": "4.0.9"
}
},
"node_modules/@types/js-yaml": {
"version": "4.0.9",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
"license": "MIT"
}
}
}
{
"name": "sample-types-js-yaml-load",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for @types/js-yaml load",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"@types/js-yaml": "4.0.9"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify load in pkg:npm/%40types/js-yaml@4.0.9",
"kind": "HOW",
"packages": [
"pkg:npm/%40types/js-yaml@4.0.9"
],
"symbols": [
"load"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const fs = require('node:fs');
const path = require('node:path');
/**
* Resolves the path to the @types/js-yaml declaration file.
* @returns {string} Absolute path to index.d.ts
*/
function getDeclarationPath() {
const pkgJsonPath = require.resolve('@types/js-yaml/package.json');
const pkgDir = path.dirname(pkgJsonPath);
return path.join(pkgDir, 'index.d.ts');
}
/**
* Loads the declaration file content from @types/js-yaml.
* @returns {string} The text content of index.d.ts
*/
function loadDeclarationContent() {
const declPath = getDeclarationPath();
return fs.readFileSync(declPath, 'utf8');
}
/**
* Validates that the declaration file defines expected TypeScript constructs for load and its dependencies.
* @returns {object} Summary of discovered type declarations
*/
function inspectTypeDefinitions() {
const content = loadDeclarationContent();
const hasNamespace = content.includes('export as namespace jsyaml;');
const hasLoadFunction = content.includes('export function load(str: string, opts?: LoadOptions): unknown;');
const hasLoadOptions = content.includes('export interface LoadOptions');
const hasFilenameOption = content.includes('filename?: string | undefined;');
const hasOnWarningOption = content.includes('onWarning?(this: null, e: YAMLException): void;');
const hasSchemaOption = content.includes('schema?: Schema | undefined;');
const hasJsonOption = content.includes('json?: boolean | undefined;');
const hasListenerOption = content.includes('listener?(this: State, eventType: EventType, state: State): void;');
const hasSchemaClass = content.includes('export class Schema');
const hasYamlExceptionClass = content.includes('export class YAMLException extends Error');
const hasStateInterface = content.includes('export interface State');
const hasEventType = content.includes('export type EventType = "open" | "close";');
return {
hasNamespace,
hasLoadFunction,
hasLoadOptions,
hasFilenameOption,
hasOnWarningOption,
hasSchemaOption,
hasJsonOption,
hasListenerOption,
hasSchemaClass,
hasYamlExceptionClass,
hasStateInterface,
hasEventType
};
}
module.exports = {
getDeclarationPath,
loadDeclarationContent,
inspectTypeDefinitions
};
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const { getDeclarationPath, loadDeclarationContent, inspectTypeDefinitions } = require('../src/index.js');
// 1. Verify package manifest exports and metadata
const pkgJson = require('@types/js-yaml/package.json');
assert.strictEqual(pkgJson.name, '@types/js-yaml', 'package name should match @types/js-yaml');
assert.strictEqual(pkgJson.version, '4.0.9', 'package version should match 4.0.9');
assert.strictEqual(pkgJson.types, 'index.d.ts', 'package types entry should point to index.d.ts');
assert.ok(pkgJson.exports && pkgJson.exports['.'], 'exports entry point should be configured');
// 2. Verify declaration file existence
const declPath = getDeclarationPath();
assert.strictEqual(fs.existsSync(declPath), true, 'index.d.ts should exist on disk');
// 3. Verify declaration content and structure
const content = loadDeclarationContent();
assert.strictEqual(typeof content, 'string', 'declaration content should be a string');
assert.strictEqual(content.includes('export as namespace jsyaml;'), true, 'declaration should declare jsyaml namespace');
// 4. Verify load function declaration signature
assert.strictEqual(
content.includes('export function load(str: string, opts?: LoadOptions): unknown;'),
true,
'index.d.ts must declare load function accepting string input and optional LoadOptions returning unknown'
);
// 5. Verify LoadOptions interface and member options
assert.strictEqual(content.includes('export interface LoadOptions'), true, 'index.d.ts must declare LoadOptions interface');
assert.strictEqual(content.includes('filename?: string | undefined;'), true, 'LoadOptions must declare optional filename property');
assert.strictEqual(content.includes('onWarning?(this: null, e: YAMLException): void;'), true, 'LoadOptions must declare onWarning hook');
assert.strictEqual(content.includes('schema?: Schema | undefined;'), true, 'LoadOptions must declare optional schema property');
assert.strictEqual(content.includes('json?: boolean | undefined;'), true, 'LoadOptions must declare optional json flag');
assert.strictEqual(content.includes('listener?(this: State, eventType: EventType, state: State): void;'), true, 'LoadOptions must declare parse event listener');
// 6. Verify supporting types used by load: Schema, YAMLException, State, EventType
assert.strictEqual(content.includes('export class Schema'), true, 'index.d.ts must declare Schema class');
assert.strictEqual(content.includes('export class YAMLException extends Error'), true, 'index.d.ts must declare YAMLException class');
assert.strictEqual(content.includes('export interface State'), true, 'index.d.ts must declare State interface');
assert.strictEqual(content.includes('export type EventType = "open" | "close";'), true, 'index.d.ts must declare EventType type');
// 7. Verify helper module inspection
const inspection = inspectTypeDefinitions();
assert.strictEqual(inspection.hasNamespace, true, 'inspection should confirm namespace');
assert.strictEqual(inspection.hasLoadFunction, true, 'inspection should confirm load function signature');
assert.strictEqual(inspection.hasLoadOptions, true, 'inspection should confirm LoadOptions interface');
assert.strictEqual(inspection.hasFilenameOption, true, 'inspection should confirm filename option');
assert.strictEqual(inspection.hasOnWarningOption, true, 'inspection should confirm onWarning option');
assert.strictEqual(inspection.hasSchemaOption, true, 'inspection should confirm schema option');
assert.strictEqual(inspection.hasJsonOption, true, 'inspection should confirm json option');
assert.strictEqual(inspection.hasListenerOption, true, 'inspection should confirm listener option');
assert.strictEqual(inspection.hasSchemaClass, true, 'inspection should confirm Schema class');
assert.strictEqual(inspection.hasYamlExceptionClass, true, 'inspection should confirm YAMLException class');
assert.strictEqual(inspection.hasStateInterface, true, 'inspection should confirm State interface');
assert.strictEqual(inspection.hasEventType, true, 'inspection should confirm EventType union');
console.log('Contract tests passed successfully.');
Seeder de origen
anónimo