サンプル
lru-cache 6.0.0
検証済みサンプル — npm lru-cache 6.0.0. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: cache.set(key, value) and cache.get(key) store and retrieve values
sha256:4889208dd521d04e712cd35ec4b50e62c5f5f738754494631e6701226e613c9a
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify pkg:npm/lru-cache@6.0.0
- パッケージ
- 作成日
- 2026-08-21T13:50:43Z
コントラクト
- 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
ファイル
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
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.');
オリジンシーダー
匿名