Skip to content

feat(docs): devops docs drift reports the drift that no PR check finds #4920

Not planned

Description

@dan-petty

Problem or Motivation

Some drift has no PR cause, or a PR rule for it would give false positives. The census baseline has:

  • closed items named as open with no PR cause (Metrics and logs are kept for two hours #550 at k8s/README.md lines 346 and 499);
  • identifiers (docs/TESTING.md FakeValkeyClient, valkey.md is_safe_endpoint(), and 2 living low);
  • 11 bare file names;
  • copied CONST_/DEFAULT_ values (docs/KNOWN_ISSUES.md line 26);
  • 48 findings in ADRs in force;
  • knowledge base review age;
  • dead external URLs;
  • duplicated rules.

No command finds them today. The census script of the study is not in the repository.

Proposed Solution & Architectural Design

Add devops docs drift [--rule <name>] [--offline] [--format json] [--dry-run]. It runs every rule of the rule module of #4904 and these scheduled rules:

  1. Closed items named as open: read the listing snapshot of perf(roadmap): intake reads only the issues that changed #4552 (0 requests), else paced REST.
  2. Identifiers in code spans, against an AST and import index of src/ and tests/.
  3. Bare file names.
  4. Copied CONST_/DEFAULT_ values with unit conversions. When a measured run on main shows 0 false positives, this rule moves to the docs row.
  5. ADRs in force that name a removed path or command, as a finding that asks for a superseding ADR or a status change.
  6. Knowledge base review age (setting docs.kb_review_max_age_days, default 180) and DriftManual.
  7. A reader for lychee JSON output.
  8. Duplicated rules: Qdrant similarity between chunks of two standards documents in the existing RAG docs collection, with 0 model calls. --offline skips this rule and says so.

Each finding has file, line, token, rule, class, area, evidence and a proposed fix. --dry-run sends 0 requests. Add a "content census" routine to docs/ROUTINE_TASKS.md, so agents can run it before the brain runs exist.

Target Subsystem

SDLC, Git & PR Governance (devops docs, docs/ROUTINE_TASKS.md).

Existing Tool Considered

lychee (external URLs), Qdrant (the existing collection), ast, git and the listing snapshot. No open tool covers the project-specific rules. Cost: about 300 lines plus tests, about 250k tokens and 5 h.

Acceptance Criteria

  • Tests use the census findings as fixtures, and each of the 8 rules finds its planted defect.
  • --dry-run sends 0 requests (a test).
  • On main, --offline finishes in under 60 s on the devcontainer.
  • The duplicated-rule rule finds the coverage-rule pair of CONTRIBUTING.md and docs/TESTING.md in a fixture.
  • docs/ROUTINE_TASKS.md has the routine.

Dependencies

#4904, #4910.

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 lychee, a maintained open link checker with JSON output, which covers only the dead external URL rule; nothing found covers the seven project-specific rules (closed items, identifiers, constants, stale ADRs), so the command must build them.

Covers:

  • Dead external URL detection in Markdown and HTML
  • JSON report that a drift command can convert
  • Deterministic CLI check with no model calls

Lacks:

  • Closed issues still named as open in documents
  • Code-span identifiers checked against an AST and import index
  • Bare file names, copied constants, stale ADR references, duplicated rules

Proposed design

Problem statement

Add devops docs drift to report documentation drift that no pull request check finds. The command uses the rule module of #4904 and the scheduled rules of this issue. It reads lychee JSON for dead external URLs and builds the project-specific rules. It waits on #4904 and #4910.

Acceptance criteria

Requirement: Drift command runs the rule set

The devops docs drift command SHALL run each rule of the rule module of #4904 and each scheduled rule of this issue.

Scenario: All rules run

  • WHEN A test runs the command against a fixture repository built from the census findings with one planted defect for each rule.
  • THEN The command reports at least one finding for each planted defect.

Requirement: Closed item from snapshot

The command SHALL report a closed item that a document names as open from the listing snapshot of #4552 when the snapshot is present.

Scenario: Closed item from snapshot

  • WHEN A fixture document names issue 550 as open and the listing snapshot marks issue 550 closed.
  • THEN The command reports a finding at the document line with rule closed-item-open and sends no REST request.

Requirement: Closed item from REST fallback

The command SHALL use paced REST to get the open or closed state of an item when the listing snapshot of #4552 is absent.

Scenario: Closed item from REST

  • WHEN A test runs the command on a fixture with no listing snapshot and a stub REST client that marks issue 550 closed.
  • THEN The command reports a finding with rule closed-item-open and the stub records one paced REST request.

Requirement: Identifier checked against code index

The command SHALL report an identifier in a code span that the AST and import index of src/ and tests/ does not define.

Scenario: Unknown identifier

  • WHEN A fixture document has the code span FakeValkeyClient and the fixture index has no such symbol.
  • THEN The command reports a finding with the file, line, token FakeValkeyClient and rule identifier.

Requirement: Bare file name

The command SHALL report a bare file name that has no repository path.

Scenario: Bare file name

  • WHEN A fixture document contains valkey.md with no repository path.
  • THEN The command reports a finding with rule bare-file-name and the token valkey.md.

Requirement: Copied constant mismatch

The command SHALL report a copied CONST_ or DEFAULT_ value when the document value differs from the code value after unit conversion.

Scenario: Copied constant mismatch

  • WHEN A fixture document states DEFAULT_SAMPLE_TIMEOUT_SECONDS = 3600.0 and the fixture source sets DEFAULT_SAMPLE_TIMEOUT_SECONDS to 1200.0.
  • THEN The command reports a finding with rule copied-constant and the two values.

Requirement: Copied constant unit conversion

The command SHALL convert units before it compares a copied CONST_ or DEFAULT_ value.

Scenario: Copied constant with unit conversion

  • WHEN A fixture document states DEFAULT_SAMPLE_TIMEOUT_SECONDS = 60 and the fixture source sets it to 60.0 seconds.
  • THEN The command reports no copied-constant finding.

Requirement: ADR names a removed command

The command SHALL report an ADR in force that names a removed path or command and SHALL propose a superseding ADR or a status change.

Scenario: ADR names removed command

  • WHEN A fixture ADR with status accepted names a command that the fixture command index marks removed.
  • THEN The command reports a finding with rule adr-stale-reference and a proposed fix that names a superseding ADR or a status change.

Requirement: Superseded ADR gets a count only

The command SHALL count a superseded ADR and SHALL report no stale-reference finding for it.

Scenario: Superseded ADR gets a count

  • WHEN A fixture ADR with status superseded names the same removed command.
  • THEN The command reports one count for the ADR and no adr-stale-reference finding.

Requirement: Knowledge base review age

The command SHALL report a knowledge base document whose review age exceeds docs.kb_review_max_age_days, with default 180, and SHALL read the DriftManual.

Scenario: Old knowledge base review

  • WHEN A fixture knowledge base document has a review date older than 180 days, the setting is unset, and the DriftManual lists the document.
  • THEN The command reports a finding with rule kb-review-age and the age in days.

Requirement: Lychee JSON reader

The command SHALL read lychee JSON output and convert each dead external URL into a finding.

Scenario: Lychee dead URL

  • WHEN A test feeds lychee JSON with one error for https://example.invalid/dead.
  • THEN The command reports one finding with rule external-url and the URL.

Requirement: Duplicated rules

The command SHALL report duplicated rules from Qdrant similarity of chunks in the existing RAG docs collection, with 0 model calls.

Scenario: Duplicated coverage rule

  • WHEN A Qdrant stub returns two similar chunks from CONTRIBUTING.md and docs/TESTING.md in the RAG docs collection.
  • THEN The command reports a finding with rule duplicated-rule and makes no model call.

Requirement: Offline mode skips Qdrant

The command SHALL skip the duplicated-rule rule in --offline mode and SHALL state that it skipped the rule.

Scenario: Offline skips Qdrant

  • WHEN A test runs devops docs drift --offline with a Qdrant stub.
  • THEN The command sends no Qdrant request and prints a message that names the skipped rule.

Requirement: Dry run sends no request

The command SHALL send 0 requests in --dry-run mode.

Scenario: Dry run sends no request

  • WHEN A test runs devops docs drift --dry-run with a request counter on the REST and Qdrant clients.
  • THEN The counter records 0 requests.

Requirement: JSON finding schema

The command SHALL write each finding with file, line, token, rule, class, area, evidence and proposed fix in --format json.

Scenario: JSON finding schema

  • WHEN A test runs devops docs drift --format json on a fixture with one defect.
  • THEN Each finding object in the JSON output has the eight keys.

Requirement: Rule filter

The command SHALL run only the named rule when --rule <name> is given.

Scenario: Rule filter

  • WHEN A test runs devops docs drift --rule bare-file-name on a fixture with a bare file name and a closed item.
  • THEN The command reports the bare file name finding and no closed item finding.

Requirement: Content census routine

docs/ROUTINE_TASKS.md SHALL hold a content census routine that agents run before the brain runs exist.

Scenario: Routine present

  • WHEN The docs test suite runs after the routine is added.
  • THEN The test finds a content census section in docs/ROUTINE_TASKS.md that names the command devops docs drift.

Requirement: Offline run time

On main, devops docs drift --offline SHALL finish in under 60 s on the devcontainer.

Scenario: Offline run time

  • WHEN The live check uv run devops docs drift --offline runs on the devcontainer at main.
  • THEN The elapsed time is under 60 s.

Existing Tool Considered

The alternatives check in the issue body gives verdict partly for lycheeverse/lychee (Apache-2.0, maintained). The proposal uses lychee JSON output for the dead external URL rule and refers to that block for what lychee covers and lacks. The proposal builds the other seven project-specific rules because the block lists them as lacks. The built rules cost about 300 lines plus tests, about 250k tokens and 5 h.

Key questions

  • Which tool covers the external URL rule?: Use lycheeverse/lychee for the dead external URL rule. The alternatives check in the issue body gives verdict partly. The command reads lychee JSON output. The command builds the other rules. (best practice) [sources: AGENTS.md, docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: lycheeverse/lychee. The check gives verdict partly and lychee writes JSON for dead external URLs.
    • Rejected: custom external URL checker. It duplicates lychee and adds code to keep.
    • Rejected: markdownlint. It checks Markdown style, not dead external URLs.
    • Rejected: vale. It checks prose style, not dead external URLs.
  • Should the drift findings come from deterministic rules with no model calls?: Yes. Use deterministic rules. The duplicated-rule rule uses Qdrant similarity with 0 model calls. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md, AGENTS.md]
    • Chosen: deterministic rules. ADR 0005 admits findings from tools and checked facts, not models.
    • Rejected: model review. ADR 0005 rejects model-generated findings for this work.
  • How does the command get the open or closed state of an item?: Read the listing snapshot of perf(roadmap): intake reads only the issues that changed #4552 first. Use paced REST only when the snapshot is absent. (best practice) [sources: CONTEXT.md, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]
    • Chosen: listing snapshot first. The snapshot sends 0 requests and CONTEXT.md names the lane listing snapshot.
    • Rejected: paced REST every run. It spends rate limit and adds latency.
    • Rejected: no check. It misses the closed-item drift class.
  • Does --dry-run send no request?: Yes. The command sends 0 requests in --dry-run mode. (best practice) [sources: CONTEXT.md]
    • Chosen: no requests. CONTEXT.md defines a dry run as a step that sends no request.
    • Rejected: read-only requests. It breaks the --dry-run contract.
  • Should the duplicated-rule rule use the existing Qdrant RAG docs collection?: Yes. Use the existing RAG docs collection in Qdrant. Make 0 model calls. (best practice) [sources: src/devops_cli/ai/rag/indexer.py, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md]
    • Chosen: existing Qdrant collection. The RAG docs collection already holds the chunks and adds no store.
    • Rejected: new vector store. It adds a dependency and cost.
    • Rejected: text diff. It misses semantic duplication.
  • What does a finding in an ADR in force ask for?: Ask for a superseding ADR or a status change. Do not edit the ADR text to remove drift. A superseded ADR gets a count only. (best practice) [sources: CONTEXT.md]
    • Chosen: superseding ADR or status change. The issue body asks for one of these and an ADR is a record.
    • Rejected: edit the ADR text. An ADR is a record and a later change supersedes it.
    • Rejected: note at the top only. The issue body asks for a superseding ADR or a status change.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4904, #4910

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/docs
    status/new
    on Nov 12, 2026
  3. added
    value/medium
    effort/high
    on Nov 12, 2026
  4. added
    value/high
    and removed
    value/medium
    effort/high
    on Nov 12, 2026
  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.

    • 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 adds a new command, and no current failure blocks users.
    • Value: Medium. It finds documentation drift that no current check finds for maintainers and agents.
    • Effort: High. It adds 8 rules, tests and integrations in about 300 lines.
    • Related: feat(docs): docs check finds the delivered issue named as open #4912, which asks for a different change. Both find closed issues named as open, but 4912 adds a PR-time check from change folders and the candidate adds a scheduled drift command.
  6. added
    effort/high
    and removed
    priority/p2-medium
    on Nov 12, 2026
  7. 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 is a valuable new command but depends on #4904 and #4910 and is not blocking current work.
    • Value: High. Eight categories of docs drift are invisible today and affect project governance and accuracy.
    • Effort: High. Eight rules, multiple external integrations (lychee, Qdrant, AST), roughly 300 lines plus tests and 5 h of work.
    • Related: feat(ai): add devops ai agent-audit for recurring problems #2346, which asks for a different change. Both detect recurring problems that go unnoticed, but #2346 targets agent session patterns while this targets documentation drift across 8 specific rules.
  8. 9 remaining items

  9. added
    owner/service
    and removed
    owner/service
    on Nov 30, 2026
  10. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Plan state: branch feat/4920-devops-docs-drift-reports-the-drift, draft pull request #7989. The pull request plans the item and closes no issue. The stage job and the step fix-plan edit this comment, and a comment of each run tells what the run did.

    The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:

    1. Add the drift finding model and engine: 38260 tokens
    2. Add the identifier, bare file name and copied constant rules: 41131 tokens
    3. Add the setting docs.kb_review_max_age_days: 52433 tokens
    4. Add the ADR stale reference and knowledge base review age rules: 40313 tokens
    5. Add the closed item rule and the lychee JSON reader: 39091 tokens
    6. Add the duplicated rule check over Qdrant vectors: 56462 tokens
    7. Add the drift command to the docs group: 45448 tokens
    8. Add the content census routine and measure the run time: 20667 tokens

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • major ignores_existing_code at tasks (3): Group 3 tells the implementer to edit docs/CONFIGURATION.md by hand. A tool generates that file from settings.py and the file says not to edit it. A hand edit fails the docs check. The group should regenerate the file with uv run devops docs generate, as group 7 does for docs/commands/docs.md. Evidence: "Edit docs/CONFIGURATION.md to describe the key docs.kb_review_max_age_days and its default 180"
    • minor spec_delta_wrong at spec docs-drift (Content census routine): The scenario THEN says the routine section names the drift command. uv run devops ci docs exit 0 does not assert that. No test in the plan checks the section. The issue body asks for a docs test that finds the section. Evidence: "The command exits 0 and the routine task document holds a content census section that names the drift command."
  11. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The stage job staged the plan of draft pull request #7989. The plan state comment of #7989 holds the branch, the task groups and the findings.

    The default branch changed these paths that the plan names, after the commit that the planner read. Read the commits before you judge the plan:

    The runs of the planner and the review made 65 model request(s), and used 5847553 input tokens and 78876 output tokens. The tool calls, in order:

    Run 1 (stage):

    1. read_issue({"number":4904})
    2. repo_map({"directory":"src/devops_cli/docs"})
    3. search_code({"text":"docs_app.command","path":"src/devops_cli/commands"})
    4. search_code({"text":"devops docs","path":"src/devops_cli/commands"})
    5. file_symbols({"path":"src/devops_cli/commands/docs.py"})
    6. read_file({"path":"src/devops_cli/commands/docs.py"})
    7. read_issue({"number":4910})
    8. search_code({"text":"path_collector"})
    9. read_file({"path":"src/devops_cli/docs/stale_issue.py"})
    10. search_code({"text":"drift_manual"})
    11. search_code({"text":"class DriftManual","path":"src"})
    12. read_file({"path":"src/devops_cli/ai/kb.py","start_line":200,"end_line":340})
    13. search_code({"text":"class DocsSettings","path":"src"})
    14. search_code({"text":"kb_review","path":"src"})
    15. search_code({"text":"alternatives_recheck_days","path":"src"})
    16. search_code({"text":"docs: ","path":"src/devops_cli/config/settings.py"})
    17. search_code({"text":" docs","path":"src/devops_cli/config/settings.py"})
    18. search_code({"text":"class Settings(","path":"src/devops_cli/config/settings.py"})
    19. read_file({"path":"src/devops_cli/config/settings.py","start_line":2913,"end_line":3000})
    20. references({"name":"UIConfig"})
    21. references({"name":"DEFAULT_ROADMAP_ALTERNATIVES_RECHECK_DAYS"})
    22. references({"name":"recheck_days"})
    23. read_issue({"number":4552})
    24. search_code({"text":"class SnapshotStore","path":"src"})
    25. file_symbols({"path":"src/devops_cli/roadmap/stores/listing_snapshot.py"})
    26. read_file({"path":"src/devops_cli/roadmap/stores/listing_snapshot.py","start_line":60,"end_line":185})
    27. search_code({"text":"class IssueRecord","path":"src"})
    28. read_file({"path":"src/devops_cli/roadmap/stores/store.py","start_line":748,"end_line":790})
    29. search_code({"text":"def ","path":"src/devops_cli/ai/rag/indexer.py"})
    30. read_file({"path":"src/devops_cli/ai/rag/indexer.py","start_line":790,"end_line":884})
    31. search_code({"text":" def ","path":"src/devops_cli/ai/rag/qdrant.py"})
    32. read_file({"path":"src/devops_cli/ai/rag/qdrant.py","start_line":322,"end_line":376})
    33. search_code({"text":"site_strict"})
    34. read_file({"path":"src/devops_cli/lang/en/help.py","start_line":1340,"end_line":1385})
    35. read_spec({"capability":"docs-reference-checks"})
    36. read_spec({"capability":"docs-code-span-paths"})
    37. search_code({"text":"## ","path":"docs/ROUTINE_TASKS.md"})
    38. search_code({"text":"lychee"})
    39. read_file({"path":"src/devops_cli/roadmap/steps/pages_health.py","start_line":598,"end_line":645})
    40. search_code({"text":"site build","path":"docs/commands"})
    41. search_code({"text":"site_outside_nav","path":"src/devops_cli/lang"})
    42. search_code({"text":"class GitHubRoadmapStore","path":"src/devops_cli/roadmap/stores"})

    Run 2 (stage):

    1. file_symbols({"path":"src/devops_cli/commands/docs.py"})
    2. read_file({"path":"src/devops_cli/commands/docs.py","start_line":1,"end_line":70})
    3. file_symbols({"path":"src/devops_cli/roadmap/adr.py"})
    4. file_symbols({"path":"src/devops_cli/docs/path_collector.py"})
    5. search_code({"text":"def adr_of(","path":"src/devops_cli/roadmap/adr.py"})

    Run 4 (stage_verify):

    1. search_code({"text":"class DocsConfig"})
    2. search_code({"text":"class DriftManual"})
    3. search_code({"text":"def rag_collection_names"})
    4. search_code({"text":"def scroll_points","path":"src/devops_cli/ai/rag/qdrant.py"})
    5. read_file({"path":"src/devops_cli/ai/rag/qdrant.py","start_line":350,"end_line":375})
    6. search_code({"text":" docs: ","path":"src/devops_cli/config/settings.py"})
    7. search_code({"text":"def setting_default"})

    Run 5 (stage):

    1. search_code({"text":"CONFIGURATION.md","path":"src/devops_cli/docs"})

    Run 6 (stage_verify):

    1. search_code({"text":"class DocsCommandHelp","path":"src/devops_cli/lang/en"})
    2. search_code({"text":"CONST_SETTINGS_SECTION_METADATA","path":"src/devops_cli"})
    3. read_file({"path":"src/devops_cli/docs/generator.py","start_line":1015,"end_line":1060})
    4. search_code({"text":" docs: ","path":"src/devops_cli/config/settings.py"})

    Tool calls: file_symbols=5 (empty=0), read_file=13 (empty=0), read_issue=3 (empty=0), read_spec=2 (empty=0), references=3 (empty=0), repo_map=1 (empty=0), search_code=32 (empty=8)

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

    The plan request held these comments of the item whole: #4920 (comment), #4920 (comment), #4920 (comment), #4920 (comment), #4920 (comment), #4920 (comment).

    Warnings:

    • Scoped test tests/docs/test_docs_drift.py does not exist.
    • Scoped test tests/docs/test_docs_drift_text_rules.py does not exist.
    • Scoped test tests/config/test_docs_settings.py does not exist.
    • Scoped test tests/docs/test_docs_drift_adr_rules.py does not exist.
    • Scoped test tests/docs/test_docs_drift_remote_rules.py does not exist.
    • Scoped test tests/docs/test_docs_drift_duplicates.py does not exist.
    • Scoped test tests/commands/test_docs_drift_command.py does not exist.
  12. removed
    owner/service
    on Dec 1, 2026
  13. added 3 commits that reference this issue on Dec 1, 2026
  14. added
    status/planned
    and removed
    status/ready
    on Dec 1, 2026
  15. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor

    Review of #7989 on 2026-12-01: the plan is merged, but the Service does not build it. #7975 limits its jobs to bug and security items, and the implement job also excludes effort/high. A person or an agent must claim the item, run it with --item, or close it. It counts toward roadmap.stage.planned_limit. One open defect: the routine scenario states that ci docs proves that the section exists, and that check does not.

  16. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor

    Closed by the owner decision of 2026-12-01. The Service builds bug and security items only (#7975), and no person or agent claims this item. The plan of #7989 stays in openspec/changes/ until a cleanup removes it. File a new item if devops docs drift is wanted again.

  17. removed
    status/planned
    on Dec 1, 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/highpriority/p2-mediumscope/docssource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions