Skip to content

refactor(tools): read tool versions from the installed tool #4388

Closed as not planned

Description

@devops-cli-service

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_version and 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_version from 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_version or importlib.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_version and rules.lock:8 in one commit (extra='forbid'), pinned_semgrep_version and the compare at :174-177. commands/review.py:2872 prints the detected semgrep --version (_detect_semgrep_version). Add the file that holds the semgrep pin to the paths filter of rule-pack.yml, so a semgrep bump runs semgrep --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.lock from 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 -- src returns only src/devops_cli/tools_lock, commands/install_tools.py, commands/ci.py and devcontainer/devcontainer_plans.py.
  • devops review rules test --check passes in rule-pack.yml.
  • devops k8s doctor reports the client kubectl version.

Depends on: #4362, #6409

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.py and src/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_version from no module under devops_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 kubectl that answers version --client -o json with {"clientVersion":{"gitVersion":"v1.31.2"}}
  • THEN the doctor reports the skew for 1.31.2 and reads no entry of tools.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.3 on its version command
  • THEN the record holds 1.2.3 from the installed tool and no value from tools.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 semgrep versions
  • THEN the two hashes differ, and a change to tools.lock alone 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 semgrep that prints 1.99.0
  • THEN the rule pack records 1.99.0 and devops_cli.review.rules_pack holds no pinned_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_lock call and marks the replay test live

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.lock and 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.json runs
  • 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,zizmor runs 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 --check runs
  • 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_version now, and who calls it?: path_version is at src/devops_cli/tools_lock/versions.py:24. Its product caller is src/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_version live 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.
  • How does the k8s doctor get the kubectl skew version?: Run kubectl version --client -o json and read clientVersion.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.lock value. The owner decision of 2026-11-19 forbids a pin in product code.
  • How does a review record state a tool version?: Use path_version for a binary and importlib.metadata for 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_version for binaries and importlib.metadata for packages. Each source gives the version of the installed item, and path_version already handles a binary.
    • Rejected: One --version parser for every tool. Each tool prints a different shape, so one parser fails.
    • Rejected: The tools.lock value. The lock is a copy, and the owner decision forbids it as a source.
  • 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_version on the installed binary. Delete pinned_semgrep_version and 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_version from the installed binary. The function already reads the installed binary, and it is the one source of the version.
    • Rejected: pinned_semgrep_version from 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.
  • Which file holds the Semgrep pin after the rules lock entry goes?: tools.lock holds the Semgrep pin. ADR 0005 keeps the tools lock for the sandbox and the canary, and the rules lock line is a copy. Add tools.lock to the paths filter of rule-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.json under build(npm): make openspec and style-dictionary devDependencies #6409. (best practice) [sources: src/devops_cli/openspec/gate.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4362, #6409

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

  1. added
    source/agent
    type/refactor
    status/new
    value/low
    effort/medium
    on Nov 10, 2026
  2. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    ContributorAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The refactor prefix of the title gives the type.
    • Scope: none. The title has the scope tools, and .github/labels.yml declares no scope/tools label. Add the label to the file to give the scope to this item.
    • Priority: P3-Low. The item is deferred until a later item removes devops install-tools, and it changes no user behaviour.
    • Value: Low. The change removes internal coupling and gives no direct gain to users.
    • Effort: Medium. Four modules, the installer, CI and research need a new pin source, and a new test must scan the packages.
    • Related: refactor(security): tools are found on PATH and not in tools.lock #4362, which asks for a different change. Both items want no product code to read tools.lock, but #4362 changes the tool lookup and the candidate moves the version pins.
  3. added
    priority/p3-low
    on Nov 10, 2026
  4. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    ContributorAuthor

    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.

  5. changed the title [-]refactor(tools): move the tools.lock version pins out of product code[/-] [+]refactor(tools): read tool versions from the installed tool[/+] on Nov 19, 2026
  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor

    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.

  7. added
    owner/agent
    on Nov 20, 2026
  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    Owner

    PR #6543 (#6416) runs Rule Pack Tests in the devtools image. The Semgrep of the image is 1.186.0, and src/devops_cli/review/rules/rules.lock records 1.179.0, so devops review rules test --check fails with k8s-networkpolicy-ingress-any: semgrep_version '1.179.0' != pinned '1.186.0' until this item deletes the compare. #6543 does not edit rules_pack.py or rules.lock.

  9. added
    status/in-progress
    and removed
    status/new
    on Nov 20, 2026
  10. dan-petty commented on Nov 20, 2026

    @dan-petty
    Owner

    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.

  11. removed
    status/in-progress
    owner/agent
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p3-lowsource/agenttype/refactorvalue/low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions