Clocktypetype Clock = { now(): number; sleep(ms: number): Promise<void> };Time: the instant in milliseconds since the epoch, and a wait.
What the layers are given instead of reaching for it: the clock and the sleep, the tracer and the sink of the audit. Each is a value a caller passes, so that every layer is a function of its arguments and a test holds time in its hand.
import type { Clock } from "./ports.ts";
const clock: Clock = { now: () => 0, sleep: async () => {} };Clocktypetype Clock = { now(): number; sleep(ms: number): Promise<void> };Time: the instant in milliseconds since the epoch, and a wait.
Spantypetype Span = { end(attributes: Readonly<Record<string, string | number>>): void };A span that has begun: it ends with the attributes of what happened.
Tracertypetype Tracer = { start(name: string, attributes: Readonly<Record<string, string | number>>): Span };Where spans begin.
AuditRecordtypetype AuditRecord = {
readonly at: string;
readonly store: string;
readonly op: OpName;
readonly path?: string;
readonly outcome: "ok" | "missing" | "conflict" | "refused" | "unavailable" | "tampered";
readonly size?: number;
};What the audit says of one operation. It holds no bytes and no text of a file.
AuditSinktypeno test imports ittype AuditSink = (record: AuditRecord) => Promise<void>;Where the audit records go: it may throw, and the operation says so.