Documentation
¶
Overview ¶
Package timescale compresses the schedule of a run in time: with HL_TIME_SCALE=60 an hour of the agents' schedule passes in a minute. It exists for the eval stands of evallab, where a cron «every 30 minutes» would otherwise hold a runner for hours; a runtime without the variable runs on the plain clock.
Two clocks come out of it. The logical clock is the one the agents live by: it starts at the epoch (HL_TIME_EPOCH_MS, the stand's start, shared by the runtime and every agent of the stand) and runs Factor times faster than the wall clock from there. Durations of the schedule — an idle window, a sweep, a wait for a subchat — are logical and last Real(d) of the wall clock. What the work itself takes (a model's answer, a command) is not compressed: nothing can make it faster.
Claude Code reads its wall clock for its crons and wakeups (CronCreate, /loop, ScheduleWakeup: Date.now polled every second), so its clock is moved with a preload (Preload, PreloadEnv) that turns Date only: its timers and timeouts stay on the real clock, a request or a command is never cut short by the scale. Its transcript is then written on the logical clock, which is what evallab reads the windows of its checkpoints in.
Index ¶
Constants ¶
const ( // Env is the variable of the scale: how many times faster the schedule goes; 1 or nothing is the plain clock. Env = "HL_TIME_SCALE" // EpochEnv is the moment both clocks agree, in Unix milliseconds: the stand's start. EpochEnv = "HL_TIME_EPOCH_MS" // Max is the largest scale taken: a day in 24 seconds, past which a sweep of seconds would see nothing. Max = 3600 )
const Preload = `` /* 631-byte string literal not displayed */
Preload is the script that moves a Claude Code's wall clock (Bun's --preload): Date.now, new Date() and Date() run on the logical clock of HL_TIME_SCALE and HL_TIME_EPOCH_MS; a date built from a value, the timers and performance.now stay as they are.
Variables ¶
This section is empty.
Functions ¶
func Now ¶
Now is the logical now: what an agent of the stand reads off its clock. Compare the times an agent wrote (a wakeup, a cron job's creation) with this, not with time.Now.
Types ¶
type Clock ¶
Clock is a scale with its epoch: the process's (Process) or a stand's.
func Process ¶
func Process() Clock
Process is this process's clock, from HL_TIME_SCALE and HL_TIME_EPOCH_MS (the epoch defaults to the first read).
func (Clock) Env ¶
Env are the variables that put a process on this clock: a runtime, or with PreloadEnv an agent.
func (Clock) PreloadEnv ¶
PreloadEnv are the variables that give a Claude Code this logical clock, the preload being written at path. old is the BUN_OPTIONS it had, kept after the preload.