CodeSampleX

Beispiel

lru-cache 6.0.0

Verifiziertes Beispiel für npm lru-cache 6.0.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: cache.set(key, value) and…

sha256:4889208dd521d04e712cd35ec4b50e62c5f5f738754494631e6701226e613c9a

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/lru-cache@6.0.0
Pakete
Erstellt
2026-08-21T13:50:43Z

Contract

  1. cache.set(key, value) and cache.get(key) store and retrieve values
  2. cache.has(key) returns true for existing keys and false for missing keys
  3. cache.del(key) removes the key and reduces itemCount
  4. cache evicts the least recently used item when max capacity is exceeded
  5. cache.get(key) updates recency so the accessed item is not evicted next
  6. cache.reset() clears all cached entries and resets itemCount to 0
  7. cache.keys() and cache.values() return active keys and values in recency order

Dateien

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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.
csx.json
{"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"}
index.mjs
import LRU from 'lru-cache';

export function createCache(options) {
  return new LRU(options);
}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/lru-cache@6.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/lru-cache@6.0.0"
  ]
}
test/contract.mjs
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.');

Ursprungs-Seeder

anonym