Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions inc/Cleanup/DataMachineJobCleanupRunEvidenceStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function aggregate_cleanup_child_jobs( array $child_jobs ): array {

$parent_job_ids = array();
foreach ( $child_jobs as $child ) {
$parent_job_id = (int) ( is_array($child) ? ( $child['parent_job_id'] ?? 0 ) : 0 );
$parent_job_id = (int) ( $child['parent_job_id'] ?? 0 );
if ( $parent_job_id > 0 ) {
$parent_job_ids[ $parent_job_id ] = true;
}
Expand Down Expand Up @@ -206,10 +206,10 @@ private function aggregate_cleanup_child_jobs( array $child_jobs ): array {
}
}

$summary['artifact_cleanup']['freed_human'] = $this->format_bytes($summary['artifact_cleanup']['bytes_reclaimed']);
$summary['cleanup_items']['freed_human'] = $this->format_bytes($summary['cleanup_items']['bytes_reclaimed']);
$summary['children']['batch_job_ids'] = array_values(array_unique($summary['children']['batch_job_ids']));
$summary['children']['chunk_job_ids'] = array_values(array_unique($summary['children']['chunk_job_ids']));
$summary['artifact_cleanup']['freed_human'] = $this->format_bytes($summary['artifact_cleanup']['bytes_reclaimed']);
$summary['cleanup_items']['freed_human'] = $this->format_bytes($summary['cleanup_items']['bytes_reclaimed']);
$summary['children']['batch_job_ids'] = array_values(array_unique($summary['children']['batch_job_ids']));
$summary['children']['chunk_job_ids'] = array_values(array_unique($summary['children']['chunk_job_ids']));
$summary['children']['pending_job_ids'] = array_values(array_unique($summary['children']['pending_job_ids']));
$summary['children']['pending_without_drainable_action_job_ids'] = array_values(array_unique($summary['children']['pending_without_drainable_action_job_ids']));
$summary['children']['processing_job_ids'] = array_values(array_unique($summary['children']['processing_job_ids']));
Expand All @@ -227,30 +227,30 @@ private function aggregate_cleanup_child_jobs( array $child_jobs ): array {
* @return array<string,mixed>
*/
private function summarize_cleanup_children( array $children ): array {
$limit = 10;
$batch_ids = (array) ( $children['batch_job_ids'] ?? array() );
$chunk_ids = (array) ( $children['chunk_job_ids'] ?? array() );
$pending = (array) ( $children['pending_job_ids'] ?? array() );
$limit = 10;
$batch_ids = (array) ( $children['batch_job_ids'] ?? array() );
$chunk_ids = (array) ( $children['chunk_job_ids'] ?? array() );
$pending = (array) ( $children['pending_job_ids'] ?? array() );
$undrainable = (array) ( $children['pending_without_drainable_action_job_ids'] ?? array() );
$processing = (array) ( $children['processing_job_ids'] ?? array() );
$processing = (array) ( $children['processing_job_ids'] ?? array() );

return array(
'processing' => (int) ( $children['processing'] ?? 0 ),
'completed' => (int) ( $children['completed'] ?? 0 ),
'failed' => (int) ( $children['failed'] ?? 0 ),
'skipped' => (int) ( $children['skipped'] ?? 0 ),
'running' => (int) ( $children['running'] ?? 0 ),
'total' => (int) ( $children['total'] ?? 0 ),
'statuses' => (array) ( $children['statuses'] ?? array() ),
'batch_total' => count($batch_ids),
'chunk_total' => count($chunk_ids),
'failed_job_ids' => (array) ( $children['failed_job_ids'] ?? array() ),
'pending_job_ids' => array_slice($pending, 0, $limit),
'processing' => (int) ( $children['processing'] ?? 0 ),
'completed' => (int) ( $children['completed'] ?? 0 ),
'failed' => (int) ( $children['failed'] ?? 0 ),
'skipped' => (int) ( $children['skipped'] ?? 0 ),
'running' => (int) ( $children['running'] ?? 0 ),
'total' => (int) ( $children['total'] ?? 0 ),
'statuses' => (array) ( $children['statuses'] ?? array() ),
'batch_total' => count($batch_ids),
'chunk_total' => count($chunk_ids),
'failed_job_ids' => (array) ( $children['failed_job_ids'] ?? array() ),
'pending_job_ids' => array_slice($pending, 0, $limit),
'pending_without_drainable_action_job_ids' => array_slice($undrainable, 0, $limit),
'processing_job_ids' => array_slice($processing, 0, $limit),
'pending_truncated' => count($pending) > $limit,
'processing_truncated' => count($processing) > $limit,
'diagnostic_job_id_lists' => 'Re-run status with --verbose or use cleanup evidence for full child job IDs.',
'processing_job_ids' => array_slice($processing, 0, $limit),
'pending_truncated' => count($pending) > $limit,
'processing_truncated' => count($processing) > $limit,
'diagnostic_job_id_lists' => 'Re-run status with --verbose or use cleanup evidence for full child job IDs.',
);
}

Expand Down Expand Up @@ -298,8 +298,8 @@ private function cleanup_run_drain_summary( int $job_id, string $state, array $c
}

return array(
'needed' => in_array($state, array( 'running', 'waiting_on_children' ), true),
'commands' => $commands,
'needed' => in_array($state, array( 'running', 'waiting_on_children' ), true),
'commands' => $commands,
'active_child_job_ids' => $active_child_ids,
'undrainable_child_job_ids' => $undrainable_child_ids,
'bytes_reclaimed' => (int) ( $cleanup_items['bytes_reclaimed'] ?? 0 ),
Expand Down
6 changes: 3 additions & 3 deletions inc/Tasks/WorkspaceHygieneReportTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public function executeTask( int $jobId, array $params ): void {
$this->failJob($jobId, $result->get_error_message());
return;
}
$worktrees = (array) ( $result['worktrees'] ?? array() );
$cleanup = (array) ( $result['cleanup']['summary'] ?? array() );
$fast_counts = (array) ( $result['fast_stats']['counts'] ?? array() );
$worktrees = (array) ( $result['worktrees'] ?? array() );
$cleanup = (array) ( $result['cleanup']['summary'] ?? array() );
$fast_counts = (array) ( $result['fast_stats']['counts'] ?? array() );
$inventory_cleanup_candidates = (int) ( $cleanup['inventory_cleanup_candidate_count'] ?? $fast_counts['cleanup_eligible_unprobed_count'] ?? 0 );
do_action(
'datamachine_log',
Expand Down
6 changes: 3 additions & 3 deletions inc/Workspace/WorktreeCleanupClassifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
final class WorktreeCleanupClassifier {

public const BUCKET_SAFE_TO_REMOVE_NOW = 'safe_to_remove_now';
public const BUCKET_CLEANUP_ELIGIBLE_UNPROBED = 'cleanup_eligible_pending_revalidation';
public const BUCKET_CLEANUP_ELIGIBLE_UNPROBED = 'cleanup_eligible_pending_revalidation';
public const BUCKET_NEEDS_RECONCILIATION = 'needs_reconciliation';
public const BUCKET_NEEDS_FULL_REVIEW = 'needs_full_review';
public const BUCKET_BLOCKED_BY_DIRTY_OR_UNPUSHED = 'blocked_by_dirty_or_unpushed';
Expand Down Expand Up @@ -132,10 +132,10 @@ public static function buckets(
array $skipped_by_reason,
string $candidate_bucket = self::BUCKET_SAFE_TO_REMOVE_NOW
): array {
$buckets = array(
$buckets = array(
self::BUCKET_ARTIFACT_ONLY_DIRTY => 0,
self::BUCKET_BLOCKED_BY_DIRTY_OR_UNPUSHED => 0,
self::BUCKET_CLEANUP_ELIGIBLE_UNPROBED => 0,
self::BUCKET_CLEANUP_ELIGIBLE_UNPROBED => 0,
self::BUCKET_NEEDS_FULL_REVIEW => 0,
self::BUCKET_NEEDS_RECONCILIATION => 0,
self::BUCKET_SAFE_TO_REMOVE_NOW => 0,
Expand Down
Loading