Sample
http-cache-semantics 4.3.0: CachePolicy, CachePolicy.storable, CachePolicy.stale
Verified sample for npm http-cache-semantics 4.3.0: CachePolicy, CachePolicy.storable, CachePolicy.stale. The contract ran on node 22 · linux debian/x64 …
sha256:81aa90e528785d4293dae39801fcd3a6a6a3bc1a0e53e0eb4d05667aab145824
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
- 1
- Signing keys that built it
- 1
Declared environment
node linux 24 · ubuntu · glibc 2.39 x64 node npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-10-17 |
Case
HOW- Goal
- verify pkg:npm/http-cache-semantics@4.3.0
- Packages
- Symbols
-
- CachePolicy
- CachePolicy.storable
- CachePolicy.stale
- CachePolicy.timeToLive
- CachePolicy.satisfiesWithoutRevalidation
- CachePolicy.revalidationHeaders
- CachePolicy.revalidatedPolicy
- CachePolicy.toObject
- CachePolicy.fromObject
- Environment
- node
- Created
- 2026-10-17T23:42:28Z
Contract
- CachePolicy.storable evaluates whether an HTTP response can be stored in cache according to Cache-Control headers
- CachePolicy.stale and CachePolicy.timeToLive evaluate whether a cached HTTP response has expired based on max-age
- CachePolicy.satisfiesWithoutRevalidation determines if a cached response can satisfy a new incoming HTTP request
- CachePolicy.revalidationHeaders generates conditional request headers including if-none-match for 304 revalidation
- CachePolicy.revalidatedPolicy returns updated policy instance merging cached headers with 304 revalidation response headers
- CachePolicy.toObject and CachePolicy.fromObject serialize and restore policy state
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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 pkg:npm/http-cache-semantics@4.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/http-cache-semantics@4.3.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:86cd9831f7974ccc828601407b3134153528a0864e929376dd12b7337e76388e","contract":["CachePolicy.storable evaluates whether an HTTP response can be stored in cache according to Cache-Control headers","CachePolicy.stale and CachePolicy.timeToLive evaluate whether a cached HTTP response has expired based on max-age","CachePolicy.satisfiesWithoutRevalidation determines if a cached response can satisfy a new incoming HTTP request","CachePolicy.revalidationHeaders generates conditional request headers including if-none-match for 304 revalidation","CachePolicy.revalidatedPolicy returns updated policy instance merging cached headers with 304 revalidation response headers","CachePolicy.toObject and CachePolicy.fromObject serialize and restore policy state"],"goal":"verify pkg:npm/http-cache-semantics@4.3.0","kind":"HOW","packages":["pkg:npm/http-cache-semantics@4.3.0"],"schemaVersion":1,"symbols":["CachePolicy","CachePolicy.storable","CachePolicy.stale","CachePolicy.timeToLive","CachePolicy.satisfiesWithoutRevalidation","CachePolicy.revalidationHeaders","CachePolicy.revalidatedPolicy","CachePolicy.toObject","CachePolicy.fromObject"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/http-cache-semantics@4.3.0"],"schemaVersion":1,"subject":"pkg:npm/http-cache-semantics@4.3.0","symbols":["CachePolicy","CachePolicy.storable","CachePolicy.stale","CachePolicy.timeToLive","CachePolicy.satisfiesWithoutRevalidation","CachePolicy.revalidationHeaders","CachePolicy.revalidatedPolicy","CachePolicy.toObject","CachePolicy.fromObject"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-http-cache-semantics",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-http-cache-semantics",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"http-cache-semantics": "4.3.0"
}
},
"node_modules/http-cache-semantics": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.3.0.tgz",
"integrity": "sha512-M5t5LlJpS1UHMjvwRQVdFHvPISGeLAxNcrWuJkeGh0KxsqCHZ1O3NXZU/8x7cD0BDcGW8kapxMKTvwlqrNkHkA==",
"license": "BSD-2-Clause"
}
}
}
{
"name": "sample-http-cache-semantics",
"version": "1.0.0",
"private": true,
"description": "verify pkg:npm/http-cache-semantics@4.3.0",
"type": "module",
"main": "src/index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"http-cache-semantics": "4.3.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/http-cache-semantics@4.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/http-cache-semantics@4.3.0"
]
}
import CachePolicy from 'http-cache-semantics';
export { CachePolicy };
export function createCachePolicy(request, response, options) {
return new CachePolicy(request, response, options);
}
export function isResponseStorable(request, response, options) {
const policy = new CachePolicy(request, response, options);
return policy.storable();
}
export function isCacheFresh(policy) {
return !policy.stale();
}
export function canSatisfyRequest(policy, request) {
return policy.satisfiesWithoutRevalidation(request);
}
export function getRevalidationHeaders(policy, request) {
return policy.revalidationHeaders(request);
}
export function applyRevalidation(policy, revalidationRequest, revalidationResponse) {
return policy.revalidatedPolicy(revalidationRequest, revalidationResponse);
}
import assert from 'node:assert/strict';
import CachePolicy from 'http-cache-semantics';
import {
createCachePolicy,
isResponseStorable,
isCacheFresh,
canSatisfyRequest,
getRevalidationHeaders,
applyRevalidation,
} from '../src/index.mjs';
function runContract() {
const req = {
url: 'https://example.com/api/items',
method: 'GET',
headers: {
accept: 'application/json',
},
};
const resFresh = {
status: 200,
headers: {
'cache-control': 'public, max-age=3600',
etag: '"v1-etag"',
'last-modified': 'Wed, 21 Oct 2025 07:28:00 GMT',
'content-type': 'application/json',
},
};
// 1. CachePolicy.storable evaluates whether an HTTP response can be stored in cache according to Cache-Control headers
const policyFresh = createCachePolicy(req, resFresh);
assert.strictEqual(policyFresh.storable(), true);
assert.strictEqual(isResponseStorable(req, resFresh), true);
const resNoStore = {
status: 200,
headers: {
'cache-control': 'no-store',
},
};
assert.strictEqual(isResponseStorable(req, resNoStore), false);
// 2. CachePolicy.stale and timeToLive evaluate whether a cached HTTP response has expired based on max-age
assert.strictEqual(policyFresh.stale(), false);
assert.strictEqual(isCacheFresh(policyFresh), true);
assert.strictEqual(policyFresh.timeToLive() > 0, true);
const resStale = {
status: 200,
headers: {
'cache-control': 'public, max-age=0',
etag: '"v1-etag"',
},
};
const policyStale = createCachePolicy(req, resStale);
assert.strictEqual(policyStale.stale(), true);
assert.strictEqual(isCacheFresh(policyStale), false);
// 3. CachePolicy.satisfiesWithoutRevalidation determines if a cached response can satisfy a new incoming HTTP request
assert.strictEqual(canSatisfyRequest(policyFresh, req), true);
assert.strictEqual(
canSatisfyRequest(policyFresh, {
url: 'https://example.com/api/items',
method: 'POST',
headers: { accept: 'application/json' },
}),
false
);
assert.strictEqual(canSatisfyRequest(policyStale, req), false);
// 4. CachePolicy.revalidationHeaders generates conditional request headers including if-none-match for 304 revalidation
const revalHeaders = getRevalidationHeaders(policyStale, req);
assert.strictEqual(revalHeaders['if-none-match'], '"v1-etag"');
// 5. CachePolicy.revalidatedPolicy returns updated policy instance merging cached headers with 304 revalidation response headers
const revalReq = {
url: 'https://example.com/api/items',
method: 'GET',
headers: revalHeaders,
};
const revalRes = {
status: 304,
headers: {
'cache-control': 'public, max-age=7200',
etag: '"v1-etag"',
},
};
const revalidated = applyRevalidation(policyStale, revalReq, revalRes);
assert.strictEqual(revalidated.matches, true);
assert.strictEqual(revalidated.modified, false);
assert.strictEqual(revalidated.policy.storable(), true);
assert.strictEqual(revalidated.policy.stale(), false);
// 6. CachePolicy.toObject and CachePolicy.fromObject serialize and restore policy state
const obj = policyFresh.toObject();
const restored = CachePolicy.fromObject(obj);
assert.strictEqual(restored.storable(), true);
assert.strictEqual(restored.stale(), false);
assert.deepStrictEqual(restored.responseHeaders()['content-type'], 'application/json');
}
runContract();
Origin Seeder
anonymous