Repository navigation
fix(clock): computers and clock-following agents declare the times they hold, and the gateway refuses to take the clock outside them - #892
Open
earakely-scale wants to merge 16 commits into
Conversation
The clock page held the universe as one signed 64-bit count of nanoseconds, which runs out on 2262-04-11: a later date made every follower crash-loop with nothing saying why. The page (version 3) holds whole seconds and nanoseconds in the same 80 bytes; agent-env's libfaketime keeps universe times as 128-bit nanoseconds in its waits and computes clock reads with 64-bit operations alone, in one place both share; the egress proxy reads the new page and no longer overflows on a certificate ending past 2262; a page of another version is replaced at boot and never read. The gateway names 9999-12-31T23:59:59Z, the latest it reaches, in every error about the range. The clock gates run at 1950, across 2262, in 3026 and in 9999. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… universe clock Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Python and the clock page hold CPython keeps time as 64-bit nanoseconds (time.time() raises, datetime.now() sticks at 2262-04-11 outside them), so the gateway refuses a time outside that range, or one it would run past the end from within a real hour, with a message naming the range. The page, C and Go go back to main; the pre-1970 deadline fix stays, with libfaketime's spec written with its sign once before 1970. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… either end of the clock's range ft_ns clamped any deadline past +-9e9 s (1684..2255) to +-4.6e18 ns, so near either end of the range an absolute wait ended at once or never; it's now exact and saturates beyond 64 bits. A deadline and the universe at opposite ends no longer overflow in ft_real_of or the timers, and the universe at a real time (reads and waits share ft_universe_at) stops at the end of 64 bits rather than wrapping when a gateway outlives its range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ery refusal names the range where it's read The gateway's clock stopped refusing times outside 1677-09-21..2262-04-11, but a clock armed within its last real hour still ran past the end: the gateway's reads went on toward 9999, a computer's follower then wrote a universe the page can't hold and crash-looped with the page left mid-write, and the session's clock stopped at the end of 64 bits, where any deadline computed from now was already reached, so waits in a loop spun. - The gateway's clock stands at LATEST: its reads, state and watch stop there, and its state says rate 0 there, so followers stop with it. It can still be frozen or advanced to the time it shows, and set back. - A write is refused for passing the end within a real hour only when it brings the end closer: an advance to the time the clock shows (as always_on's settle makes) or a rate no faster goes through in the last hour. The check compares seconds, so a rate too slow for a microsecond an hour is refused too. - Every out-of-range spelling names the range: a UTC instant past datetime's ends (0001 at +01:00, 9999 at -01:00) and year 0000; a string that isn't RFC3339 at all is refused as one, five digits or not. - sync_env_clock reports a time or rate the gateway would refuse as a config problem, before anything deploys, naming the time as the task wrote it, its zone included; a zoned wall time no date holds names the range too. - The clock/v1 card states the range. - The protocol client takes a bare-string error as the message, so a refused clock write read through invoke (the hooks, always_on) says why instead of "400 error: Bad Request". - clockpage.py writes a universe outside the range at its end, so a write never fails halfway. - agent-env's libfaketime: the universe stops at FT_END, the range's last second, as the gateway's does, and a deadline past it is never reached; a page before 1970 runs on exactly however far it runs (128-bit sum); a periodic realtime timer armed on a frozen clock gets no kernel interval, where x86_64 got 1 ns from interval / 0; timerfd_gettime gives the whole time left to a deadline at the other end of the range. - get_time drops its zone-overflow error, which a clock inside the range can't reach. Tests: unit tests for each gateway case, the card, sync_env_clock's config problems, the client's string error and the page writer's bounds; tst/env's stale 9999 tests moved to the range; clock gates for waits at the end (running into it and frozen there), a page before 1970 left to run 29.7 h, timers on a frozen clock, and a page written past the end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ond once the clock runs again Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt names a sync_env_clock step once set_rate refused any rate faster than the current one, and advance any jump, that would bring the clock to the end of its range within a real hour. A clock armed an hour or more before the end and frozen, as always_on freezes it between turns (or a harness that pauses it, or sync_env_clock at rate 0 then set_env_clock_rate), couldn't be started again there: always_on failed mid-run at a time inside the range, where main completes, and a hook's advance to an event in that hour failed too. Only set_time, which arms the clock, still refuses that hour; set_rate takes any rate and advance any time up to the end, and a clock that reaches the end stands there at rate 0, as one that outlives its range does. A clock armed frozen at the end now answers set_rate as one that ran there does. sync_env_clock's config problem no longer names its step itself, as the verifiers' don't: lint, which adds the step, printed "step 'clock': step 'clock': ...". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
marked this pull request as ready for review
November 24, 2026 03:11
…ck gets there, and session_time stands there too A clock running into the end stood still for reads but not for a periodic timer the kernel held, which ticked on until the follower wrote the standing page: libfaketime's helper now wakes when the clock reaches the end and stops them there, and a timer armed past it gets no interval. agentenv_protocol's session_time, which stamps an agent's trajectory, stops at the end as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…program's loop does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nread expirations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… it, and the gateway keeps to it The gateway no longer limits every clock to 1677..2262: an MCP-only env's clock reaches what a datetime holds, as before. A computer's card and a clock-following agent's declare clock/v1's range (what 64 bits of nanoseconds since 1970 hold, as their clock page and Python keep time); core passes a computer's to the gateway (CLOCK_FOLLOWER_RANGES) and an agent brings its own to declare_follower. While the clock has such a follower, set_time and advance refuse a time outside its range, naming it, set_time one it would run past the end of from within a real hour, and declare_follower one the clock is outside now (an agent then can't follow: skipped, or the step fails under require_agent_clock). A follower that declares none leaves the clock as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
…ad range never stops the gateway Fixes from testing the per-follower clock ranges, the design unchanged: - declare_follower refuses a ranged follower the clock would run past the end of from within a real hour, as set_time refuses arming with it, so arming first and declaring the agent after no longer gets around the horizon. - Its range refusals carry error code outside_range, and follow() reports only those as outside_range: any other refusal (a name a start follower holds) raises as it does for an agent with no range. - Core parses a computer's or an agent's card range itself; one that doesn't parse is logged and left out, as a card that declares none, rather than crash-looping the gateway at boot (CLOCK_FOLLOWER_RANGES) or being sent to declare_follower. - A range that doesn't parse is refused naming "range earliest" or "range latest", not virtual_time. - set_time checks an unknown time zone before overflow again, as main does. - ExternalChild holds the parsed FollowerRange, so it stays hashable. set_rate stays unchecked: a horizon check there would refuse always_on starting a clock it froze near the end again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… there, and sync_env_clock is as on main While the clock has a follower that holds only a range of times, its reads, state and watch stand at the end of the narrowest such range, at rate 0, so the gateway's tools and the computer agree (Greptile). sync_env_clock's up-front check is dropped: it reached steps with no follower range, which run as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e and an MCP-only gateway arming past 2262 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…there, rather than only reading there Its run up to the end is folded in and its rate set to 0 the first time anything reads or writes it after, so its delays and marks stop with it (elapsed and at_elapsed agree with the time it shows), retiring the follower leaves it where it stands rather than jumping it to where it would have run, and a follower declared while it stands is taken (Greptile, testers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Re the outside-diff P1 Gateway and computer times split ( While the clock has a follower that holds only a range of times, a clock that runs to the end of that range stops there at rate 0. Its reads, state, watch and Without a ranged follower (an MCP-only gateway, or followers from before |
…cross a follower's end never passes it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Setting the env clock past 2262-04-11 broke computers, and nothing said why (FD-6471). The clock page, which every computer's follower writes and every faked process reads, holds the universe as a signed 64-bit count of nanoseconds since 1970. That count runs out on 2262-04-11. Arming a later date made the follower crash-loop, and the computer failed with "the clock follower hasn't heard from the gateway yet".
Widening the page isn't enough, because CPython keeps time the same way. Outside 1677-09-21 to 2262-04-11, inside a faked session:
time.time()raisesOverflowError;import loggingfails, so most Python programs don't start;datetime.now()silently sticks at the edge of the range.The limit belongs to what follows the clock, not to the clock. An MCP-only env's gateway clock is a Python
datetimeand reaches year 9999 fine. So the envs and agents that can't go further now say so, and the gateway refuses on their behalf.What
Followers declare the times they hold.
range: 1677-09-21T00:12:44Z to 2262-04-11T23:47:16Z (agentenv_protocol.computer.clock.RANGE).CLOCK_FOLLOWER_RANGES, read from the computer's card). An agent brings its own todeclare_follower.The gateway keeps to its followers' ranges (
env/gateway/clock.py,clock_followers.py):set_timeandadvancerefuse a time outside it, naming the follower:virtual_time '3026-11-23T12:00:00Z' is outside the times clock follower 'desktop' holds, 1677-09-21T00:12:44Z to 2262-04-11T23:47:16Z.set_timealso refuses a time it would run past the end of the range from within a real hour, so a rate of 86400 still arms at today's dates.declare_followerrefuses an agent whose range the clock is outside now, or would run past from within a real hour. The refusal carries error codeoutside_range, and that agent can't follow: it's skipped, or the step fails underrequire_agent_clock, as for any other reason.set_rate, which refuses nothing, soalways_oncan always restart a clock it froze.get_timeand delays all stop with it, so the gateway's tools agree with the computer.set_ratewhile it stands answers rate 0, until aset_timemoves it.Nothing changes without a declared range. An MCP-only env, or a computer or agent whose card predates
range, gets the clock as on main, up to what adatetimeholds.Smaller change: the protocol client takes a gateway's bare-string
erroras the message. The advance-to-next-event hook andalways_onnow say why a clock write failed, rather than "400 error: Bad Request".agent-env's libfaketime and the page. Three of these were existing bugs, found by the new range gates:
timerfd_settime,timer_settime,FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIMEandclock_nanosleep(TIMER_ABSTIME)gotEINVALbefore.ft_nsused to clamp any deadline past ±9e9 s, before 1684-10 or after 2255-03, so a wait there ended at once or never. A deadline and the universe at opposite ends no longer overflow.@-631108799.-991862200.session_time()too. The page writer keeps any universe inside the range.Known limits, unchanged:
parkUntilfor a negative absolute time.Tests
Unit, gateway:
CLOCK_FOLLOWER_RANGESparsing.Unit, core and protocol:
declare_follower, and its refusal reported asoutside_range(only on that error code), or failing the step when required;range;Integration:
computer_clock_testasserts the desktop's range in the gateway's state, and its refusal of 3026 naming it;gateway_test's clock extension test arms an MCP-only gateway at 3026 and 9999.Clock gates (
tst/clock/range_test.py), at 1677-09-22, 1950-01-01 and 2261-08-01, and in the last hour:The tier passes 69/69 on x86_64 and arm64.
E2E and chaos:
always_on, the hooks and triggers, and 4000 seeded clock operations, A/B against main.get_timeand main's refusals.outside_range, or fail the step when required, and they bind or free the clock as they come and go.get_timeand the session'sdateand python3 all read 2262-04-11T23:47:16Z.set_timeback to 1950 recovers, and triggers resume.Docs
The docs site should cover:
rangeon an env's or agent's card: the times it holds, and the computers' and clock-following agents' 1677-09-21T00:12:44Z to 2262-04-11T23:47:16Z;set_timeoradvanceoutside a follower's range, naming it;sync_env_clock'soutside_rangereason for an agent that can't follow.Agents get their range on their cards once their images are rebuilt with this release's protocol.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previous backward-read issue is fixed, and no new blocking issue was found.Summary
Followers declare the dates they support, and the gateway keeps clock writes and running time within those dates.
Reviews (14) · Last reviewed commit: "fix(clock): each clock operation reads r..." · Reviewed by Greptile