agent-orchestrator
agent-orchestrator copied to clipboard
[Bug]: Workspace projects copy node_modules, .venv and tracked folders into every session worktree, and fail on symlinks
What went wrong?
A workspace project (a folder with several child Git repositories) copies every top-level directory that is not its own Git repository into each session worktree, including the first orchestrator session. That includes dependency and build folders (node_modules, .venv, dist, .next) and, when the parent is itself a Git repo, its tracked folders. On a real-sized project the copy is slow, multiplies disk use per session, and often fails the whole session start.
detectWorkspaceChildren(backend/internal/service/project/workspace_registration.go:156) marks every directory except.gitthatisGitReporejects asneeds_init.isGitRepo(service.go:1171) requires the folder to be its own toplevel, so an ordinary subfolder of a Git parent qualifies. There is no ignore-rule, dot-folder or size check.workspaceRootIgnoreDenylist(workspace_registration.go:20) already listsnode_modules/,dist/,build/,.cache/,.turbo/,target/,coverage/,tmp/,temp/, but it is only written to the parent.gitignore, never used to filter the copy.ensureWorkspaceGitignore(workspace_registration.go:342) also appends/<name>/for each of these plain folders, andadoptWorkspaceParentcommits that.gitignoreinto the user's parent repository, so tracked folders get listed as ignored.- At spawn,
createSessionWorkspaceAt(session_manager/manager.go:2345) passes eachneeds_initchild without.gitas aWorkspaceProjectAssetConfig.copyWorkspaceAssetTree(adapters/workspace/gitworktree/workspace.go:709) copies it byte by byte with no context (no cancellation, ignores the spawn deadline), no size cap, and no clonefile/reflink. It aborts the start on any absolute symlink (e.g..venv/bin/python), any symlink resolving outside the folder, and any socket or FIFO. - The rows are created once at registration, so a project keeps this behavior until it is re-added.
Introduced by #4993. Its tests cover only a small notes/ folder.
Steps to reproduce
- Make a plain folder
ws/containingws/app(a Git repo with anoriginand one commit),ws/node_modules(a few hundred MB, or any folder with an absolute symlink inside) andws/.venv(a Python venv). - Add
ws/as a project; the import flow requires the workspace kind. - Start any session (the first orchestrator session counts).
- The start either takes minutes while
node_modulesand.venvare copied into~/.ao/data/worktrees/..., or fails withgitworktree: copy workspace asset ".venv": absolute symlink ...: unsafe path. - With a Git parent instead, also check the parent's last commit:
.gitignorenow lists ordinary folders such as/src/.
Expected behavior
- Only folders the user would want in every session are copied: never ignored folders, known dependency/build folders, dot-folders such as
.venv, or folders the parent repo already tracks. - A copied folder never fails the start because of an absolute or escaping symlink or a special file; those are skipped (or recreated) and logged.
- The copy honors cancellation and the spawn deadline, uses clonefile/reflink where available, and fails with a clear message naming the folder if it exceeds a size cap.
- Orchestrator does not add plain folders to the parent's
.gitignore. - Existing workspace projects with bad
needs_initrows are repaired once.
Follow-up (separate): show the copied-folder list with sizes at import and in Project Settings so it can be edited (related #5773).
Version
main at 8207c224b5 (also in v0.15.x).