@@ -1377,6 +1377,7 @@ private function render_cleanup_operator_summary( array $summary ): void {
13771377 WP_CLI ::log ('Cleanup operator summary: ' );
13781378 $ cleanup_counts = (array ) ( $ summary ['cleanup_counts ' ] ?? array () );
13791379 $ artifacts = (array ) ( $ summary ['artifact_cleanup ' ] ?? array () );
1380+ $ remaining_safe = (int ) ( $ summary ['remaining_safe_candidates ' ] ?? $ summary ['remaining_safely_removable_worktrees ' ] ?? 0 );
13801381 $ this ->format_items (
13811382 array (
13821383 array (
@@ -1399,6 +1400,14 @@ private function render_cleanup_operator_summary( array $summary ): void {
13991400 'metric ' => 'bytes_reclaimed ' ,
14001401 'value ' => $ this ->format_bytes ($ cleanup_counts ['bytes_reclaimed ' ] ?? 0 ),
14011402 ),
1403+ array (
1404+ 'metric ' => 'remaining_safe_candidates ' ,
1405+ 'value ' => $ remaining_safe ,
1406+ ),
1407+ array (
1408+ 'metric ' => 'protected_unpushed_candidates ' ,
1409+ 'value ' => (int ) ( $ summary ['protected_unpushed_candidates ' ] ?? 0 ),
1410+ ),
14021411 array (
14031412 'metric ' => 'remaining_reclaimable_artifacts ' ,
14041413 'value ' => $ this ->format_bytes ($ artifacts ['remaining_reclaimable_artifact_bytes ' ] ?? 0 ),
@@ -1459,24 +1468,28 @@ private function build_cleanup_operator_summary( array $result ): array {
14591468
14601469 return array_filter (
14611470 array (
1462- 'success ' => (bool ) ( $ result ['success ' ] ?? false ),
1463- 'run_id ' => (string ) ( $ result ['run_id ' ] ?? '' ),
1464- 'job_id ' => isset ($ result ['job_id ' ]) ? (int ) $ result ['job_id ' ] : null ,
1465- 'mode ' => (string ) ( $ result ['mode ' ] ?? $ result ['evidence ' ]['engine_data ' ]['cleanup_run ' ]['mode ' ] ?? '' ),
1466- 'state ' => (string ) ( $ result ['state ' ] ?? '' ),
1467- 'status ' => (string ) ( $ result ['status ' ] ?? '' ),
1468- 'parent_status ' => (string ) ( $ result ['parent_status ' ] ?? '' ),
1469- 'created_at ' => (string ) ( $ result ['created_at ' ] ?? '' ),
1470- 'completed_at ' => (string ) ( $ result ['completed_at ' ] ?? $ result ['parent_completed_at ' ] ?? '' ),
1471- 'cleanup_counts ' => array (
1471+ 'success ' => (bool ) ( $ result ['success ' ] ?? false ),
1472+ 'run_id ' => (string ) ( $ result ['run_id ' ] ?? '' ),
1473+ 'job_id ' => isset ($ result ['job_id ' ]) ? (int ) $ result ['job_id ' ] : null ,
1474+ 'mode ' => (string ) ( $ result ['mode ' ] ?? $ result ['evidence ' ]['engine_data ' ]['cleanup_run ' ]['mode ' ] ?? '' ),
1475+ 'state ' => (string ) ( $ result ['state ' ] ?? '' ),
1476+ 'status ' => (string ) ( $ result ['status ' ] ?? '' ),
1477+ 'parent_status ' => (string ) ( $ result ['parent_status ' ] ?? '' ),
1478+ 'created_at ' => (string ) ( $ result ['created_at ' ] ?? '' ),
1479+ 'completed_at ' => (string ) ( $ result ['completed_at ' ] ?? $ result ['parent_completed_at ' ] ?? '' ),
1480+ 'cleanup_counts ' => array (
14721481 'planned ' => (int ) ( $ cleanup_items ['planned_rows ' ] ?? 0 ),
14731482 'applied ' => (int ) ( $ cleanup_items ['applied_rows ' ] ?? 0 ),
14741483 'skipped ' => (int ) ( $ cleanup_items ['skipped_rows ' ] ?? 0 ),
14751484 'failed ' => (int ) ( $ cleanup_items ['failed_rows ' ] ?? 0 ),
14761485 'bytes_reclaimed ' => (int ) ( $ cleanup_items ['bytes_reclaimed ' ] ?? 0 ),
14771486 'freed_human ' => (string ) ( $ cleanup_items ['freed_human ' ] ?? $ this ->format_bytes ($ cleanup_items ['bytes_reclaimed ' ] ?? 0 ) ),
14781487 ),
1479- 'artifact_cleanup ' => array (
1488+ 'total_bytes_reclaimed ' => (int ) ( $ remaining ['total_bytes_reclaimed ' ] ?? $ cleanup_items ['bytes_reclaimed ' ] ?? 0 ),
1489+ 'total_reclaimed_human ' => $ this ->format_bytes ($ remaining ['total_bytes_reclaimed ' ] ?? $ cleanup_items ['bytes_reclaimed ' ] ?? 0 ),
1490+ 'remaining_safe_candidates ' => (int ) ( $ remaining ['remaining_safe_candidates ' ] ?? $ remaining ['remaining_safely_removable_worktrees ' ] ?? 0 ),
1491+ 'protected_unpushed_candidates ' => (int ) ( $ remaining ['protected_unpushed_candidates ' ] ?? 0 ),
1492+ 'artifact_cleanup ' => array (
14801493 'planned ' => (int ) ( $ artifacts ['planned_rows ' ] ?? 0 ),
14811494 'applied ' => (int ) ( $ artifacts ['applied_rows ' ] ?? 0 ),
14821495 'skipped ' => (int ) ( $ artifacts ['skipped_rows ' ] ?? 0 ),
@@ -1485,13 +1498,14 @@ private function build_cleanup_operator_summary( array $result ): array {
14851498 'remaining_reclaimable_artifact_bytes ' => (int ) ( $ remaining ['remaining_reclaimable_artifact_bytes ' ] ?? $ artifacts ['remaining_reclaimable_artifact_bytes ' ] ?? 0 ),
14861499 'remaining_reclaimable_human ' => $ this ->format_bytes ($ remaining ['remaining_reclaimable_artifact_bytes ' ] ?? $ artifacts ['remaining_reclaimable_artifact_bytes ' ] ?? 0 ),
14871500 ),
1488- 'children ' => $ this ->build_cleanup_operator_child_summary ( (array ) ( $ result ['children ' ] ?? $ result ['evidence ' ]['children ' ] ?? array () ) ),
1489- 'by_type ' => (array ) ( $ cleanup_items ['by_type ' ] ?? array () ),
1490- 'skipped_by_reason ' => (array ) ( $ remaining ['skipped_by_reason ' ] ?? $ cleanup_items ['skipped_examples_by_reason ' ] ?? array () ),
1491- 'failed_by_reason ' => (array ) ( $ cleanup_items ['failed_by_reason ' ] ?? $ artifacts ['failed_by_reason ' ] ?? array () ),
1492- 'top_blocked_examples ' => $ this ->cleanup_operator_blocked_examples ($ result ),
1493- 'recommended_commands ' => (array ) ( $ remaining ['recommended_commands ' ] ?? array () ),
1494- 'locks ' => (array ) ( $ result ['locks ' ] ?? array () ),
1501+ 'children ' => $ this ->build_cleanup_operator_child_summary ( (array ) ( $ result ['children ' ] ?? $ result ['evidence ' ]['children ' ] ?? array () ) ),
1502+ 'by_type ' => (array ) ( $ cleanup_items ['by_type ' ] ?? array () ),
1503+ 'skipped_by_reason ' => (array ) ( $ remaining ['skipped_by_reason ' ] ?? $ cleanup_items ['skipped_examples_by_reason ' ] ?? array () ),
1504+ 'failed_by_reason ' => (array ) ( $ cleanup_items ['failed_by_reason ' ] ?? $ artifacts ['failed_by_reason ' ] ?? array () ),
1505+ 'top_blocked_examples ' => $ this ->cleanup_operator_blocked_examples ($ result ),
1506+ 'recommended_commands ' => (array ) ( $ remaining ['recommended_commands ' ] ?? array () ),
1507+ 'next_commands ' => (array ) ( $ remaining ['next_commands ' ] ?? array () ),
1508+ 'locks ' => (array ) ( $ result ['locks ' ] ?? array () ),
14951509 ),
14961510 fn ( $ value ) => null !== $ value && array () !== $ value && '' !== $ value
14971511 );
@@ -1673,13 +1687,21 @@ private function render_cleanup_remaining_work_summary( array $summary ): void {
16731687 WP_CLI ::log ('Remaining work summary: ' );
16741688 $ this ->format_items (
16751689 array (
1690+ array (
1691+ 'metric ' => 'total_bytes_reclaimed ' ,
1692+ 'value ' => $ this ->format_bytes ($ summary ['total_bytes_reclaimed ' ] ?? 0 ),
1693+ ),
16761694 array (
16771695 'metric ' => 'remaining_reclaimable_artifact_bytes ' ,
16781696 'value ' => $ this ->format_bytes ($ summary ['remaining_reclaimable_artifact_bytes ' ] ?? 0 ),
16791697 ),
16801698 array (
1681- 'metric ' => 'remaining_safely_removable_worktrees ' ,
1682- 'value ' => (int ) ( $ summary ['remaining_safely_removable_worktrees ' ] ?? 0 ),
1699+ 'metric ' => 'remaining_safe_candidates ' ,
1700+ 'value ' => (int ) ( $ summary ['remaining_safe_candidates ' ] ?? $ summary ['remaining_safely_removable_worktrees ' ] ?? 0 ),
1701+ ),
1702+ array (
1703+ 'metric ' => 'protected_unpushed_candidates ' ,
1704+ 'value ' => (int ) ( $ summary ['protected_unpushed_candidates ' ] ?? 0 ),
16831705 ),
16841706 ),
16851707 array ( 'metric ' , 'value ' ),
@@ -3635,7 +3657,7 @@ public function worktree( array $args, array $assoc_args ): void {
36353657
36363658 $ input = array ();
36373659 $ input_builder = (string ) ( $ operation_config ['input_builder ' ] ?? '' );
3638- if ( '' !== $ input_builder && method_exists ( $ this , $ input_builder ) ) {
3660+ if ( '' !== $ input_builder ) {
36393661 $ input = $ this ->{$ input_builder }($ operation , $ assoc_args );
36403662 }
36413663
0 commit comments