timescale

package
v0.16.521 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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
)
View Source
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 At

func At(t time.Time) time.Time

At is the logical time of a wall-clock moment on this process's clock.

func Factor

func Factor() float64

Factor is the scale of this process: 1 on the plain clock.

func Label

func Label(f float64) string

Label is how a scale is shown to a person: «×60», "" on the plain clock.

func Logical

func Logical(d time.Duration) time.Duration

Logical is how long a wall-clock duration is on this process's logical clock.

func Now

func Now() time.Time

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.

func On

func On() bool

On reports whether this process's schedule is compressed.

func Parse

func Parse(s string) float64

Parse reads a scale: a number from 1 to Max; anything else is the plain clock (1).

func Real

func Real(d time.Duration) time.Duration

Real is how long a logical duration of this process's schedule lasts on the wall clock.

func Set

func Set(f float64, at time.Time)

Set fixes the scale and the epoch of this process (tests, and a process that takes them from flags).

Types

type Clock

type Clock struct {
	Factor float64
	Epoch  time.Time
}

Clock is a scale with its epoch: the process's (Process) or a stand's.

func New

func New(f float64, at time.Time) Clock

New is a clock of scale f from at: f is taken as Parse takes it.

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) At

func (c Clock) At(t time.Time) time.Time

At is the logical time of a wall-clock moment.

func (Clock) Env

func (c Clock) Env() map[string]string

Env are the variables that put a process on this clock: a runtime, or with PreloadEnv an agent.

func (Clock) Logical

func (c Clock) Logical(d time.Duration) time.Duration

Logical is how long a wall-clock duration is on the logical clock.

func (Clock) On

func (c Clock) On() bool

On reports whether the clock compresses the schedule.

func (Clock) PreloadEnv

func (c Clock) PreloadEnv(path, old string) map[string]string

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.

func (Clock) Real

func (c Clock) Real(d time.Duration) time.Duration

Real is how long a logical duration lasts on the wall clock: d itself on the plain clock, never less than a millisecond for a positive d.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL