CodeSampleX

サンプル

js-yaml 3.15.1

検証済みサンプル — npm js-yaml 3.15.1. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: yaml.safeLoad parses YAML string with scalars, arrays, and nested…

sha256:25ee6ddb57eb0259c7da115bf40850dd4e306246838818bffee041b701db870a

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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-24

ケース

HOW
ゴール
verify pkg:npm/js-yaml@3.15.1
パッケージ
環境
node 22.23.2
作成日
2026-08-24T20:23:56Z

コントラクト

  1. yaml.safeLoad parses YAML string with scalars, arrays, and nested mappings into JavaScript objects
  2. yaml.safeLoad handles null, boolean, integer, float, and date types accurately
  3. yaml.safeLoad throws YAMLException on invalid YAML syntax
  4. yaml.safeLoadAll parses multiple documents separated by --- in a single string
  5. yaml.safeDump serializes JavaScript objects into valid YAML format
  6. yaml.safeDump supports options such as indent and sortKeys
  7. yaml.safeLoad with FAILSAFE_SCHEMA parses all scalars as strings without implicit type casting
  8. yaml.safeLoad and yaml.safeDump round-trip preserves object structure and data integrity

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
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 pkg:npm/js-yaml@3.15.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/js-yaml@3.15.1
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.
csx.json
{"case":{"caseId":"case:sha256:34fcfac29a841a2cefd64d451a07c39cf15b7a932a59750d50426cacab266fcf","constraints":{"executionContext":"node"},"contract":["yaml.safeLoad parses YAML string with scalars, arrays, and nested mappings into JavaScript objects","yaml.safeLoad handles null, boolean, integer, float, and date types accurately","yaml.safeLoad throws YAMLException on invalid YAML syntax","yaml.safeLoadAll parses multiple documents separated by --- in a single string","yaml.safeDump serializes JavaScript objects into valid YAML format","yaml.safeDump supports options such as indent and sortKeys","yaml.safeLoad with FAILSAFE_SCHEMA parses all scalars as strings without implicit type casting","yaml.safeLoad and yaml.safeDump round-trip preserves object structure and data integrity"],"goal":"verify pkg:npm/js-yaml@3.15.1","kind":"HOW","packages":["pkg:npm/js-yaml@3.15.1"],"schemaVersion":1},"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@3.15.1"],"schemaVersion":1,"subject":"pkg:npm/js-yaml@3.15.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "js-yaml-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "js-yaml-verification",
      "version": "1.0.0",
      "dependencies": {
        "js-yaml": "3.15.1"
      }
    },
    "node_modules/argparse": {
      "version": "1.0.10",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
      "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
      "license": "MIT",
      "dependencies": {
        "sprintf-js": "~1.0.2"
      }
    },
    "node_modules/esprima": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
      "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
      "license": "BSD-2-Clause",
      "bin": {
        "esparse": "bin/esparse.js",
        "esvalidate": "bin/esvalidate.js"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/js-yaml": {
      "version": "3.15.1",
      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.1.tgz",
      "integrity": "sha512-S99WuO3HlhO3XN41EtYUNl9zzXjoJx7QvmipxsJVxtCBT0YHEFy+iOJhjSvrmV12nYhWpZaM8lPHkJm0yUMbag==",
      "license": "MIT",
      "dependencies": {
        "argparse": "^1.0.7",
        "esprima": "^4.0.0"
      },
      "bin": {
        "js-yaml": "bin/js-yaml.js"
      }
    },
    "node_modules/sprintf-js": {
      "version": "1.0.3",
      "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
      "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
      "license": "BSD-3-Clause"
    }
  }
}
package.json
{
  "name": "js-yaml-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for js-yaml",
  "dependencies": {
    "js-yaml": "3.15.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/js-yaml@3.15.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/js-yaml@3.15.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
const assert = require('node:assert');
const yaml = require('js-yaml');

// 1. yaml.safeLoad parses YAML string with scalars, arrays, and nested mappings into JavaScript objects
const doc1 = `
title: CodeSampleX
count: 42
items:
  - alpha
  - beta
nested:
  enabled: true
`;
const parsed1 = yaml.safeLoad(doc1);
assert.deepStrictEqual(parsed1, {
  title: 'CodeSampleX',
  count: 42,
  items: ['alpha', 'beta'],
  nested: { enabled: true }
});

// 2. yaml.safeLoad handles null, boolean, integer, float, and date types accurately
const doc2 = `
nullVal: null
tildeNull: ~
boolTrue: true
boolFalse: false
intVal: 100
floatVal: 3.1415
dateVal: 2026-08-21T00:00:00Z
`;
const parsed2 = yaml.safeLoad(doc2);
assert.strictEqual(parsed2.nullVal, null);
assert.strictEqual(parsed2.tildeNull, null);
assert.strictEqual(parsed2.boolTrue, true);
assert.strictEqual(parsed2.boolFalse, false);
assert.strictEqual(parsed2.intVal, 100);
assert.strictEqual(parsed2.floatVal, 3.1415);
assert.ok(parsed2.dateVal instanceof Date);
assert.strictEqual(parsed2.dateVal.toISOString(), '2026-08-21T00:00:00.000Z');

// 3. yaml.safeLoad throws YAMLException on invalid YAML syntax
assert.throws(() => {
  yaml.safeLoad('foo: [bar: baz');
}, yaml.YAMLException);

// 4. yaml.safeLoadAll parses multiple documents separated by --- in a single string
const multiDoc = `
---
doc: 1
---
doc: 2
`;
const docs = [];
yaml.safeLoadAll(multiDoc, (d) => docs.push(d));
assert.deepStrictEqual(docs, [{ doc: 1 }, { doc: 2 }]);

// 5. yaml.safeDump serializes JavaScript objects into valid YAML format
const obj = { name: 'test', values: [1, 2, 3] };
const dumped = yaml.safeDump(obj);
assert.strictEqual(typeof dumped, 'string');
assert.deepStrictEqual(yaml.safeLoad(dumped), obj);

// 6. yaml.safeDump supports options such as indent and sortKeys
const sortObj = { z: 1, a: 2, m: 3 };
const dumpedSorted = yaml.safeDump(sortObj, { sortKeys: true, indent: 4 });
assert.strictEqual(dumpedSorted, 'a: 2\nm: 3\nz: 1\n');

// 7. yaml.safeLoad with FAILSAFE_SCHEMA parses all scalars as strings without implicit type casting
const failsafeDoc = 'number: 123\nflag: true';
const failsafeParsed = yaml.safeLoad(failsafeDoc, { schema: yaml.FAILSAFE_SCHEMA });
assert.strictEqual(failsafeParsed.number, '123');
assert.strictEqual(failsafeParsed.flag, 'true');

// 8. yaml.safeLoad and yaml.safeDump round-trip preserves object structure and data integrity
const complexObj = {
  service: 'api-server',
  port: 8080,
  tags: ['web', 'node'],
  meta: { active: true, version: 1.5 }
};
const roundTrip = yaml.safeLoad(yaml.safeDump(complexObj));
assert.deepStrictEqual(roundTrip, complexObj);

console.log('Contract passed');

オリジンシーダー

匿名