Sample
lru-cache 10.4.3: LRUCache
Verified sample for npm lru-cache 10.4.3: LRUCache. The contract ran on node 22 · linux alpine/x64 · docker and passed: assert LRUCache instantiates with…
sha256:31b23d141194aa1eba5ff161dec7e142bd479909033830e82c4854877d95f827
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 2
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3
- Packages
- Symbols
-
- lru-cache.LRUCache
- Environment
- node 22.23.2
- Created
- 2026-08-23T05:16:31Z
Contract
- assert LRUCache instantiates with options and performs set and get operations
- assert LRUCache evicts least recently used items when max capacity is reached
- assert LRUCache peek reads values without updating recency order
- assert LRUCache supports item deletion and clear operations
- assert LRUCache supports ttl expiration for cached entries
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
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 lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/lru-cache@10.4.3
Demonstrate these symbols/APIs:
- lru-cache.LRUCache
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:819931733a12c835847bd0bfe51248ac0cdffe8dc13a96403713298a29e3c887","constraints":{"executionContext":"node"},"contract":["assert LRUCache instantiates with options and performs set and get operations","assert LRUCache evicts least recently used items when max capacity is reached","assert LRUCache peek reads values without updating recency order","assert LRUCache supports item deletion and clear operations","assert LRUCache supports ttl expiration for cached entries"],"goal":"verify lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3","kind":"HOW","packages":["pkg:npm/lru-cache@10.4.3"],"schemaVersion":1,"symbols":["lru-cache.LRUCache"]},"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/lru-cache@10.4.3"],"schemaVersion":1,"subject":"pkg:npm/lru-cache@10.4.3","symbols":["lru-cache.LRUCache"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-lru-cache-lrucache",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-lru-cache-lrucache",
"version": "1.0.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-lrucache",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of lru-cache LRUCache",
"main": "src/index.js",
"dependencies": {
"lru-cache": "10.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/lru-cache@10.4.3"
],
"symbols": [
"lru-cache.LRUCache"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const { LRUCache } = require('lru-cache');
/**
* Create a new LRUCache instance with given options.
* @param {object} options
* @returns {LRUCache}
*/
function createCache(options = {}) {
return new LRUCache(options);
}
module.exports = {
LRUCache,
createCache,
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { LRUCache, createCache } = require('../src/index.js');
// 1. assert LRUCache instantiates with options and performs set and get operations
{
const cache = createCache({ max: 10 });
assert.ok(cache instanceof LRUCache, 'cache should be an instance of LRUCache');
cache.set('key1', 'value1');
assert.equal(cache.get('key1'), 'value1', 'get should retrieve the stored value');
assert.equal(cache.has('key1'), true, 'has should return true for stored key');
assert.equal(cache.size, 1, 'size should reflect number of stored items');
}
// 2. assert LRUCache evicts least recently used items when max capacity is reached
{
const cache = new LRUCache({ max: 2 });
cache.set('a', 1);
cache.set('b', 2);
cache.get('a'); // 'a' accessed, so 'b' becomes least recently used
cache.set('c', 3); // causes 'b' to be evicted
assert.equal(cache.get('a'), 1, 'key a should remain in cache');
assert.equal(cache.get('c'), 3, 'key c should be stored in cache');
assert.equal(cache.has('b'), false, 'key b should be evicted');
assert.equal(cache.get('b'), undefined, 'get on evicted key b should return undefined');
assert.equal(cache.size, 2, 'cache size should not exceed max');
}
// 3. assert LRUCache peek reads values without updating recency order
{
const cache = new LRUCache({ max: 2 });
cache.set('a', 1);
cache.set('b', 2);
// peek 'a' does not refresh 'a' recency, so 'a' remains older than 'b'
const peekVal = cache.peek('a');
assert.equal(peekVal, 1, 'peek should return the value');
cache.set('c', 3); // 'a' is evicted because it was not refreshed by peek
assert.equal(cache.has('a'), false, 'key a should have been evicted');
assert.equal(cache.has('b'), true, 'key b should remain in cache');
assert.equal(cache.has('c'), true, 'key c should remain in cache');
}
// 4. assert LRUCache supports item deletion and clear operations
{
const cache = new LRUCache({ max: 5 });
cache.set('x', 10);
cache.set('y', 20);
assert.equal(cache.size, 2);
const deleted = cache.delete('x');
assert.equal(deleted, true, 'delete should return true for deleted key');
assert.equal(cache.has('x'), false, 'has should return false after delete');
assert.equal(cache.size, 1);
cache.clear();
assert.equal(cache.size, 0, 'size should be 0 after clear');
assert.equal(cache.has('y'), false, 'all keys should be removed after clear');
}
// 5. assert LRUCache supports ttl expiration for cached entries
{
const cache = new LRUCache({ max: 5, ttl: 50 });
cache.set('temp', 'temporary-val');
assert.equal(cache.get('temp'), 'temporary-val', 'value should be available immediately');
// Wait for TTL expiration
await new Promise((resolve) => setTimeout(resolve, 80));
assert.equal(cache.get('temp'), undefined, 'expired item should return undefined');
assert.equal(cache.has('temp'), false, 'has should return false for expired item');
}
console.log('All LRUCache contract assertions passed successfully.');
Origin Seeder
anonymous