Exemplo
js-yaml 4.1.0: load
Amostra verificada para npm js-yaml 4.1.0: load. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: yaml.load parses YAML mapping, sequence…
sha256:65ea4d5b1a46193b007805523740c2971c59c60588f1ecd89996ef4c2a9e3367
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-28 |
Caso
HOW- Objetivo
- verify js-yaml.load in pkg:npm/js-yaml@4.1.0
- Pacotes
- Símbolos
-
- js-yaml.load
- Ambiente
- node 22.23.2
- Criado
- 2026-08-28T03:39:00Z
Contrato
- yaml.load parses YAML mapping, sequence, and scalar types into JavaScript values
- yaml.load returns undefined for empty input string
- yaml.load returns null for comment-only input or explicit null/tilde scalar
- yaml.load throws YAMLException when stream contains multiple documents
- yaml.load throws YAMLException on duplicate mapping keys by default
- yaml.load allows duplicate mapping keys when json option is enabled
- yaml.load respects schema option such as FAILSAFE_SCHEMA preserving scalar strings
- yaml.load invokes custom listener callback during parsing
- yaml.load throws YAMLException on invalid YAML syntax
Arquivos
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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 js-yaml.load in pkg:npm/js-yaml@4.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/js-yaml@4.1.0
Demonstrate these symbols/APIs:
- js-yaml.load
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:95f61d883dbd9f993184f411e4f9648d4137f1ef7732e987ece8d9024d7c3749","contract":["yaml.load parses YAML mapping, sequence, and scalar types into JavaScript values","yaml.load returns undefined for empty input string","yaml.load returns null for comment-only input or explicit null/tilde scalar","yaml.load throws YAMLException when stream contains multiple documents","yaml.load throws YAMLException on duplicate mapping keys by default","yaml.load allows duplicate mapping keys when json option is enabled","yaml.load respects schema option such as FAILSAFE_SCHEMA preserving scalar strings","yaml.load invokes custom listener callback during parsing","yaml.load throws YAMLException on invalid YAML syntax"],"goal":"verify js-yaml.load in pkg:npm/js-yaml@4.1.0","kind":"HOW","packages":["pkg:npm/js-yaml@4.1.0"],"schemaVersion":1,"symbols":["js-yaml.load"]},"contractCommand":["node","test/contract.mjs"],"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/js-yaml@4.1.0"],"schemaVersion":1,"subject":"pkg:npm/js-yaml@4.1.0","symbols":["js-yaml.load"],"verifierAdapter":"node-typescript@1"}
const yaml = require('js-yaml');
/**
* Parses a YAML string into a JavaScript value.
*
* @param {string} input - YAML string to parse.
* @param {object} [options] - Parsing options.
* @returns {*} Parsed value.
*/
function parseYaml(input, options) {
return yaml.load(input, options);
}
module.exports = {
parseYaml,
yaml,
};
{
"name": "sample-js-yaml-load",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-js-yaml-load",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"js-yaml": "4.1.0"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"license": "Python-2.0"
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
}
}
}
{
"name": "sample-js-yaml-load",
"version": "1.0.0",
"description": "Clean-room sample verifying js-yaml.load functionality",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"js-yaml": "4.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify js-yaml.load in pkg:npm/js-yaml@4.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/js-yaml@4.1.0"
],
"symbols": [
"js-yaml.load"
]
}
import assert from 'node:assert';
import yaml from 'js-yaml';
import { parseYaml } from '../index.js';
// 1. Basic parsing of YAML mapping, sequence, and scalar types
const yamlSource = `
name: CodeSampleX
version: 4
active: true
pi: 3.14
items:
- first
- second
nested:
key: value
`;
const doc1 = parseYaml(yamlSource);
assert.deepStrictEqual(doc1, {
name: 'CodeSampleX',
version: 4,
active: true,
pi: 3.14,
items: ['first', 'second'],
nested: {
key: 'value',
},
});
const directDoc = yaml.load(yamlSource);
assert.deepStrictEqual(directDoc, doc1);
// 2. Empty string returns undefined
assert.strictEqual(parseYaml(''), undefined);
assert.strictEqual(yaml.load(''), undefined);
// 3. Comment-only or explicit null returns null
assert.strictEqual(parseYaml('# comment only\n'), null);
assert.strictEqual(parseYaml('null'), null);
assert.strictEqual(parseYaml('~'), null);
// 4. Multiple documents in a stream throw YAMLException in load()
assert.throws(
() => {
parseYaml('---\ndoc: 1\n---\ndoc: 2\n');
},
{
name: 'YAMLException',
}
);
// 5. Duplicate keys throw YAMLException by default
assert.throws(
() => {
parseYaml('key: first\nkey: second');
},
{
name: 'YAMLException',
}
);
// 6. Duplicate keys are permitted when json: true option is enabled
const jsonModeDoc = parseYaml('key: first\nkey: second', { json: true });
assert.deepStrictEqual(jsonModeDoc, { key: 'second' });
// 7. Schema option: FAILSAFE_SCHEMA preserves scalar types as strings
const failsafeDoc = parseYaml('num: 123\nflag: true', { schema: yaml.FAILSAFE_SCHEMA });
assert.deepStrictEqual(failsafeDoc, { num: '123', flag: 'true' });
// 8. Custom listener option receives parse events
const events = [];
parseYaml('item: value', {
listener: (op, state) => {
events.push({ op, hasResult: state.result !== undefined });
},
});
assert.strictEqual(events.length > 0, true);
// 9. Invalid YAML syntax throws YAMLException
assert.throws(
() => {
parseYaml('foo: : bar');
},
{
name: 'YAMLException',
}
);
console.log('All contract assertions passed.');
Seeder de origem
anônimo