refactor(workspace): bounded worktree allocation and cleanup run control operations - #1272
Merged
Merged
Conversation
The audit ratchet treated inc/Cleanup as a Store convention, so the new operation was a naming outlier. Moving it next to WorktreeAllocationOperation keeps Cleanup/ as evidence stores and makes drain orchestration explicit steps instead of a page-loop lookalike.
chubes4
force-pushed
the
refactor/1243-worktree-allocation-operation
branch
from
August 27, 2026 23:21
e821798 to
3adc424
Compare
chubes4
marked this pull request as ready for review
August 27, 2026 23:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1243 — this branch advances the issue but does not close it. It lands the first bounded application operations (worktree allocation, cleanup run control) and the shared standalone test runner, covering sequencing steps 1–4 for the worktree-allocation slice. The remaining #1243 scope (repository lifecycle, inventory/inspection, workspace locking services, full operation-declared metadata, bootstrap special-case removal) is not addressed here.
What changes
Typed allocation contract and operation
WorktreeAllocationRequest(inc/Workspace/WorktreeAllocationRequest.php): a readonly typed input object with onefrom_input()normalizer that replaces ~19-positional-parameter calls and duplicated default handling across adapters.WorktreeAllocationOperation(inc/Workspace/WorktreeAllocationOperation.php): the canonical application operation forplan()andadd(). It owns task-tracker admission, local-primary detection, remote-backend routing, local fallback, and the remote-unsupported admission refusals (percentage-byte-floor exception, capacity remediation) that previously lived inline inWorkspaceAbilities::worktreeAdd().WorkspaceWorktreeLifecyclegainsworktree_plan_request()/worktree_add_request()taking the typed request; the legacy positionalworktree_plan()/worktree_add()remain as thin adapters.Adapters route through the operations
WorkspaceAbilities::worktreeAdd()/worktreePlan()delegate toWorktreeAllocationOperation; the duplicated input normalization, remote admission checks, andhasLocalPrimaryCheckout()were deleted (~170 lines).CodeTaskCreator,WorkspaceCodeTaskWorkspace, andCodeTaskWorkspaceInterfacenow pass aWorktreeAllocationRequestinstead of 10 positional arguments.WorkspaceRepositoryLifecycleprimary-refresh builds the typed request instead of a positional call.Cleanup run control operation
CleanupRunControlOperation(inc/Cleanup/CleanupRunControlOperation.php) with constructor-visible dependencies (evidence store, command runner, ability resolver). It owns job-backed drain (parent + child passes, drainability repairs) and resume/cancel control with typed\WP_Errorresults.WorkspaceCommanddelegatesdrain_cleanup_run_to_status()andcontrol_cleanup_run_job()to it and no longer referencesSystemTaskDrainabilitydirectly (~180 lines removed).Model tools projected from abilities
inc/Tools/WorkspaceTools.phpdeleted (1,793 lines); its tools are projected from canonical abilities viaAbilityToolProjections.GitHubToolsreduced from ~1,500 lines of wrappers to two bespoke adapters (manage_github_issuecomposition,add_label_to_issuecollection adaptation); one-to-one GitHub tools are registered throughAbilityToolProjections(adds worktree-plan, publish-runner, and six GitHub projections).WorkspaceTools.Behavioral fixes on the operation boundary
changed_sectionsnaming the evidence sections that invalidated the digest.WorktreeStalenessProbe::fetch()classifies Git's "couldn't find remote ref" diagnostic separately from transport failure (missing_remote_ref), and the allocation preflight can proceed from a local ref or explicit base when the remote ref is absent.Shared test infrastructure
bin/dmc-test(isolated per-test PHP processes, targeted paths supported) andtests/support/bootstrap.php;tests/TESTING.mddocuments it.worktree-allocation-request,workspace-operation-architecture(asserts ability/CLI adapters cannot bypass the operations and that deleted tool wrappers stay deleted),ability-tool-projections, cleanup drainability-repair coverage, and staleness fetch-retry cases. Superseded contract tests removed.Net: +1,069 / −3,753 lines across 29 files.
Verification
bin/dmc-testphp -lover all 23 changed PHP filesgit statusNotes: the repository defines no locally installable lint/static-analysis tooling (no
composer.jsonscripts, no vendor dependencies, no phpcs/phpstan binary in the environment;phpstan.neonexists but PHPStan is not vendored). CI lint/test/audit run through the Homeboy review workflow (review audit, review lint, review test) on this PR.AI assistance disclosure
An earlier AI session (under human direction) implemented the branch commits. This publication pass — issue review, branch/diff inspection, verification (
bin/dmc-test,php -l), push, and this draft PR — was performed by Z.AI GLM 5.3 via OpenCode. Chris Huber directs the work and remains responsible for reviewing and merging it.