Exemple
proper-lockfile 4.1.2: checkSync
Échantillon vérifié pour npm proper-lockfile 4.1.2: checkSync. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:4df5b0572844339b453a195f17077357a833465f8746f7209002729701dafaee
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-05 |
Cas
HOW- Objectif
- verify proper-lockfile.checkSync in pkg:npm/proper-lockfile@4.1.2
- Paquets
- Symboles
-
- proper-lockfile.checkSync
- Créé
- 2026-09-05T19:11:58Z
Contrat
- proper-lockfile.checkSync returns false when a file is not locked
- proper-lockfile.checkSync returns true when a file has an active lock acquired via lockSync
- proper-lockfile.checkSync returns false after an active lock is released via the release function
- proper-lockfile.checkSync returns false after an active lock is released via unlockSync
- proper-lockfile.checkSync supports custom stale option to evaluate lock status
- proper-lockfile.checkSync synchronously returns a boolean value rather than a Promise
- proper-lockfile.checkSync throws ENOENT when checking a non-existent file with default realpath true
- proper-lockfile.checkSync returns false without throwing when checking a non-existent file with realpath false
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Code source
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 proper-lockfile.checkSync in pkg:npm/proper-lockfile@4.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/proper-lockfile@4.1.2
Demonstrate these symbols/APIs:
- proper-lockfile.checkSync
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:d03d59361e31457803e949ecd96adbed8e751c854186cfc54acf0f8343b49b05","contract":["proper-lockfile.checkSync returns false when a file is not locked","proper-lockfile.checkSync returns true when a file has an active lock acquired via lockSync","proper-lockfile.checkSync returns false after an active lock is released via the release function","proper-lockfile.checkSync returns false after an active lock is released via unlockSync","proper-lockfile.checkSync supports custom stale option to evaluate lock status","proper-lockfile.checkSync synchronously returns a boolean value rather than a Promise","proper-lockfile.checkSync throws ENOENT when checking a non-existent file with default realpath true","proper-lockfile.checkSync returns false without throwing when checking a non-existent file with realpath false"],"goal":"verify proper-lockfile.checkSync in pkg:npm/proper-lockfile@4.1.2","kind":"HOW","packages":["pkg:npm/proper-lockfile@4.1.2"],"schemaVersion":1,"symbols":["proper-lockfile.checkSync"]},"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/proper-lockfile@4.1.2"],"schemaVersion":1,"subject":"pkg:npm/proper-lockfile@4.1.2","symbols":["proper-lockfile.checkSync"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-proper-lockfile-checksync",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-proper-lockfile-checksync",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"proper-lockfile": "4.1.2"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/proper-lockfile": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz",
"integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.4",
"retry": "^0.12.0",
"signal-exit": "^3.0.2"
}
},
"node_modules/retry": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz",
"integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==",
"license": "MIT",
"engines": {
"node": ">= 4"
}
},
"node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
"license": "ISC"
}
}
}
{
"name": "sample-proper-lockfile-checksync",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"proper-lockfile": "4.1.2"
}
}
{
"schemaVersion": 1,
"goal": "verify proper-lockfile.checkSync in pkg:npm/proper-lockfile@4.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/proper-lockfile@4.1.2"
],
"symbols": [
"proper-lockfile.checkSync"
]
}
import lockfile from 'proper-lockfile';
export const {
lock,
unlock,
lockSync,
unlockSync,
check,
checkSync
} = lockfile;
/**
* Checks synchronously whether a given file path is locked.
* @param {string} file Path to the file to check
* @param {object} [options] Options passed to proper-lockfile.checkSync
* @returns {boolean} True if locked, false otherwise
*/
export function isFileLocked(file, options) {
return lockfile.checkSync(file, options);
}
export default lockfile;
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import lockfile, { checkSync, lockSync, unlockSync, isFileLocked } from '../src/index.mjs';
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-lockfile-contract-'));
const testFile = path.join(tmpDir, 'resource.txt');
fs.writeFileSync(testFile, 'test payload', 'utf8');
try {
// 1. proper-lockfile.checkSync returns false when a file is not locked
{
const unlockedDirect = checkSync(testFile);
assert.equal(unlockedDirect, false);
const unlockedHelper = isFileLocked(testFile);
assert.equal(unlockedHelper, false);
}
// 2. proper-lockfile.checkSync returns true when a file has an active lock acquired via lockSync
{
const release = lockSync(testFile);
const lockedDirect = checkSync(testFile);
assert.equal(lockedDirect, true);
const lockedHelper = isFileLocked(testFile);
assert.equal(lockedHelper, true);
// 3. proper-lockfile.checkSync returns false after an active lock is released via the release function
release();
assert.equal(checkSync(testFile), false);
assert.equal(isFileLocked(testFile), false);
}
// 4. proper-lockfile.checkSync returns false after an active lock is released via unlockSync
{
lockSync(testFile);
assert.equal(checkSync(testFile), true);
unlockSync(testFile);
assert.equal(checkSync(testFile), false);
}
// 5. proper-lockfile.checkSync supports custom stale option to evaluate lock status
{
const release = lockSync(testFile, { stale: 6000 });
assert.equal(checkSync(testFile, { stale: 6000 }), true);
release();
assert.equal(checkSync(testFile, { stale: 6000 }), false);
}
// 6. proper-lockfile.checkSync synchronously returns a boolean value rather than a Promise
{
const result = checkSync(testFile);
assert.equal(typeof result, 'boolean');
assert.equal(result instanceof Promise, false);
}
// 7. proper-lockfile.checkSync throws ENOENT when checking a non-existent file with default realpath true
{
const nonExistentFile = path.join(tmpDir, 'does-not-exist.txt');
assert.throws(
() => {
checkSync(nonExistentFile);
},
(err) => {
return err && err.code === 'ENOENT';
}
);
}
// 8. proper-lockfile.checkSync returns false without throwing when checking a non-existent file with realpath false
{
const nonExistentFile = path.join(tmpDir, 'does-not-exist.txt');
const result = checkSync(nonExistentFile, { realpath: false });
assert.equal(result, false);
}
console.log('Contract assertions passed.');
} finally {
try {
fs.rmSync(tmpDir, { recursive: true, force: true });
} catch {
// Ignore cleanup error
}
}
Seeder d'origine
anonyme