fix(swarm): validate spawn working_dir, expand ~ in tool paths, clearer write errors
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
PRs are restricted to collaborators on this repo, so opening an issue per CONTRIBUTING convention instead.
Problem
Three related rough edges hit in real swarm usage on v0.84.0:
- Bad
working_dirat swarm spawn produces a broken worker. The session starts fine, then every bash call fails with a crypticos error 2(the shell cannot spawn with a nonexistent cwd). The worker burns a full turn rediscovering its sandbox is broken. - File tools reject
~/...paths.read/edit/writeonly handle absolute or working-dir-relative paths, so workers writing~/.config/...getFile not found. writehides the real cause of parent-dir failures. A wrong username in an absolute path makescreate_dir_allfail under/Users, surfacing as a barePermission denied (os error 13)with no path named.
Proposed changes (5 commits, tested, green)
Branch: https://github.com/JJ245-JJ/jcode/tree/pr/swarm-spawn-validation (fork, based on current master @ 4e85d4423, ahead by 5, +203/-17 across 9 files)
resolve_spawn_working_dirtilde-expands and validates the directory up front, rejecting the spawn withworking_dir does not exist: <path>. Check the path (watch for username typos) and spawn again.Same check increate_headless_sessionas defense in depth.ToolContext::resolve_pathexpands a leading~/~/...to home (non-tilde and~otheruserforms fall through to existing handling).writenames the parent directory and hints at path spelling whencreate_dir_allfails.- Lean swarm worker toolset adapted to the registration-based session tool policy API (the old
set_session_tool_policycall no longer exists on master, soset_lean_swarm_worker_toolsfails to compile without this). - Tests: nonexistent-dir rejection, tilde expansion (spawn + resolve_path), existing-dir fixtures for the resolution preference tests.
cargo test -p jcode-app-core --lib resolve_spawn_working_dir-> 4 passed; crate compiles clean on master.
Verified end-to-end on a live server: spawn with a bad dir is rejected immediately with the clear error; workers successfully use write/read tools and ~ paths.
Happy to open a proper PR if given collaborator access or if you prefer I re-push the branch somewhere convenient.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with resolve_spawn_working_dir and create_headless_session for spawn validation, then inspect ToolContext::resolve_path and the write tool's parent-directory error handling. Run cargo test -p jcode-app-core --lib resolve_spawn_working_dir and check the session tool policy entry point. Done means invalid directories are rejected early, leading ~ paths work, and write failures identify the affected path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100