Sample
js-yaml 4.1.0: load
Verified sample for npm js-yaml 4.1.0: load. The contract ran on node 22 · linux alpine/x64 · docker and passed: yaml.load parses YAML mapping, sequence, and…
sha256:65ea4d5b1a46193b007805523740c2971c59c60588f1ecd89996ef4c2a9e3367
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify js-yaml.load in pkg:npm/js-yaml@4.1.0
- Packages
- Symbols
-
- js-yaml.load
- Environment
- node 22.23.2
- Created
- 2026-08-28T03:39:00Z
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
Files
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
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.');
Origin Seeder
anonymous