fix: use absolute worktree paths, check sqlite3 availability

- worktreePath() now returns absolute path using findMainRepoDir()
- Fixes 'cannot change to worktrees/...' error from inside worktree
- test-worker.sh now checks sqlite3 is available before running

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
dan 2026-01-11 21:24:03 -08:00
parent 62e81b720e
commit b13109e8e0
2 changed files with 19 additions and 16 deletions

View file

@ -34,9 +34,18 @@ TEST_DIR=$(mktemp -d)
TEST_REPO="$TEST_DIR/repo"
ORIG_DIR="$(pwd)"
# Set up SQLite library path
SQLITE_LIB=$(nix-build '<nixpkgs>' -A sqlite.out --no-out-link 2>/dev/null)/lib
export LD_LIBRARY_PATH="${SQLITE_LIB}:${LD_LIBRARY_PATH:-}"
# Set up SQLite library and binary paths
SQLITE_OUT=$(nix-build '<nixpkgs>' -A sqlite.out --no-out-link 2>/dev/null)
if [[ -d "${SQLITE_OUT}" ]]; then
export LD_LIBRARY_PATH="${SQLITE_OUT}/lib:${LD_LIBRARY_PATH:-}"
export PATH="${SQLITE_OUT}/bin:${PATH}"
fi
# Verify sqlite3 is available
if ! command -v sqlite3 &>/dev/null; then
echo "ERROR: sqlite3 not found. Run tests with: nix-shell -p sqlite --run 'bash $0'"
exit 1
fi
cleanup() {
cd "$ORIG_DIR"
@ -369,17 +378,10 @@ echo "## Invalid State Transitions"
run_worker spawn --taskId=test-invalid --fromBranch=master > /dev/null
run_worker start --task=test-invalid > /dev/null
# NOTE: Should return exit code 3 (ExitInvalidTransition) but currently returns 1
# See skills-lxb9 for fix
output=$(run_worker approve --taskId=test-invalid 2>&1)
exit_code=$?
if [[ "$exit_code" != "0" ]]; then
echo -e "${GREEN}PASS${NC}: Approve from WORKING fails (exit code: $exit_code)"
((PASSED++))
else
echo -e "${RED}FAIL${NC}: Approve from WORKING should fail"
((FAILED++))
fi
assert_exit_code "Approve from WORKING returns ExitInvalidTransition" "3" "$exit_code"
assert_output_contains "Approve error message" "Cannot approve" "$output"
# --- Review-Gate Integration ---
echo ""

View file

@ -11,10 +11,6 @@ proc branchName*(taskId: string): string =
## Get the feature branch name for a task
&"feat/{taskId}"
proc worktreePath*(taskId: string): string =
## Get the worktree path for a task
&"{WorktreesDir}/{taskId}"
proc findMainRepoDir*(): string =
## Find the main repository directory, even when running from a worktree.
## Uses git to find the common git directory, then derives the main repo.
@ -34,6 +30,11 @@ proc findMainRepoDir*(): string =
else: getCurrentDir() / gitCommonDir
result = parentDir(mainGitDir)
proc worktreePath*(taskId: string): string =
## Get the absolute worktree path for a task.
## Uses repo root to ensure path works from any directory.
findMainRepoDir() / WorktreesDir / taskId
proc getMainRepoBusDbPath*(): string =
## Get the absolute path to bus.db in the main repository.
## Works correctly even when called from a worktree.