@@ -377,9 +377,9 @@ private function append_active_no_signal_backlog_summary( array &$result, int $l
377377 );
378378 if ( is_wp_error ($ report ) ) {
379379 $ result ['remaining_active_no_signal_backlog ' ] = array (
380- 'available ' => false ,
381- 'reason ' => (string ) $ report ->get_error_code (),
382- 'message ' => $ report ->get_error_message (),
380+ 'available ' => false ,
381+ 'reason ' => (string ) $ report ->get_error_code (),
382+ 'message ' => $ report ->get_error_message (),
383383 'next_commands ' => array (
384384 sprintf ('studio wp datamachine-code workspace worktree active-no-signal-report --limit=%d --offset=0 --format=json ' , $ limit ),
385385 ),
@@ -414,7 +414,7 @@ private function build_active_no_signal_backlog_summary( array $report, int $lim
414414 if ( ! is_array ($ row ) ) {
415415 continue ;
416416 }
417- $ reason = (string ) ( $ row ['suggested_action ' ] ?? 'insufficient_signal ' );
417+ $ reason = (string ) ( $ row ['suggested_action ' ] ?? 'insufficient_signal ' );
418418 $ buckets [ $ reason ] ??= array (
419419 'count ' => 0 ,
420420 'examples ' => array (),
@@ -437,15 +437,15 @@ private function build_active_no_signal_backlog_summary( array $report, int $lim
437437 }
438438
439439 return array (
440- 'available ' => true ,
441- 'total_active_no_signal ' => $ total ,
442- 'sampled ' => $ sampled ,
443- 'unreviewed_count ' => max (0 , $ total - $ sampled ),
444- 'by_actionable_reason ' => $ buckets ,
445- 'counts_scope ' => 'bounded_post_drain_sample_only ' ,
446- 'limitation ' => 'Counts by actionable reason cover only this bounded post-drain sample; active-no-signal report has pagination but no safe bucket filter, so full per-bucket totals are not scanned by default. ' ,
447- 'pagination ' => $ pagination ,
448- 'next_commands ' => array_values (array_unique (array_filter ( $ commands) )),
440+ 'available ' => true ,
441+ 'total_active_no_signal ' => $ total ,
442+ 'sampled ' => $ sampled ,
443+ 'unreviewed_count ' => max (0 , $ total - $ sampled ),
444+ 'by_actionable_reason ' => $ buckets ,
445+ 'counts_scope ' => 'bounded_post_drain_sample_only ' ,
446+ 'limitation ' => 'Counts by actionable reason cover only this bounded post-drain sample; active-no-signal report has pagination but no safe bucket filter, so full per-bucket totals are not scanned by default. ' ,
447+ 'pagination ' => $ pagination ,
448+ 'next_commands ' => array_values (array_unique ($ commands )),
449449 );
450450 }
451451
@@ -517,16 +517,17 @@ private function run_bounded_apply( object $ability, array &$result, bool $apply
517517 }
518518
519519 private function build_continuation ( string $ stage , array $ step , int $ limit , int $ passes , bool $ force , string $ until_budget , bool $ active_no_signal_drain = false ): array {
520- $ pagination = (array ) ( $ step ['pagination ' ] ?? $ step ['continuation ' ] ?? array () );
521- $ next_offset = isset ($ pagination ['next_offset ' ]) ? max (0 , (int ) $ pagination ['next_offset ' ]) : 0 ;
522- $ command = $ this ->build_continuation_command ($ stage , $ next_offset , $ limit , $ passes , $ force , $ until_budget , $ active_no_signal_drain );
523- $ current = (int ) ( $ pagination ['offset ' ] ?? 0 );
524- $ mutated = (int ) ( $ step ['summary ' ]['written ' ] ?? 0 ) + (int ) ( $ step ['summary ' ]['removed ' ] ?? 0 );
525- $ restart = ! empty ($ pagination ['partial ' ]) && $ next_offset <= $ current && $ mutated > 0 ;
520+ $ pagination = (array ) ( $ step ['pagination ' ] ?? $ step ['continuation ' ] ?? array () );
521+ $ next_offset = isset ($ pagination ['next_offset ' ]) ? max (0 , (int ) $ pagination ['next_offset ' ]) : 0 ;
522+ $ current = (int ) ( $ pagination ['offset ' ] ?? 0 );
523+ $ mutated = (int ) ( $ step ['summary ' ]['written ' ] ?? 0 ) + (int ) ( $ step ['summary ' ]['removed ' ] ?? 0 );
524+ $ restart = ! empty ($ pagination ['partial ' ]) && $ next_offset <= $ current && $ mutated > 0 ;
525+ $ command_offset = $ restart ? 0 : $ next_offset ;
526+ $ command = $ this ->build_continuation_command ($ stage , $ command_offset , $ limit , $ passes , $ force , $ until_budget , $ active_no_signal_drain );
526527
527528 $ continuation = array (
528529 'stage ' => $ stage ,
529- 'offset ' => $ next_offset ,
530+ 'offset ' => $ command_offset ,
530531 'next_command ' => $ command ,
531532 'pagination ' => $ pagination ,
532533 );
@@ -542,7 +543,8 @@ private function build_continuation( string $stage, array $step, int $limit, int
542543 'removed ' => $ removed ,
543544 'total_mutations ' => $ written + $ removed ,
544545 'previous_offset ' => $ current ,
545- 'restart_offset ' => $ next_offset ,
546+ 'next_offset ' => $ next_offset ,
547+ 'restart_offset ' => 0 ,
546548 'candidate_set_now ' => 'changed ' ,
547549 );
548550 $ continuation ['next_command_label ' ] = 'Restart this stage from offset 0 because the cleanup candidate set changed. ' ;
0 commit comments