CodeSampleX

Exemplo

temp 0.9.4: track

Amostra verificada para npm temp 0.9.4: track. O contrato rodou em node 22 · linux debian/x64 · docker e passou: temp.track enables automatic tracking and…

sha256:54c461819086898e8c940658cdc857dde18b3299fe3ad3962ed7bf01ca718557

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-04

Caso

HOW
Objetivo
verify temp.track in pkg:npm/temp@0.9.4
Pacotes
Símbolos
  • temp.track
Ambiente
node 22.23.2
Criado
2026-09-04T12:47:17Z

Contrato

  1. temp.track enables automatic tracking and returns the temp module for chaining
  2. temp.track enables tracking so cleanupSync deletes tracked temporary directories and files and returns their counts
  3. temp.track enables tracking so async cleanup returns a promise resolving to removed counts
  4. temp.track accepts false to disable tracking, causing cleanupSync to return false
  5. temp.track when disabled causes async cleanup to reject with not tracking error

Arquivos

  • .npmrc
  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

.npmrc
audit=false
fund=false
update-notifier=false
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 temp.track in pkg:npm/temp@0.9.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/temp@0.9.4
Demonstrate these symbols/APIs:
  - temp.track

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:35e6e3e1d5b69b7557559b3a35baa148b7db29c5f2ba3bb9f6b4946e536b589e","contract":["temp.track enables automatic tracking and returns the temp module for chaining","temp.track enables tracking so cleanupSync deletes tracked temporary directories and files and returns their counts","temp.track enables tracking so async cleanup returns a promise resolving to removed counts","temp.track accepts false to disable tracking, causing cleanupSync to return false","temp.track when disabled causes async cleanup to reject with not tracking error"],"goal":"verify temp.track in pkg:npm/temp@0.9.4","kind":"HOW","packages":["pkg:npm/temp@0.9.4"],"schemaVersion":1,"symbols":["temp.track"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/temp@0.9.4"],"schemaVersion":1,"subject":"pkg:npm/temp@0.9.4","symbols":["temp.track"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-temp-track",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-temp-track",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "temp": "0.9.4"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "1.1.18",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
      "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0",
        "concat-map": "0.0.1"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    },
    "node_modules/fs.realpath": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
      "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
      "license": "ISC"
    },
    "node_modules/glob": {
      "version": "7.2.3",
      "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
      "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
      "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
      "license": "ISC",
      "dependencies": {
        "fs.realpath": "^1.0.0",
        "inflight": "^1.0.4",
        "inherits": "2",
        "minimatch": "^3.1.1",
        "once": "^1.3.0",
        "path-is-absolute": "^1.0.0"
      },
      "engines": {
        "node": "*"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/inflight": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
      "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
      "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
      "license": "ISC",
      "dependencies": {
        "once": "^1.3.0",
        "wrappy": "1"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/minimatch": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
      "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^1.1.7"
      },
      "engines": {
        "node": "*"
      }
    },
    "node_modules/minimist": {
      "version": "1.2.8",
      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
      "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/mkdirp": {
      "version": "0.5.6",
      "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
      "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
      "license": "MIT",
      "dependencies": {
        "minimist": "^1.2.6"
      },
      "bin": {
        "mkdirp": "bin/cmd.js"
      }
    },
    "node_modules/once": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
      "license": "ISC",
      "dependencies": {
        "wrappy": "1"
      }
    },
    "node_modules/path-is-absolute": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
      "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/rimraf": {
      "version": "2.6.3",
      "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
      "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
      "deprecated": "Rimraf versions prior to v4 are no longer supported",
      "license": "ISC",
      "dependencies": {
        "glob": "^7.1.3"
      },
      "bin": {
        "rimraf": "bin.js"
      }
    },
    "node_modules/temp": {
      "version": "0.9.4",
      "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz",
      "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==",
      "license": "MIT",
      "dependencies": {
        "mkdirp": "^0.5.1",
        "rimraf": "~2.6.2"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/wrappy": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
      "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-temp-track",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for temp.track in temp@0.9.4",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "temp": "0.9.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify temp.track in pkg:npm/temp@0.9.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/temp@0.9.4"
  ],
  "symbols": [
    "temp.track"
  ]
}
src/index.js
const temp = require('temp');

/**
 * Enables or disables automatic cleanup tracking for temporary files and directories.
 *
 * @param {boolean} [value=true] - Whether tracking should be enabled.
 * @returns {typeof temp} Returns the temp module for chaining.
 */
function configureTracking(value) {
  return temp.track(value);
}

/**
 * Synchronously cleans up all tracked files and directories.
 *
 * @returns {{ files: number, dirs: number }|false} Removed file and directory counts, or false if not tracking.
 */
function cleanupTrackedSync() {
  return temp.cleanupSync();
}

/**
 * Asynchronously cleans up all tracked files and directories.
 *
 * @param {Function} [callback] - Optional callback function (err, result).
 * @returns {Promise<{ files: number, dirs: number }>}
 */
function cleanupTrackedAsync(callback) {
  return temp.cleanup(callback);
}

module.exports = {
  temp,
  configureTracking,
  cleanupTrackedSync,
  cleanupTrackedAsync
};
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  temp,
  configureTracking,
  cleanupTrackedSync,
  cleanupTrackedAsync
} = require('../src/index.js');

async function runContract() {
  const leftovers = [];

  try {
    // 1. temp.track enables automatic tracking and returns the temp module for chaining
    const chained = configureTracking();
    assert.strictEqual(chained, temp, 'temp.track() must return the temp module instance');

    // 2. temp.track enables tracking so cleanupSync deletes tracked temporary directories and files and returns their counts
    const testDir = temp.mkdirSync('csx-track-dir-sync');
    const testFile = temp.openSync('csx-track-file-sync');
    fs.closeSync(testFile.fd);

    leftovers.push(testDir, testFile.path);

    assert.ok(fs.existsSync(testDir), 'testDir must exist before cleanupSync');
    assert.ok(fs.existsSync(testFile.path), 'testFile must exist before cleanupSync');

    const syncResult = cleanupTrackedSync();
    assert.ok(typeof syncResult === 'object' && syncResult !== null, 'cleanupSync should return an object when tracking is enabled');
    assert.strictEqual(syncResult.dirs, 1, 'cleanupSync should report 1 deleted dir');
    assert.strictEqual(syncResult.files, 1, 'cleanupSync should report 1 deleted file');

    assert.ok(!fs.existsSync(testDir), 'testDir must be deleted by cleanupSync');
    assert.ok(!fs.existsSync(testFile.path), 'testFile must be deleted by cleanupSync');

    // 3. temp.track enables tracking so async cleanup returns a promise resolving to removed counts
    const testDirAsync = temp.mkdirSync('csx-track-dir-async');
    const testFileAsync = temp.openSync('csx-track-file-async');
    fs.closeSync(testFileAsync.fd);

    leftovers.push(testDirAsync, testFileAsync.path);

    assert.ok(fs.existsSync(testDirAsync), 'testDirAsync must exist before async cleanup');
    assert.ok(fs.existsSync(testFileAsync.path), 'testFileAsync must exist before async cleanup');

    const asyncResult = await cleanupTrackedAsync();
    assert.ok(typeof asyncResult === 'object' && asyncResult !== null, 'async cleanup should resolve to an object');
    assert.strictEqual(asyncResult.dirs, 1, 'async cleanup should report 1 deleted dir');
    assert.strictEqual(asyncResult.files, 1, 'async cleanup should report 1 deleted file');

    assert.ok(!fs.existsSync(testDirAsync), 'testDirAsync must be deleted by async cleanup');
    assert.ok(!fs.existsSync(testFileAsync.path), 'testFileAsync must be deleted by async cleanup');

    // 4. temp.track accepts false to disable tracking, causing cleanupSync to return false
    const chainedDisable = configureTracking(false);
    assert.strictEqual(chainedDisable, temp, 'temp.track(false) must return the temp module instance');

    const disabledSyncResult = cleanupTrackedSync();
    assert.strictEqual(disabledSyncResult, false, 'cleanupSync must return false when tracking is disabled');

    // 5. temp.track when disabled causes async cleanup to reject with not tracking error
    await assert.rejects(
      async () => {
        await cleanupTrackedAsync();
      },
      {
        name: 'Error',
        message: 'not tracking'
      },
      'cleanup() must reject with "not tracking" error when tracking is disabled'
    );

    console.log('Contract assertions passed successfully.');
  } finally {
    // Clean up any unexpected leftovers
    for (const item of leftovers) {
      try {
        if (fs.existsSync(item)) {
          fs.rmSync(item, { recursive: true, force: true });
        }
      } catch {
        // ignore cleanup error
      }
    }
  }
}

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

Seeder de origem

anônimo