/** * 运行时基础件 —— 时钟与 ID 生成器。 * domain 零 `Date.now` / `Math.random`(§5.3),二者一律经 port 注入;实现在此。 */ import { randomUUID } from 'node:crypto'; export type Clock = { now(): Date }; export type IdGenerator = { next(): string }; export const systemClock: Clock = { now: () => new Date() }; export function createIdGenerator(prefix = ''): IdGenerator { return { next: () => `${prefix}${randomUUID()}` }; }