feat: add isolated worktree execution for apply subagents (#182)#184
Merged
Conversation
Introduce apply-worktree-isolation: dispatched subagent bundles now run inside ephemeral git worktrees under .specflow/worktrees/<run>/<bundle>/. The main agent remains the sole workflow-state mutator and gains the integration authority role — inspecting each subagent's worktree diff, cross-checking against produced_artifacts, and importing accepted patches via git apply --binary --index. Integration rejects on undeclared paths, protected-path touches (task-graph.json / tasks.md / .specflow/**), empty-diff-on-success, or patch-apply failure; rejected bundles land in the new integration_rejected status with their worktree retained for /specflow.fix_apply. Subagent failures land in the new subagent_failed status with the same retention. Workspace state (tracked + untracked) is materialized into each new worktree so later bundles observe earlier bundle imports. Fail-fast on worktree-add errors, no silent fallback to inline execution. - task-planner status enum extended to 6 values; --allow-reset gates reset transitions to pending from the new failure statuses. - assignExecutionMode derives mode solely from the existing subagent- eligibility rule (no subagent-shared mode). - Full git-apply coverage: creates, deletes, modifies, mode changes, renames, binary content (git diff --binary --find-renames + git apply --binary --index). - Documentation: docs/apply-worktree-recovery.md operator playbook. - 921/921 tests pass including 5 real-git integration tests that spawn actual git against temp repos. Issue: #182
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.
Summary
/specflow.applysubagent-dispatched bundles. Dispatched subagents now run in ephemeral git worktrees at.specflow/worktrees/<run-id>/<bundle-id>/; the main agent remains the sole workflow-state mutator.produced_artifacts, reject onundeclared_path/protected_path/empty_diff_on_success/patch_apply_failure, and import accepted patches viagit apply --binary --index.task-plannerstatus enum withsubagent_failedandintegration_rejected; add--allow-resetflag tospecflow-advance-bundlefor/specflow.fix_applyrecovery paths. Retention policy: remove worktree ondone, retain on failure.git worktree addfailure — no silent fallback to inline execution.docs/apply-worktree-recovery.mdoperator playbook covering diagnosis and recovery for both failure modes.Issue
Closes #182