Exemplo
fresh 2.0.0
Amostra verificada para npm fresh 2.0.0. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: fresh(reqHeaders, resHeaders) returns false for…
sha256:a13513787b8f06f4ff588920fa652e8e8d861f2bb13222af32c831056298e691
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Caso
HOW- Objetivo
- verify pkg:npm/fresh@2.0.0
- Pacotes
- Criado
- 2026-08-20T13:52:02Z
Contrato
- fresh(reqHeaders, resHeaders) returns false for unconditional requests without if-modified-since or if-none-match
- fresh(reqHeaders, resHeaders) returns false when Cache-Control header contains no-cache even if ETags match
- fresh(reqHeaders, resHeaders) returns true when if-none-match exactly matches the response etag
- fresh(reqHeaders, resHeaders) returns true when matching weak ETags like W/"123" and "123"
- fresh(reqHeaders, resHeaders) returns true when if-none-match is wildcard *
- fresh(reqHeaders, resHeaders) returns true when if-modified-since is at or after response last-modified date
- fresh(reqHeaders, resHeaders) prioritizes if-none-match over if-modified-since when both are present
Arquivos
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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/fresh@2.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/fresh@2.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:f8aa366ce0acad548bde72db92105d45ed260fe9a6f4c004e3f20cd9b8121604","contract":["fresh(reqHeaders, resHeaders) returns false for unconditional requests without if-modified-since or if-none-match","fresh(reqHeaders, resHeaders) returns false when Cache-Control header contains no-cache even if ETags match","fresh(reqHeaders, resHeaders) returns true when if-none-match exactly matches the response etag","fresh(reqHeaders, resHeaders) returns true when matching weak ETags like W/\"123\" and \"123\"","fresh(reqHeaders, resHeaders) returns true when if-none-match is wildcard *","fresh(reqHeaders, resHeaders) returns true when if-modified-since is at or after response last-modified date","fresh(reqHeaders, resHeaders) prioritizes if-none-match over if-modified-since when both are present"],"goal":"verify pkg:npm/fresh@2.0.0","kind":"HOW","packages":["pkg:npm/fresh@2.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/fresh@2.0.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
import fresh from 'fresh';
export function isResponseFresh(reqHeaders, resHeaders) {
return fresh(reqHeaders, resHeaders);
}
{
"name": "sample-fresh",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-fresh",
"version": "1.0.0",
"dependencies": {
"fresh": "2.0.0"
}
},
"node_modules/fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
"integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}
{
"name": "sample-fresh",
"version": "1.0.0",
"description": "Clean-room verification sample for fresh",
"type": "module",
"private": true,
"dependencies": {
"fresh": "2.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/fresh@2.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/fresh@2.0.0"
]
}
import assert from 'node:assert/strict';
import fresh from 'fresh';
import { isResponseFresh } from '../index.mjs';
// 1. Unconditional requests return false
assert.equal(fresh({}, {}), false);
assert.equal(isResponseFresh({ host: 'example.com' }, { etag: '"123"' }), false);
// 2. Cache-Control: no-cache returns false even when ETags match
assert.equal(fresh({ 'if-none-match': '"123"', 'cache-control': 'no-cache' }, { etag: '"123"' }), false);
assert.equal(fresh({ 'if-none-match': '"123"', 'cache-control': 'max-age=0, no-cache' }, { etag: '"123"' }), false);
// 3. Exact if-none-match match returns true
assert.equal(fresh({ 'if-none-match': '"123"' }, { etag: '"123"' }), true);
assert.equal(fresh({ 'if-none-match': '"123"' }, { etag: '"456"' }), false);
assert.equal(fresh({ 'if-none-match': '"foo", "bar"' }, { etag: '"bar"' }), true);
// 4. Weak ETag matching returns true
assert.equal(fresh({ 'if-none-match': 'W/"123"' }, { etag: '"123"' }), true);
assert.equal(fresh({ 'if-none-match': '"123"' }, { etag: 'W/"123"' }), true);
assert.equal(fresh({ 'if-none-match': 'W/"123"' }, { etag: 'W/"123"' }), true);
// 5. Wildcard * if-none-match returns true
assert.equal(fresh({ 'if-none-match': '*' }, { etag: '"anything"' }), true);
assert.equal(fresh({ 'if-none-match': '*' }, {}), true);
// 6. if-modified-since comparison
const now = new Date('2026-08-20T12:00:00Z').toUTCString();
const past = new Date('2026-08-20T11:00:00Z').toUTCString();
const future = new Date('2026-08-20T13:00:00Z').toUTCString();
assert.equal(fresh({ 'if-modified-since': now }, { 'last-modified': past }), true);
assert.equal(fresh({ 'if-modified-since': now }, { 'last-modified': now }), true);
assert.equal(fresh({ 'if-modified-since': past }, { 'last-modified': now }), false);
// 7. if-none-match takes precedence over if-modified-since
assert.equal(fresh({ 'if-none-match': '"mismatch"', 'if-modified-since': future }, { etag: '"actual"', 'last-modified': past }), false);
assert.equal(fresh({ 'if-none-match': '"match"', 'if-modified-since': past }, { etag: '"match"', 'last-modified': future }), true);
console.log('All fresh@2.0.0 contract assertions passed.');
Seeder de origem
anônimo