Repository navigation
Description
Problem Description
The agent tool scan_uv_audit and its MCP tool check that their directory is inside the workspace (_run_adapter_scan in src/devops_cli/ai/tools/builtin_tools.py). uv audit finds the project from that directory and then from each parent directory. The workspace check does not apply to the project that uv finds. When no directory from the named directory up to the workspace root holds a project, uv finds a project in a parent directory of the workspace and audits its uv.lock.
The reply gives each finding at uv.lock:<package> and does not name the lockfile. Thus an agent reads the package names and versions of a lockfile outside the workspace, and takes them as the audit of the workspace.
Before the uv audit adapter (#2106), the tool ran uv audit in the directory of the process, with the same gap. A review of #2106 found it. #2106 does not change how uv finds the project, so this issue holds the gap.
Reproduction Steps
- Make a uv project at
/tmp/example/proj(apyproject.tomland itsuv.lock), and an empty directory/tmp/example/proj/sub. - Start the agent tools with
/tmp/example/proj/subas the workspace (the working directory of the process). - Call
scan_uv_audit("."). - Run
uv workspace dir --project /tmp/example/proj/sub. uv 0.12.23 writes/tmp/example/proj: the audit used theuv.lockof that directory, which is outside the workspace.
Expected vs Actual Behavior
Expected: the tool audits only a uv.lock inside the workspace. When the project that uv finds is outside the workspace, the reply gives no result (not_applicable or failed), with a reason that names the directory of that project.
Actual: scan_uv_audit(".") replies uv audit scan status: ok with the findings of /tmp/example/proj/uv.lock, and scan_uv_audit("..") replies Access Denied: .. is outside workspace.
A possible fix: before the audit, ask uv for the root of the project with uv workspace dir --project <directory> (uv 0.12.23 writes no preview warning for it), and refuse a root outside the workspace. Another possible fix: give the root that uv finds in the reply, and in the location of each finding.
Environment Diagnostics
- uv 0.12.23 (the devcontainer) and 0.13.6 (the images).
- devops-cli
mainafter fix(security): scan_uv_audit runs a uv audit adapter, and the uv pip audit command that uv does not have goes #2106.
Logs, Traces, or Terminal Output
$ uv workspace dir --project /tmp/example/proj/sub
/tmp/example/proj
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Source: #2106
Proposed design
Problem statement
The scan_uv_audit tool checks that its target directory is inside the workspace, but uv resolves the project by walking up parent directories. When no directory from the target to the workspace root holds a project, uv finds a project in a parent of the workspace and audits its uv.lock. The reply does not name the lockfile, so an agent reads findings from the wrong project and treats them as the audit of the workspace.
Acceptance criteria
Requirement: Project root boundary check
The tool SHALL resolve the project root via uv workspace dir --project and verify it is inside the workspace before running the audit.
Scenario: Project root outside workspace
- WHEN scan_uv_audit(".") is called with the workspace at /tmp/example/proj/sub and the project at /tmp/example/proj
- THEN the reply has status not_applicable and the reason names /tmp/example/proj
Requirement: Audit proceeds for in-workspace project
When the project root is inside the workspace, the tool SHALL run the audit and return its findings.
Scenario: Project root inside workspace
- WHEN scan_uv_audit(".") is called with the workspace at /tmp/example/proj and the project at /tmp/example/proj
- THEN the reply has status ok and findings from /tmp/example/proj/uv.lock
Requirement: Refusal reason names the project directory
When the project root is outside the workspace, the reply SHALL name the directory of that project in the reason field.
Scenario: Reason contains project path
- WHEN the project root resolved by uv workspace dir is outside the workspace
- THEN the reason in the reply contains the absolute path of the project root
Existing Tool Considered
uv workspace dir (uv 0.12.23+) resolves the project root from a directory and writes it to stdout. It covers the need to identify which project a target belongs to. The project calls it and checks the result against the workspace boundary. No new library is needed.
Key questions
- Which fix approach prevents the wrong audit?: Call uv workspace dir --project before the audit and refuse if the project root is outside the workspace. This prevents the incorrect audit from running at all. (best practice) [sources: src/devops_cli/ai/tools/builtin_tools.py]
- Chosen: Pre-audit boundary check via uv workspace dir. Prevents the wrong audit from running. The expected behavior states the tool audits only a uv.lock inside the workspace.
- Rejected: Report the project root in the reply only. Adds transparency but still runs the audit on the wrong project. Does not meet the expected behavior.
- Where in the code is the boundary check implemented?: In run_uv_audit_scan in devops_cli/security/uv_audit.py, because that adapter knows about uv project resolution and can call uv workspace dir with the target path it receives. (best practice) [sources: src/devops_cli/ai/tools/builtin_tools.py]
- Chosen: In run_uv_audit_scan (the uv adapter). The adapter knows about uv project resolution. It receives the target path and can call uv workspace dir and check the result against Path.cwd().
- Rejected: In scan_uv_audit in builtin_tools.py. Also works, but duplicates uv-specific logic in the generic tool layer. The adapter is the right place for uv-specific checks.
- What status does the reply carry when the project is outside the workspace?: not_applicable, because the audit is not applicable to a project outside the workspace. The body lists not_applicable as the first option. (best practice) [sources: src/devops_cli/ai/tools/builtin_tools.py]
- Chosen: not_applicable. The audit is not applicable to a project outside the workspace. The body lists it first. It is in CONST_SCAN_NO_RESULT_STATUSES so the reply adds the no-result line.
- Rejected: failed. Implies the audit ran and errored, which is not the case. The audit was correctly refused before running.
Open questions
- Does uv workspace dir --project work without a preview warning on uv 0.12.23? (missing verified source)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-06: in-use.
The item already names this tool.
Tool: astral-sh/uv (https://github.com/astral-sh/uv), Apache-2.0, last activity 2026-11-06, maintained.
Activity
dan-petty commentedon Oct 28, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The tool audits a uv.lock outside the workspace, which is incorrect behaviour in a delivered feature.A security scan tool reports findings from the wrong file, but the scenario needs a specific directory layout.An agent could act on audit results from the wrong project, but the trigger is a narrow setup.The fix is one extra call to uv workspace dir and a boundary check before the audit runs.Both work on scan_uv_audit in the same tool file; #2106 delivers the adapter, this candidate fixes a gap the adapter left in project resolution.devops-cli-service commentedon Oct 29, 2026
Refine cannot set this item to Ready at 4a3242e until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
[-]fix(ai): scan_uv_audit audits the uv.lock of a project outside the workspace when the workspace holds no project[/-][+]fix(ai): Refuse uv audit when project is outside workspace[/+]dan-petty commentedon Nov 6, 2026
The job shortened the title of this item. The summary had 103 characters, and the limit is 60. The type and the scope stay.
fix(ai): scan_uv_audit audits the uv.lock of a project outside the workspace when the workspace holds no projectfix(ai): Refuse uv audit when project is outside workspacedevops-cli-service commentedon Nov 6, 2026
Alternatives check: in-use
The item already names this tool.
Tool: astral-sh/uv (https://github.com/astral-sh/uv)
Covers:
uv workspace dir --project <directory>resolves which project a directory belongs to and writes the project root to stdout, which is exactly the fact the tool needs before auditinguv audit), so no new library, dependency or install path is addedLacks:
uv auditstill discovers the project by walking up parent directories, so without the pre-check the wronguv.lockis still auditedSearches run:
Sources:
Checked on 2026-11-06. A person decides what this means for the item. The check changes no label and closes no issue.
fix(ai): Refuse uv audit when project is outside workspace (#4239)
devops-cli-service commentedon Nov 9, 2026
Released in v0.101.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.101.0
devops-cli-service commentedon Nov 9, 2026
Live since 2026-11-09 15:38 UTC