Sample
js-yaml 4.1.0: Schema
Verified sample for npm js-yaml 4.1.0: Schema. The contract ran on node 22 · linux alpine/x64 · docker and passed: new yaml.Schema(type) instantiates a…
sha256:b533e7691f258bb33632b9d30b1c31a8dcda08defc74578051404dd3abc98f92
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.Schema in pkg:npm/js-yaml@4.1.0
- Packages
- Symbols
-
- js-yaml.Schema
- Environment
- node 22.23.2
- Created
- 2026-08-28T03:32:13Z
Contract
- new yaml.Schema(type) instantiates a custom Schema containing the explicit Type
- yaml.DEFAULT_SCHEMA.extend(type) creates a new Schema inheriting default types with added custom explicit Type
- yaml.DEFAULT_SCHEMA.extend([type1, type2]) creates a new Schema with multiple custom explicit Types
- yaml.DEFAULT_SCHEMA.extend({ implicit: [type] }) extends schema with custom implicit scalar Type
- yaml.load with extended Schema deserializes custom explicit tags into instantiated objects
- yaml.dump with extended Schema serializes custom objects with custom tag notation
- yaml.load with extended Schema resolves custom implicit scalar types automatically
- yaml.DEFAULT_SCHEMA.extend throws YAMLException when given invalid type definitions
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
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.Schema 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.Schema
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:49e7986e3830f5671e94e65545f4eeb60ad5ba9eae0872ea5f12d5264d5b24c1","constraints":{"executionContext":"node"},"contract":["new yaml.Schema(type) instantiates a custom Schema containing the explicit Type","yaml.DEFAULT_SCHEMA.extend(type) creates a new Schema inheriting default types with added custom explicit Type","yaml.DEFAULT_SCHEMA.extend([type1, type2]) creates a new Schema with multiple custom explicit Types","yaml.DEFAULT_SCHEMA.extend({ implicit: [type] }) extends schema with custom implicit scalar Type","yaml.load with extended Schema deserializes custom explicit tags into instantiated objects","yaml.dump with extended Schema serializes custom objects with custom tag notation","yaml.load with extended Schema resolves custom implicit scalar types automatically","yaml.DEFAULT_SCHEMA.extend throws YAMLException when given invalid type definitions"],"goal":"verify js-yaml.Schema in pkg:npm/js-yaml@4.1.0","kind":"HOW","packages":["pkg:npm/js-yaml@4.1.0"],"schemaVersion":1,"symbols":["js-yaml.Schema"]},"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/js-yaml@4.1.0"],"schemaVersion":1,"subject":"pkg:npm/js-yaml@4.1.0","symbols":["js-yaml.Schema"],"verifierAdapter":"node-typescript@1"}
{
"name": "js-yaml-schema-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "js-yaml-schema-verification",
"version": "1.0.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": "js-yaml-schema-verification",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for js-yaml.Schema",
"dependencies": {
"js-yaml": "4.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify js-yaml.Schema in pkg:npm/js-yaml@4.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/js-yaml@4.1.0"
],
"symbols": [
"js-yaml.Schema"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const assert = require('node:assert');
const yaml = require('js-yaml');
// Helper classes for custom types
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
}
const PointType = new yaml.Type('!point', {
kind: 'mapping',
resolve: function(data) {
return data !== null && typeof data === 'object' && typeof data.x === 'number' && typeof data.y === 'number';
},
construct: function(data) {
return new Point(data.x, data.y);
},
instanceOf: Point,
represent: function(point) {
return { x: point.x, y: point.y };
}
});
const PersonType = new yaml.Type('!person', {
kind: 'mapping',
resolve: function(data) {
return data !== null && typeof data === 'object' && typeof data.name === 'string' && typeof data.age === 'number';
},
construct: function(data) {
return new Person(data.name, data.age);
},
instanceOf: Person,
represent: function(person) {
return { name: person.name, age: person.age };
}
});
const HexType = new yaml.Type('!hex', {
kind: 'scalar',
resolve: function(data) {
return typeof data === 'string' && /^0x[0-9a-fA-F]+$/.test(data);
},
construct: function(data) {
return parseInt(data, 16);
},
predicate: function(data) {
return typeof data === 'number';
},
represent: function(data) {
return '0x' + data.toString(16);
}
});
const RegexType = new yaml.Type('!regex', {
kind: 'scalar',
resolve: function(data) {
return typeof data === 'string' && data.startsWith('/') && data.endsWith('/');
},
construct: function(data) {
return new RegExp(data.slice(1, -1));
}
});
// 1. new yaml.Schema(type) instantiates a custom Schema containing the explicit Type
const standaloneSchema = new yaml.Schema(PointType);
assert.ok(standaloneSchema instanceof yaml.Schema);
assert.ok(Array.isArray(standaloneSchema.explicit));
assert.ok(standaloneSchema.explicit.includes(PointType));
// 2. yaml.DEFAULT_SCHEMA.extend(type) creates a new Schema inheriting default types with added custom explicit Type
const pointSchema = yaml.DEFAULT_SCHEMA.extend(PointType);
assert.ok(pointSchema instanceof yaml.Schema);
assert.notStrictEqual(pointSchema, yaml.DEFAULT_SCHEMA);
// 3. yaml.DEFAULT_SCHEMA.extend([type1, type2]) creates a new Schema with multiple custom explicit Types
const multiSchema = yaml.DEFAULT_SCHEMA.extend([PointType, PersonType, HexType]);
assert.ok(multiSchema instanceof yaml.Schema);
// 4. yaml.DEFAULT_SCHEMA.extend({ implicit: [type] }) extends schema with custom implicit scalar Type
const implicitSchema = yaml.DEFAULT_SCHEMA.extend({ implicit: [RegexType] });
assert.ok(implicitSchema instanceof yaml.Schema);
assert.ok(implicitSchema.implicit.includes(RegexType));
// 5. yaml.load with extended Schema deserializes custom explicit tags into instantiated objects
const pointYaml = 'location: !point\n x: 15\n y: 30';
const loadedPoint = yaml.load(pointYaml, { schema: pointSchema });
assert.ok(loadedPoint.location instanceof Point);
assert.strictEqual(loadedPoint.location.x, 15);
assert.strictEqual(loadedPoint.location.y, 30);
const multiYaml = `
user: !person
name: Alice
age: 28
address: !point
x: 100
y: 200
flags: !hex 0x2a
`;
const loadedMulti = yaml.load(multiYaml, { schema: multiSchema });
assert.ok(loadedMulti.user instanceof Person);
assert.strictEqual(loadedMulti.user.name, 'Alice');
assert.strictEqual(loadedMulti.user.age, 28);
assert.ok(loadedMulti.address instanceof Point);
assert.strictEqual(loadedMulti.flags, 42);
// 6. yaml.dump with extended Schema serializes custom objects with custom tag notation
const pointDumped = yaml.dump({ location: new Point(15, 30) }, { schema: pointSchema });
assert.ok(pointDumped.includes('!point'));
const reloaded = yaml.load(pointDumped, { schema: pointSchema });
assert.ok(reloaded.location instanceof Point);
assert.strictEqual(reloaded.location.x, 15);
assert.strictEqual(reloaded.location.y, 30);
// 7. yaml.load with extended Schema resolves custom implicit scalar types automatically
const regexYaml = 'pattern: /abc[0-9]+/';
const loadedRegex = yaml.load(regexYaml, { schema: implicitSchema });
assert.ok(loadedRegex.pattern instanceof RegExp);
assert.ok(loadedRegex.pattern.test('abc1234'));
// 8. yaml.DEFAULT_SCHEMA.extend throws YAMLException when given invalid type definitions
assert.throws(() => {
yaml.DEFAULT_SCHEMA.extend('not-a-type');
}, yaml.YAMLException);
assert.throws(() => {
yaml.DEFAULT_SCHEMA.extend([{ invalid: true }]);
}, yaml.YAMLException);
console.log('Contract passed');
Origin Seeder
anonymous