From 162d9c7d3c205c90760d72496f7698a76dccc579 Mon Sep 17 00:00:00 2001 From: "homeboy-ci[bot]" <266378653+homeboy-ci[bot]@users.noreply.github.com> Date: Fri, 3 Jul 2026 13:23:45 -0400 Subject: [PATCH] Fix cleanup eligible drain dry-run counts --- inc/Cli/Commands/WorkspaceCommand.php | 7 ++++++- .../WorkspaceCleanupEligibleDrainOrchestrator.php | 5 ++++- tests/smoke-cleanup-eligible-drain.php | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/inc/Cli/Commands/WorkspaceCommand.php b/inc/Cli/Commands/WorkspaceCommand.php index 5b8f5d67..1ca6c9f9 100644 --- a/inc/Cli/Commands/WorkspaceCommand.php +++ b/inc/Cli/Commands/WorkspaceCommand.php @@ -6398,6 +6398,10 @@ private function render_worktree_cleanup_eligible_drain_result( array $result, a 'metric' => 'processed', 'value' => (int) ( $summary['processed'] ?? 0 ), ), + array( + 'metric' => 'planned', + 'value' => (int) ( $summary['planned'] ?? 0 ), + ), array( 'metric' => 'would_remove', 'value' => (int) ( $summary['would_remove'] ?? 0 ), @@ -6437,6 +6441,7 @@ private function render_worktree_cleanup_eligible_drain_result( array $result, a fn( $row ) => array( 'pass' => (int) ( $row['pass'] ?? 0 ), 'processed' => (int) ( $row['processed'] ?? 0 ), + 'planned' => (int) ( $row['planned'] ?? 0 ), 'would_remove' => (int) ( $row['would_remove'] ?? 0 ), 'removed' => (int) ( $row['removed'] ?? 0 ), 'skipped' => (int) ( $row['skipped'] ?? 0 ), @@ -6445,7 +6450,7 @@ private function render_worktree_cleanup_eligible_drain_result( array $result, a ), $passes ), - array( 'pass', 'processed', 'would_remove', 'removed', 'skipped', 'remaining_total', 'bytes' ), + array( 'pass', 'processed', 'planned', 'would_remove', 'removed', 'skipped', 'remaining_total', 'bytes' ), array( 'format' => 'table' ), 'pass' ); diff --git a/inc/Workspace/WorkspaceCleanupEligibleDrainOrchestrator.php b/inc/Workspace/WorkspaceCleanupEligibleDrainOrchestrator.php index 6462e7fb..e8ff14d9 100644 --- a/inc/Workspace/WorkspaceCleanupEligibleDrainOrchestrator.php +++ b/inc/Workspace/WorkspaceCleanupEligibleDrainOrchestrator.php @@ -82,6 +82,7 @@ public function run( array $input ): array|\WP_Error { 'summary' => array( 'passes' => 0, 'processed' => 0, + 'planned' => 0, 'would_remove' => 0, 'removed' => 0, 'skipped' => 0, @@ -133,7 +134,8 @@ public function run( array $input ): array|\WP_Error { 'pass' => $pass, 'dry_run' => ! empty($pass_result['dry_run']), 'processed' => (int) ( $summary['processed'] ?? 0 ), - 'would_remove' => ! empty($pass_result['dry_run']) ? count( (array) ( $pass_result['candidates'] ?? array() ) ) : 0, + 'planned' => ! empty($pass_result['dry_run']) ? count( (array) ( $pass_result['candidates'] ?? array() ) ) : 0, + 'would_remove' => (int) ( $summary['would_remove'] ?? 0 ), 'removed' => (int) ( $summary['removed'] ?? 0 ), 'skipped' => (int) ( $summary['skipped'] ?? 0 ), 'bytes_reclaimed' => (int) ( $summary['bytes_reclaimed'] ?? 0 ), @@ -147,6 +149,7 @@ public function run( array $input ): array|\WP_Error { $result['pass_results'][] = $pass_summary; ++$result['summary']['passes']; $result['summary']['processed'] += $pass_summary['processed']; + $result['summary']['planned'] += $pass_summary['planned']; $result['summary']['would_remove'] += $pass_summary['would_remove']; $result['summary']['removed'] += $pass_summary['removed']; $result['summary']['skipped'] += $pass_summary['skipped']; diff --git a/tests/smoke-cleanup-eligible-drain.php b/tests/smoke-cleanup-eligible-drain.php index 5291e4d8..506f837a 100644 --- a/tests/smoke-cleanup-eligible-drain.php +++ b/tests/smoke-cleanup-eligible-drain.php @@ -98,7 +98,8 @@ function cleanup_eligible_drain_assert( bool $condition, string $label ): void { cleanup_eligible_drain_assert(false === $preview['applied'], 'preview is non-destructive'); cleanup_eligible_drain_assert(1 === count($preview_ability->calls), 'preview runs one pass'); cleanup_eligible_drain_assert('preview' === $preview['summary']['stop_reason'], 'preview stop reason'); -cleanup_eligible_drain_assert(2 === $preview['summary']['would_remove'], 'preview counts would-remove candidates'); +cleanup_eligible_drain_assert(2 === $preview['summary']['planned'], 'preview counts planned candidates'); +cleanup_eligible_drain_assert(0 === $preview['summary']['would_remove'], 'preview does not claim removal before fresh safety checks'); $empty_ability = new CleanupEligibleDrainFakeAbility( array(