Skip to content
This repository was archived by the owner on Sep 2, 2026. It is now read-only.

Commit b1d2cf4

Browse files
authored
Merge pull request #1305 from Extra-Chill/fix/issue-1301-data-machine-code
Avoid workspace scan during worktree planning
2 parents cdff267 + 7263720 commit b1d2cf4

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

‎inc/Workspace/WorkspaceWorktreeLifecycle.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5777,7 +5777,7 @@ protected function inspect_worktree_capacity( string $repo, string $branch, bool
57775777
$this->workspace_path,
57785778
WorktreeDiskBudget::thresholds($repo, $branch),
57795779
$force,
5780-
array( 'include_workspace_usage' => true ),
5780+
array( 'include_workspace_usage' => false ),
57815781
$demand_plan
57825782
);
57835783
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Worktree admission must not block on a workspace-wide allocation walk.
4+
*/
5+
6+
declare(strict_types=1);
7+
8+
namespace DataMachineCode\Workspace {
9+
final class WorktreeContextInjector {
10+
public static function bootstrap_capacity_reservations(): array {
11+
return array( 'bytes' => 0, 'inodes' => 0 );
12+
}
13+
}
14+
15+
final class WorktreeDiskBudget {
16+
public static array $options = array();
17+
18+
public static function thresholds( string $repo, string $branch ): array {
19+
return array();
20+
}
21+
22+
public static function inspect( string $workspace, array $thresholds, bool $force, array $options, array $demand ): array {
23+
self::$options = $options;
24+
return array( 'status' => 'ok', 'creation_allowed' => true );
25+
}
26+
}
27+
}
28+
29+
namespace {
30+
if ( ! defined('ABSPATH') ) {
31+
define('ABSPATH', __DIR__ . '/fixtures/');
32+
}
33+
34+
require_once dirname(__DIR__) . '/inc/Workspace/WorkspaceWorktreeLifecycle.php';
35+
36+
use DataMachineCode\Workspace\WorkspaceWorktreeLifecycle;
37+
use DataMachineCode\Workspace\WorktreeDiskBudget;
38+
39+
final class WorktreePlanCapacityHotPathHarness {
40+
use WorkspaceWorktreeLifecycle { inspect_worktree_capacity as public inspectCapacity; }
41+
42+
private string $workspace_path = '/workspace';
43+
}
44+
45+
$result = ( new WorktreePlanCapacityHotPathHarness() )->inspectCapacity(
46+
'repo',
47+
'branch',
48+
false,
49+
array( 'bytes' => 1, 'inodes' => 1 )
50+
);
51+
52+
if ( true !== ( $result['creation_allowed'] ?? false ) ) {
53+
throw new RuntimeException('Capacity admission result was not preserved.');
54+
}
55+
if ( false !== ( WorktreeDiskBudget::$options['include_workspace_usage'] ?? null ) ) {
56+
throw new RuntimeException('Worktree planning enabled the synchronous workspace allocation walk.');
57+
}
58+
59+
echo "worktree-plan-capacity-hot-path: ok\n";
60+
}

0 commit comments

Comments
 (0)