Spawned session subprocess can't recompile Kaimon when target project's manifest invalidates the precompile cache #47
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
kahliburke/Kaimon.jl#47
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Claude Code ran into this problem and created the following after debugging - Jeff
Spawned session subprocess can't recompile Kaimon when target project's manifest invalidates the precompile cache
Symptom
Calling
start_session(project_path=<P>)against a projectPwhoseManifest.tomlhas drifted enough to invalidate Kaimon's precompile cache returns:The reported log path does not exist (see #43 — log file is never written), and the server log only records:
…with no underlying stack trace.
What's actually happening
Reproducing the spawn manually (the boot script from
_build_session_scriptplus the env overlay fromspawn_session!):surfaces:
Root cause
spawn_session!sets the subprocessJULIA_LOAD_PATHto@:@v#.#:@stdlib— the shell default forjulia --project=<target>. When Kaimon's precompile cache is valid for that target, this is fine: the cache loads as a binary blob without any dep resolution.When the cache is invalid (changes in the target's Manifest can invalidate it via
wrong dep version loaded/wrong source/incompatible header), Julia rebuilds Kaimon from source in a worker. That rebuild needs to resolve Kaimon'susing JSON(and all other direct deps) via the worker's LOAD_PATH — none of which has Kaimon's own deps:@= target'sProject.toml(no JSON unless the user happens to depend on it)@v#.#= global v1.12 env (rarely populated)@stdlib= stdlib onlyThe
insert!(LOAD_PATH, 1, pkgdir(Kaimon))line in the boot script doesn't help: a bare pkgdir is not an env, has no manifest, and Julia uses it only to find Kaimon's source — falling back to the active project for dep resolution.Reproduction recipe
Pkg.update,Pkg.rmof a transitive dep, switching Julia patch versions, etc.). In my case it wasPkg.rmon heavy deps from a project that had grown stale, which caused JLLWrappers / Parsers to resolve to versions Kaimon wasn't built against.start_session(project_path=<that project>).@jeffwack Thanks for the report and PR. I will investigate. Apologies for the delay in responding.
I've seen the issue as well. It's why I moved to a workflow where I setup the gate differently. It would be great if this could be fixed.
Fixed on the 2.0 line (branch
fix/47-spawn-loadpath-20, commit6de5ba6).Root cause confirmed exactly as reported: agent-spawned sessions booted the heavyweight
Kaimonpackage, and when the target project'sManifest.tomlinvalidated Kaimon's precompile cache, the worker rebuilding Kaimon from source couldn't resolve its deps (JSON, ZMQ, …) against the target's manifest — so the subprocess died silently at boot.Rather than make the heavy recompile resolvable (patching the session's
LOAD_PATHso Kaimon can rebuild against its own manifest), 2.0 removes the heavy package from the session entirely:Agent-spawned sessions now boot only the lightweight
KaimonGatepackage (ZMQ + stdlib), the same way user-initiatedstartup.jlsessions already connect. The TUI enriches the gate over the wire, so loading the full Kaimon into a session bought nothing. With no Kaimon in the session, there is nothing for a drifted target manifest to invalidate — the failure mode is gone, not worked around.Mechanics:
using KaimonGate; KaimonGate.serve(...).pkgdir(KaimonGate)— its own env, whoseManifest.tomlpins ZMQ — is appended toJULIA_LOAD_PATHso the gate resolves (and recompiles from source if needed) without requiring a global install, regardless of the target's manifest.KAIMON_GATE_*env vars, so the joined-session experience is unchanged.Verification:
KAIMON_GATE_*identity survives the restart.Lands with 2.0. Thanks @jeffwack — the root-cause writeup made this straightforward to confirm.
Fixed in 2.0 — spawned sessions now boot the lightweight KaimonGate (with LOAD_PATH set), so the subprocess no longer recompiles full Kaimon when a manifest invalidates the precompile cache. The missing session log noted here is also fixed (see #43). Shipping in 2.0.