Skip to content

fm-spawn: registering a live repo via a projects/ symlink breaks worktree-entry detection #598

Description

@tkt028

Summary

bin/fm-spawn.sh refuses to launch a crewmate when the project is registered as a symlink
under projects/<name> that points at a real repo elsewhere on disk. treehouse actually
creates a correct isolated worktree, but fm-spawn's worktree-entry detection mis-fires and the
isolation guard then (correctly) refuses — with an error that blames treehouse.

Root cause

PROJ_ABS is computed as cd "$dir" && pwd (symlink-preserving), e.g.
.../projects/tkt-env. The launch template cds the pane into that path, then fm-spawn waits
for the pane's reported cwd to change away from $PROJ_ABS:

for _ in $(seq 1 60); do
  p=$(spawn_current_path "$T" ...)
  if [ -n "$p" ] && [ "$p" != "$PROJ_ABS" ]; then WT="$p"; break; fi
  ...

But the pane reports its resolved cwd (the symlink's real target, e.g.
/Users/me/repos/tkt-env), which already != $PROJ_ABS on the very first poll — before
treehouse get has entered a worktree. So WT is set to the repo root, and
validate_spawn_worktree refuses with:

error: treehouse get did not yield an isolated worktree (resolved '<repo-root>';
worktree root '<repo-root>'; primary '<symlink-path>'); refusing to launch ...

The message points at treehouse, but treehouse worked; the real cause is the symlink/realpath
mismatch in the cwd-change heuristic.

Reproduction

  1. ln -s /abs/path/to/repo projects/myrepo
  2. bin/fm-spawn.sh task-x projects/myrepo → refuses (blames treehouse).
  3. bin/fm-spawn.sh task-x /abs/path/to/repo → works cleanly.

Impact

Registering an existing live repo (rather than a fresh clone under projects/) via the
natural projects/<name> symlink is silently broken, and the error misattributes the failure
to treehouse.

Suggested fixes (any one)

  • Canonicalize PROJ_ABS with pwd -P so it matches the pane's resolved cwd, and/or
  • Compare resolved paths in the cwd-change loop (realpath/pwd -P both sides), and/or
  • Document that a live repo must be registered by absolute path, not a projects/ symlink.

🤖 Claude Code · claude-opus-4-8 · 2026-07-15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions