Skip to content

fix(cli): gate checks the worktree it runs in, not the main checkout (#582) - #585

Merged
dan-petty merged 1 commit into
release/v0.2.23from
fix/582-worktree-gate-resolution
Sep 25, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
fix/582-worktree-gate-resolution

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Closes #582.

When running devops ci, devops test, devops uv, devops release, or devops scan complexity from a secondary or nested linked git worktree (created via git worktree add):

  1. Worktree Isolation: Resolved project root via new find_worktree_root() which detects .git linked worktree pointer files (gitdir: with valid commondir) and .git directories, preventing gate commands from ascending past the worktree to the enclosing main checkout.
  2. Submodule Safety: Verified .git files lacking a commondir (git submodules) continue resolving to their enclosing repository.
  3. Shared Data Resolution: Updated main_worktree_root() to start resolution from find_worktree_root() and follow commondir directly to the primary checkout root for shared .data/ directory resolution.
  4. Header Transparency: Emitted Executing CI quality gates concurrently in {root}... in devops ci so the target root is clear to the caller.
  5. Complexity Maintenance: Refactored test CLI command by extracting _build_test_cmd helper to lower cyclomatic complexity from $M = 11$ to $M \le 7$.

Verification

  • uv run pytest tests/test_repos.py tests/test_data_dir_worktrees.py tests/test_ci.py -v: All tests passed.
  • uv run devops scan complexity src/devops_cli/core/repo.py src/devops_cli/commands/ci.py tests/test_repos.py tests/test_ci.py: Compliant ($M \le 10$, depth $\le 5$).
  • uv run devops ci: 100% passing status across all 10 quality gates.

@dan-petty
dan-petty merged commit fe20c8f into release/v0.2.23 Sep 25, 2026
8 checks passed
@dan-petty
dan-petty deleted the fix/582-worktree-gate-resolution branch September 25, 2026 18:09
dan-petty added a commit that referenced this pull request Sep 25, 2026
…rktree everywhere (#612, #613) (#614)

#585 fixed #582 for nested worktrees, but its resolver stopped at the
first directory with its own .git. A clone under repos/ and each worktree
of it then resolved to the clone, for the gate and for shared data, which
landed in the clone's working tree. A nested worktree whose git directory
was pruned, or whose checkout moved, still gated the main checkout.

find_worktree_root now stops at the nearest linked worktree, live or
stale, and otherwise keeps the workspace root, so the main checkout,
clones under repos/, their worktrees and submodules resolve as before
#585. main_worktree_root shares the workspace's data with them again.
The gate names the root it checks before the cache lookup and for every
single check, warns from a stale worktree with the fix for each cause,
and resolves its root on each call instead of at import.

Commands that read, index or deploy the current tree now use it too:
repomap, the architecture diagram, the AST graph (which came back empty
from a nested worktree), review auto-fix, tf deploys and Kube-linter
locations. A tf deploy from a worktree that lacks the main checkout's
untracked local state stops when auto-approved and asks otherwise, since
apply would plan to create every resource again.

Every case is tested against real git layouts, and an acceptance probe
over eleven layouts matches the required gate and data roots. The #582
roadmap entry moves to v0.2.23 with a note on what #612 corrected.

Closes #612
Closes #613
dan-petty added a commit that referenced this pull request Sep 25, 2026
…eader, writer and cleanup (#616) (#618)

#553 made shared data resolve under the main worktree, but several sites
still anchored it at the top-most root or the current directory. From a
linked worktree outside the checkout they read and wrote the worktree's
own .data, so data split across worktrees and was lost with them:
workspace clean (which also ignored data.dir and DEVOPS_CLI_DATA_DIR),
the hallucination catalogue's relative DEVOPS_CLI_DATA_DIR, the benchmark
and prompt-eval datasets (the benchmark silently fell back to baseline
cases), model bundles, workspace discovery, the analysis and CI result
caches, the library drift report, the dashboard, the controller and the
sandbox logs and registry.

Every one now resolves through resolve_data_path; prompt-eval verifies
sources in the worktree it runs in. The CI result cache lives in the
shared cache directory, one file per worktree, so a gate never trusts
another worktree's result.

workspace clean prunes the configured data directory, where data is
written, and refuses anything that is not a dedicated data directory:
system and top-level directories, the home directory and its parents,
repositories and git directories, worktrees and their parents,
directories holding tracked files or another repository, and another
workspace's data, also through a symlink.

A checkout or worktree below another repository still resolves shared
data to the outer directory, as since before #585; strict xfail tests
record it and #617 tracks it.

Closes #616
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.

1 participant