Skip to content

Support unattended orchestrator worktree lifecycle #2

Closed

Description

@EdoMon93

Goal

Let an orchestrator create isolated Claude, Codex, and synthesizer worktrees at the same exact revision, then remove each workspace safely through a predictable CLI.

The orchestrator owns repository locking, fetching, workspace inspection, active-workspace protection, and retention. mkwt owns exact-commit creation, unattended behavior, structured results, and removal of an explicitly identified linked worktree.

Proposed interface

The final interface is documented in the pinned CLI contract below.

mkwt create \
  --repo /srv/repos/project \
  --path /srv/workspaces/run-123/claude \
  --commit FULL_COMMIT_SHA \
  --detach \
  --config /etc/orchestrator/mkwt.conf \
  --non-interactive \
  --json

mkwt remove \
  --repo /srv/repos/project \
  --path /srv/workspaces/run-123/claude \
  --non-interactive \
  --json

Implementation issues

Completion criteria

  • Verify two detached worktrees at the same SHA.
  • Verify operation with stdin redirected from /dev/null and with file descriptor 0 closed.
  • Verify path collisions and missing commits/configuration fail without unintended mutations.
  • Verify partial creation failure reports surviving resources for recovery.
  • Verify dirty-removal refusal, explicit forced removal, and repeated removal.
  • Verify paths containing spaces and wrong-repository removal.
  • Verify JSON stdout and exit semantics across successful and failing operations.
  • Publish the final CLI/config/JSON contract, tested Git/runtime requirements, installation instructions, and pinned release tag or full source commit.
  • The installed executable exposes its version and source revision outside the source checkout.

Baseline findings

Inspected checkout: 7fc39e1b01a3ddfaabc940f336f5f1ea67e51b3d. This is a baseline, not a pin for the requested functionality.

Temporary-repository probes confirmed:

  • Git can create two detached worktrees at the exact same SHA.
  • Current mkwt first use with stdin closed still prints prompts, accepts defaults, writes .worktrees/mkwt.conf, edits .gitignore, and creates a worktree.
  • Current mkwt rejects an existing destination.
  • A configured hook failure returns nonzero and leaves the created worktree, with its path printed as plain text.
  • The proposed --repo option is currently unsupported; no remove subcommand or version identifier exists.
  • All four existing VS Code/config tests passed.

Source: https://github.com/EdoMon93/mkwt/blob/7fc39e1b01a3ddfaabc940f336f5f1ea67e51b3d/bin/mkwt

Backward compatibility and rollback

The current implementation is preserved by annotated tag v0.1.0, pointing to 7fc39e1b01a3ddfaabc940f336f5f1ea67e51b3d. This is a rollback pin for existing users, not the release containing the new functionality. Keep the tag unchanged.

Preserve the existing mkwt <branch> [--base <branch>] [--vscode | --no-vscode] invocation, plain-path stdout, repository-local Bash config, and interactive defaults. Scope the new unattended/no-fetch/JSON requirements to the new operations or explicit flags. Retain existing symlink, environment-file, hook, and VS Code behavior for legacy use.

Potential breaks to resolve explicitly:

  • create and remove are valid branch names in the current CLI. A new subcommand dispatcher can steal existing invocations such as mkwt create and mkwt remove; preserve unambiguous legacy behavior and test it, or document a necessary migration before shipping.

  • Requiring external config or replacing Bash configuration globally would break existing .worktrees/mkwt.conf files and first-use behavior.

  • Returning JSON by default would break command substitution such as cd "$(mkwt fix/foo)".

  • Removing automatic fetching, wizard/setup defaults, or hooks globally would change legacy behavior.

  • Adding runtime dependencies can break existing Bash/Git-only installations. Keep old use working or clearly document the new requirements before release.

  • Add legacy regression coverage alongside the new acceptance suite.

  • Identify any remaining incompatible behavior on this issue before implementation/release; do not silently redefine legacy commands.

To restore the baseline in a clean mkwt source checkout:

git fetch origin tag v0.1.0
git switch --detach v0.1.0
./setup.sh

Existing source checkouts may contain local changes; installation should be performed from a clean checkout of the tagged source.

Required everyday human workflow

The user relies on mkwt <branch> for daily development: it performs the usual configured worktree setup and opens VS Code. Preserve that invocation and behavior without requiring new flags, a different command name, or migration to external configuration. Automation behavior must be explicitly selected and must not change the interactive defaults or existing VS Code settings/overrides.

  • Verify mkwt <branch> still performs configured setup and opens VS Code with an existing launch-enabled config.
  • Verify existing prompt-based VS Code behavior and --vscode/--no-vscode overrides remain unchanged.
  • Surface any implementation that would require changing this human workflow before proceeding; preserving it is a requirement.

Baseline release published

v0.1.0 was published as the baseline release, preserving source commit 7fc39e1b01a3ddfaabc940f336f5f1ea67e51b3d. Its release notes include everyday usage, pinned installation, rollback instructions, and the distinction between this baseline and the future automation release. A fresh tagged checkout passed Bash syntax validation and all four existing VS Code/config tests. The automation implementation and installed --version identifier were delivered subsequently in PR #8.

Delivered

Merged in PR #8, with CI passing on main. All requested lifecycle behaviors are implemented, with 23 integration tests plus the four existing tests. The human branch/config/VS Code workflow remains intact. Repository locking, retention, fetching, and active-workspace protection remain with the orchestrator.

  • Stable release: v0.2.0
  • Pinned source commit: 9b0610857bd4f82921401512a0ab428c5e0f7463
  • CLI/config/JSON contract
  • Compatibility: preserve mkwt <branch> and configured VS Code behavior; automation only requires Bash 4.4+ and Git 2.48+.

v0.2.0 is the latest stable release; v0.1.0 remains available for rollback. The implementation is merged and all acceptance criteria are complete.

Copilot reviewed the final implementation commit and reported no findings before merge. Main CI passed all 23 automation integration tests and four legacy tests. Additional probes verified unreadable-config refusal without mutations and recovery reporting after a successful checkout followed by an injected failure.

The stable version was finalized in PR #9 after Copilot review with no findings. The installed executable reports 0.2.0. The superseded beta release and tag were removed at the user’s request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions