Repository navigation
Description
Problem
devops ci in a worktree of another repository checks devops-cli and not that repository. The worktree is one of the clone repos/dan-petty/homelab, at .data/agent/worktrees/h-<issue> of the devops-cli checkout. The run prints Quality gate root: /workspaces/devops-cli and reads the workflow files of devops-cli. So devops ci --check --only actionlint,zizmor reports pass for a homelab branch whose workflow files it did not read. A pull request of that repository can then name a check result that is about a different tree.
Evidence
- In the homelab worktree, on a branch that changes
.github/workflows/k8s.ymlandlint.yml:devops ci --check --only actionlintprintsQuality gate root: /workspaces/devops-cliandpass [actionlint](devops-climainat3e1bf8540).uv run --project /workspaces/devops-cli devops ci --check --only actionlint,zizmorgives the same root. - In the same folder,
actionlint .github/workflows/*.ymlandzizmor --offline .github/workflows/read the homelab files. - Checkouts and Worktrees Below Another Repository Resolve to Their Own Repository #617 ("Checkouts and Worktrees Below Another Repository Resolve to Their Own Repository") is closed as completed.
Acceptance criteria
devops ciin a worktree of a clone belowrepos/uses that worktree as the quality gate root, or it stops with a message that names the root it would check.- A test covers a worktree of a nested clone that is below the data directory of the outer checkout.
Alternatives check of 2026-11-27: in-use.
The repository already uses this tool.
Tool: git/git (https://github.com/git/git), NOASSERTION, last activity 2026-11-26, maintained.
Reason: Searches found no dedicated alternative: Git's rev-parse --show-toplevel, already wrapped as git_show_toplevel, resolves a linked worktree's own root, but it exits 128 on a stale worktree and leaves the gate cache keying and stop behaviour to project code.
Covers:
- Resolves a linked worktree's own top level, not the outer checkout
- Already wrapped as git_show_toplevel and used by devops review path
- Runs from the current directory with no new dependency
Lacks:
- Exits 128 when a linked worktree's git directory is gone
- No gate cache or coverage-index keying by root
- No stop message or gate orchestration; project code must change
Proposed design
Problem statement
devops ci in a linked worktree of a clone under repos/ announces the outer devops-cli checkout and reads its workflow files. A pull request of the nested repository can then cite a check result about a different tree. The fix makes the gate root the git worktree that holds the current directory. It stops outside a work tree and keys the cache and coverage index by the gate root.
Acceptance criteria
Requirement: Gate root from the git worktree
devops ci SHALL take its quality gate root from the git worktree that holds the current directory.
Scenario: Worktree of a clone below the data directory
- WHEN A test builds an outer checkout with a clone at
repos/<owner>/<name>and a linked worktree at.data/agent/worktrees/h-1. The test answersgit rev-parse --show-toplevelwith the worktree path. The test runs the gate there. - THEN The announced
Quality gate rootis the worktree path. Each process that the gate starts with a working directory runs in that worktree.
Requirement: Stale worktree still checked
When git rev-parse --show-toplevel fails for a stale linked worktree, the command MUST use the nearest ancestor with a .git entry and keep the stale-worktree warning.
Scenario: Stale linked worktree
- WHEN A test removes the git directory of a linked worktree. The test answers
git rev-parse --show-toplevelwith exit 128. The test runs the gate from the worktree. - THEN The announced root is the worktree. The command prints the stale linked worktree warning.
Requirement: Stop outside a work tree
When the current directory is not in a git work tree, the command MUST stop with exit code 1 and name that directory.
Scenario: Directory that is not in a work tree
- WHEN A test runs
devops ci --checkin a temporary directory with no.gitentry in it or above it. The test answersgit rev-parse --show-toplevelwith exit 128. - THEN The command exits 1. It prints a message that names that directory. It starts no check.
Requirement: Cache and coverage index keyed by the gate root
The CI cache and coverage index of a gate run MUST be keyed by the quality gate root.
Scenario: Cache and coverage paths of the nested clone worktree
- WHEN A test resolves the CI cache path and the coverage index path for the worktree
.data/agent/worktrees/h-1of a clone underrepos/. The test resolves the same paths for the outer checkout. - THEN The cache path and the coverage index path of the worktree differ from those of the outer checkout. A passing gate run in the worktree writes the file named for the worktree.
Existing Tool Considered
The alternatives check in the issue body records git/git (https://github.com/git/git) with the verdict in-use. The block lists what Git covers and lacks. The proposal uses git_show_toplevel for the root. It adds a fallback to the nearest .git ancestor for a stale worktree. It adds a stop with the named directory outside a work tree. It keys the cache and coverage index by the gate root.
Key questions
- Why does
devops cicheck the outer checkout in a worktree of a clone underrepos/?:_get_project_rootcallsfind_worktree_root._checks_as_its_own_treeresolves a linked worktree whose owner is a clone underrepos/to the workspace. The clone is nested in the workspace by design. The gate then announces and checks the workspace. [sources: src/devops_cli/commands/ci.py:133, src/devops_cli/core/repo.py:241, src/devops_cli/core/repo.py:256, tests/commands/test_repos.py] - Which method gives the quality gate root of the worktree that holds the current directory?: Resolve it with
git rev-parse --show-toplevelfrom the current directory through the existinggit_show_toplevel. When Git cannot answer because the git directory of the worktree is gone, use the nearest ancestor that holds a.gitentry. Stop when there is none. Keepfind_worktree_rootas it is, because every other command depends on its workspace resolution. (best practice) [sources: src/devops_cli/git/operations.py:664, src/devops_cli/commands/review.py:238, src/devops_cli/core/repo.py:55, tests/commands/test_ci.py, tests/commands/test_repos.py, src/devops_cli/commands/ci.py:133]- Chosen:
git_show_toplevel, then the nearest.gitentry for a stale worktree. Git answers with the worktree that holds the directory. The fallback keeps the stale-worktree warning. - Rejected: Keep
find_worktree_rootand fall back to it. It is the reported defect. For a worktree of arepos/clone it names the outer checkout. - Rejected: Change
find_worktree_rootso a worktree of arepos/clone checks itself. The repository records that such a worktree resolves to the workspace and asserts it. A change would move every command, not just the gate. - Rejected: Require a
--rootoption on each call. The default stays wrong for the nested worktree. Each caller must remember the option.
- Chosen:
- Does a linked worktree below another checkout have its own git root?: Yes. A linked worktree has its own work tree. Its
.gitis agitdir:file that names<common dir>/worktrees/<name>, and acommondirfile names the shared git directory.git rev-parse --show-toplevelrun there prints the worktree path. A worktree of a clone underrepos/is a work tree of its own too.find_worktree_rootstill resolves it to the workspace by design, which is the defect this issue fixes for the gate. [sources: src/devops_cli/core/repo.py:93, src/devops_cli/core/repo.py:100, src/devops_cli/git/operations.py:664, tests/commands/test_repos.py] - What does the command do when the current directory is not in a git work tree?: Stop with exit code 1 and a message that names the directory. Start no check. (best practice) [sources: src/devops_cli/commands/ci.py:133, src/devops_cli/core/repo.py:55, src/devops_cli/lang/en/messages.py:592, src/devops_cli/config/constants.py:2006]
- Chosen: Stop and name the directory. Git gives no work tree there. A stop keeps the reported result tied to one tree and shows the premise that failed.
- Rejected: Check the current directory. It reports a verdict for a tree that is not a work tree. The git-based checks of the gate fail there.
- Rejected: Fall back to the devops-cli checkout. That fallback is the reported defect. The run checks a tree that the caller did not name.
- Rejected: Use the nearest parent directory with a
pyproject.toml. It can name another repository and hides the mistake.
- By what key does a gate run name its cache and coverage-index files?: By the quality gate root itself (
root.resolve()). A worktree of a clone underrepos/gets its own file and never writes to the file of the outer checkout. (best practice) [sources: src/devops_cli/ci/cache.py, tests/commands/test_ci.py, src/devops_cli/core/repo.py:241]- Chosen: The quality gate root. The gate root is the tree the verdict is about. Each worktree keeps its own file as the docstring promises.
- Rejected: Keep
find_worktree_root(root). It hashes every worktree of a clone as the workspace. Parallel worktrees overwrite each other and the file is named for a tree the run did not check. - Rejected:
main_worktree_root(root). Every worktree would share one name, which loses the per-worktree separation.
- Do the k8s and docs row failures belong to this issue?: No. They are separate defects in the gate rows. Defer them to new issues. The root fix stays in one pull request. (best practice) [sources: AGENTS.md]
- Chosen: Defer them to separate issues. The root fix changes one resolution point. The row failures need their own causes and tests.
- Rejected: Expand this issue to fix both rows. It mixes three defects in one pull request. It breaks the rule of one issue, one pull request.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 27, 2026
The CI gate reports pass on the wrong files, which can let unverified changes merge.devops-cli-service commentedon Nov 27, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 27, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 27, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 28, 2026
Two more failures of
devops ciin a tree of dan-petty/homelab, seen on 2026-11-28 in a copy of homelabmain(a review of the plan pull requests homelab#611, #617 and #632):uv run devops ci --check --only k8sstops withModuleNotFoundError: No module named 'tests'.docsrow (devops docs check) exits 1 on homelabREADME.mdlines 283 and 370: it reads<plan id>in a command example as an extra argument. It does not readk8s/README.md.So a verify of a homelab task that names either row fails on the base and after the change.
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.
fix(ci): allow dry-run and job-time outside a git work tree (#7369)
fix(ci): resolve gate root from nearest git work tree (#7369) (#7563)
chore(main): release 0.232.10 (#7565)
devops-cli-service commentedon Nov 28, 2026
Released in v0.232.10: https://github.com/dan-petty/devops-cli/releases/tag/v0.232.10
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 14:05 UTC