Skip to content

Commit 845eb9a

Browse files
authored
fix: skip PR lookup for unsafe active rows (#381)
1 parent 147a261 commit 845eb9a

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

inc/Workspace/Workspace.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5647,13 +5647,17 @@ private function build_active_no_signal_evidence_row( array $row, array &$github
56475647
}
56485648
}
56495649

5650-
$slug = $this->time_worktree_probe( $out['probe_timings_ms'], 'github_slug', fn() => $this->resolve_github_slug( $primary_path ) );
5651-
if ( null !== $slug ) {
5652-
$pr = $this->time_worktree_probe( $out['probe_timings_ms'], 'github_pr_lookup', fn() => $this->find_pr_for_branch_direct( $slug, $branch, $github_cache, false ) );
5653-
if ( is_wp_error( $pr ) ) {
5654-
$out['pr_error'] = $pr->get_error_message();
5655-
} elseif ( is_array( $pr ) ) {
5656-
$out['pr'] = $pr;
5650+
if ( (int) ( $out['dirty'] ?? 0 ) > 0 || (int) ( $out['unpushed'] ?? 0 ) > 0 ) {
5651+
$out['pr_lookup_skipped'] = 'dirty_or_unpushed_rows_are_always_manual_review';
5652+
} else {
5653+
$slug = $this->time_worktree_probe( $out['probe_timings_ms'], 'github_slug', fn() => $this->resolve_github_slug( $primary_path ) );
5654+
if ( null !== $slug ) {
5655+
$pr = $this->time_worktree_probe( $out['probe_timings_ms'], 'github_pr_lookup', fn() => $this->find_pr_for_branch_direct( $slug, $branch, $github_cache, false ) );
5656+
if ( is_wp_error( $pr ) ) {
5657+
$out['pr_error'] = $pr->get_error_message();
5658+
} elseif ( is_array( $pr ) ) {
5659+
$out['pr'] = $pr;
5660+
}
56575661
}
56585662
}
56595663

tests/smoke-worktree-metadata-reconcile.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ function size_format( $bytes ): string {
524524
$assert( true, isset( $active_report['summary']['slow_rows'][0]['elapsed_ms'] ), 'active/no-signal summary includes slow row timing samples' );
525525
$assert( true, isset( $active_rows['demo@dirty-active']['probe_timings_ms']['dirty_count'] ), 'active/no-signal rows include dirty probe timing' );
526526
$assert( true, isset( $active_rows['demo@dirty-active']['probe_timings_ms']['upstream_equivalence'] ), 'active/no-signal rows include upstream equivalence probe timing' );
527+
$assert( 'dirty_or_unpushed_rows_are_always_manual_review', $active_rows['demo@dirty-active']['pr_lookup_skipped'] ?? '', 'dirty active/no-signal rows skip GitHub PR lookup' );
528+
$assert( false, isset( $active_rows['demo@dirty-active']['probe_timings_ms']['github_pr_lookup'] ), 'dirty active/no-signal rows do not spend time on GitHub PR lookup' );
527529
$assert( true, isset( $active_rows['demo@dirty-active']['upstream_equivalence']['probe_timings_ms']['git_cherry'] ), 'upstream equivalence includes git cherry probe timing' );
528530
$assert( true, isset( $active_rows['demo@dirty-active']['upstream_equivalence']['probe_timings_ms']['dirty_path_classification'] ), 'upstream equivalence includes dirty path classification timing' );
529531
$assert( true, (int) ( $active_rows['demo@dirty-active']['upstream_equivalence']['dirty_paths']['inspected'] ?? 0 ) >= 1, 'batched dirty path classification preserves inspected path count' );

0 commit comments

Comments
 (0)