Exemple
lru-cache 6.0.0
Échantillon vérifié pour npm lru-cache 6.0.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : cache.set(key, value) and…
sha256:4889208dd521d04e712cd35ec4b50e62c5f5f738754494631e6701226e613c9a
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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
Cas
HOW- Objectif
- verify pkg:npm/lru-cache@6.0.0
- Paquets
- Créé
- 2026-08-21T13:50:43Z
Contrat
- cache.set(key, value) and cache.get(key) store and retrieve values
- cache.has(key) returns true for existing keys and false for missing keys
- cache.del(key) removes the key and reduces itemCount
- cache evicts the least recently used item when max capacity is exceeded
- cache.get(key) updates recency so the accessed item is not evicted next
- cache.reset() clears all cached entries and resets itemCount to 0
- cache.keys() and cache.values() return active keys and values in recency order
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@6.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/lru-cache@6.0.0
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:47e1a2affbbb295cb66ba426707a9aaee4bcd3db7fed3b64b5c386801487e487","contract":["cache.set(key, value) and cache.get(key) store and retrieve values","cache.has(key) returns true for existing keys and false for missing keys","cache.del(key) removes the key and reduces itemCount","cache evicts the least recently used item when max capacity is exceeded","cache.get(key) updates recency so the accessed item is not evicted next","cache.reset() clears all cached entries and resets itemCount to 0","cache.keys() and cache.values() return active keys and values in recency order"],"goal":"verify pkg:npm/lru-cache@6.0.0","kind":"HOW","packages":["pkg:npm/lru-cache@6.0.0"],"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@6.0.0"],"schemaVersion":1,"subject":"pkg:npm/lru-cache@6.0.0","verifierAdapter":"node-typescript@1"}
import LRU from 'lru-cache';
export function createCache(options) {
return new LRU(options);
}
{
"name": "sample-lru-cache",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-lru-cache",
"version": "1.0.0",
"dependencies": {
"lru-cache": "6.0.0"
}
},
"node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"license": "ISC",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"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": "6.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/lru-cache@6.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/lru-cache@6.0.0"
]
}
import assert from 'node:assert/strict';
import LRU from 'lru-cache';
import { createCache } from '../index.mjs';
// 1. cache.set(key, value) and cache.get(key) store and retrieve values
const cache = createCache({ max: 3 });
cache.set('a', 'alpha');
cache.set('b', 'beta');
assert.equal(cache.get('a'), 'alpha');
assert.equal(cache.get('b'), 'beta');
assert.equal(cache.get('c'), undefined);
// 2. cache.has(key) returns true for existing keys and false for missing keys
assert.equal(cache.has('a'), true);
assert.equal(cache.has('b'), true);
assert.equal(cache.has('missing'), false);
// 3. cache.del(key) removes the key and reduces itemCount
assert.equal(cache.itemCount, 2);
cache.del('b');
assert.equal(cache.has('b'), false);
assert.equal(cache.get('b'), undefined);
assert.equal(cache.itemCount, 1);
// 4. cache evicts the least recently used item when max capacity is exceeded
const smallCache = new LRU({ max: 2 });
smallCache.set('x', 1);
smallCache.set('y', 2);
smallCache.set('z', 3);
assert.equal(smallCache.has('x'), false);
assert.equal(smallCache.get('y'), 2);
assert.equal(smallCache.get('z'), 3);
assert.equal(smallCache.itemCount, 2);
// 5. cache.get(key) updates recency so the accessed item is not evicted next
const lruCache = new LRU({ max: 2 });
lruCache.set('first', '1');
lruCache.set('second', '2');
lruCache.get('first');
lruCache.set('third', '3');
assert.equal(lruCache.has('second'), false);
assert.equal(lruCache.has('first'), true);
assert.equal(lruCache.has('third'), true);
// 6. cache.reset() clears all cached entries and resets itemCount to 0
lruCache.reset();
assert.equal(lruCache.itemCount, 0);
assert.equal(lruCache.has('first'), false);
assert.equal(lruCache.has('third'), false);
// 7. cache.keys() and cache.values() return active keys and values in recency order
const iterCache = new LRU({ max: 3 });
iterCache.set('k1', 'v1');
iterCache.set('k2', 'v2');
iterCache.set('k3', 'v3');
assert.deepEqual(Array.from(iterCache.keys()), ['k3', 'k2', 'k1']);
assert.deepEqual(Array.from(iterCache.values()), ['v3', 'v2', 'v1']);
console.log('All lru-cache@6.0.0 contract assertions passed.');
Seeder d'origine
anonyme