@@ -783,11 +783,11 @@ private function attach_cleanup_run_commands( array $result, string $mode ): arr
783783 }
784784
785785 $ result ['commands ' ] = array (
786- 'drain_parent ' => sprintf ('studio wp datamachine drain --job-id=%d ' , $ job_id ),
787- 'status ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --format=json ' , $ run_id ),
788- 'status_verbose ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --verbose --format=json ' , $ run_id ),
789- 'one_command_drain ' => sprintf ('studio wp datamachine-code workspace cleanup run --mode=%s --drain --format=json ' , $ mode ),
790- 'bytes_verification ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --format=json ' , $ run_id ),
786+ 'drain_parent ' => sprintf ('studio wp datamachine drain --job-id=%d ' , $ job_id ),
787+ 'status ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --format=json ' , $ run_id ),
788+ 'status_verbose ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --verbose --format=json ' , $ run_id ),
789+ 'one_command_drain ' => sprintf ('studio wp datamachine-code workspace cleanup run --mode=%s --drain --format=json ' , $ mode ),
790+ 'bytes_verification ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --format=json ' , $ run_id ),
791791 );
792792
793793 return $ result ;
@@ -811,8 +811,8 @@ private function drain_cleanup_run_to_status( array $result, array $assoc_args )
811811 return $ result ;
812812 }
813813
814- $ commands = array ();
815- $ errors = array ();
814+ $ commands = array ();
815+ $ errors = array ();
816816 $ max_passes = 10 ;
817817
818818 $ parent_command = sprintf ('datamachine drain --job-id=%d ' , $ job_id );
@@ -829,7 +829,7 @@ private function drain_cleanup_run_to_status( array $result, array $assoc_args )
829829 break ;
830830 }
831831
832- $ children = (array ) ( $ status ['evidence ' ]['children ' ] ?? array () );
832+ $ children = (array ) ( $ status ['evidence ' ]['children ' ] ?? array () );
833833 $ active_child_ids = array_values (
834834 array_unique (
835835 array_filter (
@@ -856,17 +856,17 @@ private function drain_cleanup_run_to_status( array $result, array $assoc_args )
856856 }
857857 }
858858
859- $ final = $ this ->cleanup_run_evidence_store ()->read ($ run_id , false , ! empty ($ assoc_args ['verbose ' ]));
860- $ output = $ final instanceof \WP_Error ? $ result : $ final ;
859+ $ final = $ this ->cleanup_run_evidence_store ()->read ($ run_id , false , ! empty ($ assoc_args ['verbose ' ]));
860+ $ output = $ final instanceof \WP_Error ? $ result : $ final ;
861861 $ output ['initial_run ' ] = $ result ;
862862 $ output ['drain ' ] = array (
863- 'success ' => array () === $ errors ,
864- 'commands ' => $ commands ,
865- 'errors ' => $ errors ,
866- 'verify_command ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --format=json ' , $ run_id ),
867- 'bytes_reclaimed ' => (int ) ( $ output ['cleanup_items ' ]['bytes_reclaimed ' ] ?? 0 ),
868- 'freed_human ' => (string ) ( $ output ['cleanup_items ' ]['freed_human ' ] ?? $ this ->format_bytes (0 ) ),
869- 'completion_state ' => (string ) ( $ output ['state ' ] ?? 'unknown ' ),
863+ 'success ' => array () === $ errors ,
864+ 'commands ' => $ commands ,
865+ 'errors ' => $ errors ,
866+ 'verify_command ' => sprintf ('studio wp datamachine-code workspace cleanup status %s --format=json ' , $ run_id ),
867+ 'bytes_reclaimed ' => (int ) ( $ output ['cleanup_items ' ]['bytes_reclaimed ' ] ?? 0 ),
868+ 'freed_human ' => (string ) ( $ output ['cleanup_items ' ]['freed_human ' ] ?? $ this ->format_bytes (0 ) ),
869+ 'completion_state ' => (string ) ( $ output ['state ' ] ?? 'unknown ' ),
870870 );
871871
872872 return $ output ;
@@ -879,10 +879,6 @@ private function drain_cleanup_run_to_status( array $result, array $assoc_args )
879879 * @return string Empty string on success.
880880 */
881881 private function run_wp_cli_command ( string $ command ): string {
882- if ( ! method_exists ('WP_CLI ' , 'runcommand ' ) ) {
883- return 'WP_CLI::runcommand is unavailable; run the reported drain commands manually. ' ;
884- }
885-
886882 try {
887883 WP_CLI ::runcommand (
888884 $ command ,
@@ -1070,7 +1066,7 @@ private function run_cleanup_review( array $assoc_args ): void {
10701066 'stale_liveness_only ' => true ,
10711067 'older_than ' => isset ($ assoc_args ['older-than ' ]) && '' !== trim ( (string ) $ assoc_args ['older-than ' ]) ? trim ( (string ) $ assoc_args ['older-than ' ]) : '14d ' ,
10721068 );
1073- $ result = $ ability ? $ ability ->execute ($ input ) : new \WP_Error ('worktree_cleanup_ability_missing ' , 'Worktree cleanup ability not registered. ' );
1069+ $ result = $ ability ? $ ability ->execute ($ input ) : new \WP_Error ('worktree_cleanup_ability_missing ' , 'Worktree cleanup ability not registered. ' );
10741070 $ this ->render_worktree_cleanup_result_from_ability ($ result , $ assoc_args );
10751071 return ;
10761072
@@ -1341,10 +1337,22 @@ private function render_cleanup_drain_summary( array $drain ): void {
13411337 WP_CLI ::log ('Drain summary: ' );
13421338 $ this ->format_items (
13431339 array (
1344- array ( 'metric ' => 'success ' , 'value ' => ! empty ($ drain ['success ' ]) ? 'yes ' : 'no ' ),
1345- array ( 'metric ' => 'completion_state ' , 'value ' => (string ) ( $ drain ['completion_state ' ] ?? 'unknown ' ) ),
1346- array ( 'metric ' => 'bytes_reclaimed ' , 'value ' => $ this ->format_bytes ($ drain ['bytes_reclaimed ' ] ?? 0 ) ),
1347- array ( 'metric ' => 'verify_command ' , 'value ' => (string ) ( $ drain ['verify_command ' ] ?? '' ) ),
1340+ array (
1341+ 'metric ' => 'success ' ,
1342+ 'value ' => ! empty ($ drain ['success ' ]) ? 'yes ' : 'no ' ,
1343+ ),
1344+ array (
1345+ 'metric ' => 'completion_state ' ,
1346+ 'value ' => (string ) ( $ drain ['completion_state ' ] ?? 'unknown ' ),
1347+ ),
1348+ array (
1349+ 'metric ' => 'bytes_reclaimed ' ,
1350+ 'value ' => $ this ->format_bytes ($ drain ['bytes_reclaimed ' ] ?? 0 ),
1351+ ),
1352+ array (
1353+ 'metric ' => 'verify_command ' ,
1354+ 'value ' => (string ) ( $ drain ['verify_command ' ] ?? '' ),
1355+ ),
13481356 ),
13491357 array ( 'metric ' , 'value ' ),
13501358 array ( 'format ' => 'table ' ),
0 commit comments