Repository navigation
Description
Problem
Product code reads tool versions from tools.lock, which is a copy of the pins:
- k8s/doctor.py:513-525 takes the kubectl skew version from it.
- review/analysis.py:629-636, review/canary.py:372-390 (used at :474, :509) and ai/kb.py:528-543 record pinned versions.
- ai/review/profile.py:44,200 hashes
tools.lock. - review/rules_pack.py holds
RuleLockEntry.semgrep_version, rules.lock:8,pinned_semgrep_versionand a compare at :174-177. - research/tool_pins.py and defaults.py:929-934 read it for the inventory.
The earlier refined plan of this issue moved the pins into a generated src/devops_cli/config/tool_pins.json with a drift test. The owner rule of 2026-11-19 (devops-cli is not a package manager: no pin in src/ that a dependency update must change) forbids that. Owner decision of 2026-11-19: the devtools image installs the tools, so the installed tool is the one source of its version.
Change
- Move
versions.path_versionfrom tools_lock to core. - k8s/doctor.py:513-525 takes the kubectl skew version from
kubectl version --client -o json. - review/analysis.py:629-636, review/canary.py:372-390 and ai/kb.py:528-543 record the installed versions (
path_versionorimportlib.metadata). - ai/review/profile.py:44,200 hashes the installed tool versions that the analysis reads, not
tools.lock. - review/rules_pack.py: delete
RuleLockEntry.semgrep_versionand rules.lock:8 in one commit (extra='forbid'),pinned_semgrep_versionand the compare at :174-177. commands/review.py:2872 prints the detectedsemgrep --version(_detect_semgrep_version). Add the file that holds the semgrep pin to the paths filter of rule-pack.yml, so a semgrep bump runssemgrep --test. - openspec/gate.py: build(npm): make openspec and style-dictionary devDependencies #6409 owns the version guard. Owner decision of 2026-11-19: OpenSpec becomes a devDependency of a devops-cli
package.json, so npm checks the installed version. This item does not remove the guard. - research/tool_pins.py goes, and defaults.py:929-934 drops
tools.lockfrom the inventory paths. - osv-scanner and Trivy keep scanning the locks. Leave the audit rows of ci.py:893-910 to chore(tools): remove devops install-tools and tools.lock #4363, so no audit stops before the locks go.
- Tests: replace the version equality of tests/tools_lock/test_openspec_contract.py:34-37 with a live-marked test that replays each recorded scenario against the installed openspec. Drop the kubeconform fixture equality (test_security_kubeconform.py:151). Change test_k8s_doctor.py:526, test_k8s.py:196, test_scanner_contract.py:96,120, test_tool_executor_contract.py:142,366-395, test_review_tool_binary_digest.py:169-183,225 and test_review_rules_pack.py:101-117,130,167,216.
Renovate. Remove the prBodyNotes line of the OpenSpec rule (renovate.json:317) that asks a person to record the fixture again. No manager change.
Risk. Medium. Many readers. The kubectl skew rule needs kubectl present. The review record format changes, because path_version returns the first output line and not a bare version.
Proof
- Scoped pytest of the changed modules passes.
git grep -nE 'load_tools_lock|tools_lock_digest|read_tools_lock' origin/main -- srcreturns only src/devops_cli/tools_lock, commands/install_tools.py, commands/ci.py and devcontainer/devcontainer_plans.py.devops review rules test --checkpasses in rule-pack.yml.devops k8s doctorreports the client kubectl version.
Proposed design
Problem statement
Product code reads tool versions from tools.lock, which is a copy of the pins. The devtools image installs the tools, so the installed tool is the one source of its version (owner decision of 2026-11-19). This change moves each reader to the installed tool. It keeps tools.lock only for the sandbox, the canary and the scanners.
Acceptance criteria
Requirement: Product code reads no tools lock
No product module except devops_cli.tools_lock, commands/install_tools.py, commands/ci.py and devcontainer/devcontainer_plans.py SHALL import load_tools_lock, tools_lock_digest or read_tools_lock.
Scenario: A source scan finds no lock reader in product code
- WHEN a test runs
git grep -nE 'load_tools_lock|tools_lock_digest|read_tools_lock' -- src - THEN the output names only
src/devops_cli/tools_lock,src/devops_cli/commands/install_tools.py,src/devops_cli/commands/ci.pyandsrc/devops_cli/devcontainer/devcontainer_plans.py
Requirement: The version helper leaves the tools lock
Each caller SHALL import path_version from a core module and not from a module under devops_cli.tools_lock.
Scenario: The install command imports the helper from core
- WHEN a test reads the imports of
src/devops_cli/commands/install_tools.py - THEN the module imports
path_versionfrom no module underdevops_cli.tools_lock
Requirement: The k8s doctor reads the client kubectl version
The k8s doctor SHALL take the kubectl skew version from kubectl version --client -o json.
Scenario: The doctor parses the client version
- WHEN a test calls the doctor with a fake
kubectlthat answersversion --client -o jsonwith{"clientVersion":{"gitVersion":"v1.31.2"}} - THEN the doctor reports the skew for
1.31.2and reads no entry oftools.lock
Requirement: Review records state the installed tool version
The review analysis, the canary and the knowledge base SHALL record the installed version of each tool that they name.
Scenario: A record follows the installed binary
- WHEN a test runs the analysis with a fake tool that prints
1.2.3on its version command - THEN the record holds
1.2.3from the installed tool and no value fromtools.lock
Requirement: The review profile hashes installed tool versions
The review profile SHALL hash the installed tool versions that the analysis reads and SHALL NOT hash tools.lock.
Scenario: A tool bump changes the profile hash
- WHEN a test builds the profile with two different installed
semgrepversions - THEN the two hashes differ, and a change to
tools.lockalone leaves the hash the same
Requirement: The rules lock holds no Semgrep version
The rule-pack lock model SHALL reject a semgrep_version field.
Scenario: A lock entry with a Semgrep version fails to load
- WHEN a test loads a rule-pack lock entry that holds
semgrep_version - THEN the load raises a validation error, because the model forbids extra fields
Requirement: The rule pack detects the Semgrep version
The rule pack SHALL take the Semgrep version from _detect_semgrep_version and SHALL NOT define pinned_semgrep_version.
Scenario: The detected version is the installed one
- WHEN a test runs the rule pack with a fake
semgrepthat prints1.99.0 - THEN the rule pack records
1.99.0anddevops_cli.review.rules_packholds nopinned_semgrep_version
Requirement: The OpenSpec contract test replays the recordings
The OpenSpec contract test SHALL replay each recorded scenario against the installed OpenSpec and SHALL NOT compare the recorded version with tools.lock.
Scenario: The module holds no lock comparison
- WHEN a test reads the source of
tests/tools_lock/test_openspec_contract.py - THEN the source holds no
load_tools_lockcall and marks the replay testlive
Requirement: The tool inventory lists no tools lock
The tool inventory SHALL list no path of tools.lock and SHALL NOT provide devops_cli.research.tool_pins.
Scenario: The default inventory holds no tools lock
- WHEN a test builds the default inventory paths and imports
devops_cli.research.tool_pins - THEN no path ends with
tools.lockand the import fails
Requirement: The Renovate OpenSpec rule asks for no new recording
The Renovate configuration SHALL NOT ask a person to record the OpenSpec fixture again.
Scenario: The Renovate configuration validates
- WHEN
npx --yes --package renovate -- renovate-config-validator renovate.jsonruns - THEN the validator reports the configuration valid
Requirement: A Semgrep bump runs the rule-pack tests
The rule-pack workflow SHALL run the rule-pack tests when the file that holds the Semgrep pin changes.
Scenario: The workflow passes its validators
- WHEN
uv run devops ci --check --only actionlint,zizmorruns on the change to.github/workflows/rule-pack.yml - THEN actionlint and zizmor report no error in the workflow
Requirement: The rule pack passes its tests
The rule pack SHALL pass devops review rules test --check after the Semgrep pin goes.
Scenario: The rules test passes
- WHEN
devops review rules test --checkruns - THEN the command exits 0 and reports no failing rule test
Existing Tool Considered
No alternatives check has run. The installed tools cover the need: kubectl version --client -o json and semgrep --version print the version of the binary that runs, and Python's importlib.metadata gives the version of an installed package. These cover the version of an installed tool. They lack a shared reader: each tool has its own output, and importlib.metadata sees no binary. The change adds no new tool and no new version reader. It moves path_version to a core module and reads these outputs. It keeps tools.lock for the sandbox and the canary, as ADR 0005 requires.
Key questions
- Where is
path_versionnow, and who calls it?:path_versionis atsrc/devops_cli/tools_lock/versions.py:24. Its product caller issrc/devops_cli/commands/install_tools.py:65,400. The change moves it to a core module and updates that import. [sources: src/devops_cli/tools_lock/versions.py:24, src/devops_cli/commands/install_tools.py:65, src/devops_cli/commands/install_tools.py:400] - Where does
path_versionlive after the change?: Move it to a core module. Keep one helper and one caller import. (best practice) [sources: src/devops_cli/tools_lock/versions.py:24, src/devops_cli/commands/install_tools.py:65]- Chosen: Core module. The owner decision moves the helper out of
tools_lock, and one helper serves each caller. - Rejected: Keep it in
tools_lock. The module name keeps the pin tie that the item removes. - Rejected: Copy it into each reader. Several copies drift apart, and each needs a fix.
- Chosen: Core module. The owner decision moves the helper out of
- How does the k8s doctor get the kubectl skew version?: Run
kubectl version --client -o jsonand readclientVersion.gitVersion. (best practice) [sources: src/devops_cli/k8s/doctor.py:513]- Chosen:
kubectl version --client -o json. The client prints its own version in a documented JSON shape. - Rejected: Parse the text of
kubectl version --client. The text layout changes between releases. - Rejected: Keep the
tools.lockvalue. The owner decision of 2026-11-19 forbids a pin in product code.
- Chosen:
- How does a review record state a tool version?: Use
path_versionfor a binary andimportlib.metadatafor an installed Python package. The record holds the first line of the tool's output. (best practice) [sources: src/devops_cli/tools_lock/versions.py:24, src/devops_cli/commands/install_tools.py:400]- Chosen:
path_versionfor binaries andimportlib.metadatafor packages. Each source gives the version of the installed item, andpath_versionalready handles a binary. - Rejected: One
--versionparser for every tool. Each tool prints a different shape, so one parser fails. - Rejected: The
tools.lockvalue. The lock is a copy, and the owner decision forbids it as a source.
- Chosen:
- What does the review profile hash cover?: Hash the installed tool versions that the analysis reads. Do not hash
tools.lock. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md, src/devops_cli/ai/review/profile.py:44]- Chosen: The installed tool versions that the analysis reads. ADR 0005 defines stability over the tools that run, and the installed tool is the one source of its version.
- Rejected: The bytes of
tools.lock. The owner decision forbids a pin in product code. - Rejected: The review session id. A session id changes on each run, so equal inputs give different hashes.
- Where does the rule pack get the Semgrep version?: Use
_detect_semgrep_versionon the installed binary. Deletepinned_semgrep_versionand the compare that uses it. (best practice) [sources: src/devops_cli/review/rules_pack.py:127, src/devops_cli/review/rules_pack.py:212, src/devops_cli/review/rules_pack.py:238]- Chosen:
_detect_semgrep_versionfrom the installed binary. The function already reads the installed binary, and it is the one source of the version. - Rejected:
pinned_semgrep_versionfrom the lock. The owner decision forbids the pin, and the rules lock entry is a copy. - Rejected: The rules lock entry. The change deletes that entry, so no value remains.
- Chosen:
- Which file holds the Semgrep pin after the rules lock entry goes?:
tools.lockholds the Semgrep pin. ADR 0005 keeps the tools lock for the sandbox and the canary, and the rules lock line is a copy. Addtools.lockto the paths filter ofrule-pack.yml. [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md, src/devops_cli/review/rules_pack.py:127] - What replaces the OpenSpec version equality in the contract test?: Replace it with a live-marked test that replays each recorded scenario against the installed OpenSpec. (best practice) [sources: tests/tools_lock/test_openspec_contract.py]
- Chosen: A live-marked replay of each recorded scenario. The replay checks the installed tool, and the version equality reads the lock.
- Rejected: Keep the equality with the pin. The owner decision forbids the pin as a source, and the test fails on each bump.
- Rejected: Delete the contract test. The replay is the contract of the recorded scenarios, and a delete loses it.
- Does this item remove the OpenSpec version guard?: No. build(npm): make openspec and style-dictionary devDependencies #6409 owns the guard, and this item leaves it. OpenSpec becomes a devDependency of a devops-cli
package.jsonunder build(npm): make openspec and style-dictionary devDependencies #6409. (best practice) [sources: src/devops_cli/openspec/gate.py]- Chosen: Leave the guard to build(npm): make openspec and style-dictionary devDependencies #6409. The body gives the guard to build(npm): make openspec and style-dictionary devDependencies #6409, and this item does not remove it.
- Rejected: Remove the guard here. The change would take work that build(npm): make openspec and style-dictionary devDependencies #6409 owns, and the item states that it keeps the guard.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Watched files
A commit on the default branch that changes one of these files starts the next refine round.
src/devops_cli/openspec/gate.py
Activity
devops-cli-service commentedon Nov 10, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
refactorprefix of the title gives the type.tools, and .github/labels.yml declares no scope/tools label. Add the label to the file to give the scope to this item.The item is deferred until a later item removes devops install-tools, and it changes no user behaviour.The change removes internal coupling and gives no direct gain to users.Four modules, the installer, CI and research need a new pin source, and a new test must scan the packages.Both items want no product code to read tools.lock, but #4362 changes the tool lookup and the candidate moves the version pins.devops-cli-service commentedon Nov 11, 2026
Refine cannot set this item to Ready at 6a09588 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
The next refine round also looks at the item again when a commit on the default branch changes one of these files:
src/devops_cli/ai/kb.py,src/devops_cli/commands/ci.py,src/devops_cli/devcontainer/devcontainer_plans.py,src/devops_cli/roadmap/runner_tools.py.[-]refactor(tools): move the tools.lock version pins out of product code[/-][+]refactor(tools): read tool versions from the installed tool[/+]devops-cli-service commentedon Nov 19, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.
dan-petty commentedon Nov 20, 2026
PR #6543 (#6416) runs
Rule Pack Testsin the devtools image. The Semgrep of the image is 1.186.0, andsrc/devops_cli/review/rules/rules.lockrecords 1.179.0, sodevops review rules test --checkfails withk8s-networkpolicy-ingress-any: semgrep_version '1.179.0' != pinned '1.186.0'until this item deletes the compare. #6543 does not editrules_pack.pyorrules.lock.refactor(tools): read tool versions from the installed tool
dan-petty commentedon Nov 20, 2026
Closed as not planned: replaced by #4363. Owner decision of 2026-11-20 (#4363, comment 7047909430): one pull request deletes the tools lock and every reader. The reviewed work of PR #6544 stays on its branch for reuse.
refactor(review): find tools on PATH and read installed versions
refactor(review): find tools on PATH and read installed versions
refactor(review): find tools on PATH and read installed versions