Skip to content

refactor(ai): knowledge base pages hold no locked version #7232

Description

@dan-petty

Problem or Motivation

A dependency update must edit knowledge base pages under src/. Of 109 dependency update commits on main since 2026-11-01, 19 changed a file under src/ or tests/, and the largest group is the pages under src/devops_cli/ai/knowledge_base/ (19 file edits).

The cause: each page states the versions that it applies to (applies_to, for example pkg:pypi/<name>@<locked minor>.*), and src/devops_cli/ai/kb.py (near lines 272 to 279 and 380 to 406) reads uv.lock and reports a page whose range does not hold the locked version as drift. Until #7229 three tests of tests/review/test_kb_manuals_metadata.py failed on that drift. #7229 removed these tests, but the pages still hold a copy of the locked version.

Owner rule of 2026-11-19: a dependency version lives only in the manifest of its package manager, and an update that changes no interface needs no edit under src/ or tests/.

Proposed Solution

Disposition: change the code and the pages.

  • A page names the library, and names a version only where its text is true for that version alone (a floor, such as "from 2.0").
  • The drift report compares the page with the version that ran only when the page states a floor or a ceiling.
  • Remove the exact minor ranges from the front matter of the pages.

Proof: a Renovate minor update of one Python library passes CI with no edit of a page. A test of kb.py with a page and a lock that the test writes.

Existing Tool Considered

Renovate has no manager for prose. The fix is to hold no copy of the pin. No new code is necessary.

Alternatives check of 2026-11-25: not-applicable.
Class: refactor, no search.
Tool: none found.

Proposed design

Problem statement

Remove the locked version from the knowledge base pages. Keep the drift report for a page that states a floor or a ceiling. A dependency update edits knowledge base pages under src/devops_cli/ai/knowledge_base/, because each page states an exact minor range in its applies_to front matter. src/devops_cli/ai/kb.py reads uv.lock and reports a page as drift when its range does not hold the locked version. The owner rule of 2026-11-19 puts each version in the manifest of its package manager alone.

Acceptance criteria

Requirement: A version-free applies_to entry is valid

The front-matter validator SHALL accept an applies_to entry that names a package or a tool with no version.

Scenario: A package name with no version passes validation

  • WHEN The test in tests/ai/test_kb.py validates KbFrontMatter with applies_to set to pkg:pypi/requests.
  • THEN KbFrontMatter accepts the value, and parse_manual_front_matter returns an empty error.

Requirement: A page with no version does not drift

The matcher SHALL report no drift for a page whose applies_to entry holds no version, whatever the locked version is.

Scenario: A lock change keeps the page matched

  • WHEN A test in tests/ai/test_kb.py writes a uv.lock with version 2.31.0 and loads a page with pkg:pypi/requests, then writes 2.32.0 and loads the page again.
  • THEN load_matched_kb_manuals puts the page in matched and not in drift in both runs.

Requirement: A bare package that the lock does not hold is drift

The matcher MUST report drift when a page names a package that the locked inventory does not hold.

Scenario: A missing package is drift

  • WHEN A test in tests/ai/test_kb.py writes a uv.lock with no requests entry and loads a page with pkg:pypi/requests.
  • THEN load_matched_kb_manuals puts the page in drift with a reason that holds not found in locked inventory.

Requirement: A locked version inside a floor matches

The matcher MUST report no drift when the locked version is at or above a stated floor.

Scenario: A locked version above the floor matches

  • WHEN A test in tests/ai/test_kb.py writes a uv.lock with version 2.31.0 and loads a page with pkg:pypi/requests@>=2.0.
  • THEN load_matched_kb_manuals puts the page in matched and not in drift.

Requirement: A locked version below a floor is drift

The matcher MUST report drift when the locked version is below a stated floor.

Scenario: A locked version below the floor is drift

  • WHEN A test in tests/ai/test_kb.py writes a uv.lock with version 1.9.0 and loads a page with pkg:pypi/requests@>=2.0.
  • THEN load_matched_kb_manuals puts the page in drift with a reason that holds >=2.0 and 1.9.0.

Requirement: The bundled pages hold no exact range

Each knowledge base page SHALL hold no exact minor range and no == pin in a pkg: or tool: entry of its applies_to front matter.

Scenario: The bundled pages are scanned for exact ranges

  • WHEN A test in tests/ai/test_kb.py reads each page under src/devops_cli/ai/knowledge_base/ with parse_manual_front_matter.
  • THEN No pkg: or tool: entry ends with .*, and no entry holds ==.

Requirement: Pending a person after the merge

A Renovate minor update of one Python library MUST pass CI with no edit under src/devops_cli/ai/knowledge_base/.

Scenario: The next Renovate minor update passes with no page edit

  • WHEN After the merge, Renovate opens a minor update pull request for one Python library.
  • THEN The required checks pass, and the pull request changes no file under src/devops_cli/ai/knowledge_base/.

Existing Tool Considered

No open tool covers the need. The alternatives check of 2026-11-25 in the issue body gives the verdict not-applicable: class refactor, no search, no tool found. The need is to stop holding a copy of a version in prose, and Renovate has no manager for prose. The proposal builds no new component, so no tool exists to match. The written cost is about 20 changed lines in src/devops_cli/ai/kb.py, one line in each page that holds an exact range, and no new dependency or module to keep.

Key questions

  • Which form does an applies_to entry take when the page holds no version?: The entry names the package or the tool and stops before @, such as pkg:pypi/requests or tool:ruff. A page keeps a version only as a floor or a ceiling, such as pkg:pypi/requests@>=2.0, where its text is true from that version on. A bare pkg: name still drifts when the locked inventory does not hold the package, because the page names a library that the environment must have. (best practice) [sources: src/devops_cli/ai/kb.py:184]
    • Chosen: Bare name with no @. It holds no copy of a version. The owner rule of 2026-11-19 puts each version in the manifest of its package manager alone.
    • Rejected: Wildcard @*. It still holds a version-shaped token, and it keeps a copy of the pin that the owner rule removes.
    • Rejected: Keep the exact minor range. It is the cause of the drift and of the page edit on each dependency update.
  • Does the drift report keep a comparison for a page that states a floor or a ceiling?: Yes. The matcher keeps the range path. A page with >=2.0 matches a locked version at or above 2.0 and drifts below it. A page with no version does not drift on a version change. (best practice) [sources: src/devops_cli/ai/kb.py]
    • Chosen: Keep the range path and drop only the exact range. The owner rule allows a version where the text is true from that version on. _version_matches_pattern already builds a SpecifierSet for each operator.
    • Rejected: Remove the drift report for pages. It removes the check that a floor still holds, and the owner rule keeps the floor.
    • Rejected: Compare only the major version. The page states a floor, not a major range, and a major compare hides a real mismatch.
  • Where does kb.py read the locked version, and how does a test give it a lock?: _lookup_uv_lock_version reads uv.lock in the current folder into the module cache _UV_LOCK_CACHE. _read_uv_lock_versions maps each package name, in lower case with -, to its version. A test writes a uv.lock in a temporary folder, changes to it, and calls reset_uv_lock_cache() before each read. A test can also pass locked_packages to load_matched_kb_manuals. [sources: src/devops_cli/ai/kb.py, tests/ai/test_kb.py:165]
  • What else in the repository reads applies_to?: The repository defines applies_to in src/devops_cli/ai/kb.py:184 and again at src/devops_cli/ai/review/defects.py:139. The proposal changes the grammar in kb.py and the pages. Refine reads line 139 and confirms that the second field accepts the bare form, or changes it in the same pull request. [sources: src/devops_cli/ai/review/defects.py:139, src/devops_cli/ai/kb.py:184]
  • Do the three tests that test(tests): remove tests that force a version or a setting #7229 removed come back?: No. The pull request adds a test in tests/ai/test_kb.py that writes a page and a uv.lock. It does not restore the removed tests in tests/review/test_kb_manuals_metadata.py, because they asserted the exact range that the owner rule removes. (best practice) [sources: tests/ai/test_kb.py:165, tests/review/test_kb_manuals_metadata.py, src/devops_cli/ai/kb.py]
    • Chosen: Add a new test in tests/ai/test_kb.py. It asserts the new behavior with a page and a lock that the test writes.
    • Rejected: Restore the three removed tests. They asserted the exact range and the drift that the change removes.
  • Which pages hold an exact minor range?: The scan covers each page under src/devops_cli/ai/knowledge_base/ with a pkg: or tool: entry. The count is not known before the scan. The new test names each page that still holds a .* wildcard or an == pin, and the pull request edits each page that the test names. [sources: tests/ai/test_kb.py]
  • Which documents show the old front-matter form?: Refine reads src/devops_cli/ai/knowledge_base/README.md and each document that describes the front matter. The pull request changes each one that shows the old form. AGENTS.md rule 8 keeps a document true in the pull request that makes it wrong. (best practice) [sources: AGENTS.md, src/devops_cli/ai/knowledge_base/README.md]
    • Chosen: Update each document in the same pull request. AGENTS.md rule 8 forbids a document that the change makes wrong.
    • Rejected: Update the documents in a second pull request. It leaves main with a wrong example and breaks the one-issue-one-pull-request rule.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/refactor
    scope/ai
    source/agent
    status/new
    value/medium
    on Nov 25, 2026
  2. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor
  3. added
    effort/medium
    priority/p2-medium
    on Nov 25, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 28, 2026
  5. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  6. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  7. removed
    status/in-review
    on Nov 29, 2026
  8. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 18:59 UTC

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/p2-mediumscope/aisource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions