Skip to content

Commit 154854d

Browse files
authored
Include lifecycle candidates in active cleanup evidence (#669)
* Add stale active worktree cleanup policy * Revert "Add stale active worktree cleanup policy" This reverts commit 09b682a. * Include lifecycle candidates in active cleanup evidence
1 parent acc4ee6 commit 154854d

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

inc/Workspace/WorkspaceActiveNoSignalCleanup.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function worktree_active_no_signal_report( array $opts = array() ): array
4747
$active = array_values(
4848
array_filter(
4949
(array) ( $inventory['skipped'] ?? array() ),
50-
fn( $row ) => is_array($row) && in_array( (string) ( $row['reason_code'] ?? '' ), array( 'active_no_signal', 'no_inventory_cleanup_signal' ), true)
50+
fn( $row ) => is_array($row) && in_array( (string) ( $row['reason_code'] ?? '' ), array( 'active_no_signal', 'no_inventory_cleanup_signal', 'lifecycle_reconciliation_candidate' ), true)
5151
)
5252
);
5353
$total = count($active);
@@ -140,7 +140,7 @@ public function worktree_active_no_signal_report( array $opts = array() ): array
140140
'summary' => array_merge($summary, array( 'slow_rows' => $this->summarize_slow_worktree_rows($rows) )),
141141
'pagination' => $pagination,
142142
'evidence' => array(
143-
'scope' => 'review-only active_no_signal worktree lifecycle evidence',
143+
'scope' => 'review-only active/no-signal and lifecycle reconciliation worktree evidence',
144144
'safety' => 'No worktrees or remote branches are deleted. Dirty and unpushed probes are evidence only.',
145145
'budget' => null === $budget_context ? null : $this->summarize_worktree_loop_budget_context($budget_context, $budget_stopped),
146146
'probe_cache' => $probe_cache['stats'],
@@ -1121,6 +1121,7 @@ private function build_active_no_signal_evidence_row( array $row, array &$github
11211121
'branch_identity' => $branch_identity,
11221122
'path' => $path,
11231123
'created_at' => $row['created_at'] ?? null,
1124+
'inventory_reason_code' => $row['reason_code'] ?? null,
11241125
'lifecycle_state' => $metadata['lifecycle_state'] ?? null,
11251126
'metadata' => $metadata,
11261127
'last_seen_at' => $metadata['last_seen_at'] ?? ( $metadata['observed_at'] ?? null ),

tests/smoke-worktree-metadata-reconcile.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ function () use ( $tmp ) {
558558
$active_rows[ $row['handle'] ?? '' ] = $row;
559559
}
560560
$assert('finalized_pr_reconcile', $active_rows['demo@head-merged']['suggested_action'] ?? '', 'active/no-signal report finds merged PRs by branch head');
561+
$assert('finalized_pr_reconcile', $active_rows['demo@pr-merged']['suggested_action'] ?? '', 'active/no-signal report includes lifecycle reconciliation candidates with merged PR evidence');
562+
$assert('lifecycle_reconciliation_candidate', $active_rows['demo@pr-merged']['inventory_reason_code'] ?? '', 'active/no-signal report preserves lifecycle reconciliation source reason');
561563
$assert('active_open_pr', $active_rows['demo@already-current']['suggested_action'] ?? '', 'active/no-signal report preserves open PRs as active');
562564
$assert(106, (int) ( $active_rows['demo@head-merged']['pr']['number'] ?? 0 ), 'active/no-signal report includes PR evidence');
563565
$assert('unsafe_dirty_or_unpushed', $active_rows['demo@dirty-active']['suggested_action'] ?? '', 'active/no-signal report keeps dirty rows unsafe');
@@ -702,7 +704,7 @@ public function worktree_list( ?string $repo = null, ?string $state = null, arra
702704
$run(sprintf('git remote set-url origin %s', escapeshellarg($remote)), $primary);
703705
$assert(true, ! is_wp_error($finalized_dry_run) && ( $finalized_dry_run['success'] ?? false ), 'finalized active/no-signal dry-run succeeds');
704706
$assert(true, (bool) ( $finalized_dry_run['dry_run'] ?? false ), 'finalized active/no-signal dry-run does not write');
705-
$assert(1, (int) ( $finalized_dry_run['summary']['planned'] ?? 0 ), 'finalized active/no-signal dry-run plans merged PR rows only');
707+
$assert(2, (int) ( $finalized_dry_run['summary']['planned'] ?? 0 ), 'finalized active/no-signal dry-run plans merged PR rows only');
706708
$assert('', \DataMachineCode\Workspace\WorktreeContextInjector::get_metadata('demo@head-merged')['cleanup_eligible_at'] ?? '', 'finalized active/no-signal dry-run leaves metadata unchanged');
707709
$run('git remote set-url origin https://github.com/acme/demo.git', $primary);
708710
$budgeted_finalized_dry_run = $ws->worktree_active_no_signal_finalized_apply(array( 'dry_run' => true, 'limit' => 20, 'offset' => 0, 'internal_budget_label' => '1s', 'internal_budget_seconds' => 1, 'internal_budget_started' => microtime(true) - 1 ));

0 commit comments

Comments
 (0)