Skip to content

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

Open

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-21: partly.
Tool: lycheeverse/lychee (https://github.com/lycheeverse/lychee), Apache-2.0, last activity 2026-11-16, maintained.
Reason: Searches found only link checkers: lychee reports broken hyperlinks and local file link targets, but it reads no inline code spans and resolves nothing against the tracked git tree, so it covers only part of the need.

Covers:

  • Broken hyperlink and mail address detection in Markdown and HTML
  • Resolution of local file link targets
  • Findings that name the file and line
  • Relative URL and anchor fragment checks

Lacks:

  • No read of inline code spans
  • No resolve against the git ls-files tracked set
  • No glob match for a code-span path
  • No (target) mark or <...> placeholder handling
  • No probable new path in the message

Proposed design

Problem statement

Add the code-span path rule to devops docs check after #4894 lands and when the rule reports 0 findings on main. Fix the 19 low-confidence tokens in the same pull request, delete the old test, and update CONTRIBUTING.md and the Documentation Sync row. The only check of a documentation path reads docs/TESTING.md. The content census at cd6fb76 found 10 living high and 19 living low path findings. The standards pass of 2026-11-11 (#4772) fixed 22 moved test paths by hand. A code span in a hand-written document, a prompt, a project skill or the knowledge base can name a path that git does not track, and no check reports it.

Acceptance criteria

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

devops docs check SHALL run the code-span path rule from a module under src/devops_cli/docs/ over the hand-written and prompt documents, which include the project skills and the knowledge base.

Scenario: Each document kind is inspected

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

Requirement: A code span at a tracked top-level entry 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: A code span at a src/devops_cli package must exist

The rule SHALL report a finding when the first segment of a code span is a package directory under src/devops_cli 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: A glob in a code span matches a tracked file

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

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: 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 a <...> 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: 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: 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 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 Documentation Sync 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: 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-21 in the issue body records partly for lychee (https://github.com/lycheeverse/lychee), Apache-2.0, maintained; its Covers: and Lacks: lists are the record. This change builds the code-span rule that lychee lacks with git ls-files and markdown-it-py, at 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: 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 from DocGenerator.check_docs. The docs row of devops ci runs devops docs check. (best practice) [sources: src/devops_cli/commands/docs.py:150, src/devops_cli/docs/generator.py:1392, docs/SDLC.md:215, docs/ROUTINE_TASKS.md:33]
    • Chosen: module under src/devops_cli/docs/. The command already 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 and prompt classes of CONST_DOCS_NAME_CHECKED_CLASSES. The hand-written class is the complement of the inventory, so it holds the project skills and the knowledge base. The prompt class holds src/devops_cli/ai/personas/**/*.md and src/devops_cli/ai/tasks/**/*.md. (best practice) [sources: src/devops_cli/config/constants.py:532, src/devops_cli/config/constants.py:519, src/devops_cli/config/constants.py:523, src/devops_cli/docs/inventory.py:37]
    • Chosen: hand-written and prompt classes. The hand-written class includes the project skills and the knowledge base; the prompt class covers the documents a model loads at run time.
    • Rejected: every class of the inventory. Generated pages are checked against their generator, records are history, and tool-generated skills are checked against regeneration.
    • Rejected: hand-written only. A stale path in a prompt sends the model to a missing file.
  • How does the rule read the tracked files?: The rule starts one git ls-files -z through run_subprocess for each run and reads each document once. list_repo_files adds untracked files with --others, so it is no substitute. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py:143, src/devops_cli/core/repo.py:628, docs/TESTING.md:80]
    • Chosen: one git ls-files -z call through run_subprocess. docs/TESTING.md holds every start of git to the process runner, and one call gives the tracked set of the whole run.
    • 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 of git 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, skips fenced code blocks and takes each inline code span with its line number, as the 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:30, src/devops_cli/docs/markdown_argv_collector.py:138, src/devops_cli/docs/markdown_argv_collector.py:158]
    • Chosen: line-by-line inline code regex. It gives the exact line of each span and skips fenced blocks, which the docs row needs for file:line.
    • Rejected: the markdown-it token map. The map gives the line of the inline block, not the line of each span inside a multi-line paragraph.
    • Rejected: a full markdown parse and a search for each span. A span can repeat, and a search gives no reliable line.
  • How does the rule match a glob in a code span?: The rule matches the glob against the tracked list with fnmatch.fnmatchcase, and only when glob.has_magic says the span is a glob. A glob that matches no tracked file is a finding. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py:199, src/devops_cli/roadmap/stage/stage_paths.py:53]
    • Chosen: match against the git ls-files list with fnmatch.fnmatchcase. StagedTree.has does this with has_magic; the tracked list is the subject of the rule, and the standard library supplies the matcher.
    • Rejected: walk the working tree with glob.glob. It counts an untracked file as a match, so a stale glob can pass.
  • Which code spans does the rule inspect?: The rule inspects a code span only when it holds a / or a glob and its first segment is a tracked top-level entry or a package directory under src/devops_cli. A package-relative span resolves as src/devops_cli/<span> as well as at the root. 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:209, src/devops_cli/roadmap/stage/stage_paths.py:217, src/devops_cli/roadmap/init.py, src/devops_cli/docs/init.py]
    • Chosen: first segment is a tracked top-level entry or a src/devops_cli package, with a slash or a glob. StagedTree.as_path requires a slash and a known first folder; the package branch adds the module paths that documents name relative to the package.
    • Rejected: every code span that holds a slash. It reports commands and URLs, 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 the (target) mark?: A code span that an emphasis starting with (target) follows names a planned path, so the rule reports no finding for it. docs/TESTING.md already marks a name that does not exist yet this way, and the deleted test reads it the same way. (best practice) [sources: docs/TESTING.md:57]
    • Chosen: skip a code span that an emphasis starting with (target) follows. docs/TESTING.md already uses *(target)* for a path that does not exist yet, and the deleted test reads the mark the same way.
    • Rejected: an allow list in the module. An allow list hides a stale path, and the body forbids it.
    • Rejected: a TODO comment beside the path. It is invisible in the rendered page and it needs a second rule to find it.
  • How does the rule treat a <...> placeholder?: It resolves only the text before the first <...> placeholder. So tests/support/fakes/<edge>.py passes when tests/support/fakes/ is tracked, and tests/nowhere/<edge>.py fails when it is not. This keeps the behavior of the test that the change deletes. (best practice) [sources: docs/TESTING.md:82]
    • Chosen: resolve the text before the placeholder. The deleted test does this; docs/TESTING.md:82 holds tests/support/fakes/<edge>.py, and the folder is tracked.
    • Rejected: skip every span with a placeholder. A placeholder under a missing folder would pass, and the deleted test reports it.
    • Rejected: treat the placeholder as a glob. < is no glob character, and the tracked set holds no file with it.
  • How does the message name the probable new path?: The rule lists the tracked files with the same base name, sorted, at most five, and names each in the message. It does not guess one. When no tracked file has that base name, the message says so. This is the same_name index of StagedTree. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py:205, src/devops_cli/roadmap/stage/stage_paths.py:71]
    • Chosen: list the tracked files with the same base name, sorted, at most five. StagedTree.same_name builds the index and caps the list; a person or agent copies a real path.
    • Rejected: name the one tracked file with the same base name. A guess hides a wrong path when several files share the name.
    • Rejected: a similarity search of git history. It needs the old blob, and a document holds no commit.
  • Does the new rule replace the test that reads only docs/TESTING.md?: Yes for a path that starts at a tracked top-level entry or a src/devops_cli package, such as tests/invariants/test_agents_md.py. A bare file name in docs/TESTING.md has no check until child 12 of feat(docs): track current content and brain-fed reference docs #4880 lands. (best practice) [sources: docs/TESTING.md]
    • Chosen: delete test_the_test_rules_name_only_test_files_that_exist. The new rule reports the same stale test paths and reads every document class; the placeholder and (target) behavior is kept.
    • Rejected: keep both tests. Two checks report one stale path, and the old test reads one file.
  • How does the change fix a finding, including the 19 low-confidence tokens?: Each finding is fixed by rewording the sentence, linking the path or narrowing the stated scope. The module holds no list of accepted paths. docs/SDLC.md forbids an escape or exemption to make a check pass, and AGENTS.md rule 11 asks for the cause to be fixed. (best practice) [sources: docs/SDLC.md:223, AGENTS.md:17]
    • 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: an allow list of accepted paths. It hides a stale path, and the body forbids it.
  • 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:154, src/devops_cli/roadmap/stage/stage_paths.py:143]
    • 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: a 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 the 19 low-confidence tokens in the same pull request. (best practice) [sources: docs/ROUTINE_TASKS.md:33, docs/SDLC.md:215]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4894

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.

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/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions