CodeSampleX

Sample

real-require 1.0.0: realImport

Verified sample for npm real-require 1.0.0: realImport. The contract ran on node 22 · linux debian/x64 · docker and passed: realImport is exported as a…

sha256:9658e8538cebb3037499f2b00be62dce628572c412b530b082039f8d2d3021ed

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
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
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-10-12

Case

HOW
Goal
verify real-require.realImport in pkg:npm/real-require@1.0.0
Packages
Symbols
  • real-require.realImport
Created
2026-10-12T09:16:38Z

Contract

  1. realImport is exported as a callable function from real-require
  2. realImport returns a Promise resolving to the module namespace for built-in modules
  3. realImport dynamically imports installed packages by package name
  4. realImport dynamically imports local ES modules via file URL and exposes named and default exports
  5. realImport rejects with an error when attempting to import a nonexistent module
  6. dynamicImport helper wraps realImport to load modules dynamically
  7. importNamedExport helper retrieves a specific named export from a dynamically imported module

Files

  • PROMPT.md
  • csx.json
  • fixtures/helper.mjs
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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: verify real-require.realImport in pkg:npm/real-require@1.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/real-require@1.0.0
Demonstrate these symbols/APIs:
  - real-require.realImport

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:55094863593fc5ccd36c51f9b52421bd7d8e5d48bb013db35ea28c2a5b0e0359","contract":["realImport is exported as a callable function from real-require","realImport returns a Promise resolving to the module namespace for built-in modules","realImport dynamically imports installed packages by package name","realImport dynamically imports local ES modules via file URL and exposes named and default exports","realImport rejects with an error when attempting to import a nonexistent module","dynamicImport helper wraps realImport to load modules dynamically","importNamedExport helper retrieves a specific named export from a dynamically imported module"],"goal":"verify real-require.realImport in pkg:npm/real-require@1.0.0","kind":"HOW","packages":["pkg:npm/real-require@1.0.0"],"schemaVersion":1,"symbols":["real-require.realImport"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/real-require@1.0.0"],"schemaVersion":1,"subject":"pkg:npm/real-require@1.0.0","symbols":["real-require.realImport"],"verifierAdapter":"node-typescript@1"}
fixtures/helper.mjs
export const greeting = 'hello from fixture';

export function calculateSum(a, b) {
  return a + b;
}

export default {
  type: 'fixture-module',
  active: true
};
package-lock.json
{
  "name": "sample-real-require",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-real-require",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "real-require": "1.0.0"
      }
    },
    "node_modules/real-require": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz",
      "integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-real-require",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for real-require@1.0.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "real-require": "1.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify real-require.realImport in pkg:npm/real-require@1.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/real-require@1.0.0"
  ],
  "symbols": [
    "real-require.realImport"
  ]
}
src/index.js
'use strict';

const { realImport, realRequire } = require('real-require');

/**
 * Dynamically imports a module by specifier or file URL using realImport.
 *
 * @param {string} specifier - Module specifier, path, or file URL.
 * @returns {Promise<any>} Module namespace object.
 */
async function dynamicImport(specifier) {
  return realImport(specifier);
}

/**
 * Dynamically imports a module and retrieves a specific named export.
 *
 * @param {string} specifier - Module specifier, path, or file URL.
 * @param {string} exportName - Name of the exported property to retrieve.
 * @returns {Promise<any>} The exported value.
 */
async function importNamedExport(specifier, exportName) {
  const moduleNamespace = await realImport(specifier);
  return moduleNamespace[exportName];
}

module.exports = {
  realImport,
  realRequire,
  dynamicImport,
  importNamedExport
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  realImport,
  realRequire,
  dynamicImport,
  importNamedExport
} = require('../src/index.js');

async function main() {
  // 1. realImport is exported as a callable function from real-require
  assert.equal(typeof realImport, 'function', 'realImport should be a function');
  assert.equal(typeof realRequire, 'function', 'realRequire should be a function');

  // 2. realImport returns a Promise resolving to the module namespace for built-in modules
  const pathModulePromise = realImport('node:path');
  assert(pathModulePromise instanceof Promise, 'realImport should return a Promise');
  const pathModule = await pathModulePromise;
  assert(pathModule !== null && typeof pathModule === 'object', 'Resolved module should be an object');
  assert.equal(typeof pathModule.join, 'function', 'pathModule should expose join function');
  assert.equal(pathModule.posix.join('foo', 'bar'), 'foo/bar', 'join should concatenate path segments');

  // 3. realImport dynamically imports installed packages by package name
  const selfPkg = await realImport('real-require');
  assert(selfPkg !== null && typeof selfPkg === 'object', 'Installed package should resolve to object');
  assert.equal(typeof selfPkg.realImport, 'function', 'Imported package should expose realImport');
  assert.equal(typeof selfPkg.realRequire, 'function', 'Imported package should expose realRequire');

  // 4. realImport dynamically imports local ES modules via file URL and exposes named and default exports
  const fixtureUrl = new URL('../fixtures/helper.mjs', import.meta.url).href;
  const fixture = await realImport(fixtureUrl);
  assert(fixture !== null && typeof fixture === 'object', 'Fixture module should resolve to namespace');
  assert.equal(fixture.greeting, 'hello from fixture', 'Named export greeting should match');
  assert.equal(typeof fixture.calculateSum, 'function', 'calculateSum should be a function');
  assert.equal(fixture.calculateSum(3, 4), 7, 'calculateSum(3, 4) should return 7');
  assert.equal(fixture.default.type, 'fixture-module', 'Default export type should match');
  assert.equal(fixture.default.active, true, 'Default export active should be true');

  // 5. realImport rejects with an error when attempting to import a nonexistent module
  await assert.rejects(
    async () => {
      await realImport('node:nonexistent_builtin_for_testing_purposes');
    },
    (err) => {
      assert(err instanceof Error, 'Rejected value should be an Error');
      assert(
        err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'ERR_UNKNOWN_BUILTIN_MODULE',
        `Unexpected error code: ${err.code}`
      );
      return true;
    }
  );

  // 6. dynamicImport helper wraps realImport to load modules dynamically
  const urlModule = await dynamicImport('node:url');
  assert(urlModule !== null && typeof urlModule === 'object', 'URL module should resolve');
  assert.equal(typeof urlModule.fileURLToPath, 'function', 'fileURLToPath should be a function');

  // 7. importNamedExport helper retrieves a specific named export from a dynamically imported module
  const joinFn = await importNamedExport('node:path', 'join');
  assert.equal(typeof joinFn, 'function', 'Retrieved named export join should be a function');
  const fixtureDefault = await importNamedExport(fixtureUrl, 'default');
  assert.equal(fixtureDefault.type, 'fixture-module', 'Retrieved default export property should match');

  console.log('All contract assertions passed successfully.');
}

main().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Origin Seeder

anonymous