CodeSampleX

Sample

collect-v8-coverage 1.0.3: collect v8 code coverage with CoverageInstrumenter

Verified sample for npm collect-v8-coverage 1.0.3: collect v8 code coverage with CoverageInstrumenter. The contract ran on node 22 · linux alpine/x64 …

sha256:8acf89122104e78542b76bca22e55abad4cfea3170d6808d9e5f6b8a6d5d6b72

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
3
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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-26
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-07
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-08

Case

HOW
Goal
collect v8 code coverage with CoverageInstrumenter
Packages
Symbols
  • CoverageInstrumenter
Environment
node 22.23.2
Created
2026-08-26T06:40:49Z

Contract

  1. CoverageInstrumenter initializes with inspector session capabilities
  2. CoverageInstrumenter startInstrumenting connects inspector session and enables precise coverage
  3. CoverageInstrumenter stopInstrumenting returns script coverage array containing function ranges and invocation counts
  4. CoverageInstrumenter stopInstrumenting disables coverage tracking and profiler session

Files

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

Download the source artifact (tar.gz)

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: collect v8 code coverage with CoverageInstrumenter
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/collect-v8-coverage@1.0.3
Demonstrate these symbols/APIs:
  - CoverageInstrumenter

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:c74a49f0cc61223cdb1f38b5ed445fa09b525e1831d6a80b3e3ec417cfb30d1c","contract":["CoverageInstrumenter initializes with inspector session capabilities","CoverageInstrumenter startInstrumenting connects inspector session and enables precise coverage","CoverageInstrumenter stopInstrumenting returns script coverage array containing function ranges and invocation counts","CoverageInstrumenter stopInstrumenting disables coverage tracking and profiler session"],"goal":"collect v8 code coverage with CoverageInstrumenter","kind":"HOW","packages":["pkg:npm/collect-v8-coverage@1.0.3"],"schemaVersion":1,"symbols":["CoverageInstrumenter"]},"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/collect-v8-coverage@1.0.3"],"schemaVersion":1,"subject":"pkg:npm/collect-v8-coverage@1.0.3","symbols":["CoverageInstrumenter"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-collect-v8-coverage",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-collect-v8-coverage",
      "version": "1.0.0",
      "dependencies": {
        "collect-v8-coverage": "1.0.3"
      }
    },
    "node_modules/collect-v8-coverage": {
      "version": "1.0.3",
      "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz",
      "integrity": "sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-collect-v8-coverage",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "collect-v8-coverage": "1.0.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "collect v8 code coverage with CoverageInstrumenter",
  "kind": "HOW",
  "packages": [
    "pkg:npm/collect-v8-coverage@1.0.3"
  ],
  "symbols": [
    "CoverageInstrumenter"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { CoverageInstrumenter } from 'collect-v8-coverage';

// 1. CoverageInstrumenter initializes with inspector session capabilities
{
  const instrumenter = new CoverageInstrumenter();
  assert.ok(instrumenter instanceof CoverageInstrumenter);
  assert.equal(typeof instrumenter.startInstrumenting, 'function');
  assert.equal(typeof instrumenter.stopInstrumenting, 'function');
}

// 2. CoverageInstrumenter startInstrumenting connects inspector session and enables precise coverage
// 3. CoverageInstrumenter stopInstrumenting returns script coverage array containing function ranges and invocation counts
{
  const instrumenter = new CoverageInstrumenter();
  await instrumenter.startInstrumenting();

  function sampleFunction(a, b) {
    if (a > b) {
      return a * 2;
    }
    return b * 2;
  }

  const result = sampleFunction(10, 5);
  assert.equal(result, 20);

  const coverage = await instrumenter.stopInstrumenting();
  assert.ok(Array.isArray(coverage));
  assert.ok(coverage.length > 0);

  for (const script of coverage) {
    assert.equal(typeof script.scriptId, 'string');
    assert.equal(typeof script.url, 'string');
    assert.ok(Array.isArray(script.functions));
    for (const fn of script.functions) {
      assert.equal(typeof fn.functionName, 'string');
      assert.ok(Array.isArray(fn.ranges));
      assert.equal(typeof fn.isBlockCoverage, 'boolean');
      for (const range of fn.ranges) {
        assert.equal(typeof range.startOffset, 'number');
        assert.equal(typeof range.endOffset, 'number');
        assert.equal(typeof range.count, 'number');
      }
    }
  }

  const contractCoverage = coverage.find(item => item.url && item.url.includes('contract.mjs'));
  assert.ok(contractCoverage, 'expected coverage to include contract.mjs');
  const targetFn = contractCoverage.functions.find(fn => fn.functionName === 'sampleFunction');
  assert.ok(targetFn, 'expected coverage to record sampleFunction');
  assert.ok(targetFn.ranges.length > 0);
  assert.equal(targetFn.ranges[0].count, 1);
}

// 4. CoverageInstrumenter stopInstrumenting disables coverage tracking and profiler session
{
  const instrumenter = new CoverageInstrumenter();
  await instrumenter.startInstrumenting();
  const coverage = await instrumenter.stopInstrumenting();
  assert.ok(Array.isArray(coverage));
}

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous