Dataface Tasks

CBox setup-worktree ROOT_WORKTREE_PATH fallback

IDM1-INFRA-022
Statuscompleted
Priorityp1
Milestonem1-ft-analytics-analyst-pilot
Ownerhead-of-engineering

Problem

The cbox worktree setup copies .env from the root worktree into new sandbox worktrees, but this step fails when the ROOT_WORKTREE_PATH environment variable is unset — which is the default case for most operator environments. The failure silently skips .env provisioning, leaving the sandbox without required configuration (e.g., SECRET_KEY, DATABASE_URL, API keys). Sandboxes then fail at runtime with confusing missing-config errors that don't point back to the real cause. The setup should derive the root worktree path from git metadata when the env var is absent, rather than silently skipping the copy.

Context

Possible Solutions

Plan

Implementation Progress

Implementation notes

  • Added _resolve_root_worktree_path(repo_path, worktree_dir) to libs/cbox/cbox/cli.py.
  • _run_worktree_setup(...) now resolves ROOT_WORKTREE_PATH with fallback order: 1. existing ROOT_WORKTREE_PATH env var (if valid) 2. provided repo_path 3. derived root from git rev-parse --git-common-dir
  • Added tests in libs/cbox/test_sandbox_start.py for:
  • existing behavior (repo_path expansion)
  • env-var preference when valid
  • git-common-dir fallback resolution

Review Feedback

  • [ ] Review cleared