Skip to content

feat(docs): docs check refuses paths that do not exist #4904

Done

Description

@dan-petty

Problem or Motivation

The content census at cd6fb76 found 10 living high and 19 living low path findings, 31 in history sections and 29 in ADRs in force. The standards pass of 2026-11-11 (#4772) fixed 22 moved test paths by hand. The only path check (test_the_test_rules_name_only_test_files_that_exist) reads only docs/TESTING.md.

Proposed Solution & Architectural Design

  1. Add a rule module in src/devops_cli/docs/ that devops docs check runs over the hand-written and prompt classes, the skills and the knowledge base.
  2. A code span whose first segment is a tracked top-level entry or a package of src/devops_cli must resolve in git ls-files. A glob must match.
  3. The (target) mark names a planned path.
  4. The message names the tracked file with the same base name as the probable new path.
  5. Bare file names go to the scheduled rules of child 12 of feat(docs): track current content and brain-fed reference docs #4880.
  6. Delete the test that reads only docs/TESTING.md.

The PR decides each of the 19 low-confidence tokens in the document: reword, link or narrow the stated scope. It never adds an allow list. Precision rule: the rule goes into the docs row only when its run on main gives 0 findings after #4894. Update CONTRIBUTING.md and the docs row of docs/ROUTINE_TASKS.md.

Target Subsystem

SDLC, Git & PR Governance (devops docs check, src/devops_cli/docs/).

Existing Tool Considered

git ls-files and markdown-it-py (already dependencies). No open tool checks code-span paths against a git tree. Cost: about 150 lines plus tests, about 100k tokens and 2.5 h.

Acceptance Criteria

  • A planted moved path fails with file:line and the probable new path.
  • The rule gives 0 findings on main at the merge.
  • The old test is gone.
  • The docs row grows by at most 8 s on the runner.

Dependencies

#4894.

Source: #4880

Alternatives check of 2026-11-27: partly.
Tool: lycheeverse/lychee (https://github.com/lycheeverse/lychee), Apache-2.0, last activity 2026-11-23, maintained.
Reason: Searches found only link checkers: lychee resolves relative file links and reports file:line in Markdown, but it ignores inline code spans and git tracking, so it covers the path check only in part.

Covers:

  • Resolves relative file links in Markdown, HTML and reStructuredText
  • Reports the file and line of each broken path
  • Exits nonzero in CI on a broken link

Lacks:

  • Reads links only, never inline code spans
  • No glob match against the git-tracked file list
  • No mark for planned paths or probable-new-path hint
  • Checks the working tree, not git ls-files

Proposed design

Problem statement

The docs check has no rule for paths in inline code spans. A code span can name a path that git does not track in a hand-written document, a project skill or the knowledge base. This change adds the code-span path rule for hand-written documents, fixes every finding on the tree, deletes the old test and updates the documents. The prompt class is deferred because its examples are not tracked files.

Acceptance criteria

Requirement: Rule runs over hand-written documents

devops docs check SHALL run the code-span path rule over the hand-written document class, which holds the project skills and the knowledge base.

Scenario: Each hand-written document kind is inspected

  • WHEN the check runs over a tree with one project skill and one knowledge-base document, each with one stale path
  • THEN the check reports two findings, each with its file and line

Requirement: Tracked top-level path must exist

The rule SHALL report a finding when the first segment of a code span is a tracked top-level entry and no tracked file has the path.

Scenario: A moved document path fails

  • WHEN a hand-written document holds the code span docs/OLD_GUIDE.md and git tracks no such path
  • THEN the rule reports one finding at the line of the code span

Requirement: Package path must exist

The rule SHALL report a finding when the first segment of a code span is a package under src/devops_cli, the span has an extension that a tracked file under that package has, and neither the span nor src/devops_cli/<span> is tracked.

Scenario: A moved module path fails

  • WHEN a document holds the code span roadmap/missing.py and git tracks no such path at the root or under src/devops_cli/roadmap/
  • THEN the rule reports one finding at the line of the code span

Requirement: Unknown package extension is not inspected

The rule MUST NOT report a finding for a code span whose package has no tracked file with the extension of the span.

Scenario: An upstream Go path passes

  • WHEN a document holds the code span server/sched.go and no tracked file under src/devops_cli/server/ has the extension .go
  • THEN the rule reports no finding

Requirement: Glob matches a tracked file

The rule SHALL report a finding when a code span holds a glob that matches no tracked file and no tracked directory.

Scenario: A glob that matches nothing fails

  • WHEN a document holds the code span src/devops_cli/docs/*.missing and no tracked file matches the glob
  • THEN the rule reports one finding at the line of the code span

Requirement: Directory glob matches a tracked directory

The rule SHALL match a glob that ends with / against the tracked directories as well as the tracked files.

Scenario: A directory glob passes

  • WHEN a document holds the code span tests/gate/*_checks/ and git tracks a file under tests/gate/tree_checks/
  • THEN the rule reports no finding

Requirement: The (target) mark names a planned path

The rule MUST NOT report a finding for a code span that an emphasis starting with (target) follows.

Scenario: A planned path passes

  • WHEN a document holds the code span docs/NEW_GUIDE.md followed by *(target)* and git tracks no such path
  • THEN the rule reports no finding

Requirement: A placeholder is checked up to the placeholder

The rule SHALL resolve only the text before the first <...> placeholder in a code span.

Scenario: A placeholder in a tracked folder passes

  • WHEN a document holds the code span tests/support/fakes/<edge>.py and git tracks tests/support/fakes/clock.py
  • THEN the rule reports no finding

Requirement: Two placeholders are not inspected

The rule MUST NOT report a finding for a code span that holds more than one <...> placeholder.

Scenario: A runtime path with two placeholders passes

  • WHEN a document holds the code span roadmap/listing/<owner>/<name>.json and git tracks no such path
  • THEN the rule reports no finding

Requirement: A non-line colon is not inspected

The rule MUST NOT report a finding for a code span that holds a colon which is not a trailing line number.

Scenario: A Docker image tag passes

  • WHEN a document holds the code span valkey/valkey:9.1.2-alpine
  • THEN the rule reports no finding

Requirement: A slash token with no file form is not inspected

The rule MUST NOT report a finding for a code span that has no known file extension, no glob and no trailing slash.

Scenario: A Kubernetes object reference passes

  • WHEN a document holds the code span gitea/gitea-admin
  • THEN the rule reports no finding

Requirement: A line suffix is stripped

The rule SHALL strip a trailing :<line> or :<start>-<end> from a code span before it resolves the path.

Scenario: A line suffix does not hide a moved path

  • WHEN a document holds the code span docs/OLD_GUIDE.md:12 and git tracks no such path
  • THEN the rule reports one finding for docs/OLD_GUIDE.md

Requirement: A bare file name is not the subject of the rule

The rule MUST NOT report a finding for a code span whose first segment is a bare file name.

Scenario: A bare file name passes

  • WHEN a document holds the code span conftest.py and git tracks no file at that path
  • THEN the rule reports no finding

Requirement: Fenced code blocks are not inspected

The rule MUST NOT report a finding for a code span inside a fenced code block.

Scenario: A stale path in a fenced block passes

  • WHEN a document holds a fenced block with the code span docs/OLD_GUIDE.md
  • THEN the rule reports no finding

Requirement: The finding names the probable new path

The rule SHALL name each tracked file with the same base name as the probable new path in the finding, at most five, sorted.

Scenario: A moved path names its probable file

  • WHEN a document holds docs/OLD_GUIDE.md, git tracks no such path, and git tracks exactly one file named OLD_GUIDE.md at docs/guides/OLD_GUIDE.md
  • THEN the message names docs/guides/OLD_GUIDE.md

Requirement: One git call for each run of the rule

The rule SHALL read the tracked files with one git ls-files -z call for each run of the rule.

Scenario: Ten documents start git once

  • WHEN the rule runs over ten documents
  • THEN the git fake records one ls-files call

Requirement: The repository tree has no path finding

The rule SHALL report no finding when it runs over the repository tree of the change.

Scenario: The docs check passes on the tree

  • WHEN uv run devops docs check runs over the repository tree of the change
  • THEN the code-span path rule reports no finding

Requirement: The docs row runs the code-span path rule

The docs row of devops ci SHALL fail when a code-span path in a checked document does not resolve.

Scenario: The docs row reports a stale code-span path

  • WHEN uv run devops ci --check --only docs runs over a tree with one stale code-span path
  • THEN the row fails and prints the finding with its file and line

Requirement: The old test is deleted

The change SHALL delete the test test_the_test_rules_name_only_test_files_that_exist.

Scenario: No test holds the old name

  • WHEN a person runs ! git grep -n test_the_test_rules_name_only_test_files_that_exist tests/
  • THEN the command exits 0 and prints nothing

Requirement: The documents name the code-span path rule

CONTRIBUTING.md and the docs row of docs/ROUTINE_TASKS.md SHALL name the code-span path rule.

Scenario: The documents name the rule

  • WHEN a person runs git grep -n "code-span path" CONTRIBUTING.md docs/ROUTINE_TASKS.md
  • THEN the command prints a line in each file and exits 0

Requirement: The homelab switch page is a record

The docs inventory SHALL classify docs/HOMELAB_REPO_SWITCH.md as a record.

Scenario: The homelab switch page is a record

  • WHEN the test reads the inventory class of docs/HOMELAB_REPO_SWITCH.md
  • THEN the class is record

Requirement: Pending a person after the merge

The docs row SHALL take at most 8 s more than the docs row on main.

Scenario: A person measures the docs row on the runner

  • WHEN a person runs the docs row on the runner after the merge and compares its elapsed time with the docs row on main
  • THEN the elapsed time is at most 8 s more

Existing Tool Considered

The alternatives check of 2026-11-27 in the issue body records partly for lychee (https://github.com/lycheeverse/lychee), Apache-2.0, maintained. The block holds what lychee covers and lacks. This change does what the block says lychee lacks: it scans inline code spans, matches globs against one git ls-files -z call, honors the (target) mark, and names the probable new path. Cost: about 150 lines plus tests, about 100k tokens and 2.5 h.

Key questions

  • Which test reads only docs/TESTING.md?: test_the_test_rules_name_only_test_files_that_exist in tests/invariants/test_agents_md.py reads only docs/TESTING.md. [sources: tests/invariants/test_agents_md.py, docs/TESTING.md]
  • Where does the rule live, and which row runs it?: The rule is a module under src/devops_cli/docs/. devops docs check calls it. The docs row of devops ci runs devops docs check. (best practice) [sources: src/devops_cli/commands/docs.py, src/devops_cli/docs/generator.py, docs/ROUTINE_TASKS.md, docs/SDLC.md]
    • Chosen: Module under src/devops_cli/docs/. The docs command owns the docs checks, so one module serves the command and the row.
    • Rejected: check_* function in tests/gate/. The docs row runs devops docs check, not a separate gate module.
    • Rejected: New command. It adds a command to keep and a second entry point for one check.
  • Which documents does the rule read?: The rule reads the hand-written class of the docs inventory. That class holds the project skills and the knowledge base. The prompt class is deferred to a separate issue. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/docs/inventory.py, docs/TESTING.md]
    • Chosen: Hand-written class. It covers the project skills and the knowledge base without illustrative prompt paths.
    • Rejected: Prompt class in this change. Prompt documents hold illustrative paths that are not tracked files.
    • Rejected: Every class of the inventory. Generated pages, records and tool-generated skills have other checks.
  • How does the rule read the tracked files?: The rule starts one git ls-files -z through run_subprocess for each run. list_repo_files includes untracked files, so it is no substitute. (best practice) [sources: src/devops_cli/core/repo.py, docs/TESTING.md]
    • Chosen: One git ls-files -z call through run_subprocess. docs/TESTING.md holds every git start to the process runner, and one call gives the tracked set.
    • Rejected: Walk the working tree with pathlib. It counts untracked and ignored files, so a path that git does not track passes.
    • Rejected: Read .git/index directly. It copies the index format and its rules into the product code.
  • How does the rule find a code span and its line?: It reads each document line by line. It skips fenced code blocks and takes each inline code span with its line number, as markdown_argv_collector does. It reads the text after the span on the same line for the (target) mark. (best practice) [sources: src/devops_cli/docs/markdown_argv_collector.py, docs/TESTING.md]
    • Chosen: Line-by-line inline code scan. It gives the exact line of each span and skips fenced blocks.
    • Rejected: markdown-it token map. The map gives the line of the inline block, not each span in a multi-line paragraph.
    • Rejected: Full markdown parse and search for each span. A span can repeat, and a search gives no reliable line.
  • Which code spans does the rule inspect?: The rule inspects a code span only when it holds a / or a glob, and it has a known file extension, a glob or a trailing /. Its first segment must be a tracked top-level entry or a package directory under src/devops_cli. A package-relative span must have an extension that a tracked file under that package has. A bare file name is not a finding, because child 12 of feat(docs): track current content and brain-fed reference docs #4880 covers it. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py, src/devops_cli/docs/inventory.py, src/devops_cli/roadmap/init.py, src/devops_cli/docs/init.py]
    • Chosen: Path-shaped span with a tracked top-level entry or package prefix. It limits the rule to paths and skips Docker tags, object references and stack names.
    • Rejected: Every code span that holds a slash. It reports commands, URLs and object references, and it holds no limit that a person can state.
    • Rejected: Only paths under src/. It misses every path that starts at docs/ or tests/.
  • How does the rule treat non-path slash tokens?: The rule skips a span with a colon that is not a trailing line number. It skips a span with no known extension, no glob and no trailing /. It skips a span with more than one <...> placeholder. These rules skip Docker tags, Kubernetes object references, OpenTofu stack names and gitignored runtime paths. (best practice) [sources: src/devops_cli/ai/knowledge_base/it_domains/tools/valkey.md, src/devops_cli/ai/knowledge_base/it_domains/tools/ollama.md, k8s/README.md, SECURITY.md]
    • Chosen: Skip a token that is not path-shaped. The examples are not repository paths, and an allow list is forbidden.
    • Rejected: Allow list of tokens. It hides a stale path, and the body forbids it.
    • Rejected: Inspect every slash token. It reports 63 findings, including tokens that are not paths.
  • How does the rule treat a glob that names a directory?: The rule matches a glob against the tracked files and their parent directories. So tests/gate/*_checks/ passes when a file under tests/gate/tree_checks/ is tracked. (best practice) [sources: CONTRIBUTING.md, src/devops_cli/roadmap/stage/stage_paths.py]
    • Chosen: Match files and their parent directories. git ls-files lists files, and a directory glob names a directory.
    • Rejected: Match files only. tests/gate/*_checks/ then fails on a tracked directory.
    • Rejected: Rewrite the glob. It changes the document and hides the real path form.
  • How does the change treat docs/HOMELAB_REPO_SWITCH.md and the homelab k8s/ paths?: The change classifies docs/HOMELAB_REPO_SWITCH.md as a record, so the rule skips it. The change fixes each stale k8s/ path in the hand-written documents that remain. (best practice) [sources: docs/HOMELAB_REPO_SWITCH.md, src/devops_cli/config/constants.py, docs/CLUSTER.md, k8s/README.md]
    • Chosen: Record class for the switch page and fix the other paths. The page records a past switch, and the other documents name live paths.
    • Rejected: Allow list for the page. It hides a stale path, and the body forbids it.
    • Rejected: Skip every k8s/ path. It misses a stale live path under k8s/.
  • How does the change fix each finding, including the 63 findings on main?: Each finding is fixed by rewording the sentence, linking the path or narrowing the stated scope. The module holds no list of accepted paths. AGENTS.md rule 11 asks for the cause to be fixed. (best practice) [sources: AGENTS.md]
    • Chosen: Reword, link or narrow the stated scope. The document then names a path that exists, and the check stays true for the next change.
    • Rejected: Allow list of accepted paths. It hides a stale path, and the body forbids it.
    • Rejected: Fix only the 19 low-confidence tokens. The rule reports 63 findings on main, so the row would fail.
  • Should the prompt class be checked in this change?: No. The prompt class is deferred. Prompt documents hold illustrative paths such as src/app.py:12 and tests/roadmap/test_feature.py, which are not tracked files. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_stage_change.md, docs/TESTING.md]
    • Chosen: Defer the prompt class. The prompt examples are not tracked files, and the rule would report false findings.
    • Rejected: Check the prompt class now. It reports illustrative paths as stale.
    • Rejected: Skip every prompt path. It leaves a stale real path in a prompt unchecked with no marker.
  • How does the change hold the 8 s budget of the docs row?: The rule starts one git ls-files and reads each document once. No test bounds elapsed wall-clock time from above, per docs/TESTING.md. A person measures the docs row on the runner after the merge. (best practice) [sources: docs/TESTING.md]
    • Chosen: One git call and one read for each document. It is the smallest work that gives the tracked set and the code spans.
    • Rejected: Test that asserts the row ends within 8 s. docs/TESTING.md forbids a test that bounds elapsed wall-clock time from above.
  • When does the rule join the docs row?: The rule joins the docs row after docs: fix the stale statements that the content census found #4894 lands and when its run on main gives 0 findings. The change fixes all findings on main in the same pull request. (best practice) [sources: docs/ROUTINE_TASKS.md, AGENTS.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4894

Moved to new items

#7652

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/docs
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. added
    effort/medium
    and removed
    effort/medium
    on Nov 12, 2026
  4. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/docs. The (docs) scope of the title gives the scope.
    • Priority: P2-Medium. It catches a recurring class of documentation errors but does not block a release or fix a security issue.
    • Value: Medium. It prevents a known recurring class of wrong-path references in documentation.
    • Effort: Medium. About 150 lines plus tests and updates to two files, estimated at 2.5 hours.
    • Related: fix(docs): rule documents name files that are gone or moved #3508, which asks for a different change. Both address documents that name files that are gone or moved; 3508 fixes specific text, the candidate adds a check that catches such paths.
  5. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

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

    • Priority: P2-Medium. The check prevents recurring stale paths, but it depends on 4894 and is not urgent.
    • Value: Medium. It stops wrong paths in docs from misleading users and agents.
    • Effort: Medium. It needs about 150 lines, tests, and a decision on 19 low-confidence tokens.
    • Related: docs: fix the stale statements that the content census found #4894, which asks for a different change. Both items address stale document paths from the content census; 4894 fixes the findings, while the candidate adds a check that prevents new ones.
  6. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: The searches found only general Markdown link checkers; lychee validates local file link targets in a document, which covers the link-target half of keeping stale paths out of the docs. None of the tools parse inline code spans, resolve them against git ls-files, match globs or suggest the probable new path, so the rule this issue asks for is not covered.

    Tool: lycheeverse/lychee (https://github.com/lycheeverse/lychee)

    • License: Apache-2.0
    • Last activity: 2026-11-13
    • Maintained: yes

    Covers:

    • Checks links in Markdown documents, including local file targets, so a document that points at a moved or deleted file can be caught
    • Runs offline against the working tree, without network access
    • Reports the document that holds the broken target
    • Accepts include and exclude patterns for the files it checks

    Lacks:

    • Reads Markdown link targets only, not inline code spans, so the paths this issue targets are not inspected
    • Has no rule that the first segment of a code span must be a tracked top-level entry or a package under src/devops_cli
    • Does not resolve a path against git ls-files or match globs inside a code span
    • Has no (target) marker for a planned path
    • Does not name the tracked file with the same base name as the probable new path
    • Does not route bare file names to a separate scheduled rule
    • Cannot replace the existing docs rule or its test inside devops docs check

    Tools considered:

    Searches run:

    • lychee link checker relative file paths markdown offline, results: 5
    • tool that checks file paths in markdown docs against git tracked files, results: 5
    • lychee link checker github, results: 5
    • remark-validate-links verify markdown links to local files exist, results: 5
    • lycheeverse lychee, results: 5
    • markdown link checker validate code spans paths repository, results: 5
    • remark-lint-relative-links github, results: 5
    • validate file paths inside inline code spans in markdown documentation tool, results: 5
    • lycheeverse lychee offline check local file links markdown, results: 5
    • github action verify file paths referenced in documentation code blocks exist in repository, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at fccb781 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.

  8. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  9. 6 remaining items

  10. added
    status/new
    and removed
    owner/agent
    on Nov 28, 2026
  11. added
    status/ready
    and removed
    status/new
    on Nov 28, 2026
  12. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  13. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  14. removed
    status/in-review
    on Nov 29, 2026
  15. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 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/docssource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions