From e8fca0213f092ebdb4046d319e8e42011b7a980d Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 14:41:59 +0000 Subject: [PATCH 1/8] feat: discover projects in grouped folders --- lane-start | 83 ++++++++--- park | 110 +++++++++++---- resume | 101 +++++++++---- status | 110 +++++++++++---- tests/test_grouped_project_lookup.py | 204 +++++++++++++++++++++++++++ 5 files changed, 503 insertions(+), 105 deletions(-) create mode 100644 tests/test_grouped_project_lookup.py diff --git a/lane-start b/lane-start index f824fbd2..9ef0505e 100755 --- a/lane-start +++ b/lane-start @@ -1082,30 +1082,67 @@ fi # options at `--` like every other POSIX utility, and the step line this # function produces — `repo repocase → repoCase` — is asserted on the macOS job, # where an `ls` that refused `--` would leave it silent. -projects_dir_matches() { # - ls -- "$PROJECTS_ROOT" 2>/dev/null | - awk -v want="$1" 'BEGIN { w = tolower(want) } tolower($0) == w { print }' | - while IFS= read -r pdm_m; do - [ -d "$PROJECTS_ROOT/$pdm_m" ] && printf '%s\n' "$pdm_m" +# BEGIN GROUPED PROJECT DISCOVERY +# Self-contained installed commands share this block; a regression test checks +# byte equality. Names are logical; targets are physical. Never enter a repo, +# estate, or supporting checkout collection while looking for grouping folders. +project_directory_rows() { + local base="$1" depth="${2:-0}" child name physical boundary + [ -d "$base" ] || return 0 + for child in "$base"/*; do + [ -d "$child" ] || continue + name="${child##*/}" + case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + case "$child" in *$'\t'*|*$'\n'*) continue ;; esac + physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac + boundary=0 + if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || + [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then + boundary=1 + fi + if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + printf '%s\t%s\n' "$name" "$physical" + fi + if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then + project_directory_rows "$child" "$((depth + 1))" + fi done } +# END GROUPED PROJECT DISCOVERY + +project_matches() { + local match_name match_dir git_dir common_dir canonical_name + while IFS=$'\t' read -r match_name match_dir; do + if [ -f "$match_dir/HEAD" ] && [ -d "$match_dir/objects" ]; then continue; fi + if [ -e "$match_dir/.git" ]; then + git_dir="$(git -C "$match_dir" rev-parse --git-dir 2>/dev/null)" || continue + common_dir="$(git -C "$match_dir" rev-parse --git-common-dir 2>/dev/null)" || continue + [ "$git_dir" = "$common_dir" ] || continue + [ -z "$(git -C "$match_dir" rev-parse --show-superproject-working-tree 2>/dev/null)" ] || continue + fi + canonical_name="${match_dir##*/}" + if [ "$(printf '%s' "$canonical_name" | tr '[:upper:]' '[:lower:]')" = "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" ]; then + match_name="$canonical_name" + fi + printf '%s\t%s\n' "$match_name" "$match_dir" + done < <(project_directory_rows "$PROJECTS_ROOT" | + awk -F '\t' -v want="$1" 'BEGIN { w = tolower(want) } tolower($1) == w') | awk -F '\t' '!seen[$2]++' +} +projects_dir_matches() { + project_matches "$1" | cut -f1 +} + if [ -n "$repo" ] && [ -d "$PROJECTS_ROOT" ]; then repo_hits="$(projects_dir_matches "$repo" || :)" repo_hit_n=0 if [ -n "$repo_hits" ]; then repo_hit_n="$(printf '%s\n' "$repo_hits" | grep -c . || :)"; fi - # THE REFUSAL IS FOR A RUN THAT HAS NO OTHER ANSWER, AND `--dir` IS THE OTHER - # ANSWER. Its own remedy names `--dir `, so refusing a run that already - # passed one is refusing the fix it printed: `lane-start --dir /chosen repotwin - # 1` was rejected before the rung that honours the flag (Copilot round 1 on - # openRepoTools#41). With the checkout named, the ambiguity that is left is - # only about the lane-s NAME, which keeps the spelling that was typed and is - # then overruled by the register row-s a few lines below — so this SAYS what - # it did not resolve and carries on. - if [ "$repo_hit_n" -gt 1 ] && [ -z "$dir_override" ]; then - die "$PROJECTS_ROOT holds $repo_hit_n directories whose names differ only by case for '$repo': $(printf '%s\n' "$repo_hits" | tr '\n' ' ')— a lane name is ONE name under any case (Amendment 15(a)), so there is no spelling of '$repo' this can take without choosing which repository the lane is in. Name the checkout yourself with --dir , or rename one of those directories." 2 - fi - if [ "$repo_hit_n" -gt 1 ]; then - note "$PROJECTS_ROOT holds $repo_hit_n directories whose names differ only by case for '$repo': $(printf '%s\n' "$repo_hits" | tr '\n' ' ')— --dir has named the checkout, so this run is not ambiguous about WHERE the lane is. Its NAME keeps the '$repo' you typed, and the register row's own spelling wins over that below (Amendment 15(a))." + # A unique physical target supplies canonical spelling. Multiple targets + # wait for the explicit/recorded directory rungs: only a new default must + # refuse to choose among them. + if [ "$repo_hit_n" -gt 1 ] && [ -n "$dir_override" ]; then + note "multiple project targets match '$repo' — --dir has named the checkout, so the explicit directory remains authoritative" fi if [ "$repo_hit_n" = 1 ] && [ "$repo_hits" != "$repo" ]; then step "repo $repo → $repo_hits (Amendment 15(a): the checkout's real directory name under $PROJECTS_ROOT)" @@ -1370,10 +1407,14 @@ if [ -n "$DIR" ] && [ ! -d "$DIR" ]; then die "no such directory: $DIR (from $DIR_SOURCE) — pass --dir if this lane's checkout is somewhere else" 1 fi if [ -z "$DIR" ]; then - if [ -d "$PROJECTS_ROOT/$repo" ]; then - DIR="$PROJECTS_ROOT/$repo"; DIR_SOURCE="the default \$PROJECTS_ROOT/" + default_matches="$(project_matches "$repo")" + if [ -n "$default_matches" ]; then + default_count="$(printf '%s\n' "$default_matches" | wc -l | tr -d ' ')" + [ "$default_count" -eq 1 ] || die "$PROJECTS_ROOT holds $default_count directories whose names differ only by case or grouping for '$repo': $default_matches — Amendment 15(a) requires one default target; pass --dir " 2 + DIR="$(printf '%s\n' "$default_matches" | cut -f2-)" + DIR_SOURCE="grouped project lookup under \$PROJECTS_ROOT" else - DIR_DEFAULT_TRIED="$PROJECTS_ROOT/$repo" + DIR_DEFAULT_TRIED="$PROJECTS_ROOT/$repo (including grouping folders)" fi fi diff --git a/park b/park index d558d053..7d2b41f7 100755 --- a/park +++ b/park @@ -397,11 +397,57 @@ estate_walk_up() { return 1 } +# BEGIN GROUPED PROJECT DISCOVERY +# Self-contained installed commands share this block; a regression test checks +# byte equality. Names are logical; targets are physical. Never enter a repo, +# estate, or supporting checkout collection while looking for grouping folders. +project_directory_rows() { + local base="$1" depth="${2:-0}" child name physical boundary + [ -d "$base" ] || return 0 + for child in "$base"/*; do + [ -d "$child" ] || continue + name="${child##*/}" + case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + case "$child" in *$'\t'*|*$'\n'*) continue ;; esac + physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac + boundary=0 + if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || + [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then + boundary=1 + fi + if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + printf '%s\t%s\n' "$name" "$physical" + fi + if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then + project_directory_rows "$child" "$((depth + 1))" + fi + done +} +# END GROUPED PROJECT DISCOVERY + +estate_directory_rows() { + local dir + for dir in "${PROJECTS_DIRS[@]}"; do + project_directory_rows "$dir" + done | awk -F '\t' '!seen[$2]++' +} + estate_by_name() { - local want="$1" dir + local want="$1" dir name child hits candidate is_safe_folder_name "$want" || return 1 for dir in "${PROJECTS_DIRS[@]}"; do - estate_here "$dir/$want" && return 0 + hits="$(while IFS=$'\t' read -r name child; do + [ "$name" = "$want" ] || continue + if estate_here "$child"; then printf '%s\n' "$child"; fi + done < <(project_directory_rows "$dir") | LC_ALL=C sort -u)" + [ -n "$hits" ] || continue + if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then + die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" + fi + candidate="$hits" + estate_here "$candidate" && return 0 done return 1 } @@ -410,18 +456,15 @@ estate_by_name() { # a refusal to print: a person who typed the command in the wrong folder needs # the names, not an instruction to go and look for them. list_estates() { - local dir child - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for child in "$dir"/*; do + local _grouped_name child + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue if is_family_folder "$child"; then printf ' family %-20s %s\n' "${child##*/}" "$child" elif is_project_root "$child"; then printf ' project %-20s %s\n' "${child##*/}" "$child" fi - done - done + done < <(estate_directory_rows) } estates_or_none() { @@ -454,12 +497,12 @@ estates_or_none() { # shellcheck disable=SC2329 # `park` never asks: it files the record, and # never looks a holder up by it. The block is byte-identical by design. family_folders_with_id() { - local want="$1" dir child prior dup + local want="$1" dir child prior dup _grouped_name local -a found=() [ -n "$want" ] || return 0 for dir in "${PROJECTS_DIRS[@]}"; do [ -d "$dir" ] || continue - for child in "$dir"/*; do + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue is_family_folder "$child" || continue yaml_scalar "$child/${child##*/}/family.yaml" id || continue @@ -471,7 +514,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done + done < <(project_directory_rows "$dir" | awk -F '\t' '!seen[$2]++') done } @@ -522,28 +565,36 @@ repo_slug_of() { printf '%s/%s\n' "$owner" "$name" } -# The clone under the projects directory whose `origin` IS that repository - -# ruling 1. Two levels deep, because the estates this standard places are -# `/` and `//`. +# Match origins only in discovered development checkouts, including a +# family's direct sibling checkouts. Never descend into pinned Git members. clone_with_origin() { - local want dir candidate origin found + local want candidate origin found hits child name git_dir common_dir want="$(lower "$1")" - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for candidate in "$dir"/*/ "$dir"/*/*/; do - candidate="${candidate%/}" + hits="$(while IFS=$'\t' read -r name child; do + for candidate in "$child" "$child"/*; do + if [ "$candidate" != "$child" ]; then + is_family_folder "$child" || continue + fi [ -e "$candidate/.git" ] || continue + git_dir="$(git -C "$candidate" rev-parse --git-dir 2>/dev/null)" || continue + common_dir="$(git -C "$candidate" rev-parse --git-common-dir 2>/dev/null)" || continue + [ "$git_dir" = "$common_dir" ] || continue + [ -z "$(git -C "$candidate" rev-parse --show-superproject-working-tree 2>/dev/null)" ] || continue origin="$(git -C "$candidate" remote get-url origin 2>/dev/null || true)" [ -n "$origin" ] || continue found="$(repo_slug_of "$origin" || true)" [ -n "$found" ] || continue if [ "$(lower "$found")" = "$want" ]; then - printf '%s\n' "$candidate" - return 0 + (cd -- "$candidate" && pwd -P) fi done - done - return 1 + done < <(estate_directory_rows) | LC_ALL=C sort -u)" + [ -n "$hits" ] || return 1 + if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then + printf 'multiple development checkouts have origin %s; stand in the intended checkout: %s\n' "$1" "$hits" >&2 + return 2 + fi + printf '%s\n' "$hits" } # The family's members, by the same ` - project: ` row `family.py` @@ -931,16 +982,13 @@ run_one_estate() { # `members/` copy (three levels down) and a linked feature worktree # (rejected by `is_project_root` itself). all_estate_dirs() { - local dir child - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for child in "$dir"/*; do + local _grouped_name child + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue if is_family_folder "$child" || is_project_root "$child"; then printf '%s\t%s\n' "${child##*/}" "$child" fi - done - done | LC_ALL=C sort -t $'\t' -k1,1 + done < <(estate_directory_rows) | LC_ALL=C sort -t $'\t' -k1,1 } # Does this root carry the Speckit git overlay its own `make park` requires? @@ -1243,7 +1291,9 @@ elif [ -n "$REPO_SLUG" ]; then url spelling of one (https://…//.git, git@host:/). A family's members may live in another organisation, so there is no owner to assume, and a path on disk has none to read." - MATCH="$(clone_with_origin "$REPO_SLUG" || true)" + LOOKUP_RC=0 + MATCH="$(clone_with_origin "$REPO_SLUG")" || LOOKUP_RC=$? + [ "$LOOKUP_RC" -ne 2 ] || die "ambiguous repository lookup; no checkout was selected" [ -n "$MATCH" ] || die "no clone under your projects directory has origin $REPO_SLUG. \`--repo\` names a clone you ALREADY HAVE; it never clones one (RULING 2026-09-09 ruling 1). Get it, or bring the whole estate back from its diff --git a/resume b/resume index 045d608c..02a48481 100755 --- a/resume +++ b/resume @@ -381,11 +381,57 @@ estate_walk_up() { return 1 } +# BEGIN GROUPED PROJECT DISCOVERY +# Self-contained installed commands share this block; a regression test checks +# byte equality. Names are logical; targets are physical. Never enter a repo, +# estate, or supporting checkout collection while looking for grouping folders. +project_directory_rows() { + local base="$1" depth="${2:-0}" child name physical boundary + [ -d "$base" ] || return 0 + for child in "$base"/*; do + [ -d "$child" ] || continue + name="${child##*/}" + case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + case "$child" in *$'\t'*|*$'\n'*) continue ;; esac + physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac + boundary=0 + if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || + [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then + boundary=1 + fi + if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + printf '%s\t%s\n' "$name" "$physical" + fi + if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then + project_directory_rows "$child" "$((depth + 1))" + fi + done +} +# END GROUPED PROJECT DISCOVERY + +estate_directory_rows() { + local dir + for dir in "${PROJECTS_DIRS[@]}"; do + project_directory_rows "$dir" + done | awk -F '\t' '!seen[$2]++' +} + estate_by_name() { - local want="$1" dir + local want="$1" dir name child hits candidate is_safe_folder_name "$want" || return 1 for dir in "${PROJECTS_DIRS[@]}"; do - estate_here "$dir/$want" && return 0 + hits="$(while IFS=$'\t' read -r name child; do + [ "$name" = "$want" ] || continue + if estate_here "$child"; then printf '%s\n' "$child"; fi + done < <(project_directory_rows "$dir") | LC_ALL=C sort -u)" + [ -n "$hits" ] || continue + if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then + die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" + fi + candidate="$hits" + estate_here "$candidate" && return 0 done return 1 } @@ -394,18 +440,15 @@ estate_by_name() { # a refusal to print: a person who typed the command in the wrong folder needs # the names, not an instruction to go and look for them. list_estates() { - local dir child - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for child in "$dir"/*; do + local _grouped_name child + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue if is_family_folder "$child"; then printf ' family %-20s %s\n' "${child##*/}" "$child" elif is_project_root "$child"; then printf ' project %-20s %s\n' "${child##*/}" "$child" fi - done - done + done < <(estate_directory_rows) } estates_or_none() { @@ -438,12 +481,12 @@ estates_or_none() { # shellcheck disable=SC2329 # `park` never asks: it files the record, and # never looks a holder up by it. The block is byte-identical by design. family_folders_with_id() { - local want="$1" dir child prior dup + local want="$1" dir child prior dup _grouped_name local -a found=() [ -n "$want" ] || return 0 for dir in "${PROJECTS_DIRS[@]}"; do [ -d "$dir" ] || continue - for child in "$dir"/*; do + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue is_family_folder "$child" || continue yaml_scalar "$child/${child##*/}/family.yaml" id || continue @@ -455,7 +498,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done + done < <(project_directory_rows "$dir" | awk -F '\t' '!seen[$2]++') done } @@ -506,28 +549,36 @@ repo_slug_of() { printf '%s/%s\n' "$owner" "$name" } -# The clone under the projects directory whose `origin` IS that repository - -# ruling 1. Two levels deep, because the estates this standard places are -# `/` and `//`. +# Match origins only in discovered development checkouts, including a +# family's direct sibling checkouts. Never descend into pinned Git members. clone_with_origin() { - local want dir candidate origin found + local want candidate origin found hits child name git_dir common_dir want="$(lower "$1")" - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for candidate in "$dir"/*/ "$dir"/*/*/; do - candidate="${candidate%/}" + hits="$(while IFS=$'\t' read -r name child; do + for candidate in "$child" "$child"/*; do + if [ "$candidate" != "$child" ]; then + is_family_folder "$child" || continue + fi [ -e "$candidate/.git" ] || continue + git_dir="$(git -C "$candidate" rev-parse --git-dir 2>/dev/null)" || continue + common_dir="$(git -C "$candidate" rev-parse --git-common-dir 2>/dev/null)" || continue + [ "$git_dir" = "$common_dir" ] || continue + [ -z "$(git -C "$candidate" rev-parse --show-superproject-working-tree 2>/dev/null)" ] || continue origin="$(git -C "$candidate" remote get-url origin 2>/dev/null || true)" [ -n "$origin" ] || continue found="$(repo_slug_of "$origin" || true)" [ -n "$found" ] || continue if [ "$(lower "$found")" = "$want" ]; then - printf '%s\n' "$candidate" - return 0 + (cd -- "$candidate" && pwd -P) fi done - done - return 1 + done < <(estate_directory_rows) | LC_ALL=C sort -u)" + [ -n "$hits" ] || return 1 + if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then + printf 'multiple development checkouts have origin %s; stand in the intended checkout: %s\n' "$1" "$hits" >&2 + return 2 + fi + printf '%s\n' "$hits" } # The family's members, by the same ` - project: ` row `family.py` @@ -1126,7 +1177,9 @@ if [ -n "$REPO_SLUG" ]; then url spelling of one (https://…//.git, git@host:/). A family's members may live in another organisation, so there is no owner to assume, and a path on disk has none to read." - MATCH="$(clone_with_origin "$REPO_SLUG" || true)" + LOOKUP_RC=0 + MATCH="$(clone_with_origin "$REPO_SLUG")" || LOOKUP_RC=$? + [ "$LOOKUP_RC" -ne 2 ] || die "ambiguous repository lookup; no checkout was selected" [ -n "$MATCH" ] || die "no clone under your projects directory has origin $REPO_SLUG. \`--repo\` names a clone you ALREADY HAVE (RULING 2026-09-09 ruling 1). To bring an estate back that is not here yet, name it as your workspace diff --git a/status b/status index 4f8a7d9d..f9ad5825 100755 --- a/status +++ b/status @@ -518,11 +518,57 @@ estate_walk_up() { return 1 } +# BEGIN GROUPED PROJECT DISCOVERY +# Self-contained installed commands share this block; a regression test checks +# byte equality. Names are logical; targets are physical. Never enter a repo, +# estate, or supporting checkout collection while looking for grouping folders. +project_directory_rows() { + local base="$1" depth="${2:-0}" child name physical boundary + [ -d "$base" ] || return 0 + for child in "$base"/*; do + [ -d "$child" ] || continue + name="${child##*/}" + case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + case "$child" in *$'\t'*|*$'\n'*) continue ;; esac + physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac + boundary=0 + if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || + [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then + boundary=1 + fi + if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + printf '%s\t%s\n' "$name" "$physical" + fi + if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then + project_directory_rows "$child" "$((depth + 1))" + fi + done +} +# END GROUPED PROJECT DISCOVERY + +estate_directory_rows() { + local dir + for dir in "${PROJECTS_DIRS[@]}"; do + project_directory_rows "$dir" + done | awk -F '\t' '!seen[$2]++' +} + estate_by_name() { - local want="$1" dir + local want="$1" dir name child hits candidate is_safe_folder_name "$want" || return 1 for dir in "${PROJECTS_DIRS[@]}"; do - estate_here "$dir/$want" && return 0 + hits="$(while IFS=$'\t' read -r name child; do + [ "$name" = "$want" ] || continue + if estate_here "$child"; then printf '%s\n' "$child"; fi + done < <(project_directory_rows "$dir") | LC_ALL=C sort -u)" + [ -n "$hits" ] || continue + if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then + die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" + fi + candidate="$hits" + estate_here "$candidate" && return 0 done return 1 } @@ -531,18 +577,15 @@ estate_by_name() { # a refusal to print: a person who typed the command in the wrong folder needs # the names, not an instruction to go and look for them. list_estates() { - local dir child - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for child in "$dir"/*; do + local _grouped_name child + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue if is_family_folder "$child"; then printf ' family %-20s %s\n' "${child##*/}" "$child" elif is_project_root "$child"; then printf ' project %-20s %s\n' "${child##*/}" "$child" fi - done - done + done < <(estate_directory_rows) } estates_or_none() { @@ -575,12 +618,12 @@ estates_or_none() { # shellcheck disable=SC2329 # `park` never asks: it files the record, and # never looks a holder up by it. The block is byte-identical by design. family_folders_with_id() { - local want="$1" dir child prior dup + local want="$1" dir child prior dup _grouped_name local -a found=() [ -n "$want" ] || return 0 for dir in "${PROJECTS_DIRS[@]}"; do [ -d "$dir" ] || continue - for child in "$dir"/*; do + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue is_family_folder "$child" || continue yaml_scalar "$child/${child##*/}/family.yaml" id || continue @@ -592,7 +635,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done + done < <(project_directory_rows "$dir" | awk -F '\t' '!seen[$2]++') done } @@ -643,28 +686,36 @@ repo_slug_of() { printf '%s/%s\n' "$owner" "$name" } -# The clone under the projects directory whose `origin` IS that repository - -# ruling 1. Two levels deep, because the estates this standard places are -# `/` and `//`. +# Match origins only in discovered development checkouts, including a +# family's direct sibling checkouts. Never descend into pinned Git members. clone_with_origin() { - local want dir candidate origin found + local want candidate origin found hits child name git_dir common_dir want="$(lower "$1")" - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for candidate in "$dir"/*/ "$dir"/*/*/; do - candidate="${candidate%/}" + hits="$(while IFS=$'\t' read -r name child; do + for candidate in "$child" "$child"/*; do + if [ "$candidate" != "$child" ]; then + is_family_folder "$child" || continue + fi [ -e "$candidate/.git" ] || continue + git_dir="$(git -C "$candidate" rev-parse --git-dir 2>/dev/null)" || continue + common_dir="$(git -C "$candidate" rev-parse --git-common-dir 2>/dev/null)" || continue + [ "$git_dir" = "$common_dir" ] || continue + [ -z "$(git -C "$candidate" rev-parse --show-superproject-working-tree 2>/dev/null)" ] || continue origin="$(git -C "$candidate" remote get-url origin 2>/dev/null || true)" [ -n "$origin" ] || continue found="$(repo_slug_of "$origin" || true)" [ -n "$found" ] || continue if [ "$(lower "$found")" = "$want" ]; then - printf '%s\n' "$candidate" - return 0 + (cd -- "$candidate" && pwd -P) fi done - done - return 1 + done < <(estate_directory_rows) | LC_ALL=C sort -u)" + [ -n "$hits" ] || return 1 + if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then + printf 'multiple development checkouts have origin %s; stand in the intended checkout: %s\n' "$1" "$hits" >&2 + return 2 + fi + printf '%s\n' "$hits" } # The family's members, by the same ` - project: ` row `family.py` @@ -5823,16 +5874,13 @@ read_one_estate() { # reason: `~/projects` and `~/Projects` can each hold estates when both # exist, and name order reads them together. all_estate_dirs() { - local dir child - for dir in "${PROJECTS_DIRS[@]}"; do - [ -d "$dir" ] || continue - for child in "$dir"/*; do + local _grouped_name child + while IFS=$'\t' read -r _grouped_name child; do [ -d "$child" ] || continue if is_family_folder "$child" || is_project_root "$child"; then printf '%s\t%s\n' "${child##*/}" "$child" fi - done - done | LC_ALL=C sort -t $'\t' -k1,1 + done < <(estate_directory_rows) | LC_ALL=C sort -t $'\t' -k1,1 } # Read every estate in `$1`, in name order, and end with a summary. An estate @@ -6013,7 +6061,9 @@ elif [ -n "$REPO_SLUG" ]; then url spelling of one (https://…//.git, git@host:/). A family's members may live in another organisation, so there is no owner to assume, and a path on disk has none to read." - MATCH="$(clone_with_origin "$REPO_SLUG" || true)" + LOOKUP_RC=0 + MATCH="$(clone_with_origin "$REPO_SLUG")" || LOOKUP_RC=$? + [ "$LOOKUP_RC" -ne 2 ] || die "ambiguous repository lookup; no checkout was selected" [ -n "$MATCH" ] || die "no clone under your projects directory has origin $REPO_SLUG. \`--repo\` names a clone you ALREADY HAVE; nothing here clones one. Bring the estate back with \`resume \`, or read one of these: diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py new file mode 100644 index 00000000..e799821c --- /dev/null +++ b/tests/test_grouped_project_lookup.py @@ -0,0 +1,204 @@ +"""Grouped discovery through real commands; all writes use isolated registers.""" +from pathlib import Path +import subprocess +import shutil +import pytest +from conftest import REPO, WINDOWS_SKIP +from test_park_resume_commands import (FAMILY, WORKSPACE_SLUG, git, home, estate, remotes, offline, + probe_project, probe_family, sweepable_project, run) +from test_lane_start_claude_current import Sandbox + +pytestmark = [WINDOWS_SKIP, pytest.mark.skipif( + any(shutil.which(command) is None for command in ("bash", "git", "make")), + reason="grouped CLI tests require bash, git and make")] + + +def block(name): + text = (REPO / name).read_text() + return text.split("# BEGIN GROUPED PROJECT DISCOVERY", 1)[1].split("# END GROUPED PROJECT DISCOVERY", 1)[0] + + +def test_discovery_copies_match(): + assert len({block(name) for name in ("park", "resume", "status", "lane-start")}) == 1 + + +def rows(root): + result = subprocess.run(["bash", "-c", block("park") + '\nproject_directory_rows "$1"', "lookup", str(root)], text=True, capture_output=True, check=True) + return [line.split("\t") for line in result.stdout.splitlines()] + + +def test_bounds_support_collections_and_repository_boundaries(tmp_path): + for group in ("workTrees", "laneWorkspaces", "brett-wip-lanes", "worktrees"): + probe_project(tmp_path / group, "Hidden") + target = probe_project(tmp_path / "business" / "Company space", "Visible") + probe_project(tmp_path / "business" / "Company space" / "too-deep", "Deep") + outer = probe_project(tmp_path / "factories", "Outer") + probe_project(outer / "members", "Pinned") + family = probe_family(tmp_path / "healthcare", "Family") + probe_project(family.parent / "members", "Sibling") + found = rows(tmp_path) + names = [r[0] for r in found] + assert ["Visible", str(target)] in found + assert not {"Hidden", "Deep", "Pinned", "Sibling"}.intersection(names) + assert "Family" in names + + +@pytest.mark.parametrize("family", [False, True]) +def test_named_grouped_estate(tmp_path, family): + home = tmp_path / "home"; home.mkdir() + group = home / "projects" / "group space" + root = (probe_family if family else probe_project)(group, "Atlas") + result = run(REPO / "park", "Atlas", home=home) + assert result.returncode == 0, result.stderr + result.stdout + assert f"PROBE park in {root}" in result.stdout + + +@pytest.mark.parametrize("command", ["park", "resume", "status"]) +def test_distinct_matching_estates_refuse(tmp_path, command, remotes): + home = tmp_path / "home"; home.mkdir() + name = FAMILY if command == "resume" else "Atlas" + for group in ("one", "two"): + probe_project(home / "projects" / group, name) + args = [name] + if command == "resume": + args += ["--workspace", WORKSPACE_SLUG] + result = run(REPO / command, *args, home=home, env=offline(remotes)) + assert result.returncode != 0 + assert "multiple estates named" in result.stderr + assert "PROBE" not in result.stdout + + +def grouped_box(tmp_path): + box = Sandbox(tmp_path) + target = box.home / "projects" / "developerTools" / "repoZ" + target.parent.mkdir(); box.lane_dir.rename(target); box.lane_dir = target + box.resolver() + return box + + +@pytest.mark.parametrize("alias", [None, "repoZ", "repoz"]) +def test_new_lane_uses_grouped_canonical_target(tmp_path, alias): + box = grouped_box(tmp_path) + if alias: + (box.home / "projects" / alias).symlink_to(box.lane_dir, target_is_directory=True) + result = box.start() + assert result.returncode == 0, result.stderr + assert str(box.lane_dir) in box.lane_log() + assert box.claude_runs() + + +def test_ambiguous_new_lane_refuses_without_register_writes(tmp_path): + box = grouped_box(tmp_path) + other = box.home / "projects" / "other" / "repoZ"; other.mkdir(parents=True) + box.git("-C", str(other), "init", "-q") + before = box.commits() + result = box.start() + assert result.returncode != 0 + assert box.commits() == before + assert not box.lane_log() + assert not box.claude_runs() + + +def test_explicit_lane_path_wins_over_grouped_ambiguity(tmp_path): + box = grouped_box(tmp_path) + other = box.home / "projects" / "other" / "repoZ"; other.mkdir(parents=True) + box.git("-C", str(other), "init", "-q") + result = box.start("--dir", str(box.lane_dir)) + assert result.returncode == 0, result.stderr + assert str(box.lane_dir) in box.lane_log() + + +def test_grouped_sweep_runs_physical_estate_once(tmp_path): + home = tmp_path / "home"; home.mkdir() + projects = home / "projects" + root = sweepable_project(projects / "developerTools", "Atlas") + (projects / "Atlas").symlink_to(root, target_is_directory=True) + result = run(REPO / "park", "--all", home=home) + assert result.returncode == 0, result.stderr + result.stdout + assert result.stdout.count(f"PROBE park in {root}") == 1 + assert "1 estate(s) parked" in result.stdout + + +def test_configured_projects_directory_supports_groups(tmp_path): + home = tmp_path / "home"; home.mkdir() + elsewhere = tmp_path / "elsewhere" + root = probe_project(elsewhere / "group", "Atlas") + result = run(REPO / "park", "Atlas", home=home, env={"PROJECTS_DIR": str(elsewhere)}) + assert result.returncode == 0, result.stderr + result.stdout + assert f"PROBE park in {root}" in result.stdout + + +def test_missing_recorded_directory_does_not_fall_back_to_group(tmp_path): + box = grouped_box(tmp_path) + result = box.start() + assert result.returncode == 0, result.stderr + before = box.commits() + moved = box.lane_dir.with_name("moved") + box.lane_dir.rename(moved) + original = box.lane_dir + box.lane_dir = moved + replacement = box.home / "projects" / "elsewhere" / "repoZ" + replacement.mkdir(parents=True) + box.git("-C", str(replacement), "init", "-q") + result = box.start() + assert result.returncode != 0 + assert str(original) in result.stderr + assert box.commits() == before + + +def test_grouped_origin_lookup_and_duplicate_origin_refusal(tmp_path): + home = tmp_path / "home"; home.mkdir() + projects = home / "projects" + first = probe_project(projects / "business" / "Company", "Atlas") + def origin(root): + subprocess.run(["git", "init", "-q", str(root)], check=True) + subprocess.run(["git", "-C", str(root), "remote", "add", "origin", "https://github.com/testorg/Atlas.git"], check=True) + origin(first) + result = run(REPO / "park", "--repo", "testorg/Atlas", home=home) + assert result.returncode == 0, result.stderr + result.stdout + assert f"PROBE park in {first}" in result.stdout + second = probe_project(projects / "other", "AtlasCopy"); origin(second) + for command in ("park", "resume", "status"): + result = run(REPO / command, "--repo", "testorg/Atlas", home=home) + assert result.returncode != 0 + assert "multiple development checkouts" in result.stderr + assert "PROBE" not in result.stdout + + +@pytest.mark.parametrize("kind", ["linked", "bare"]) +def test_supporting_git_checkout_is_not_a_default_candidate(tmp_path, kind): + box = grouped_box(tmp_path) + other = box.home / "projects" / "other" / "repoZ" + other.parent.mkdir() + if kind == "linked": + box.git("-C", str(box.lane_dir), "commit", "-q", "--allow-empty", "-m", "fixture base") + box.git("-C", str(box.lane_dir), "worktree", "add", "--detach", str(other), "HEAD") + else: + box.git("clone", "--bare", str(box.lane_dir), str(other)) + result = box.start() + assert result.returncode == 0, result.stderr + assert str(box.lane_dir) in box.lane_log() + + +def test_resume_grouped_existing_family(home, remotes, estate): + target = home / "projects" / "group" / FAMILY + target.parent.mkdir() + estate["folder"].rename(target) + result = run(REPO / "resume", FAMILY, "--workspace", WORKSPACE_SLUG, + home=home, env=offline(remotes)) + assert result.returncode == 0, result.stderr + result.stdout + assert str(target) in result.stdout + assert "Alpha.sh ran with:" in result.stdout + assert not estate["folder"].exists() + + +def test_resume_grouped_existing_standalone(home, remotes): + target = home / "projects" / "group" / "Alpha" + target.parent.mkdir() + git("clone", "-q", str(remotes["members"]["Alpha"]), str(target), cwd=home) + result = run(REPO / "resume", "Alpha", "--workspace", "tester/solo", + home=home, env=offline(remotes)) + assert result.returncode == 0, result.stderr + result.stdout + assert str(target) in result.stdout + assert "Alpha.sh ran with:" in result.stdout + assert not (home / "projects" / "Alpha").exists() From 9d462a074c1563415435c703a72b389aa81efd25 Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 17:13:51 +0000 Subject: [PATCH 2/8] fix: retain logical family paths while deduplicating aliases --- lane-start | 11 +++-- park | 58 ++++++++++++++-------- resume | 52 +++++++++++++------- status | 58 ++++++++++++++-------- tests/test_grouped_project_lookup.py | 72 +++++++++++++++++++++++++++- 5 files changed, 185 insertions(+), 66 deletions(-) diff --git a/lane-start b/lane-start index 9ef0505e..fe91ac69 100755 --- a/lane-start +++ b/lane-start @@ -1084,8 +1084,9 @@ fi # where an `ls` that refused `--` would leave it silent. # BEGIN GROUPED PROJECT DISCOVERY # Self-contained installed commands share this block; a regression test checks -# byte equality. Names are logical; targets are physical. Never enter a repo, -# estate, or supporting checkout collection while looking for grouping folders. +# byte equality. Rows carry name, logical path and physical deduplication key. +# Keep logical paths for estate recognition; never enter a repo, estate or +# supporting checkout collection while looking for grouping folders. project_directory_rows() { local base="$1" depth="${2:-0}" child name physical boundary [ -d "$base" ] || return 0 @@ -1103,7 +1104,7 @@ project_directory_rows() { boundary=1 fi if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then - printf '%s\t%s\n' "$name" "$physical" + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then project_directory_rows "$child" "$((depth + 1))" @@ -1113,8 +1114,8 @@ project_directory_rows() { # END GROUPED PROJECT DISCOVERY project_matches() { - local match_name match_dir git_dir common_dir canonical_name - while IFS=$'\t' read -r match_name match_dir; do + local match_name match_dir git_dir common_dir canonical_name _logical_dir + while IFS=$'\t' read -r match_name _logical_dir match_dir; do if [ -f "$match_dir/HEAD" ] && [ -d "$match_dir/objects" ]; then continue; fi if [ -e "$match_dir/.git" ]; then git_dir="$(git -C "$match_dir" rev-parse --git-dir 2>/dev/null)" || continue diff --git a/park b/park index 7d2b41f7..54e035d7 100755 --- a/park +++ b/park @@ -399,8 +399,9 @@ estate_walk_up() { # BEGIN GROUPED PROJECT DISCOVERY # Self-contained installed commands share this block; a regression test checks -# byte equality. Names are logical; targets are physical. Never enter a repo, -# estate, or supporting checkout collection while looking for grouping folders. +# byte equality. Rows carry name, logical path and physical deduplication key. +# Keep logical paths for estate recognition; never enter a repo, estate or +# supporting checkout collection while looking for grouping folders. project_directory_rows() { local base="$1" depth="${2:-0}" child name physical boundary [ -d "$base" ] || return 0 @@ -418,7 +419,7 @@ project_directory_rows() { boundary=1 fi if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then - printf '%s\t%s\n' "$name" "$physical" + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then project_directory_rows "$child" "$((depth + 1))" @@ -431,17 +432,26 @@ estate_directory_rows() { local dir for dir in "${PROJECTS_DIRS[@]}"; do project_directory_rows "$dir" - done | awk -F '\t' '!seen[$2]++' + done +} + +# Validate logical family names before deduplicating their physical containers. +recognized_estate_rows() { + local name child physical + while IFS=$'\t' read -r name child physical; do + estate_here "$child" || continue + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" + done < <(estate_directory_rows) | awk -F '\t' '!seen[$3]++' } estate_by_name() { - local want="$1" dir name child hits candidate + local want="$1" dir name child physical hits candidate is_safe_folder_name "$want" || return 1 for dir in "${PROJECTS_DIRS[@]}"; do - hits="$(while IFS=$'\t' read -r name child; do + hits="$(while IFS=$'\t' read -r name child physical; do [ "$name" = "$want" ] || continue - if estate_here "$child"; then printf '%s\n' "$child"; fi - done < <(project_directory_rows "$dir") | LC_ALL=C sort -u)" + if estate_here "$child"; then printf '%s\t%s\n' "$child" "$physical"; fi + done < <(project_directory_rows "$dir") | awk -F '\t' '!seen[$2]++ {print $1}')" [ -n "$hits" ] || continue if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" @@ -456,15 +466,15 @@ estate_by_name() { # a refusal to print: a person who typed the command in the wrong folder needs # the names, not an instruction to go and look for them. list_estates() { - local _grouped_name child - while IFS=$'\t' read -r _grouped_name child; do + local _grouped_name child _physical + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue if is_family_folder "$child"; then printf ' family %-20s %s\n' "${child##*/}" "$child" elif is_project_root "$child"; then printf ' project %-20s %s\n' "${child##*/}" "$child" fi - done < <(estate_directory_rows) + done < <(recognized_estate_rows) } estates_or_none() { @@ -497,12 +507,12 @@ estates_or_none() { # shellcheck disable=SC2329 # `park` never asks: it files the record, and # never looks a holder up by it. The block is byte-identical by design. family_folders_with_id() { - local want="$1" dir child prior dup _grouped_name + local want="$1" dir child prior dup _grouped_name _physical local -a found=() [ -n "$want" ] || return 0 for dir in "${PROJECTS_DIRS[@]}"; do [ -d "$dir" ] || continue - while IFS=$'\t' read -r _grouped_name child; do + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue is_family_folder "$child" || continue yaml_scalar "$child/${child##*/}/family.yaml" id || continue @@ -514,7 +524,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done < <(project_directory_rows "$dir" | awk -F '\t' '!seen[$2]++') + done < <(project_directory_rows "$dir") done } @@ -568,13 +578,14 @@ repo_slug_of() { # Match origins only in discovered development checkouts, including a # family's direct sibling checkouts. Never descend into pinned Git members. clone_with_origin() { - local want candidate origin found hits child name git_dir common_dir + local want candidate origin found hits child name physical git_dir common_dir git_physical rank want="$(lower "$1")" - hits="$(while IFS=$'\t' read -r name child; do + hits="$(while IFS=$'\t' read -r name child physical; do for candidate in "$child" "$child"/*; do if [ "$candidate" != "$child" ]; then is_family_folder "$child" || continue fi + case "$candidate" in *$'\t'*|*$'\n'*) continue ;; esac [ -e "$candidate/.git" ] || continue git_dir="$(git -C "$candidate" rev-parse --git-dir 2>/dev/null)" || continue common_dir="$(git -C "$candidate" rev-parse --git-common-dir 2>/dev/null)" || continue @@ -585,10 +596,15 @@ clone_with_origin() { found="$(repo_slug_of "$origin" || true)" [ -n "$found" ] || continue if [ "$(lower "$found")" = "$want" ]; then - (cd -- "$candidate" && pwd -P) + git_physical="$(cd -- "$candidate" && pwd -P)" || continue + rank=1 + estate_walk_up "$candidate" && rank=0 + printf '%s\t%s\t%s\n' "$git_physical" "$rank" "$candidate" fi done - done < <(estate_directory_rows) | LC_ALL=C sort -u)" + done < <(estate_directory_rows) | + LC_ALL=C sort -s -t $'\t' -k1,1 -k2,2n | + awk -F '\t' '!seen[$1]++ {print $3}')" [ -n "$hits" ] || return 1 if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then printf 'multiple development checkouts have origin %s; stand in the intended checkout: %s\n' "$1" "$hits" >&2 @@ -982,13 +998,13 @@ run_one_estate() { # `members/` copy (three levels down) and a linked feature worktree # (rejected by `is_project_root` itself). all_estate_dirs() { - local _grouped_name child - while IFS=$'\t' read -r _grouped_name child; do + local _grouped_name child _physical + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue if is_family_folder "$child" || is_project_root "$child"; then printf '%s\t%s\n' "${child##*/}" "$child" fi - done < <(estate_directory_rows) | LC_ALL=C sort -t $'\t' -k1,1 + done < <(recognized_estate_rows) | LC_ALL=C sort -t $'\t' -k1,1 } # Does this root carry the Speckit git overlay its own `make park` requires? diff --git a/resume b/resume index 02a48481..fc669e35 100755 --- a/resume +++ b/resume @@ -383,8 +383,9 @@ estate_walk_up() { # BEGIN GROUPED PROJECT DISCOVERY # Self-contained installed commands share this block; a regression test checks -# byte equality. Names are logical; targets are physical. Never enter a repo, -# estate, or supporting checkout collection while looking for grouping folders. +# byte equality. Rows carry name, logical path and physical deduplication key. +# Keep logical paths for estate recognition; never enter a repo, estate or +# supporting checkout collection while looking for grouping folders. project_directory_rows() { local base="$1" depth="${2:-0}" child name physical boundary [ -d "$base" ] || return 0 @@ -402,7 +403,7 @@ project_directory_rows() { boundary=1 fi if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then - printf '%s\t%s\n' "$name" "$physical" + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then project_directory_rows "$child" "$((depth + 1))" @@ -415,17 +416,26 @@ estate_directory_rows() { local dir for dir in "${PROJECTS_DIRS[@]}"; do project_directory_rows "$dir" - done | awk -F '\t' '!seen[$2]++' + done +} + +# Validate logical family names before deduplicating their physical containers. +recognized_estate_rows() { + local name child physical + while IFS=$'\t' read -r name child physical; do + estate_here "$child" || continue + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" + done < <(estate_directory_rows) | awk -F '\t' '!seen[$3]++' } estate_by_name() { - local want="$1" dir name child hits candidate + local want="$1" dir name child physical hits candidate is_safe_folder_name "$want" || return 1 for dir in "${PROJECTS_DIRS[@]}"; do - hits="$(while IFS=$'\t' read -r name child; do + hits="$(while IFS=$'\t' read -r name child physical; do [ "$name" = "$want" ] || continue - if estate_here "$child"; then printf '%s\n' "$child"; fi - done < <(project_directory_rows "$dir") | LC_ALL=C sort -u)" + if estate_here "$child"; then printf '%s\t%s\n' "$child" "$physical"; fi + done < <(project_directory_rows "$dir") | awk -F '\t' '!seen[$2]++ {print $1}')" [ -n "$hits" ] || continue if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" @@ -440,15 +450,15 @@ estate_by_name() { # a refusal to print: a person who typed the command in the wrong folder needs # the names, not an instruction to go and look for them. list_estates() { - local _grouped_name child - while IFS=$'\t' read -r _grouped_name child; do + local _grouped_name child _physical + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue if is_family_folder "$child"; then printf ' family %-20s %s\n' "${child##*/}" "$child" elif is_project_root "$child"; then printf ' project %-20s %s\n' "${child##*/}" "$child" fi - done < <(estate_directory_rows) + done < <(recognized_estate_rows) } estates_or_none() { @@ -481,12 +491,12 @@ estates_or_none() { # shellcheck disable=SC2329 # `park` never asks: it files the record, and # never looks a holder up by it. The block is byte-identical by design. family_folders_with_id() { - local want="$1" dir child prior dup _grouped_name + local want="$1" dir child prior dup _grouped_name _physical local -a found=() [ -n "$want" ] || return 0 for dir in "${PROJECTS_DIRS[@]}"; do [ -d "$dir" ] || continue - while IFS=$'\t' read -r _grouped_name child; do + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue is_family_folder "$child" || continue yaml_scalar "$child/${child##*/}/family.yaml" id || continue @@ -498,7 +508,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done < <(project_directory_rows "$dir" | awk -F '\t' '!seen[$2]++') + done < <(project_directory_rows "$dir") done } @@ -552,13 +562,14 @@ repo_slug_of() { # Match origins only in discovered development checkouts, including a # family's direct sibling checkouts. Never descend into pinned Git members. clone_with_origin() { - local want candidate origin found hits child name git_dir common_dir + local want candidate origin found hits child name physical git_dir common_dir git_physical rank want="$(lower "$1")" - hits="$(while IFS=$'\t' read -r name child; do + hits="$(while IFS=$'\t' read -r name child physical; do for candidate in "$child" "$child"/*; do if [ "$candidate" != "$child" ]; then is_family_folder "$child" || continue fi + case "$candidate" in *$'\t'*|*$'\n'*) continue ;; esac [ -e "$candidate/.git" ] || continue git_dir="$(git -C "$candidate" rev-parse --git-dir 2>/dev/null)" || continue common_dir="$(git -C "$candidate" rev-parse --git-common-dir 2>/dev/null)" || continue @@ -569,10 +580,15 @@ clone_with_origin() { found="$(repo_slug_of "$origin" || true)" [ -n "$found" ] || continue if [ "$(lower "$found")" = "$want" ]; then - (cd -- "$candidate" && pwd -P) + git_physical="$(cd -- "$candidate" && pwd -P)" || continue + rank=1 + estate_walk_up "$candidate" && rank=0 + printf '%s\t%s\t%s\n' "$git_physical" "$rank" "$candidate" fi done - done < <(estate_directory_rows) | LC_ALL=C sort -u)" + done < <(estate_directory_rows) | + LC_ALL=C sort -s -t $'\t' -k1,1 -k2,2n | + awk -F '\t' '!seen[$1]++ {print $3}')" [ -n "$hits" ] || return 1 if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then printf 'multiple development checkouts have origin %s; stand in the intended checkout: %s\n' "$1" "$hits" >&2 diff --git a/status b/status index f9ad5825..bd0f4f4a 100755 --- a/status +++ b/status @@ -520,8 +520,9 @@ estate_walk_up() { # BEGIN GROUPED PROJECT DISCOVERY # Self-contained installed commands share this block; a regression test checks -# byte equality. Names are logical; targets are physical. Never enter a repo, -# estate, or supporting checkout collection while looking for grouping folders. +# byte equality. Rows carry name, logical path and physical deduplication key. +# Keep logical paths for estate recognition; never enter a repo, estate or +# supporting checkout collection while looking for grouping folders. project_directory_rows() { local base="$1" depth="${2:-0}" child name physical boundary [ -d "$base" ] || return 0 @@ -539,7 +540,7 @@ project_directory_rows() { boundary=1 fi if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then - printf '%s\t%s\n' "$name" "$physical" + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then project_directory_rows "$child" "$((depth + 1))" @@ -552,17 +553,26 @@ estate_directory_rows() { local dir for dir in "${PROJECTS_DIRS[@]}"; do project_directory_rows "$dir" - done | awk -F '\t' '!seen[$2]++' + done +} + +# Validate logical family names before deduplicating their physical containers. +recognized_estate_rows() { + local name child physical + while IFS=$'\t' read -r name child physical; do + estate_here "$child" || continue + printf '%s\t%s\t%s\n' "$name" "$child" "$physical" + done < <(estate_directory_rows) | awk -F '\t' '!seen[$3]++' } estate_by_name() { - local want="$1" dir name child hits candidate + local want="$1" dir name child physical hits candidate is_safe_folder_name "$want" || return 1 for dir in "${PROJECTS_DIRS[@]}"; do - hits="$(while IFS=$'\t' read -r name child; do + hits="$(while IFS=$'\t' read -r name child physical; do [ "$name" = "$want" ] || continue - if estate_here "$child"; then printf '%s\n' "$child"; fi - done < <(project_directory_rows "$dir") | LC_ALL=C sort -u)" + if estate_here "$child"; then printf '%s\t%s\n' "$child" "$physical"; fi + done < <(project_directory_rows "$dir") | awk -F '\t' '!seen[$2]++ {print $1}')" [ -n "$hits" ] || continue if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" @@ -577,15 +587,15 @@ estate_by_name() { # a refusal to print: a person who typed the command in the wrong folder needs # the names, not an instruction to go and look for them. list_estates() { - local _grouped_name child - while IFS=$'\t' read -r _grouped_name child; do + local _grouped_name child _physical + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue if is_family_folder "$child"; then printf ' family %-20s %s\n' "${child##*/}" "$child" elif is_project_root "$child"; then printf ' project %-20s %s\n' "${child##*/}" "$child" fi - done < <(estate_directory_rows) + done < <(recognized_estate_rows) } estates_or_none() { @@ -618,12 +628,12 @@ estates_or_none() { # shellcheck disable=SC2329 # `park` never asks: it files the record, and # never looks a holder up by it. The block is byte-identical by design. family_folders_with_id() { - local want="$1" dir child prior dup _grouped_name + local want="$1" dir child prior dup _grouped_name _physical local -a found=() [ -n "$want" ] || return 0 for dir in "${PROJECTS_DIRS[@]}"; do [ -d "$dir" ] || continue - while IFS=$'\t' read -r _grouped_name child; do + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue is_family_folder "$child" || continue yaml_scalar "$child/${child##*/}/family.yaml" id || continue @@ -635,7 +645,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done < <(project_directory_rows "$dir" | awk -F '\t' '!seen[$2]++') + done < <(project_directory_rows "$dir") done } @@ -689,13 +699,14 @@ repo_slug_of() { # Match origins only in discovered development checkouts, including a # family's direct sibling checkouts. Never descend into pinned Git members. clone_with_origin() { - local want candidate origin found hits child name git_dir common_dir + local want candidate origin found hits child name physical git_dir common_dir git_physical rank want="$(lower "$1")" - hits="$(while IFS=$'\t' read -r name child; do + hits="$(while IFS=$'\t' read -r name child physical; do for candidate in "$child" "$child"/*; do if [ "$candidate" != "$child" ]; then is_family_folder "$child" || continue fi + case "$candidate" in *$'\t'*|*$'\n'*) continue ;; esac [ -e "$candidate/.git" ] || continue git_dir="$(git -C "$candidate" rev-parse --git-dir 2>/dev/null)" || continue common_dir="$(git -C "$candidate" rev-parse --git-common-dir 2>/dev/null)" || continue @@ -706,10 +717,15 @@ clone_with_origin() { found="$(repo_slug_of "$origin" || true)" [ -n "$found" ] || continue if [ "$(lower "$found")" = "$want" ]; then - (cd -- "$candidate" && pwd -P) + git_physical="$(cd -- "$candidate" && pwd -P)" || continue + rank=1 + estate_walk_up "$candidate" && rank=0 + printf '%s\t%s\t%s\n' "$git_physical" "$rank" "$candidate" fi done - done < <(estate_directory_rows) | LC_ALL=C sort -u)" + done < <(estate_directory_rows) | + LC_ALL=C sort -s -t $'\t' -k1,1 -k2,2n | + awk -F '\t' '!seen[$1]++ {print $3}')" [ -n "$hits" ] || return 1 if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then printf 'multiple development checkouts have origin %s; stand in the intended checkout: %s\n' "$1" "$hits" >&2 @@ -5874,13 +5890,13 @@ read_one_estate() { # reason: `~/projects` and `~/Projects` can each hold estates when both # exist, and name order reads them together. all_estate_dirs() { - local _grouped_name child - while IFS=$'\t' read -r _grouped_name child; do + local _grouped_name child _physical + while IFS=$'\t' read -r _grouped_name child _physical; do [ -d "$child" ] || continue if is_family_folder "$child" || is_project_root "$child"; then printf '%s\t%s\n' "${child##*/}" "$child" fi - done < <(estate_directory_rows) | LC_ALL=C sort -t $'\t' -k1,1 + done < <(recognized_estate_rows) | LC_ALL=C sort -t $'\t' -k1,1 } # Read every estate in `$1`, in name order, and end with a summary. An estate diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index e799821c..e4b86866 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -24,7 +24,7 @@ def test_discovery_copies_match(): def rows(root): result = subprocess.run(["bash", "-c", block("park") + '\nproject_directory_rows "$1"', "lookup", str(root)], text=True, capture_output=True, check=True) - return [line.split("\t") for line in result.stdout.splitlines()] + return [[parts[0], parts[-1]] for parts in (line.split("\t") for line in result.stdout.splitlines())] def test_bounds_support_collections_and_repository_boundaries(tmp_path): @@ -202,3 +202,73 @@ def test_resume_grouped_existing_standalone(home, remotes): assert str(target) in result.stdout assert "Alpha.sh ran with:" in result.stdout assert not (home / "projects" / "Alpha").exists() + + +def logical_family_aliases(home, storage, name): + """A logical holder name unrelated to its physical container basename.""" + projects = home / "projects"; projects.mkdir(parents=True, exist_ok=True) + physical = storage / "estate-data" + holder = probe_family(storage, name) + holder.parent.rename(physical) + alias = projects / name + alias.symlink_to(physical, target_is_directory=True) + (projects / "000-invalid").symlink_to(physical, target_is_directory=True) + group = projects / "group"; group.mkdir() + (group / name).symlink_to(physical, target_is_directory=True) + return alias, physical / name + + +@pytest.mark.parametrize("sweep", [False, True]) +def test_logical_family_alias_park_dispatch_and_dedup(tmp_path, sweep): + home = tmp_path / "home" + alias, holder = logical_family_aliases(home, tmp_path / "storage", "Atlas") + result = run(REPO / "park", "--all" if sweep else "Atlas", home=home) + assert result.returncode == 0, result.stderr + result.stdout + assert result.stdout.count(f"PROBE park in {holder}") == 1 + assert alias.is_symlink() + + +@pytest.mark.parametrize("sweep", [False, True]) +def test_logical_family_alias_status_recognition(tmp_path, sweep): + home = tmp_path / "home" + alias, holder = logical_family_aliases(home, tmp_path / "storage", "Atlas") + result = run(REPO / "status", "--all" if sweep else "Atlas", home=home) + assert result.returncode in (0, 1), result.stderr + result.stdout + assert "Atlas" in result.stdout + assert "no estate" not in result.stderr + assert alias.is_symlink() + + +def aliased_real_family(home, remotes, estate, tmp_path): + physical = tmp_path / "storage" / "estate-data"; physical.parent.mkdir() + estate["folder"].rename(physical) + estate["folder"].symlink_to(physical, target_is_directory=True) + (home / "projects" / "000-invalid").symlink_to(physical, target_is_directory=True) + config = home / ".agents" / "workspace.yaml"; config.parent.mkdir() + config.write_text(f"repository: {WORKSPACE_SLUG}\npath: ~/projects/wip\n") + git("clone", "-q", str(remotes["workspace"]), str(home / "projects" / "wip"), cwd=home) + return estate["folder"], physical + + +@pytest.mark.parametrize("by_id", [False, True]) +def test_logical_family_alias_resume_name_and_family_id(home, remotes, estate, tmp_path, by_id): + alias, physical = aliased_real_family(home, remotes, estate, tmp_path) + result = run(REPO / "resume", FAMILY.lower() if by_id else FAMILY, + "--dry-run", home=home, env=offline(remotes)) + assert result.returncode == 0, result.stderr + result.stdout + assert f"present {alias} (family)" in result.stdout + assert "would clone" not in result.stdout + assert alias.is_symlink() + + +@pytest.mark.parametrize("command", ["park", "status"]) +def test_logical_family_alias_origin_lookup(home, remotes, estate, tmp_path, command): + alias, physical = aliased_real_family(home, remotes, estate, tmp_path) + slug = "testorg/" + FAMILY + git("-C", str(alias / FAMILY), "remote", "set-url", "origin", "https://github.com/" + slug + ".git", cwd=home) + args = ["--repo", slug] + if command == "park": args.append("--dry-run") + result = run(REPO / command, *args, home=home, env=offline(remotes)) + assert result.returncode in (0, 1), result.stderr + result.stdout + assert "nothing at or above" not in result.stderr + assert alias.is_symlink() From 0f5ba5d090753711df0b020e69f447a79f593d65 Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 17:47:30 +0000 Subject: [PATCH 3/8] fix: preserve recorded-home proof before grouped lane fallback --- lane-start | 22 ++++++++++------- tests/test_grouped_project_lookup.py | 36 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lane-start b/lane-start index fe91ac69..2b7b5cd3 100755 --- a/lane-start +++ b/lane-start @@ -1114,8 +1114,9 @@ project_directory_rows() { # END GROUPED PROJECT DISCOVERY project_matches() { - local match_name match_dir git_dir common_dir canonical_name _logical_dir + local match_name match_dir git_dir common_dir canonical_name _logical_dir scope="${2:-grouped}" while IFS=$'\t' read -r match_name _logical_dir match_dir; do + if [ "$scope" = flat ] && [ "${_logical_dir%/*}" != "$PROJECTS_ROOT" ]; then continue; fi if [ -f "$match_dir/HEAD" ] && [ -d "$match_dir/objects" ]; then continue; fi if [ -e "$match_dir/.git" ]; then git_dir="$(git -C "$match_dir" rev-parse --git-dir 2>/dev/null)" || continue @@ -1408,7 +1409,18 @@ if [ -n "$DIR" ] && [ ! -d "$DIR" ]; then die "no such directory: $DIR (from $DIR_SOURCE) — pass --dir if this lane's checkout is somewhere else" 1 fi if [ -z "$DIR" ]; then - default_matches="$(project_matches "$repo")" + ls_home=""; ls_rc=0 + ls_home="$("$LANES_EDIT" resolve-home "$LANE" 2>/dev/null)" || ls_rc=$? + [ "$ls_rc" = 0 ] || ls_home="" + case "$ls_home" in */*) : ;; *) ls_home="" ;; esac +fi +if [ -z "$DIR" ]; then + # Keep the historical flat default ahead of home-based recovery. Grouped + # name discovery is a new-lane default only: an older home-only record must + # reach rungs 5/6, where origin proves the checkout and rejects imposters. + default_scope=grouped + [ -z "$ls_home" ] || default_scope=flat + default_matches="$(project_matches "$repo" "$default_scope")" if [ -n "$default_matches" ]; then default_count="$(printf '%s\n' "$default_matches" | wc -l | tr -d ' ')" [ "$default_count" -eq 1 ] || die "$PROJECTS_ROOT holds $default_count directories whose names differ only by case or grouping for '$repo': $default_matches — Amendment 15(a) requires one default target; pass --dir " 2 @@ -1456,12 +1468,6 @@ fi # # BOTH ARE SKIPPED ENTIRELY WHERE THE LANE HAS NO RECORDED HOME, because there # is then nothing to prove a candidate against and a match would be a guess. -if [ -z "$DIR" ]; then - ls_home=""; ls_rc=0 - ls_home="$("$LANES_EDIT" resolve-home "$LANE" 2>/dev/null)" || ls_rc=$? - [ "$ls_rc" = 0 ] || ls_home="" - case "$ls_home" in */*) : ;; *) ls_home="" ;; esac -fi # Rung 5 — the legs. if [ -z "$DIR" ] && [ -n "$ls_home" ]; then for ls_m in "$PROJECTS_ROOT"/*/project.yaml "$PROJECTS_ROOT"/*/*/project.yaml; do diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index e4b86866..b3d84309 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -272,3 +272,39 @@ def test_logical_family_alias_origin_lookup(home, remotes, estate, tmp_path, com assert result.returncode in (0, 1), result.stderr + result.stdout assert "nothing at or above" not in result.stderr assert alias.is_symlink() + + +@pytest.mark.parametrize("matching_home", [True, False]) +def test_recorded_home_without_directory_keeps_origin_proof(tmp_path, matching_home): + box = grouped_box(tmp_path) + result = box.start() + assert result.returncode == 0, result.stderr + log = box.wip / "lanes" / "log" / "repoZ-1.md" + # Model an older record: home is known, but the directory field predates it. + import re + text = re.sub(r"; dir [^;\n]+", "", log.read_text()) + assert str(box.lane_dir) not in text + log.write_text(text) + box.git("-C", str(box.wip), "add", "--", str(log)) + box.git("-C", str(box.wip), "commit", "-q", "-m", "seed old home-only record") + box.git("-C", str(box.wip), "push", "-q", "origin", "main") + other = box.home / "projects" / "imposter" / "repoZ" + other.mkdir(parents=True) + box.git("init", "-q", str(other)) + box.git("-C", str(other), "remote", "add", "origin", "https://github.com/stranger/repoZ.git") + if not matching_home: + box.git("-C", str(box.lane_dir), "remote", "set-url", "origin", "https://github.com/stranger/also-wrong.git") + moved = box.lane_dir.with_name("moved-away") + box.lane_dir.rename(moved) + box.lane_dir = moved + before = box.commits() + result = box.start("--dry-run") + assert box.commits() == before + assert f"cd {other}" not in result.stderr + if matching_home: + assert result.returncode == 0, result.stderr + assert f"cd {box.lane_dir}" in result.stderr + assert "Evidence 7" in result.stderr + else: + assert result.returncode == 2, result.stderr + assert "nothing was started" in result.stderr From 0df2e4d6283d7f9a86c995e488304bf8e811579b Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 17:54:31 +0000 Subject: [PATCH 4/8] test: skip upstream fixtures when optional submodule is absent --- tests/test_grouped_project_lookup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index b3d84309..89a2f4de 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -3,7 +3,7 @@ import subprocess import shutil import pytest -from conftest import REPO, WINDOWS_SKIP +from conftest import NEEDS_UPSTREAM, REPO, WINDOWS_SKIP from test_park_resume_commands import (FAMILY, WORKSPACE_SLUG, git, home, estate, remotes, offline, probe_project, probe_family, sweepable_project, run) from test_lane_start_claude_current import Sandbox @@ -54,6 +54,7 @@ def test_named_grouped_estate(tmp_path, family): @pytest.mark.parametrize("command", ["park", "resume", "status"]) +@NEEDS_UPSTREAM def test_distinct_matching_estates_refuse(tmp_path, command, remotes): home = tmp_path / "home"; home.mkdir() name = FAMILY if command == "resume" else "Atlas" @@ -180,6 +181,7 @@ def test_supporting_git_checkout_is_not_a_default_candidate(tmp_path, kind): assert str(box.lane_dir) in box.lane_log() +@NEEDS_UPSTREAM def test_resume_grouped_existing_family(home, remotes, estate): target = home / "projects" / "group" / FAMILY target.parent.mkdir() @@ -192,6 +194,7 @@ def test_resume_grouped_existing_family(home, remotes, estate): assert not estate["folder"].exists() +@NEEDS_UPSTREAM def test_resume_grouped_existing_standalone(home, remotes): target = home / "projects" / "group" / "Alpha" target.parent.mkdir() @@ -251,6 +254,7 @@ def aliased_real_family(home, remotes, estate, tmp_path): @pytest.mark.parametrize("by_id", [False, True]) +@NEEDS_UPSTREAM def test_logical_family_alias_resume_name_and_family_id(home, remotes, estate, tmp_path, by_id): alias, physical = aliased_real_family(home, remotes, estate, tmp_path) result = run(REPO / "resume", FAMILY.lower() if by_id else FAMILY, @@ -262,6 +266,7 @@ def test_logical_family_alias_resume_name_and_family_id(home, remotes, estate, t @pytest.mark.parametrize("command", ["park", "status"]) +@NEEDS_UPSTREAM def test_logical_family_alias_origin_lookup(home, remotes, estate, tmp_path, command): alias, physical = aliased_real_family(home, remotes, estate, tmp_path) slug = "testorg/" + FAMILY From 7de8123ea62e9b13ac1c40dbac84d7bdc1e9717e Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 18:06:27 +0000 Subject: [PATCH 5/8] fix: exclude workspace lane collections from grouped discovery --- lane-start | 4 +++- park | 4 +++- resume | 4 +++- status | 4 +++- tests/test_grouped_project_lookup.py | 35 +++++++++++++++++++++++++++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/lane-start b/lane-start index 2b7b5cd3..e4e6b8ae 100755 --- a/lane-start +++ b/lane-start @@ -1093,9 +1093,11 @@ project_directory_rows() { for child in "$base"/*; do [ -d "$child" ] || continue name="${child##*/}" - case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + # Per-lane register clones live beside any workspace as -lanes. + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0 if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || diff --git a/park b/park index 54e035d7..f599195b 100755 --- a/park +++ b/park @@ -408,9 +408,11 @@ project_directory_rows() { for child in "$base"/*; do [ -d "$child" ] || continue name="${child##*/}" - case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + # Per-lane register clones live beside any workspace as -lanes. + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0 if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || diff --git a/resume b/resume index fc669e35..610a5b43 100755 --- a/resume +++ b/resume @@ -392,9 +392,11 @@ project_directory_rows() { for child in "$base"/*; do [ -d "$child" ] || continue name="${child##*/}" - case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + # Per-lane register clones live beside any workspace as -lanes. + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0 if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || diff --git a/status b/status index bd0f4f4a..de11481a 100755 --- a/status +++ b/status @@ -529,9 +529,11 @@ project_directory_rows() { for child in "$base"/*; do [ -d "$child" ] || continue name="${child##*/}" - case "$name" in workTrees|worktrees|laneWorkspaces|brett-wip-lanes) continue ;; esac + # Per-lane register clones live beside any workspace as -lanes. + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0 if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index 89a2f4de..28ccd2f5 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -28,7 +28,7 @@ def rows(root): def test_bounds_support_collections_and_repository_boundaries(tmp_path): - for group in ("workTrees", "laneWorkspaces", "brett-wip-lanes", "worktrees"): + for group in ("workTrees", "laneWorkspaces", "brett-wip-lanes", "wip-lanes", "personal-register-lanes", "worktrees"): probe_project(tmp_path / group, "Hidden") target = probe_project(tmp_path / "business" / "Company space", "Visible") probe_project(tmp_path / "business" / "Company space" / "too-deep", "Deep") @@ -313,3 +313,36 @@ def test_recorded_home_without_directory_keeps_origin_proof(tmp_path, matching_h else: assert result.returncode == 2, result.stderr assert "nothing was started" in result.stderr + + +@pytest.mark.parametrize("workspace", ["wip", "brett-wip", "personal-register"]) +@pytest.mark.parametrize("command", ["park", "resume", "status"]) +def test_workspace_lane_collections_do_not_ambiguate_origin_lookup(tmp_path, workspace, command): + home = tmp_path / "home"; home.mkdir() + projects = home / "projects" + root = probe_project(projects, workspace) + lane = probe_project(projects / (workspace + "-lanes"), "repoA-1") + (projects / "register-checkouts").symlink_to(lane.parent, target_is_directory=True) + slug = "tester/" + workspace + for checkout in (root, lane): + subprocess.run(["git", "init", "-q", str(checkout)], check=True) + subprocess.run(["git", "-C", str(checkout), "remote", "add", "origin", "https://github.com/" + slug + ".git"], check=True) + result = run(REPO / command, "--repo", slug, home=home) + assert "multiple development checkouts" not in result.stderr + assert str(lane) not in result.stdout + result.stderr + if command == "park": + assert result.returncode == 0, result.stderr + result.stdout + assert f"PROBE park in {root}" in result.stdout + + +def test_workspace_lane_collections_are_not_swept(tmp_path): + home = tmp_path / "home"; home.mkdir() + projects = home / "projects" + root = sweepable_project(projects, "wip") + lane = sweepable_project(projects / "wip-lanes", "repoA-1") + (projects / "register-checkouts").symlink_to(lane.parent, target_is_directory=True) + result = run(REPO / "park", "--all", home=home) + assert result.returncode == 0, result.stderr + result.stdout + assert f"PROBE park in {root}" in result.stdout + assert str(lane) not in result.stdout + result.stderr + assert "1 estate(s) parked" in result.stdout From 1e5837bcbcc071269e0e433b053e637ac5e66f42 Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 20:21:04 +0000 Subject: [PATCH 6/8] fix: preserve family boundaries through alternate aliases --- lane-start | 29 +++++++++++++++++++++------- park | 26 +++++++++++++++++++------ resume | 26 +++++++++++++++++++------ status | 26 +++++++++++++++++++------ tests/test_grouped_project_lookup.py | 18 +++++++++++++++++ 5 files changed, 100 insertions(+), 25 deletions(-) diff --git a/lane-start b/lane-start index e4e6b8ae..0e5bbb8d 100755 --- a/lane-start +++ b/lane-start @@ -1087,8 +1087,8 @@ fi # byte equality. Rows carry name, logical path and physical deduplication key. # Keep logical paths for estate recognition; never enter a repo, estate or # supporting checkout collection while looking for grouping folders. -project_directory_rows() { - local base="$1" depth="${2:-0}" child name physical boundary +project_directory_walk() { + local base="$1" depth="$2" mode="$3" families="${4-}" child name physical boundary family_container [ -d "$base" ] || return 0 for child in "$base"/*; do [ -d "$child" ] || continue @@ -1099,20 +1099,34 @@ project_directory_rows() { physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac - boundary=0 + boundary=0; family_container=0 + if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then + family_container=1 + fi + case $'\n'"$families"$'\n' in *$'\n'"$physical"$'\n'*) boundary=1 ;; esac if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || - [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + [ -e "$child/family.yaml" ] || [ "$family_container" -eq 1 ] || { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then boundary=1 fi - if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + if [ "$mode" = families ]; then + [ "$family_container" -eq 0 ] || printf '%s\n' "$physical" + elif [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then - project_directory_rows "$child" "$((depth + 1))" + project_directory_walk "$child" "$((depth + 1))" "$mode" "$families" fi done } + +project_directory_rows() { + local families + # Resolve container boundaries before emitting rows: an earlier alias with + # a different basename must not expose the same family's member projects. + families="$(project_directory_walk "$1" 0 families)" + project_directory_walk "$1" 0 rows "$families" +} # END GROUPED PROJECT DISCOVERY project_matches() { @@ -1533,6 +1547,7 @@ if [ -z "$DIR" ]; then ls_where="$PROJECTS_ROOT/$repo" [ -z "$DIR_DEFAULT_TRIED" ] || ls_where="$DIR_DEFAULT_TRIED" ls_pos="${LANE##*-}" + ls_repo="${LANE%-*}" if [ -n "$ls_home" ]; then ls_tried="the default $ls_where, the project.yaml legs of $ls_home, and a checkout of $ls_home one or two levels under $PROJECTS_ROOT" else @@ -1541,7 +1556,7 @@ if [ -z "$DIR" ]; then die "lane $LANE has no recorded checkout and none could be PROVED, so nothing was started. Tried: $ls_tried. Name it once, and every later start reads it back out of the lane's own log: - lane-start --dir $repo $ls_pos + lane-start --dir $ls_repo $ls_pos Nothing here guesses. This script writes the lane HOME from the directory's origin, and a directory that merely has the right name would re-home the lane for every \`#n\` it writes afterwards (Amendment 11 clause (c); Evidence 7, diff --git a/park b/park index f599195b..17873b8f 100755 --- a/park +++ b/park @@ -402,8 +402,8 @@ estate_walk_up() { # byte equality. Rows carry name, logical path and physical deduplication key. # Keep logical paths for estate recognition; never enter a repo, estate or # supporting checkout collection while looking for grouping folders. -project_directory_rows() { - local base="$1" depth="${2:-0}" child name physical boundary +project_directory_walk() { + local base="$1" depth="$2" mode="$3" families="${4-}" child name physical boundary family_container [ -d "$base" ] || return 0 for child in "$base"/*; do [ -d "$child" ] || continue @@ -414,20 +414,34 @@ project_directory_rows() { physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac - boundary=0 + boundary=0; family_container=0 + if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then + family_container=1 + fi + case $'\n'"$families"$'\n' in *$'\n'"$physical"$'\n'*) boundary=1 ;; esac if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || - [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + [ -e "$child/family.yaml" ] || [ "$family_container" -eq 1 ] || { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then boundary=1 fi - if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + if [ "$mode" = families ]; then + [ "$family_container" -eq 0 ] || printf '%s\n' "$physical" + elif [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then - project_directory_rows "$child" "$((depth + 1))" + project_directory_walk "$child" "$((depth + 1))" "$mode" "$families" fi done } + +project_directory_rows() { + local families + # Resolve container boundaries before emitting rows: an earlier alias with + # a different basename must not expose the same family's member projects. + families="$(project_directory_walk "$1" 0 families)" + project_directory_walk "$1" 0 rows "$families" +} # END GROUPED PROJECT DISCOVERY estate_directory_rows() { diff --git a/resume b/resume index 610a5b43..a234e933 100755 --- a/resume +++ b/resume @@ -386,8 +386,8 @@ estate_walk_up() { # byte equality. Rows carry name, logical path and physical deduplication key. # Keep logical paths for estate recognition; never enter a repo, estate or # supporting checkout collection while looking for grouping folders. -project_directory_rows() { - local base="$1" depth="${2:-0}" child name physical boundary +project_directory_walk() { + local base="$1" depth="$2" mode="$3" families="${4-}" child name physical boundary family_container [ -d "$base" ] || return 0 for child in "$base"/*; do [ -d "$child" ] || continue @@ -398,20 +398,34 @@ project_directory_rows() { physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac - boundary=0 + boundary=0; family_container=0 + if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then + family_container=1 + fi + case $'\n'"$families"$'\n' in *$'\n'"$physical"$'\n'*) boundary=1 ;; esac if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || - [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + [ -e "$child/family.yaml" ] || [ "$family_container" -eq 1 ] || { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then boundary=1 fi - if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + if [ "$mode" = families ]; then + [ "$family_container" -eq 0 ] || printf '%s\n' "$physical" + elif [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then - project_directory_rows "$child" "$((depth + 1))" + project_directory_walk "$child" "$((depth + 1))" "$mode" "$families" fi done } + +project_directory_rows() { + local families + # Resolve container boundaries before emitting rows: an earlier alias with + # a different basename must not expose the same family's member projects. + families="$(project_directory_walk "$1" 0 families)" + project_directory_walk "$1" 0 rows "$families" +} # END GROUPED PROJECT DISCOVERY estate_directory_rows() { diff --git a/status b/status index de11481a..39ad7ed2 100755 --- a/status +++ b/status @@ -523,8 +523,8 @@ estate_walk_up() { # byte equality. Rows carry name, logical path and physical deduplication key. # Keep logical paths for estate recognition; never enter a repo, estate or # supporting checkout collection while looking for grouping folders. -project_directory_rows() { - local base="$1" depth="${2:-0}" child name physical boundary +project_directory_walk() { + local base="$1" depth="$2" mode="$3" families="${4-}" child name physical boundary family_container [ -d "$base" ] || return 0 for child in "$base"/*; do [ -d "$child" ] || continue @@ -535,20 +535,34 @@ project_directory_rows() { physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac - boundary=0 + boundary=0; family_container=0 + if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then + family_container=1 + fi + case $'\n'"$families"$'\n' in *$'\n'"$physical"$'\n'*) boundary=1 ;; esac if [ -e "$child/.git" ] || [ -e "$child/project.yaml" ] || - [ -e "$child/family.yaml" ] || [ -e "$child/$name/family.yaml" ] || + [ -e "$child/family.yaml" ] || [ "$family_container" -eq 1 ] || { [ -f "$child/HEAD" ] && [ -d "$child/objects" ]; }; then boundary=1 fi - if [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then + if [ "$mode" = families ]; then + [ "$family_container" -eq 0 ] || printf '%s\n' "$physical" + elif [ "$depth" -eq 0 ] || [ "$boundary" -eq 1 ]; then printf '%s\t%s\t%s\n' "$name" "$child" "$physical" fi if [ "$boundary" -eq 0 ] && [ "$depth" -lt 2 ]; then - project_directory_rows "$child" "$((depth + 1))" + project_directory_walk "$child" "$((depth + 1))" "$mode" "$families" fi done } + +project_directory_rows() { + local families + # Resolve container boundaries before emitting rows: an earlier alias with + # a different basename must not expose the same family's member projects. + families="$(project_directory_walk "$1" 0 families)" + project_directory_walk "$1" 0 rows "$families" +} # END GROUPED PROJECT DISCOVERY estate_directory_rows() { diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index 28ccd2f5..9873e7d4 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -346,3 +346,21 @@ def test_workspace_lane_collections_are_not_swept(tmp_path): assert f"PROBE park in {root}" in result.stdout assert str(lane) not in result.stdout + result.stderr assert "1 estate(s) parked" in result.stdout + + +@pytest.mark.parametrize("physical_name", ["Atlas", "estate-data"]) +def test_family_container_alias_does_not_expose_members(tmp_path, physical_name): + home = tmp_path / "home"; home.mkdir() + alias, holder = logical_family_aliases(home, tmp_path / "storage", "Atlas") + physical = holder.parent + if physical_name != physical.name: + renamed = physical.with_name(physical_name) + physical.rename(renamed) + for link in (home / "projects" / "Atlas", home / "projects" / "000-invalid", home / "projects" / "group" / "Atlas"): + link.unlink() + link.symlink_to(renamed, target_is_directory=True) + physical = renamed + probe_project(physical, "Alpha") + found = rows(home / "projects") + assert "Atlas" in [row[0] for row in found] + assert "Alpha" not in [row[0] for row in found] From 08e15e18f2d56b144e1b109db7022caeda37524a Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 20:24:47 +0000 Subject: [PATCH 7/8] fix: exclude independent lane-register collections --- lane-start | 4 ++-- park | 4 ++-- resume | 4 ++-- status | 4 ++-- tests/test_grouped_project_lookup.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lane-start b/lane-start index 0e5bbb8d..ae94312c 100755 --- a/lane-start +++ b/lane-start @@ -1094,10 +1094,10 @@ project_directory_walk() { [ -d "$child" ] || continue name="${child##*/}" # Per-lane register clones live beside any workspace as -lanes. - case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue - case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0; family_container=0 if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then diff --git a/park b/park index 17873b8f..ed8f9587 100755 --- a/park +++ b/park @@ -409,10 +409,10 @@ project_directory_walk() { [ -d "$child" ] || continue name="${child##*/}" # Per-lane register clones live beside any workspace as -lanes. - case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue - case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0; family_container=0 if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then diff --git a/resume b/resume index a234e933..bd439be3 100755 --- a/resume +++ b/resume @@ -393,10 +393,10 @@ project_directory_walk() { [ -d "$child" ] || continue name="${child##*/}" # Per-lane register clones live beside any workspace as -lanes. - case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue - case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0; family_container=0 if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then diff --git a/status b/status index 39ad7ed2..414a7aa1 100755 --- a/status +++ b/status @@ -530,10 +530,10 @@ project_directory_walk() { [ -d "$child" ] || continue name="${child##*/}" # Per-lane register clones live beside any workspace as -lanes. - case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "$name" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$child" in *$'\t'*|*$'\n'*) continue ;; esac physical="$(cd -- "$child" 2>/dev/null && pwd -P)" || continue - case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes) continue ;; esac + case "${physical##*/}" in workTrees|worktrees|laneWorkspaces|*-lanes|*-lane-registers) continue ;; esac case "$physical" in *$'\t'*|*$'\n'*) continue ;; esac boundary=0; family_container=0 if [ -e "$child/$name/family.yaml" ] || [ -e "$physical/${physical##*/}/family.yaml" ]; then diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index 9873e7d4..e5efca2c 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -28,7 +28,7 @@ def rows(root): def test_bounds_support_collections_and_repository_boundaries(tmp_path): - for group in ("workTrees", "laneWorkspaces", "brett-wip-lanes", "wip-lanes", "personal-register-lanes", "worktrees"): + for group in ("workTrees", "laneWorkspaces", "brett-wip-lanes", "wip-lanes", "personal-register-lanes", "brett-wip-lane-registers", "worktrees"): probe_project(tmp_path / group, "Hidden") target = probe_project(tmp_path / "business" / "Company space", "Visible") probe_project(tmp_path / "business" / "Company space" / "too-deep", "Deep") From e820b0aacc1363848d045cb5aa71c3c08685e4e0 Mon Sep 17 00:00:00 2001 From: Brett Heap Date: Sun, 15 Nov 2026 21:29:03 +0000 Subject: [PATCH 8/8] fix: share family boundaries across configured project roots --- lane-start | 12 +++++++----- park | 18 ++++++++++-------- resume | 18 ++++++++++-------- status | 18 ++++++++++-------- tests/test_grouped_project_lookup.py | 20 ++++++++++++++++++++ 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/lane-start b/lane-start index ae94312c..99cfd910 100755 --- a/lane-start +++ b/lane-start @@ -1121,11 +1121,13 @@ project_directory_walk() { } project_directory_rows() { - local families - # Resolve container boundaries before emitting rows: an earlier alias with - # a different basename must not expose the same family's member projects. - families="$(project_directory_walk "$1" 0 families)" - project_directory_walk "$1" 0 rows "$families" + local base="$1" families root + shift + [ "$#" -gt 0 ] || set -- "$base" + # Resolve boundaries across every configured root before emitting rows. + # A family alias in another root must also hide this container's members. + families="$(for root in "$@"; do project_directory_walk "$root" 0 families; done)" + project_directory_walk "$base" 0 rows "$families" } # END GROUPED PROJECT DISCOVERY diff --git a/park b/park index ed8f9587..58c2e30e 100755 --- a/park +++ b/park @@ -436,18 +436,20 @@ project_directory_walk() { } project_directory_rows() { - local families - # Resolve container boundaries before emitting rows: an earlier alias with - # a different basename must not expose the same family's member projects. - families="$(project_directory_walk "$1" 0 families)" - project_directory_walk "$1" 0 rows "$families" + local base="$1" families root + shift + [ "$#" -gt 0 ] || set -- "$base" + # Resolve boundaries across every configured root before emitting rows. + # A family alias in another root must also hide this container's members. + families="$(for root in "$@"; do project_directory_walk "$root" 0 families; done)" + project_directory_walk "$base" 0 rows "$families" } # END GROUPED PROJECT DISCOVERY estate_directory_rows() { local dir for dir in "${PROJECTS_DIRS[@]}"; do - project_directory_rows "$dir" + project_directory_rows "$dir" "${PROJECTS_DIRS[@]}" done } @@ -467,7 +469,7 @@ estate_by_name() { hits="$(while IFS=$'\t' read -r name child physical; do [ "$name" = "$want" ] || continue if estate_here "$child"; then printf '%s\t%s\n' "$child" "$physical"; fi - done < <(project_directory_rows "$dir") | awk -F '\t' '!seen[$2]++ {print $1}')" + done < <(project_directory_rows "$dir" "${PROJECTS_DIRS[@]}") | awk -F '\t' '!seen[$2]++ {print $1}')" [ -n "$hits" ] || continue if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" @@ -540,7 +542,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done < <(project_directory_rows "$dir") + done < <(project_directory_rows "$dir" "${PROJECTS_DIRS[@]}") done } diff --git a/resume b/resume index bd439be3..5cdb5fa0 100755 --- a/resume +++ b/resume @@ -420,18 +420,20 @@ project_directory_walk() { } project_directory_rows() { - local families - # Resolve container boundaries before emitting rows: an earlier alias with - # a different basename must not expose the same family's member projects. - families="$(project_directory_walk "$1" 0 families)" - project_directory_walk "$1" 0 rows "$families" + local base="$1" families root + shift + [ "$#" -gt 0 ] || set -- "$base" + # Resolve boundaries across every configured root before emitting rows. + # A family alias in another root must also hide this container's members. + families="$(for root in "$@"; do project_directory_walk "$root" 0 families; done)" + project_directory_walk "$base" 0 rows "$families" } # END GROUPED PROJECT DISCOVERY estate_directory_rows() { local dir for dir in "${PROJECTS_DIRS[@]}"; do - project_directory_rows "$dir" + project_directory_rows "$dir" "${PROJECTS_DIRS[@]}" done } @@ -451,7 +453,7 @@ estate_by_name() { hits="$(while IFS=$'\t' read -r name child physical; do [ "$name" = "$want" ] || continue if estate_here "$child"; then printf '%s\t%s\n' "$child" "$physical"; fi - done < <(project_directory_rows "$dir") | awk -F '\t' '!seen[$2]++ {print $1}')" + done < <(project_directory_rows "$dir" "${PROJECTS_DIRS[@]}") | awk -F '\t' '!seen[$2]++ {print $1}')" [ -n "$hits" ] || continue if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" @@ -524,7 +526,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done < <(project_directory_rows "$dir") + done < <(project_directory_rows "$dir" "${PROJECTS_DIRS[@]}") done } diff --git a/status b/status index 414a7aa1..cf90df5c 100755 --- a/status +++ b/status @@ -557,18 +557,20 @@ project_directory_walk() { } project_directory_rows() { - local families - # Resolve container boundaries before emitting rows: an earlier alias with - # a different basename must not expose the same family's member projects. - families="$(project_directory_walk "$1" 0 families)" - project_directory_walk "$1" 0 rows "$families" + local base="$1" families root + shift + [ "$#" -gt 0 ] || set -- "$base" + # Resolve boundaries across every configured root before emitting rows. + # A family alias in another root must also hide this container's members. + families="$(for root in "$@"; do project_directory_walk "$root" 0 families; done)" + project_directory_walk "$base" 0 rows "$families" } # END GROUPED PROJECT DISCOVERY estate_directory_rows() { local dir for dir in "${PROJECTS_DIRS[@]}"; do - project_directory_rows "$dir" + project_directory_rows "$dir" "${PROJECTS_DIRS[@]}" done } @@ -588,7 +590,7 @@ estate_by_name() { hits="$(while IFS=$'\t' read -r name child physical; do [ "$name" = "$want" ] || continue if estate_here "$child"; then printf '%s\t%s\n' "$child" "$physical"; fi - done < <(project_directory_rows "$dir") | awk -F '\t' '!seen[$2]++ {print $1}')" + done < <(project_directory_rows "$dir" "${PROJECTS_DIRS[@]}") | awk -F '\t' '!seen[$2]++ {print $1}')" [ -n "$hits" ] || continue if [ "$(printf '%s\n' "$hits" | wc -l | tr -d ' ')" -gt 1 ]; then die "multiple estates named '$want' under $dir; stand in the intended estate and run $SELF_NAME without : $hits" @@ -661,7 +663,7 @@ family_folders_with_id() { [ "$dup" -eq 0 ] || continue found+=("$child") printf '%s\n' "$child" - done < <(project_directory_rows "$dir") + done < <(project_directory_rows "$dir" "${PROJECTS_DIRS[@]}") done } diff --git a/tests/test_grouped_project_lookup.py b/tests/test_grouped_project_lookup.py index e5efca2c..062c8976 100644 --- a/tests/test_grouped_project_lookup.py +++ b/tests/test_grouped_project_lookup.py @@ -364,3 +364,23 @@ def test_family_container_alias_does_not_expose_members(tmp_path, physical_name) found = rows(home / "projects") assert "Atlas" in [row[0] for row in found] assert "Alpha" not in [row[0] for row in found] + + +@pytest.mark.parametrize("command", ["park", "status"]) +def test_family_container_boundaries_span_both_projects_roots(tmp_path, command): + home = tmp_path / "home"; home.mkdir() + alias, holder = logical_family_aliases(home, tmp_path / "storage", "Atlas") + other = home / "Projects"; other.mkdir() + (home / "projects" / "000-invalid").rename(other / "000-invalid") + sweepable_project(holder.parent, "Alpha") + result = run(REPO / command, "--all", home=home) + assert "Alpha" not in result.stdout + result.stderr + if command == "park": + assert result.returncode == 0, result.stderr + result.stdout + assert result.stdout.count("PROBE park in ") == 1 + else: + # The deliberately uncommitted probe holder has findings; enumeration + # must still contain only the family, never its sibling as an estate. + assert result.returncode == 1, result.stderr + result.stdout + assert result.stdout.count("=== status Atlas ===") == 1 + assert "1 with findings" in result.stdout