Exemple
yaml 2.9.0: create and modify YAML Document with Document
Échantillon vérifié pour npm yaml 2.9.0: create and modify YAML Document with Document. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a…
sha256:8b0f97db755aed2ecdba1676d2a29fc99842af547fe48cefffc6654c5cb97784
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 windows 11 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
Cas
HOW- Objectif
- create and modify YAML Document with Document
- Paquets
- Symboles
-
- Document
- Environnement
- node 22.23.2
- Créé
- 2026-08-18T19:55:34Z
Contrat
- new Document initializes a YAML Document from JavaScript data structures
- doc.set and doc.get read and modify top-level document properties
- doc.toJS converts the Document to a plain JavaScript object
- doc.toString serializes the Document structure to valid YAML string output
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
Code 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: create and modify YAML Document with Document
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/yaml@2.9.0
Demonstrate these symbols/APIs:
- Document
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:bc92f63edfc7304176af8388781cb3e0922c51af68cc0802e82474ecdfd7bb3a","constraints":{"executionContext":"node"},"contract":["new Document initializes a YAML Document from JavaScript data structures","doc.set and doc.get read and modify top-level document properties","doc.toJS converts the Document to a plain JavaScript object","doc.toString serializes the Document structure to valid YAML string output"],"goal":"create and modify YAML Document with Document","kind":"HOW","packages":["pkg:npm/yaml@2.9.0"],"schemaVersion":1,"symbols":["Document"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"cjs","os":"windows","osVersionBucket":"11","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/yaml@2.9.0"],"schemaVersion":1,"symbols":["Document"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"yaml": "2.9.0"
}
},
"node_modules/yaml": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz",
"integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==",
"license": "ISC",
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14.6"
},
"funding": {
"url": "https://github.com/sponsors/eemeli"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"private": true,
"dependencies": {
"yaml": "2.9.0"
}
}
{
"schemaVersion": 1,
"goal": "create and modify YAML Document with Document",
"kind": "HOW",
"packages": [
"pkg:npm/yaml@2.9.0"
],
"symbols": [
"Document"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
const assert = require('node:assert/strict');
const { Document } = require('yaml');
// Contract 1: new Document initializes a YAML Document from JavaScript data structures
const initialData = {
service: 'order-api',
replicas: 3,
environment: 'staging',
tags: ['ecommerce', 'backend']
};
const doc = new Document(initialData);
assert.equal(doc.contents.items.length, 4);
// Contract 2: doc.set and doc.get read and modify top-level document properties
assert.equal(doc.get('service'), 'order-api');
assert.equal(doc.get('replicas'), 3);
doc.set('replicas', 5);
assert.equal(doc.get('replicas'), 5);
doc.set('region', 'us-east-1');
assert.equal(doc.get('region'), 'us-east-1');
// Contract 3: doc.toJS converts the Document to a plain JavaScript object
const jsResult = doc.toJS();
assert.deepEqual(jsResult, {
service: 'order-api',
replicas: 5,
environment: 'staging',
tags: ['ecommerce', 'backend'],
region: 'us-east-1'
});
// Contract 4: doc.toString serializes the Document structure to valid YAML string output
const yamlOutput = doc.toString();
assert.equal(typeof yamlOutput, 'string');
assert.ok(yamlOutput.includes('service: order-api'));
assert.ok(yamlOutput.includes('replicas: 5'));
assert.ok(yamlOutput.includes('- ecommerce'));
assert.ok(yamlOutput.includes('region: us-east-1'));
console.log('Contract verification passed successfully.');
Seeder d'origine
anonyme