Skip to content

Support unattended worktree identities and environment generation - #11

Merged
EdoMon93 merged 1 commit into
mainfrom
feat/unattended-worktree-identity
Oct 2, 2026
Merged

EdoMon93 merged 1 commit into
mainfrom
feat/unattended-worktree-identity

Conversation

@EdoMon93

@EdoMon93 EdoMon93 commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Unattended creation rejected nonempty WORKTREE_ENV, so Orchestrator could not configure an independent local database identity for each review worktree. Creation now accepts an optional --worktree-id and literal multiline environment templates, writes private files, and records identities in Git worktree registrations so changing env filenames or deleting env files cannot free an active ID.

{id} uses the explicit or automatic identity; {n} remains a separately allocated numeric slot. The CLI rejects duplicate IDs and unsafe or existing environment destinations, preserves registration and ownership information on partial failure, and adds worktree_id and worktree_env_path to JSON schema version 1. Human copy-and-append behavior remains supported. Callers must serialize repository mutations; the README specifies this contract and recovery behavior.

Prepares executable version 0.3.0 and pinned installation documentation for the tagged release. The existing v0.2.0 tag remains unchanged.

Validation: 40 Python integration tests and 4 human-workflow checks pass, along with Bash syntax and git diff checks. Coverage includes externally locked concurrent creation, duplicate identities across env filenames, moves, missing/locked worktrees, literal multiline parsing, path and file collisions, private permissions, and checkout/environment failures.

Closes #10.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 10:27

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 release change (private file creation, path-traversal/symlink defense, identity lifecycle, version bump) that warrants final human review despite no concrete defects being found.

Review effort: Balanced
Findings: None

What changed in this PR

This PR extends mkwt's unattended (create) automation interface so an orchestrator can give each review worktree an independent, durable identity and a generated per-worktree environment file. Previously unattended creation rejected a nonempty WORKTREE_ENV; now it accepts literal (optionally multiline) templates, substitutes {id}/{n}, writes a private 0600 file under safe relative paths, and records mkwt-identity/mkwt-env-path in each worktree's Git registration so an identity stays reserved even if the env file is renamed or deleted. It also bumps the executable to 0.3.0 and documents the caller-locking contract and new error codes.

Changes:

  • Add caller-supplied --worktree-id, automatic/{id} identity allocation, and DUPLICATE_WORKTREE_ID detection backed by persisted Git-registration metadata.
  • Add unattended env-file generation with strict path/symlink validation and private permissions (UNSAFE_ENV_PATH, ENV_PATH_COLLISION, ENV_GENERATION_FAILED, IDENTITY_FAILED); support literal multiline config values.
  • Bump version to 0.3.0, surface worktree_id/worktree_env_path in JSON, and document the locking/recovery contract.
File Description
bin/​mkwt New identity helpers, allocation, env generation, multiline config parsing, --worktree-id plumbing, and human-workflow identity recording; version bump.
tests/​test_automation.py Extensive new integration tests covering identities, env generation, path/symlink safety, failure classification, locking, and legacy/human compatibility.
README.md Documents --worktree-id, env generation, identity/locking contract, new error codes, JSON fields, and 0.3.0 pinning.

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

@EdoMon93
EdoMon93 merged commit a557d71 into main Oct 2, 2026
3 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

Development

Successfully merging this pull request may close these issues.

Support explicit worktree IDs and environment generation in unattended create

2 participants