Exemplo
get-caller-file 2.0.5
Amostra verificada para npm get-caller-file 2.0.5. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: getCallerFile returns the caller file…
sha256:7db40b3af8c39f559c459dbb1e0bb29459aab82c46e44bf0ed40cb4f59317b10
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
- 2
- 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 |
| 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-07 |
Caso
HOW- Objetivo
- verify pkg:npm/get-caller-file@2.0.5
- Pacotes
- Criado
- 2026-08-23T08:22:27Z
Contrato
- getCallerFile returns the caller file path of the invoking function at default position 2
- getCallerFile inspects callers at custom stack depth positions
- getCallerFile throws TypeError when position depth exceeds or equals Error.stackTraceLimit
- getCallerFile preserves existing Error.prepareStackTrace handler across invocations
- getCallerFile returns undefined when requested stack position exceeds stack depth within limits
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
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/get-caller-file@2.0.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/get-caller-file@2.0.5
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:bd427d4cca7e34f8cccfe0b0591517cb275e78be87ee3c13c9c712630c9ea74d","contract":["getCallerFile returns the caller file path of the invoking function at default position 2","getCallerFile inspects callers at custom stack depth positions","getCallerFile throws TypeError when position depth exceeds or equals Error.stackTraceLimit","getCallerFile preserves existing Error.prepareStackTrace handler across invocations","getCallerFile returns undefined when requested stack position exceeds stack depth within limits"],"goal":"verify pkg:npm/get-caller-file@2.0.5","kind":"HOW","packages":["pkg:npm/get-caller-file@2.0.5"],"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/get-caller-file@2.0.5"],"schemaVersion":1,"subject":"pkg:npm/get-caller-file@2.0.5","verifierAdapter":"node-typescript@1"}
{
"name": "sample-get-caller-file",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-get-caller-file",
"version": "1.0.0",
"dependencies": {
"get-caller-file": "2.0.5"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
}
}
}
{
"name": "sample-get-caller-file",
"version": "1.0.0",
"type": "module",
"private": true,
"description": "Clean-room code sample for get-caller-file@2.0.5",
"main": "src/index.mjs",
"license": "MIT-0",
"dependencies": {
"get-caller-file": "2.0.5"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/get-caller-file@2.0.5",
"kind": "HOW",
"packages": [
"pkg:npm/get-caller-file@2.0.5"
]
}
import getCallerFile from 'get-caller-file';
/**
* Returns the caller file of the immediate invocation.
*
* @param {number} [position=2] - The stack frame position to inspect.
* @returns {string|undefined} Caller file path or undefined if out of range.
*/
export function whoCalledMe(position) {
return getCallerFile(position);
}
/**
* Returns the caller of the outer caller using an increased stack position depth.
*
* @returns {string|undefined} Caller file path.
*/
export function nestedCaller() {
return whoCalledMe(3);
}
export default getCallerFile;
import assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
import getCallerFile, { whoCalledMe, nestedCaller } from '../src/index.mjs';
// 1. getCallerFile returns the caller file path of the invoking function at default position 2
function directCaller() {
return getCallerFile();
}
const thisFilePath = fileURLToPath(import.meta.url);
const callerResult = directCaller();
assert.ok(callerResult, 'callerResult should be non-empty string');
assert.ok(
callerResult === import.meta.url || callerResult === thisFilePath || callerResult.includes('contract.mjs'),
`callerResult (${callerResult}) should match contract.mjs`
);
// Helper function whoCalledMe correctly resolves caller to test/contract.mjs
const helperCaller = whoCalledMe();
assert.ok(helperCaller, 'helperCaller should be non-empty string');
assert.ok(
helperCaller === import.meta.url || helperCaller === thisFilePath || helperCaller.includes('contract.mjs'),
`helperCaller (${helperCaller}) should reference contract.mjs`
);
// 2. getCallerFile inspects callers at custom stack depth positions
function outerCaller() {
return nestedCaller();
}
const nestedResult = outerCaller();
assert.ok(nestedResult, 'nestedResult should be non-empty string');
assert.ok(
nestedResult === import.meta.url || nestedResult === thisFilePath || nestedResult.includes('contract.mjs'),
`nestedResult (${nestedResult}) should resolve to contract.mjs`
);
// 3. getCallerFile throws TypeError when position depth exceeds or equals Error.stackTraceLimit
assert.throws(
() => getCallerFile(Error.stackTraceLimit),
{
name: 'TypeError'
},
'getCallerFile should throw TypeError when position >= Error.stackTraceLimit'
);
// 4. getCallerFile preserves existing Error.prepareStackTrace handler across invocations
const customPrepareStackTrace = (_, stack) => stack;
Error.prepareStackTrace = customPrepareStackTrace;
try {
directCaller();
assert.equal(Error.prepareStackTrace, customPrepareStackTrace, 'prepareStackTrace handler should be preserved');
} finally {
Error.prepareStackTrace = undefined;
}
// 5. getCallerFile returns undefined when requested stack position exceeds stack depth within limits
const originalLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 50;
try {
const outOfRange = getCallerFile(40);
assert.equal(outOfRange, undefined, 'out of range position should return undefined');
} finally {
Error.stackTraceLimit = originalLimit;
}
console.log('All pkg:npm/get-caller-file@2.0.5 contract assertions passed successfully.');
Seeder de origem
anônimo