test(project-tree): cover deleted-worktree fold into parent trunk

Assert the dangling-cwd session joins the parent's main lane and that no lane
keyed by the deleted worktree path survives.
This commit is contained in:
Brooklyn Nicholson 2026-07-25 20:31:17 -05:00
parent 47c95130f7
commit 1e067ec0b5

View file

@ -466,6 +466,26 @@ def test_broad_default_non_git_cwd_stays_unscoped():
assert detached["id"] not in tree["scoped_session_ids"]
def test_deleted_sibling_worktree_folds_into_parent_home_checkout():
# A deleted <repo>-<suffix> worktree leaves its session with an unresolvable
# cwd and no persisted root. It joins the parent's trunk lane — no dead-path
# lane, no phantom project.
resolve = _resolver({"/www/hermes-agent": ("/www/hermes-agent", "/www/hermes-agent")})
sessions = [
_session("/www/hermes-agent", branch="main"),
_session("/www/hermes-agent-session-links"),
]
tree = pt.build_tree([], sessions, [], resolve, hydrate=True)
project = tree["projects"][0]
assert [p["id"] for p in tree["projects"]] == ["/www/hermes-agent"]
assert _lane_ids(project) == ["/www/hermes-agent::branch::main"]
main = project["repos"][0]["groups"][0]
assert main["isMain"] and main["path"] == "/www/hermes-agent"
assert len(main["sessions"]) == 2
def test_colliding_repo_basenames_disambiguate_labels():
resolve = _resolver(
{