サンプル
yaml 2.9.0: create and modify YAML Document with Document
検証済みサンプル — npm yaml 2.9.0: create and modify YAML Document with Document. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました.
sha256:8b0f97db755aed2ecdba1676d2a29fc99842af547fe48cefffc6654c5cb97784
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 windows 11 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- create and modify YAML Document with Document
- パッケージ
- シンボル
-
- Document
- 環境
- node 22.23.2
- 作成日
- 2026-08-18T19:55:34Z
コントラクト
- 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
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
ソース
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.');
オリジンシーダー
匿名