CodeSampleX

サンプル

esrecurse 4.3.0

検証済みサンプル — npm esrecurse 4.3.0. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: assert esrecurse.version is 4.3.0

sha256:4962f038023ce1e7c965583a42346c15f006c129e18d66504ecd1d95cd5d9e12

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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@1
2026-08-20

ケース

HOW
ゴール
verify pkg:npm/esrecurse@4.3.0
パッケージ
環境
node 22.23.2
作成日
2026-08-20T17:40:17Z

コントラクト

  1. assert esrecurse.version is 4.3.0
  2. assert esrecurse.visit traverses AST nodes and invokes visitor callbacks matching node types
  3. assert esrecurse.Visitor subclass enables stateful AST traversal and child visiting with this.visitChildren
  4. assert esrecurse.visit supports childVisitorKeys option for custom AST node types
  5. assert esrecurse.visit supports fallback option iteration for unknown node types
  6. assert esrecurse.visit safely handles null and undefined nodes without throwing

ファイル

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

ソースアーティファクトをダウンロード (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/esrecurse@4.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/esrecurse@4.3.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - 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:dab93963d64b22ea16f188258509d59756b4dd31663a59bc47d49894d55f6daa","constraints":{"executionContext":"node"},"contract":["assert esrecurse.version is 4.3.0","assert esrecurse.visit traverses AST nodes and invokes visitor callbacks matching node types","assert esrecurse.Visitor subclass enables stateful AST traversal and child visiting with this.visitChildren","assert esrecurse.visit supports childVisitorKeys option for custom AST node types","assert esrecurse.visit supports fallback option iteration for unknown node types","assert esrecurse.visit safely handles null and undefined nodes without throwing"],"goal":"verify pkg:npm/esrecurse@4.3.0","kind":"HOW","packages":["pkg:npm/esrecurse@4.3.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/esrecurse@4.3.0"],"schemaVersion":1,"subject":"pkg:npm/esrecurse@4.3.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "csx-sample-esrecurse",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "csx-sample-esrecurse",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "esrecurse": "4.3.0"
      }
    },
    "node_modules/esrecurse": {
      "version": "4.3.0",
      "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
      "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
      "license": "BSD-2-Clause",
      "dependencies": {
        "estraverse": "^5.2.0"
      },
      "engines": {
        "node": ">=4.0"
      }
    },
    "node_modules/estraverse": {
      "version": "5.3.0",
      "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
      "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=4.0"
      }
    }
  }
}
package.json
{
  "name": "csx-sample-esrecurse",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for esrecurse",
  "main": "test/contract.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "esrecurse": "4.3.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/esrecurse@4.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/esrecurse@4.3.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require('node:assert/strict');
const esrecurse = require('esrecurse');

// 1. Version property
assert.strictEqual(typeof esrecurse.version, 'string');
assert.strictEqual(esrecurse.version, '4.3.0');

// 2. esrecurse.visit traverses AST nodes and calls visitor handlers matching node type
const ast = {
  type: 'Program',
  body: [
    {
      type: 'VariableDeclaration',
      kind: 'const',
      declarations: [
        {
          type: 'VariableDeclarator',
          id: { type: 'Identifier', name: 'answer' },
          init: { type: 'Literal', value: 42 }
        }
      ]
    },
    {
      type: 'FunctionDeclaration',
      id: { type: 'Identifier', name: 'compute' },
      params: [{ type: 'Identifier', name: 'input' }],
      body: {
        type: 'BlockStatement',
        body: [
          {
            type: 'ReturnStatement',
            argument: {
              type: 'BinaryExpression',
              operator: '+',
              left: { type: 'Identifier', name: 'input' },
              right: { type: 'Identifier', name: 'answer' }
            }
          }
        ]
      }
    }
  ]
};

const visitedIdentifiers = [];
esrecurse.visit(ast, {
  Identifier(node) {
    visitedIdentifiers.push(node.name);
  }
});
assert.deepStrictEqual(visitedIdentifiers, ['answer', 'compute', 'input', 'input', 'answer']);

// 3. Visitor class extension with visitChildren
class LiteralCollector extends esrecurse.Visitor {
  constructor() {
    super();
    this.literals = [];
  }
  Literal(node) {
    this.literals.push(node.value);
  }
}

const collector = new LiteralCollector();
collector.visit(ast);
assert.deepStrictEqual(collector.literals, [42]);

// 4. Custom childVisitorKeys for custom AST nodes
const customAst = {
  type: 'CustomModule',
  customChildren: [
    { type: 'Identifier', name: 'customA' },
    { type: 'Identifier', name: 'customB' }
  ]
};
const customNames = [];
esrecurse.visit(
  customAst,
  {
    Identifier(node) {
      customNames.push(node.name);
    }
  },
  {
    childVisitorKeys: {
      CustomModule: ['customChildren']
    }
  }
);
assert.deepStrictEqual(customNames, ['customA', 'customB']);

// 5. Fallback iteration for unknown node types
const arbitraryAst = {
  type: 'UnknownWrapper',
  item: { type: 'Identifier', name: 'wrappedVar' }
};
const fallbackNames = [];
esrecurse.visit(
  arbitraryAst,
  {
    Identifier(node) {
      fallbackNames.push(node.name);
    }
  },
  { fallback: 'iteration' }
);
assert.deepStrictEqual(fallbackNames, ['wrappedVar']);

// 6. Safe handling of null and undefined nodes
assert.doesNotThrow(() => {
  esrecurse.visit(null, {});
  esrecurse.visit(undefined, {});
});

console.log('All esrecurse contract assertions passed.');

オリジンシーダー

匿名