Exemple
lru-cache 10.4.3
Échantillon vérifié pour npm lru-cache 10.4.3. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : LRUCache basic set, get, has…
sha256:65309ec6cafbc9663e1c24ef1092516275944c6f33cf2996bb924fa7f5cda513
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
- 2
- 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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
| 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 |
Cas
HOW- Objectif
- verify pkg:npm/lru-cache@10.4.3
- Paquets
- Créé
- 2026-08-21T13:46:37Z
Contrat
- LRUCache basic set, get, has, and delete operations manage cached values
- LRUCache evicts the least recently used item when cache capacity max is exceeded
- LRUCache expires cached entries after ttl duration
- LRUCache enforces maxSize using sizeCalculation and evicts entries exceeding size limit
- LRUCache peek retrieves value without altering LRU order
- LRUCache supports iteration over keys, values, and entries and clear resets cache size
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- 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 pkg:npm/lru-cache@10.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/lru-cache@10.4.3
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:bcc8101e276003eae935e76b83d0bc4144997111fe65736a0a754906f9d9919d","contract":["LRUCache basic set, get, has, and delete operations manage cached values","LRUCache evicts the least recently used item when cache capacity max is exceeded","LRUCache expires cached entries after ttl duration","LRUCache enforces maxSize using sizeCalculation and evicts entries exceeding size limit","LRUCache peek retrieves value without altering LRU order","LRUCache supports iteration over keys, values, and entries and clear resets cache size"],"goal":"verify pkg:npm/lru-cache@10.4.3","kind":"HOW","packages":["pkg:npm/lru-cache@10.4.3"],"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/lru-cache@10.4.3"],"schemaVersion":1,"subject":"pkg:npm/lru-cache@10.4.3","verifierAdapter":"node-typescript@1"}
import { LRUCache } from 'lru-cache';
export function createCache(options) {
return new LRUCache(options);
}
export { LRUCache };
{
"name": "sample-lru-cache",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-lru-cache",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"lru-cache": "10.4.3"
}
},
"node_modules/lru-cache": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
"license": "ISC"
}
}
}
{
"name": "sample-lru-cache",
"version": "1.0.0",
"description": "Clean-room verification sample for lru-cache",
"type": "module",
"private": true,
"dependencies": {
"lru-cache": "10.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/lru-cache@10.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/lru-cache@10.4.3"
]
}
import assert from 'node:assert/strict';
import { LRUCache, createCache } from '../index.mjs';
// 1. Basic set, get, has, and delete operations
{
const cache = createCache({ max: 5 });
cache.set('a', 1);
cache.set('b', 2);
assert.equal(cache.get('a'), 1);
assert.equal(cache.get('b'), 2);
assert.equal(cache.has('a'), true);
assert.equal(cache.has('missing'), false);
assert.equal(cache.delete('a'), true);
assert.equal(cache.has('a'), false);
assert.equal(cache.get('a'), undefined);
}
// 2. LRU eviction when exceeding max items
{
const cache = new LRUCache({ max: 2 });
cache.set('a', 1);
cache.set('b', 2);
assert.equal(cache.get('a'), 1); // access 'a' so 'b' is least recently used
cache.set('c', 3);
assert.equal(cache.has('b'), false);
assert.equal(cache.has('a'), true);
assert.equal(cache.has('c'), true);
assert.equal(cache.size, 2);
}
// 3. TTL expiration of cached entries
{
const cache = new LRUCache({ max: 5, ttl: 50 });
cache.set('temp', 'val');
assert.equal(cache.get('temp'), 'val');
await new Promise((resolve) => setTimeout(resolve, 80));
assert.equal(cache.get('temp'), undefined);
assert.equal(cache.has('temp'), false);
}
// 4. maxSize and sizeCalculation eviction
{
const cache = new LRUCache({
maxSize: 10,
sizeCalculation: (value) => value.length,
});
cache.set('k1', 'abcd');
cache.set('k2', 'efgh');
assert.equal(cache.calculatedSize, 8);
cache.set('k3', 'ijkl');
assert.equal(cache.has('k1'), false);
assert.equal(cache.has('k2'), true);
assert.equal(cache.has('k3'), true);
assert.equal(cache.calculatedSize, 8);
}
// 5. peek retrieves value without updating LRU order
{
const cache = new LRUCache({ max: 2 });
cache.set('x', 10);
cache.set('y', 20);
assert.equal(cache.peek('x'), 10);
cache.set('z', 30);
assert.equal(cache.has('x'), false);
assert.equal(cache.has('y'), true);
assert.equal(cache.has('z'), true);
}
// 6. Iteration over keys, values, and entries
{
const cache = new LRUCache({ max: 5 });
cache.set('1', 'one');
cache.set('2', 'two');
assert.deepEqual([...cache.keys()], ['2', '1']);
assert.deepEqual([...cache.values()], ['two', 'one']);
assert.deepEqual([...cache.entries()], [['2', 'two'], ['1', 'one']]);
cache.clear();
assert.equal(cache.size, 0);
}
console.log('All LRUCache@10.4.3 contract assertions passed.');
Seeder d'origine
anonyme