CodeSampleX

Ejemplo

react 18.3.1: StrictMode

Muestra verificada para npm react 18.3.1: StrictMode. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: react package.json declares…

sha256:f77b4dc5c243122406fcfa51f850ba6810dc7dbbb8e10c79a28e5c4d019ada20

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-27

Caso

HOW
Objetivo
verify react.StrictMode in pkg:npm/react@18.3.1
Paquetes
Símbolos
  • react.StrictMode
Entorno
node 22.23.2
Creado
2026-08-27T15:03:20Z

Contrato

  1. react package.json declares export mappings and version 18.3.1
  2. react exports StrictMode as a named export and property on the default React object matching the strict_mode symbol
  3. react createElement produces a valid React element with StrictMode type
  4. react createElement with StrictMode accepts props and preserves multiple children
  5. react StrictMode elements support element cloning with prop overrides

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 react.StrictMode in pkg:npm/react@18.3.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react@18.3.1
Demonstrate these symbols/APIs:
  - react.StrictMode

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:a2f666d3ff7377f4e619292c564d7d49e1ff53661b5c7d83cada96458e091698","contract":["react package.json declares export mappings and version 18.3.1","react exports StrictMode as a named export and property on the default React object matching the strict_mode symbol","react createElement produces a valid React element with StrictMode type","react createElement with StrictMode accepts props and preserves multiple children","react StrictMode elements support element cloning with prop overrides"],"goal":"verify react.StrictMode in pkg:npm/react@18.3.1","kind":"HOW","packages":["pkg:npm/react@18.3.1"],"schemaVersion":1,"symbols":["react.StrictMode"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react@18.3.1"],"schemaVersion":1,"subject":"pkg:npm/react@18.3.1","symbols":["react.StrictMode"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-strict-mode",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-strict-mode",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "react": "18.3.1"
      }
    },
    "node_modules/js-tokens": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
      "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
      "license": "MIT"
    },
    "node_modules/loose-envify": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
      "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
      "license": "MIT",
      "dependencies": {
        "js-tokens": "^3.0.0 || ^4.0.0"
      },
      "bin": {
        "loose-envify": "cli.js"
      }
    },
    "node_modules/react": {
      "version": "18.3.1",
      "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
      "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
      "license": "MIT",
      "dependencies": {
        "loose-envify": "^1.1.0"
      },
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-react-strict-mode",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "react": "18.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react.StrictMode in pkg:npm/react@18.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react@18.3.1"
  ],
  "symbols": [
    "react.StrictMode"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import React, { StrictMode } from 'react';

const require = createRequire(import.meta.url);

// Contract 1: react package.json declares export mappings and version 18.3.1
{
  const pkgJsonPath = require.resolve('react/package.json');
  assert.ok(fs.existsSync(pkgJsonPath));
  const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
  assert.strictEqual(pkgJson.name, 'react');
  assert.strictEqual(pkgJson.version, '18.3.1');
  assert.strictEqual(pkgJson.exports['.']['default'], './index.js');
}

// Contract 2: react exports StrictMode as a named export and property on the default React object matching the strict_mode symbol
{
  assert.strictEqual(React.version, '18.3.1');
  assert.strictEqual(React.StrictMode, StrictMode);
  assert.strictEqual(typeof React.StrictMode, 'symbol');
  assert.strictEqual(React.StrictMode, Symbol.for('react.strict_mode'));
}

// Contract 3: react createElement produces a valid React element with StrictMode type
{
  const child = React.createElement('div', null, 'child-content');
  const element = React.createElement(React.StrictMode, null, child);

  assert.strictEqual(React.isValidElement(element), true);
  assert.strictEqual(element.type, React.StrictMode);
  assert.strictEqual(element.$$typeof, Symbol.for('react.element'));
  assert.strictEqual(element.props.children, child);
  assert.strictEqual(element.key, null);
  assert.strictEqual(element.ref, null);
}

// Contract 4: react createElement with StrictMode accepts props and preserves multiple children
{
  const child1 = React.createElement('span', null, 'hello');
  const child2 = React.createElement('span', null, 'world');
  const elementWithProps = React.createElement(
    React.StrictMode,
    { key: 'strict-mode-key' },
    child1,
    child2
  );

  assert.strictEqual(React.isValidElement(elementWithProps), true);
  assert.strictEqual(elementWithProps.type, StrictMode);
  assert.strictEqual(elementWithProps.key, 'strict-mode-key');
  assert.strictEqual(React.Children.count(elementWithProps.props.children), 2);
  assert.deepStrictEqual(elementWithProps.props.children, [child1, child2]);
}

// Contract 5: react StrictMode elements support element cloning with prop overrides
{
  const initialElement = React.createElement(React.StrictMode, { key: 'initial' }, 'text');
  const cloned = React.cloneElement(initialElement, { key: 'cloned-key' }, 'replaced-text');

  assert.strictEqual(React.isValidElement(cloned), true);
  assert.strictEqual(cloned.type, React.StrictMode);
  assert.strictEqual(cloned.key, 'cloned-key');
  assert.strictEqual(cloned.props.children, 'replaced-text');
}

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

Seeder de origen

anónimo