CodeSampleX

Exemple

@webassemblyjs/ast 1.14.1: objectInstruction

Échantillon vérifié pour npm @webassemblyjs/ast 1.14.1: objectInstruction. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:781fc359b9b65989c5057466037c95a29819fb4521e5325444ac0e93a89ab76c

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 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify objectInstruction in pkg:npm/%40webassemblyjs/ast@1.14.1
Paquets
Symboles
  • objectInstruction
Environnement
node 22.23.2
Créé
2026-09-01T19:56:55Z

Contrat

  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

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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.');

Seeder d'origine

anonyme