Fix: preflight remote L3 timeouts before any startup resource - #1426
Conversation
📝 WalkthroughWalkthroughStartup timeout validation now occurs before hierarchical worker resources, daemon pipes, temporary files, or runner processes are created. Tests verify invalid parent and manifest timeout configurations fail during preflight. ChangesStartup timeout preflight
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces early validation for remote session timeouts and startup budgets in both the parent worker and the remote L3 worker daemon, ensuring that invalid configurations fail fast before any system resources (such as shared memory, pipes, or subprocesses) are allocated. Unit tests have been added to verify this preflight behavior. The reviewer suggests wrapping the parent worker's timeout validation in a level check (self.level >= 4) to avoid redundant validation on level 3 workers.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
a26236b to
a48a4c5
Compare
An invalid remote_session_timeout_s / session_timeout_s / startup_remaining_s was rejected only after the parent had already built its subtree and the daemon had already spawned the runner — the failure then had to unwind partially-created resources instead of never creating them. - Parent: validate remote_session_timeout_s at the top of _init_hierarchical, before any mailbox shm, pre-fork _Worker mmap, child fork, or daemon socket is created (previously only checked in _activate_remote_sessions, after the subtree was built). The check is gated on the presence of remote workers — only a level >= 4 parent can carry them — so a worker with no remotes never validates an unused timeout. _activate_remote_sessions early-returns on the no-remote path for the same reason. - Daemon: validate session_timeout_s in _start_session before the ready pipe, manifest tempfile, and runner Popen — a valid startup_remaining_s no longer shields an invalid session_timeout_s from the pre-spawn gate. - Runner-side (remote_l3_session) second validation is unchanged. - Device-free UT proves zero resource-constructor calls on illegal 0 / negative / inf / nan input on both the parent and daemon paths, and that a remote-less worker does not validate the remote timeout.
Scope
Narrow follow-up to #1420 (single-root startup budget). Closes the numeric
timeout preflight ordering gap only: an invalid remote timeout must fail
before any startup resource exists, not after the subtree is built and rolled
back.
Before this PR the numeric values were validated, but too late:
remote_session_timeout_sonly in_activate_remote_sessions— which runs after_init_hierarchicalalreadyallocated mailbox shm, constructed the pre-fork
_Workermmap, and forkedchildren. An invalid value built the whole subtree, then unwound it.
_start_session) validatedstartup_remaining_sbefore thespawn, but not
session_timeout_s: a validstartup_remaining_splus aninvalid
session_timeout_slaunched the runner, which only then died on it.Delivered
remote_session_timeout_sis validated at the top of_init_hierarchical, before any mailbox shm / pre-fork_Worker/ child fork/ daemon socket is created. The check is gated on the presence of remote
workers (
self._remote_worker_specs) — only a level >= 4 parent can carrythem — so a worker with no remotes never validates an unused timeout;
_activate_remote_sessionsearly-returns on the same no-remote path._start_sessionvalidatessession_timeout_s(as wellas the already-checked
startup_remaining_s) before the ready pipe, manifesttempfile, and runner
Popen.remote_l3_session).0/ negative /inf/nannow fail before resource creation onboth paths.
Explicitly NOT in scope
RemoteWorkerSpec— only the numerictimeout preflight.
known issue.
Testing
test_remote_startup_budget.py, 45 passed):TestParentPreflightBeforeResourcesandTestDaemonPreflightBeforeSpawnmock the resource constructors and assert zero
SharedMemory/_Worker(parent) and
os.pipe/NamedTemporaryFile/Popen(daemon) calls onillegal input, plus that a remote-less worker never validates the timeout.
Verified failing against pre-change source, passing after.
tests/ut/py/test_worker/+test_remote_l3_lifecycle.py: 276 passed,2 skipped — no regression from the now-earlier, remote-gated validation.