CodeSampleX

Sample

real-require 1.0.0: realRequire

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

sha256:77b9c7d06246a3b9e0883d11249f2aa10017fc1ee619621adca7eb3d69d89d17

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.realRequire in pkg:npm/real-require@1.0.0
Packages
Symbols
  • real-require.realRequire
Created
2026-10-12T09:57:46Z

Contract

  1. realRequire is exported as a function from real-require
  2. realRequire loads Node.js built-in modules using runtime require
  3. realRequire delegates to __non_webpack__require__ when globally defined
  4. realRequire falls back to standard require when __non_webpack__require__ is undefined
  5. realRequire throws MODULE_NOT_FOUND when loading non-existent modules

Files

  • PROMPT.md
  • csx.json
  • 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.realRequire 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.realRequire

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:7c2cb3546bf6ee631c39365897920b66a639e1672790ce3691e186b4b113637f","contract":["realRequire is exported as a function from real-require","realRequire loads Node.js built-in modules using runtime require","realRequire delegates to __non_webpack__require__ when globally defined","realRequire falls back to standard require when __non_webpack__require__ is undefined","realRequire throws MODULE_NOT_FOUND when loading non-existent modules"],"goal":"verify real-require.realRequire in pkg:npm/real-require@1.0.0","kind":"HOW","packages":["pkg:npm/real-require@1.0.0"],"schemaVersion":1,"symbols":["real-require.realRequire"]},"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.realRequire"],"verifierAdapter":"node-typescript@1"}
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.realRequire in pkg:npm/real-require@1.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/real-require@1.0.0"
  ],
  "symbols": [
    "real-require.realRequire"
  ]
}
src/index.js
'use strict';

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

/**
 * Loads a module using realRequire.
 *
 * @param {string} modulePath - The specifier of the module to require.
 * @returns {*} The exported module.
 */
function loadModule(modulePath) {
  return realRequire(modulePath);
}

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

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

async function testAll() {
  // 1. realRequire is exported as a function from real-require
  assert.equal(typeof realRequire, 'function', 'realRequire must be a function');
  assert.equal(typeof loadModule, 'function', 'loadModule helper must be a function');

  // 2. realRequire loads Node.js built-in modules using runtime require
  {
    const path = realRequire('node:path');
    assert.equal(typeof path.join, 'function', 'realRequire should load path module');
    assert.equal(path.join('foo', 'bar'), 'foo/bar');

    const os = loadModule('node:os');
    assert.equal(typeof os.platform, 'function', 'loadModule should load os module');
  }

  // 3. realRequire delegates to __non_webpack__require__ when globally defined
  {
    let captured = null;
    globalThis.__non_webpack__require__ = (id) => {
      captured = id;
      return { mocked: true, target: id };
    };

    try {
      const result = realRequire('virtual-mock-module');
      assert.equal(captured, 'virtual-mock-module', '__non_webpack__require__ should be invoked with target id');
      assert.deepEqual(result, { mocked: true, target: 'virtual-mock-module' });
    } finally {
      delete globalThis.__non_webpack__require__;
    }
  }

  // 4. realRequire falls back to standard require when __non_webpack__require__ is undefined
  {
    assert.equal(typeof globalThis.__non_webpack__require__, 'undefined');
    const fs = realRequire('node:fs');
    assert.equal(typeof fs.readFileSync, 'function', 'realRequire falls back to standard require for fs');
  }

  // 5. realRequire throws MODULE_NOT_FOUND when loading non-existent modules
  {
    assert.throws(
      () => realRequire('non-existent-module-xyz-12345'),
      (err) => {
        return err && (err.code === 'MODULE_NOT_FOUND' || (err.message && err.message.includes('Cannot find module')));
      },
      'realRequire should throw error for non-existent module'
    );
  }

  console.log('All real-require contract tests passed successfully.');
}

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

Origin Seeder

anonymous