Skip to content

Add opt-in unattended worktree lifecycle while preserving human usage - #8

Merged
EdoMon93 merged 3 commits into
mainfrom
feat/orchestrator-lifecycle
Oct 1, 2026
Merged

EdoMon93 merged 3 commits into
mainfrom
feat/orchestrator-lifecycle

Conversation

@EdoMon93

@EdoMon93 EdoMon93 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

An orchestrator needs independent worktrees at one exact revision and predictable unattended cleanup. This adds explicit create/remove operations with external literal configuration, detached exact-commit checkout, versioned JSON results, stable errors, and partial-failure recovery information.

The existing mkwt <branch> workflow, repository-local Bash config, configured setup, automatic fetching, plain-path stdout, and VS Code behavior remain intact. Branches literally named create and remove retain their legacy meaning unless automation flags are supplied.

Unattended creation requires setup actions to be disabled and never runs the wizard, writes config/.gitignore, or launches applications. Git hooks, filters, fsmonitor, automatic maintenance, object replacement, and lazy fetching are disabled for automation. Removal verifies registration and metadata identity, counts ignored files as dirty, preserves branches, and refuses locked/stale worktrees even with force. Repeated removal is a successful already_absent outcome.

The installer embeds the source revision in the standalone executable. The README defines the CLI/config/JSON/exit contract and compatibility boundaries. Automation requires Bash 4.4+ and Git 2.48+; the legacy human workflow retains its existing requirements. The version is 0.2.0-beta.1, with the existing v0.1.0 release retained as the rollback baseline.

Validation: Bash syntax and diff checks; all four existing tests; 23 Python integration tests, including two worktrees at the same SHA, closed stdin, preexisting and racing collisions, failures after registration and during partial-clone checkout without fetching, dirty/forced/repeated removal, branch preservation, wrong-repository and replaced-Gitfile refusal, reserved legacy branch names/VS Code, bare/SHA-256 repositories, path escaping, and installed metadata after source removal, and removal with the target itself as repository context. GitHub Actions runs both suites.

Fixes #3
Fixes #4
Fixes #5
Fixes #6
Fixes #7

Tracking issue: #2

Copilot AI balanced review requested due to automatic review settings October 1, 2026 07:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It introduces security- and operationally-sensitive behavior (force removal of filesystem worktrees, path/identity verification, and a newly published CLI/JSON contract) whose correctness and backward-compatibility guarantees warrant final human review despite no concrete defects being found.

Review effort: Balanced
Findings: None

What changed in this PR

This PR adds an opt-in, fully unattended worktree lifecycle to mkwt (a Bash tool that creates Git worktrees) so an orchestrator can create detached worktrees at an exact commit and remove them deterministically, while leaving the existing interactive mkwt <branch> human workflow untouched. Automation is engaged only when an automation flag is present, so legacy branch names like create/remove keep their meaning. It introduces a versioned JSON result contract, stable error codes, external literal (non-sourced) configuration, hook/filter/fetch suppression for automation, a --version identifier embedded at install time, documentation of the full contract, and an extensive Python integration suite wired into CI.

Changes:

  • New automation_main path in bin/mkwt implementing create/remove/--version with detached exact-commit checkout, no-fetch guarantees, literal config parsing, JSON/exit contract, and safe identity-verified removal.
  • setup.sh embeds the source revision into the installed executable; MKWT_INSTALL_DIR override added; README documents the CLI/config/JSON/exit contract and compatibility boundaries.
  • New tests/test_automation.py (21 tests) plus a GitHub Actions workflow running syntax checks, the legacy human-workflow test, and the automation suite.
File Description
bin/​mkwt Adds the automation subsystem (dispatch, JSON emit, path/symlink resolution, sanitized git wrapper, literal config parser, create/remove flows, version) ahead of the unchanged legacy workflow.
setup.sh Embeds the Git source revision (with -dirty/unknown handling) via sed into a build copy and adds MKWT_INSTALL_DIR override.
README.md Documents --version, the automation CLI, external server config, removal policy, and the JSON/exit/error-code contract, plus v0.1.0 rollback.
tests/​test_automation.py New integration suite covering creation, no-fetch partial clones, partial-failure reporting, removal safety, legacy branch/VS Code behavior, and installed version metadata.
.github/​workflows/​tests.yml Runs syntax checks, the legacy test, and the automation suite on push/PR with read-only permissions.
.gitignore Ignores __pycache__/ generated by the Python tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It is a large, security-sensitive change to a core tool with intricate Bash (traps, subshells, path normalization, config parsing, git-version-dependent behavior) whose correctness across all edge cases cannot be fully guaranteed by automated review.

Review effort: Balanced
Findings: None

@EdoMon93
EdoMon93 merged commit ebbbcda into main Oct 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants