fail kernel bootstrap fast when the bundled runtime source is missing - #2203
fail kernel bootstrap fast when the bundled runtime source is missing#2203kevinjosethomas wants to merge 1 commit into
Conversation
Incident: a long-running prime-agent session kept running after the Codex worktree it was launched from was deleted. On the next kernel start the bootstrap could not find prime-agent-runtime/pyproject.toml, fell back to the bare registry name "prime-agent-runtime" (which is not published anywhere), treated the healthy shared ~/.prime/agent/kernel-venv as stale because its recorded identity differed, deleted it, and then failed the reinstall with a bare "failed with exit code 1" because uv's stderr was discarded. Every other session sharing that venv lost its kernel too. Changes: - Resolve the runtime source before looking at the venv and throw a descriptive error (paths searched, likely cause, how to recover) when it is missing. The venv is never touched in that case. The registry fallback is gone: the runtime is always installed from a local source directory. - Capture the last 8 KB of stderr from uv/python helper invocations and include it in bootstrap errors, so the real reason is visible. - Add PRIME_AGENT_RUNTIME_SOURCE to install the runtime from an explicit checkout; it is also the test seam for the missing-source path. - Tests for the missing-source fail-fast (stale venv survives, uv never runs), the source override, and stderr propagation; Windows stdio expectations updated for the piped stderr.
Prime Agent performance — completedPR Overall: 0 regressed · 0 improved · 17 no clear change.
Python runtime
Sandbox cost: ~$0.0867 — no inference calls. Methodology and samplesMain resolved at 2026-09-10T19:40:58.749480+00:00. Harness
|
There was a problem hiding this comment.
🟠 High
When runtimeSourceDir is deleted while acquireBootstrapLock waits, this function still removes the shared venv, and bootstrapVenv then fails because the source path no longer exists. Revalidate the runtime source inside the lock immediately before teardown, and use the refreshed path for the rebuild.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/coding-agent/src/core/kernel/bootstrap.ts around line 971:
When `runtimeSourceDir` is deleted while `acquireBootstrapLock` waits, this function still removes the shared `venv`, and `bootstrapVenv` then fails because the source path no longer exists. Revalidate the runtime source inside the lock immediately before teardown, and use the refreshed path for the rebuild.
Evidence trail:
packages/coding-agent/src/core/kernel/bootstrap.ts:787-808, 890-907, 957-983; commit 147fc295
Note
Medium Risk
Changes shared kernel venv bootstrap ordering and install path resolution; incorrect behavior could still break multi-session Python kernel setup, though the intent is to reduce collateral damage when installs go missing.
Overview
Kernel bootstrap no longer destroys the shared venv when the bundled
prime-agent-runtimecheckout is gone (e.g. a long-lived session after its worktree was removed). Bootstrap resolves the runtime source directory before comparing or rebuilding~/.prime/agent/kernel-venv, and drops the old registry-name fallback—installs always come from a local path with a content hash identity.When no source is found, bootstrap fails immediately with searched paths, recovery hints (
PRIME_AGENT_RUNTIME_SOURCE, restart from a valid install, orPRIME_AGENT_KERNEL_PYTHON), and an explicit note that the existing venv was left untouched.PRIME_AGENT_RUNTIME_SOURCElets devs point bootstrap at a specific runtime checkout (also wired into the bootstrap cache key).uv/pythonhelper failures now append a bounded stderr tail instead of only an exit code.Docs add the env var and a new RLM failure-mode row; tests cover override install, missing-source safety, and stderr propagation (Windows spawn expectations updated for stderr piping).
Reviewed by Cursor Bugbot for commit 147fc29. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fail kernel bootstrap fast when bundled runtime source is missing
PRIME_AGENT_RUNTIME_SOURCEenv var so callers can point bootstrap at a specific runtime checkout; when set, it is the sole candidate and the cache key changes accordingly.bootstrapVenv; installs always use the resolved local source directory.runnow captures stderr (up to a fixed tail) and appends it to failure errors instead of reporting only the exit code.resolveRuntimeIdentityno longer returns a package-name fallback identity — any out-of-tree caller relying on that fallback will now fail when the local source is absent. Bootstrap subprocess spawn options changed to pipe stderr, so tests asserting stdio config in kernel-windows-process.test.ts were updated.📊 Macroscope summarized 147fc29. 4 files reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues