CodeSampleX

Пример

@webassemblyjs/ast 1.14.1: objectInstruction

Проверенный пример — npm @webassemblyjs/ast 1.14.1: objectInstruction. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден.

sha256:781fc359b9b65989c5057466037c95a29819fb4521e5325444ac0e93a89ab76c

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-01

Кейс

HOW
Цель
verify objectInstruction in pkg:npm/%40webassemblyjs/ast@1.14.1
Пакеты
Символы
  • objectInstruction
Окружение
node 22.23.2
Создан
2026-09-01T19:56:55Z

Контракт

  1. @webassemblyjs/ast exports objectInstruction builder function
  2. objectInstruction creates an Instr node with id and object properties and default empty args
  3. objectInstruction accepts custom instruction args and sets them on the Instr node
  4. objectInstruction accepts namedArgs options and sets them on the Instr node
  5. isInstr recognizes nodes created by objectInstruction as valid Instr nodes
  6. traverse visits Instr nodes created by objectInstruction

Файлы

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

Скачать артефакт с исходным кодом (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 objectInstruction in pkg:npm/%40webassemblyjs/ast@1.14.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40webassemblyjs/ast@1.14.1
Demonstrate these symbols/APIs:
  - objectInstruction
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:8c63d1b09e652455e54cfb470a59ad736fae08fbc98f07f463fe8974bd591ad7","constraints":{"executionContext":"node"},"contract":["@webassemblyjs/ast exports objectInstruction builder function","objectInstruction creates an Instr node with id and object properties and default empty args","objectInstruction accepts custom instruction args and sets them on the Instr node","objectInstruction accepts namedArgs options and sets them on the Instr node","isInstr recognizes nodes created by objectInstruction as valid Instr nodes","traverse visits Instr nodes created by objectInstruction"],"goal":"verify objectInstruction in pkg:npm/%40webassemblyjs/ast@1.14.1","kind":"HOW","packages":["pkg:npm/%40webassemblyjs/ast@1.14.1"],"schemaVersion":1,"symbols":["objectInstruction"]},"contractCommand":["node","test/contract.mjs"],"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/%40webassemblyjs/ast@1.14.1"],"schemaVersion":1,"subject":"pkg:npm/%40webassemblyjs/ast@1.14.1","symbols":["objectInstruction"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-webassemblyjs-ast-object-instruction",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-webassemblyjs-ast-object-instruction",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@webassemblyjs/ast": "1.14.1"
      }
    },
    "node_modules/@webassemblyjs/ast": {
      "version": "1.14.1",
      "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz",
      "integrity": "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==",
      "license": "MIT",
      "dependencies": {
        "@webassemblyjs/helper-numbers": "1.13.2",
        "@webassemblyjs/helper-wasm-bytecode": "1.13.2"
      }
    },
    "node_modules/@webassemblyjs/floating-point-hex-parser": {
      "version": "1.13.2",
      "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz",
      "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==",
      "license": "MIT"
    },
    "node_modules/@webassemblyjs/helper-api-error": {
      "version": "1.13.2",
      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz",
      "integrity": "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==",
      "license": "MIT"
    },
    "node_modules/@webassemblyjs/helper-numbers": {
      "version": "1.13.2",
      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz",
      "integrity": "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==",
      "license": "MIT",
      "dependencies": {
        "@webassemblyjs/floating-point-hex-parser": "1.13.2",
        "@webassemblyjs/helper-api-error": "1.13.2",
        "@xtuc/long": "4.2.2"
      }
    },
    "node_modules/@webassemblyjs/helper-wasm-bytecode": {
      "version": "1.13.2",
      "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz",
      "integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==",
      "license": "MIT"
    },
    "node_modules/@xtuc/long": {
      "version": "4.2.2",
      "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
      "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
      "license": "Apache-2.0"
    }
  }
}
package.json
{
  "name": "sample-webassemblyjs-ast-object-instruction",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "@webassemblyjs/ast": "1.14.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify objectInstruction in pkg:npm/%40webassemblyjs/ast@1.14.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40webassemblyjs/ast@1.14.1"
  ],
  "symbols": [
    "objectInstruction"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  objectInstruction,
  isInstr,
  traverse,
  identifier,
  numberLiteralFromRaw,
} from '@webassemblyjs/ast';

// 1. @webassemblyjs/ast exports objectInstruction builder function
assert.equal(typeof objectInstruction, 'function');

// 2. objectInstruction creates an Instr node with id and object properties and default empty args
const nopNode = objectInstruction('nop', 'test');
assert.equal(nopNode.type, 'Instr');
assert.equal(nopNode.id, 'nop');
assert.equal(nopNode.object, 'test');
assert.deepEqual(nopNode.args, []);

// 3. objectInstruction accepts custom instruction args and sets them on the Instr node
const constNode = objectInstruction('const', 'i32', [numberLiteralFromRaw(42)]);
assert.equal(constNode.type, 'Instr');
assert.equal(constNode.id, 'const');
assert.equal(constNode.object, 'i32');
assert.equal(constNode.args.length, 1);
assert.equal(constNode.args[0].type, 'NumberLiteral');
assert.equal(constNode.args[0].value, 42);

// 4. objectInstruction accepts namedArgs options and sets them on the Instr node
const offsetArg = numberLiteralFromRaw(4);
const loadNode = objectInstruction('load', 'i32', [numberLiteralFromRaw(0)], { offset: offsetArg });
assert.equal(loadNode.type, 'Instr');
assert.equal(loadNode.id, 'load');
assert.equal(loadNode.object, 'i32');
assert.ok(loadNode.namedArgs);
assert.equal(loadNode.namedArgs.offset, offsetArg);

// 5. isInstr recognizes nodes created by objectInstruction as valid Instr nodes
assert.equal(isInstr(nopNode), true);
assert.equal(isInstr(constNode), true);
assert.equal(isInstr(loadNode), true);

// 6. traverse visits Instr nodes created by objectInstruction
let visited = false;
traverse(constNode, {
  Instr(path) {
    if (path.node.id === 'const' && path.node.object === 'i32') {
      visited = true;
    }
  },
});
assert.equal(visited, true);

console.log('All contract tests passed.');

Исходный сидер

аноним