Exemplo
import-fresh 3.3.1
Amostra verificada para npm import-fresh 3.3.1. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: importFresh throws TypeError when moduleId…
sha256:b9ed95eeb82afdc30a82de96ec34c7acd2bb94eb18bd39a50db5575dd4ba8e1a
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-23 |
Caso
HOW- Objetivo
- verify pkg:npm/import-fresh@3.3.1
- Pacotes
- Criado
- 2026-08-23T14:08:52Z
Contrato
- importFresh throws TypeError when moduleId argument is not a string
- importFresh imports a module and returns its exported value
- importFresh returns a new module instance on each call bypassing require cache
- importFresh resolves relative module paths relative to the caller file directory in CommonJS
- importFresh loads fresh parsed objects for JSON files bypassing cache
- importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
- test/fixtures/data.json
- test/fixtures/stateful.cjs
- test/fixtures/sub/caller.cjs
- test/fixtures/sub/target.cjs
Código-fonte
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 pkg:npm/import-fresh@3.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/import-fresh@3.3.1
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.
{"case":{"caseId":"case:sha256:885649d8df8598de2c77ac3b0819456947b809ea10a9359ecd8f7cd395b135c8","contract":["importFresh throws TypeError when moduleId argument is not a string","importFresh imports a module and returns its exported value","importFresh returns a new module instance on each call bypassing require cache","importFresh resolves relative module paths relative to the caller file directory in CommonJS","importFresh loads fresh parsed objects for JSON files bypassing cache","importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved"],"goal":"verify pkg:npm/import-fresh@3.3.1","kind":"HOW","packages":["pkg:npm/import-fresh@3.3.1"],"schemaVersion":1},"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/import-fresh@3.3.1"],"schemaVersion":1,"subject":"pkg:npm/import-fresh@3.3.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-import-fresh",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-import-fresh",
"version": "1.0.0",
"dependencies": {
"import-fresh": "3.3.1"
}
},
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/import-fresh": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"license": "MIT",
"dependencies": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"license": "MIT",
"dependencies": {
"callsites": "^3.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"license": "MIT",
"engines": {
"node": ">=4"
}
}
}
}
{
"name": "sample-import-fresh",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"import-fresh": "3.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/import-fresh@3.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/import-fresh@3.3.1"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import path from 'node:path';
import importFresh from 'import-fresh';
const require = createRequire(import.meta.url);
const { loadRelativeTarget } = require('./fixtures/sub/caller.cjs');
// 1. importFresh throws TypeError when moduleId argument is not a string
{
assert.throws(
() => {
importFresh(12345);
},
{
name: 'TypeError',
message: 'Expected a string',
}
);
assert.throws(
() => {
importFresh(null);
},
{
name: 'TypeError',
message: 'Expected a string',
}
);
assert.throws(
() => {
importFresh(undefined);
},
{
name: 'TypeError',
message: 'Expected a string',
}
);
}
// 2. importFresh imports a module and returns its exported value
{
const fixturePath = path.resolve('test/fixtures/stateful.cjs');
const mod = importFresh(fixturePath);
assert.ok(mod !== null && typeof mod === 'object');
assert.equal(typeof mod.getExecutionCount, 'function');
assert.equal(typeof mod.instanceId, 'object');
}
// 3. importFresh returns a new module instance on each call bypassing require cache
{
const fixturePath = path.resolve('test/fixtures/stateful.cjs');
const mod1 = importFresh(fixturePath);
const mod2 = importFresh(fixturePath);
assert.notEqual(mod1, mod2);
assert.notEqual(mod1.instanceId, mod2.instanceId);
}
// 4. importFresh resolves relative module paths relative to the caller file directory in CommonJS
{
const result1 = loadRelativeTarget();
const result2 = loadRelativeTarget();
assert.equal(result1.name, 'sub-target');
assert.equal(result2.name, 'sub-target');
assert.notEqual(result1.uniqueRef, result2.uniqueRef);
}
// 5. importFresh loads fresh parsed objects for JSON files bypassing cache
{
const jsonPath = path.resolve('test/fixtures/data.json');
const data1 = importFresh(jsonPath);
const data2 = importFresh(jsonPath);
assert.deepEqual(data1, {
name: 'sample-data',
version: 1,
nested: {
active: true,
},
});
assert.notEqual(data1, data2);
assert.notEqual(data1.nested, data2.nested);
}
// 6. importFresh throws MODULE_NOT_FOUND error when the module cannot be resolved
{
assert.throws(
() => {
importFresh(path.resolve('test/fixtures/non-existent-module.cjs'));
},
(err) => {
return err.code === 'MODULE_NOT_FOUND' || err.message.includes('Cannot find module');
}
);
}
{
"name": "sample-data",
"version": 1,
"nested": {
"active": true
}
}
'use strict';
let executionCount = 0;
executionCount += 1;
module.exports = {
instanceId: {},
createdAt: Date.now(),
getExecutionCount: () => executionCount,
};
'use strict';
const importFresh = require('import-fresh');
module.exports = {
loadRelativeTarget: function () {
return importFresh('./target.cjs');
},
};
'use strict';
module.exports = {
name: 'sub-target',
uniqueRef: {},
};
Seeder de origem
anônimo