agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

[Bug]: Workspace projects copy node_modules, .venv and tracked folders into every session worktree, and fail on symlinks

Open ronishrohan opened this issue 1 week ago • 0 comments

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 .git that isGitRepo rejects as needs_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 lists node_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, and adoptWorkspaceParent commits that .gitignore into the user's parent repository, so tracked folders get listed as ignored.
  • At spawn, createSessionWorkspaceAt (session_manager/manager.go:2345) passes each needs_init child without .git as a WorkspaceProjectAssetConfig. 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

  1. Make a plain folder ws/ containing ws/app (a Git repo with an origin and one commit), ws/node_modules (a few hundred MB, or any folder with an absolute symlink inside) and ws/.venv (a Python venv).
  2. Add ws/ as a project; the import flow requires the workspace kind.
  3. Start any session (the first orchestrator session counts).
  4. The start either takes minutes while node_modules and .venv are copied into ~/.ao/data/worktrees/..., or fails with gitworktree: copy workspace asset ".venv": absolute symlink ...: unsafe path.
  5. With a Git parent instead, also check the parent's last commit: .gitignore now 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_init rows 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).

ronishrohan avatar Nov 19 '26 13:11 ronishrohan