Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Hosts — the contract

import type { HostPorts } from '@enc-protocol/cvn'
 
interface HostPorts {
  name: 'node' | 'web' | 'native' | string
  store: StorePort            // get/set/remove/keys + getJSON/setJSON
  now(): number               // wall clock, ms — the kernel is forbidden Date.now
  defer(fn, ms): () => void   // run later; returns cancel
  every(fn, ms): () => void   // run repeatedly; returns stop
  fetch: FetchLike
  randomBytes(n): Uint8Array  // the kernel is forbidden Math.random
}

Two hosts ship with the package: @enc-protocol/cvn/node and @enc-protocol/cvn/web. A third, native, lives in zooid-nativehow to build it.

The conformance suite

Every host runs the same assertions:

import { hostConformance } from '@enc-protocol/cvn/conformance'
import { test } from 'node:test'
import assert from 'node:assert/strict'
 
hostConformance(() => createMyHost(), { test, assert })

It is handed test and assert so it binds to node

, vitest or jest without importing any of them, and a factory so each test gets a fresh host. It checks the store's four operations and JSON round-trips (a corrupt value yields the fallback, never a throw), that now is a millisecond epoch that moves forward, that defer's cancel and every's stop actually stop, that randomBytes returns n bytes and not the same twice.

A host that passes conformance has not been proven to work in an app — it has been proven not to lie about the contract. That is what a native adopter needs before wiring an app: a host whose every never stops is found here, not in a battery report.