Skip to content

Commit e5cf713

Browse files
authored
Merge pull request #588 from Extra-Chill/fix/active-probe-cache-reference
Persist active worktree probe cache state
2 parents f14ab8e + c55ef44 commit e5cf713

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

inc/Workspace/Workspace.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,16 +2780,30 @@ private function build_active_no_signal_evidence_row( array $row, array &$github
27802780
}
27812781

27822782
$remote_ref = 'refs/remotes/origin/' . $branch;
2783-
$remote = $this->time_worktree_probe($out['probe_timings_ms'], 'remote_tracking', fn() => $this->cached_active_no_signal_remote_tracking_probe($primary_path, $remote_ref, $probe_cache));
2783+
$remote = $this->time_worktree_probe(
2784+
$out['probe_timings_ms'],
2785+
'remote_tracking',
2786+
function () use ( $primary_path, $remote_ref, &$probe_cache ) {
2787+
return $this->cached_active_no_signal_remote_tracking_probe($primary_path, $remote_ref, $probe_cache);
2788+
}
2789+
);
27842790
$out['remote_tracking'] = ! is_wp_error($remote) && ! $this->is_git_timeout_error($remote);
27852791

2786-
$default_ref = $this->time_worktree_probe($out['probe_timings_ms'], 'default_ref', fn() => $this->cached_active_no_signal_default_ref_probe($primary_path, $probe_cache));
2792+
$default_ref = $this->time_worktree_probe(
2793+
$out['probe_timings_ms'],
2794+
'default_ref',
2795+
function () use ( $primary_path, &$probe_cache ) {
2796+
return $this->cached_active_no_signal_default_ref_probe($primary_path, $probe_cache);
2797+
}
2798+
);
27872799
if ( is_string($default_ref) && '' !== $default_ref ) {
27882800
$out['default_ref'] = $default_ref;
27892801
$outside = $this->time_worktree_probe(
27902802
$out['probe_timings_ms'],
27912803
'commits_outside_default',
2792-
fn() => $this->cached_active_no_signal_commits_outside_default_probe($primary_path, $default_ref, $branch, $probe_cache)
2804+
function () use ( $primary_path, $default_ref, $branch, &$probe_cache ) {
2805+
return $this->cached_active_no_signal_commits_outside_default_probe($primary_path, $default_ref, $branch, $probe_cache);
2806+
}
27932807
);
27942808
if ( ! is_wp_error($outside) && ! $this->is_git_timeout_error($outside) ) {
27952809
$out['commits_outside_default'] = (int) trim( (string) ( $outside['output'] ?? '' ));
@@ -2805,7 +2819,13 @@ private function build_active_no_signal_evidence_row( array $row, array &$github
28052819
if ( (int) ( $out['dirty'] ?? 0 ) > 0 || (int) ( $out['unpushed'] ?? 0 ) > 0 ) {
28062820
$out['pr_lookup_skipped'] = 'dirty_or_unpushed_rows_are_always_manual_review';
28072821
} else {
2808-
$slug = $this->time_worktree_probe($out['probe_timings_ms'], 'github_slug', fn() => $this->cached_active_no_signal_github_slug_probe($primary_path, $probe_cache));
2822+
$slug = $this->time_worktree_probe(
2823+
$out['probe_timings_ms'],
2824+
'github_slug',
2825+
function () use ( $primary_path, &$probe_cache ) {
2826+
return $this->cached_active_no_signal_github_slug_probe($primary_path, $probe_cache);
2827+
}
2828+
);
28092829
if ( null !== $slug ) {
28102830
$pr = $this->time_worktree_probe($out['probe_timings_ms'], 'github_pr_lookup', fn() => $this->find_pr_for_branch_direct($slug, $branch, $github_cache, false));
28112831
if ( is_wp_error($pr) ) {

tests/smoke-worktree-metadata-reconcile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ function () use ( $tmp ) {
552552
$assert(true, ! is_wp_error($active_report) && ( $active_report['success'] ?? false ), 'active/no-signal report succeeds');
553553
$assert(true, (bool) ( $active_report['review_only'] ?? false ), 'active/no-signal report is review-only');
554554
$assert(true, (int) ( $active_report['summary']['inspected'] ?? 0 ) > 0, 'active/no-signal report inspects rows');
555-
$assert(true, isset($active_report['evidence']['probe_cache']['default_ref']['misses']), 'active/no-signal report exposes probe cache stats');
555+
$assert(true, (int) ( $active_report['evidence']['probe_cache']['default_ref']['misses'] ?? 0 ) > 0, 'active/no-signal report records default ref cache misses');
556556
$active_rows = array();
557557
foreach ( (array) ( $active_report['rows'] ?? array() ) as $row ) {
558558
$active_rows[ $row['handle'] ?? '' ] = $row;

0 commit comments

Comments
 (0)