CodeSampleX

Sample

vary 1.1.2

Verified sample for npm vary 1.1.2. The contract ran on node 22 · linux alpine/x64 · docker and passed: vary(res, field) sets the Vary header on response…

sha256:096d8391342654f71e83728e3b26eb9f1d537f215ae90f4372f781e75a2ee6d6

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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@1
2026-08-20

Case

HOW
Goal
verify pkg:npm/vary@1.1.2
Packages
Created
2026-08-20T14:08:03Z

Contract

  1. vary(res, field) sets the Vary header on response object
  2. vary(res, field) appends field to existing Vary header without duplicating
  3. vary(res, field) accepts an array of header field names
  4. vary(res, field) sets Vary header to * when field is *
  5. vary.append(header, field) returns updated header string without modifying existing headers
  6. vary.append(header, field) returns * if header or field contains *
  7. vary.append(header, field) throws TypeError when header or field argument is invalid
  8. vary(res, field) throws TypeError when res argument is invalid or missing methods

Files

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

Download the source artifact (tar.gz)

Source

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/vary@1.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/vary@1.1.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.
csx.json
{"case":{"caseId":"case:sha256:916edf5792a7a04cfd078ccd24ec0006e491cd746316bca53dfda326fc37a8b1","contract":["vary(res, field) sets the Vary header on response object","vary(res, field) appends field to existing Vary header without duplicating","vary(res, field) accepts an array of header field names","vary(res, field) sets Vary header to * when field is *","vary.append(header, field) returns updated header string without modifying existing headers","vary.append(header, field) returns * if header or field contains *","vary.append(header, field) throws TypeError when header or field argument is invalid","vary(res, field) throws TypeError when res argument is invalid or missing methods"],"goal":"verify pkg:npm/vary@1.1.2","kind":"HOW","packages":["pkg:npm/vary@1.1.2"],"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/vary@1.1.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-vary",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-vary",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "vary": "1.1.2"
      }
    },
    "node_modules/vary": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
      "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.8"
      }
    }
  }
}
package.json
{
  "name": "sample-vary",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "vary": "1.1.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/vary@1.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/vary@1.1.2"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const vary = require('vary');

// 1. Module export verification
assert.equal(typeof vary, 'function', 'vary must be a function');
assert.equal(typeof vary.append, 'function', 'vary.append must be a function');

// Helper to create mock response object
function createMockRes(initialHeaders = {}) {
  const headers = { ...initialHeaders };
  return {
    headers,
    getHeader(name) {
      return this.headers[name.toLowerCase()] || this.headers[name];
    },
    setHeader(name, value) {
      this.headers[name.toLowerCase()] = value;
    }
  };
}

// 2. vary(res, field) sets the Vary header on response object
const res1 = createMockRes();
vary(res1, 'Accept-Encoding');
assert.equal(res1.getHeader('Vary'), 'Accept-Encoding');

// 3. vary(res, field) appends field to existing Vary header without duplicating
const res2 = createMockRes({ vary: 'Accept' });
vary(res2, 'Accept-Encoding');
assert.equal(res2.getHeader('Vary'), 'Accept, Accept-Encoding');

// Case-insensitive duplicate check should not re-add
vary(res2, 'accept-encoding');
assert.equal(res2.getHeader('Vary'), 'Accept, Accept-Encoding');

// 4. vary(res, field) accepts an array of header field names
const res3 = createMockRes();
vary(res3, ['Accept', 'User-Agent', 'Origin']);
assert.equal(res3.getHeader('Vary'), 'Accept, User-Agent, Origin');

// 5. vary(res, field) sets Vary header to * when field is *
const res4 = createMockRes({ vary: 'Accept, Accept-Language' });
vary(res4, '*');
assert.equal(res4.getHeader('Vary'), '*');

// 6. vary.append(header, field) returns updated header string without modifying existing headers
const header1 = 'Accept-Encoding';
const appended1 = vary.append(header1, 'Origin');
assert.equal(appended1, 'Accept-Encoding, Origin');
assert.equal(header1, 'Accept-Encoding'); // unchanged original string

const appendedArray = vary.append('Accept', ['Accept-Language', 'User-Agent']);
assert.equal(appendedArray, 'Accept, Accept-Language, User-Agent');

// 7. vary.append(header, field) returns * if header or field contains *
assert.equal(vary.append('*', 'Accept'), '*');
assert.equal(vary.append('Accept', '*'), '*');
assert.equal(vary.append('Accept', ['Accept-Encoding', '*']), '*');

// 8. vary.append(header, field) throws TypeError when header or field argument is invalid
assert.throws(
  () => vary.append(null, 'Accept'),
  (err) => err instanceof TypeError && err.message === 'header argument is required'
);
assert.throws(
  () => vary.append('Accept', null),
  (err) => err instanceof TypeError && err.message === 'field argument is required'
);
assert.throws(
  () => vary.append('Accept', 'invalid header with space'),
  (err) => err instanceof TypeError && err.message === 'field argument contains an invalid header name'
);

// 9. vary(res, field) throws TypeError when res argument is invalid or missing methods
assert.throws(
  () => vary(null, 'Accept'),
  (err) => err instanceof TypeError && err.message === 'res argument is required'
);
assert.throws(
  () => vary({}, 'Accept'),
  (err) => err instanceof TypeError && err.message === 'res argument is required'
);
assert.throws(
  () => vary({ getHeader: () => {} }, 'Accept'),
  (err) => err instanceof TypeError && err.message === 'res argument is required'
);

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous