Auto OS calls
Merged
SA
3mo ago+5318+5318+0123456789012345678901234567890123456789-1465-1465-0123456789012345678901234567890123456789
Summary by cubic
Answers the clock, timezone, and unseeded random seeding inside the sandbox by default, and turns time.sleep()/asyncio.sleep() into host-side waits that don't consult the os handler (each cut to sleep_system_max). Adds a cumulative sleep budget the host charges per capped wait and enforces while waiting.
Breaking changes
date.today(),datetime.now(), andtime.time()no longer reach theoscallback by default; the sandbox answers them, and a fixed clock overrides them.- Default sleeps send
system.sleep/system.async_sleepinstead oftime.sleep/asyncio.sleep;sleep: 'call_host'restores the old handler calls. Each default sleep is one suspension againstmax_suspensions, cut tosleep_system_max. - Unseeded
randomgenerators seed from OS entropy orrandom_start;random_start: 'call_host'restores theos.urandomcall. A failed entropy read raises an uncatchableOSError, and a host reply that isn't importable bytes raises the shared'os.urandom' must return byteserror at the draw. - The CLI's
--max-sleepclamps waits and works without a mount;--max-total-sleepis off unless given (inflifts it). datetime.now(tz)under a fixed clock that can't holdtzraisesOverflowErrorinstead of falling back to the host's clock.
New options
checkout()gainsauto_os_calls/autoOsCallswithdatetime,timezone,sleep,sleep_system_max/sleepSystemMax, andrandom_start/randomStart.- A
datetimefreezes the clock,timezonepicks the system's, the host's, or a fixed UTC offset,sleep: 'zero'skips waits, andrandom_startaccepts any seedrandom.seed()takes. - A
sleep_system_maxset alongside'call_host'or'zero'is rejected withValueError/RangeError. max_total_sleep/maxTotalSleepSecs/--max-total-sleepcaps cumulative host waits; the host charges each sleep at its capped delay, refuses the sleep that would exceed the limit with an uncatchableTimeoutError, and a restored dump or worker report can only tighten the configured limit.