diff --git a/shared/lib/agent-adapters.sh b/shared/lib/agent-adapters.sh index 4d39318..6735607 100755 --- a/shared/lib/agent-adapters.sh +++ b/shared/lib/agent-adapters.sh @@ -1426,6 +1426,18 @@ _pane_child_count() { } | wc -l | tr -d ' ' } +_pane_metadata_unavailable() { + local target="$1" + local pane_pid current_command + + tmux list-panes -t "$target" >/dev/null 2>&1 || return 1 + + pane_pid=$(tmux display-message -t "$target" -p '#{pane_pid}' 2>/dev/null || echo "") + current_command=$(tmux display-message -t "$target" -p '#{pane_current_command}' 2>/dev/null || echo "") + + [[ -z "$pane_pid" && -z "$current_command" ]] +} + _pane_descendant_pids() { local root_pid="$1" local queue="$root_pid" @@ -1609,10 +1621,11 @@ agent_pane_is_ready() { local pane_pid pane_pid=$(tmux display-message -t "$target" -p '#{pane_pid}' 2>/dev/null || echo "") if [[ -z "$pane_pid" ]]; then - # Some lifecycle tests use a minimal tmux mock that accepts send-keys but - # cannot report pane metadata. In that environment, treat readiness as - # unverifiable rather than hard-failing the launch. - return 0 + if _pane_metadata_unavailable "$target"; then + _agent_log_debug "Pane $target metadata unavailable; assuming ready" + return 0 + fi + return 1 fi local current_command @@ -1655,8 +1668,8 @@ agent_verify_launch() { current_command=$(_pane_current_command "$target") children=$(_pane_child_count "$target") - if [[ -z "$current_command" && -z "$children" ]]; then - _agent_log_debug "Launch verification unavailable for $target; accepting best-effort dispatch" + if _pane_metadata_unavailable "$target"; then + _agent_log_debug "Launch verification unavailable for $target; assuming success" return 0 fi diff --git a/shared/lib/wavemill-mill.sh b/shared/lib/wavemill-mill.sh index f5cb2b3..29e5d0c 100755 --- a/shared/lib/wavemill-mill.sh +++ b/shared/lib/wavemill-mill.sh @@ -750,7 +750,7 @@ cleanup_completed_task() { if [[ "$task_branch" == "main" || "$task_branch" == "master" ]]; then log_warn " Refusing to delete protected branch: $task_branch" elif git -C "$REPO_DIR" show-ref --verify --quiet "refs/heads/$task_branch" 2>/dev/null; then - execute git -C "$REPO_DIR" branch -D "$task_branch" 2>/dev/null || true + execute git -C "$REPO_DIR" branch -D "$task_branch" >/dev/null 2>&1 || true log " ✓ Deleted local branch: $task_branch" if execute git -C "$REPO_DIR" push origin --delete "$task_branch" 2>/dev/null; then log " ✓ Deleted remote branch: $task_branch" @@ -1106,7 +1106,7 @@ cleanup_stale_tasks() { if [[ "$branch" == "main" || "$branch" == "master" ]]; then log_warn " Refusing to delete protected branch: $branch" else - git -C "$REPO_DIR" branch -D "$branch" 2>/dev/null || true + git -C "$REPO_DIR" branch -D "$branch" >/dev/null 2>&1 || true git -C "$REPO_DIR" push origin --delete "$branch" 2>/dev/null || true fi fi @@ -4058,7 +4058,7 @@ cleanup_completed_task() { if [[ "$task_branch" == "main" || "$task_branch" == "master" ]]; then log_warn " Refusing to delete protected branch: $task_branch" elif git -C "$REPO_DIR" show-ref --verify --quiet "refs/heads/$task_branch" 2>/dev/null; then - git -C "$REPO_DIR" branch -D "$task_branch" 2>/dev/null || true + git -C "$REPO_DIR" branch -D "$task_branch" >/dev/null 2>&1 || true log " ✓ Deleted local branch: $task_branch" if git -C "$REPO_DIR" push origin --delete "$task_branch" 2>/dev/null; then log " ✓ Deleted remote branch: $task_branch" diff --git a/tests/cleanup-branch.test.sh b/tests/cleanup-branch.test.sh index d96ea37..9b496dd 100644 --- a/tests/cleanup-branch.test.sh +++ b/tests/cleanup-branch.test.sh @@ -59,6 +59,14 @@ else fail "cleanup logging still reports generic branch deletion" fi +if grep -Fq 'branch -D "$task_branch" >/dev/null 2>&1 || true' <<< "$HEREDOC_CONTENT" \ + && grep -Fq 'branch -D "$task_branch" >/dev/null 2>&1 || true' <<< "$outer_cleanup" \ + && grep -Fq 'branch -D "$branch" >/dev/null 2>&1 || true' "$MILL_SCRIPT"; then + pass "cleanup suppresses git branch deletion stdout in backlog paths" +else + fail "cleanup still leaks git branch deletion stdout" +fi + if grep -Fq 'Remote branch already deleted or push failed: $task_branch' <<< "$HEREDOC_CONTENT" \ && grep -Fq 'Remote branch already deleted or push failed: $task_branch' <<< "$outer_cleanup"; then pass "cleanup tolerates already-deleted remote branches"