Skip to content

fix(ai): the knowledge base names only commands, options and components that exist #920

Closed

Description

@dan-petty

Problem Statement

The AI knowledge base (src/devops_cli/ai/knowledge_base/, 80 articles under devops_cli/ and it_domains/) is indexed for RAG by WorkspaceIndexer.index_knowledge_base (src/devops_cli/ai/rag/indexer.py:406) and is what devops ai chat --rag and the agent harness retrieve. It names commands, options and components that do not exist; each example was confirmed against the command tree at HEAD with resolve_devops_argv:

  • devops tofu (the command is devops tf); top-level devops rag (it lives under devops ai rag);
  • ai review patch, release bump and release create-pr (the release commands are release prepare and release pr);
  • scan security, scan image, scan kubelinter, scan popeye, scan pluto, scan semgrep, scan gitleaks, scan fs, scan k8s (the scanners are trivy, secrets, sast, iac, complexity, sbom, aibom, fix, report, sarif);
  • deploy-stack monitoring (stacks are chosen with --stack from infra, llm, logging and all);
  • review --provider/--model, --post-pr, ai tokens and telemetry probe;
  • settings classes and env vars that are not the real ones (DEVOPS_CLI_CONFIG_PATH, DEVOPS_CLI_LOG_LEVEL; the real override is DEVOPS_CLI_CONFIG, src/devops_cli/config/constants.py:19).

So the assistant and agents are taught commands that fail. A fact-check on 2026-10-02 checked 1,129 claims against the release/v0.2.25 tip (c279c18); a second agent re-checked every finding and confirmed each one false. 129 findings are in the knowledge base, 25 of them high severity in cli_command_reference.md alone. Since c279c18 exactly one knowledge-base line has changed: 6e5bb1f (#945) inserted a line at tasks/rag_context_indexing.md:52, so that article's findings from :65 on are one line lower (:66); every other line number holds (git diff --stat c279c18 HEAD -- src/devops_cli/ai/knowledge_base). Three items that land first also edit the directory (#420 and #767 in v0.2.26, #840 in v0.2.27) and #431 (v0.2.26) changes the extractor rule two lines describe without editing any article, so the pull request re-reads each cited line at its own tip before editing: the findings name what is wrong, not a byte offset.

A prototype of the test in the acceptance criteria, run during refinement, extracts about 465 devops … invocations from the knowledge base, of which about 118 fail to resolve, across 41 of the 80 articles (two independent prototypes gave 463/116/40 and 466/118/41; the counts depend on how comments, pipes and placeholders are cut). Between 60 and 71 of the failures are in it_domains/, which the findings list does not name at all (for example it_domains/tools/opentofu_terraform.md:35-47 devops tofu …, it_domains/tools/argocd.md:22-31 devops argo list|status|rollback and argo sync --app-name, it_domains/tools/valkey.md:48-55 --pattern, --ttl, --namespace, it_domains/topics/model_governance_routing_and_curation.md:126-135 ai curate-model, --orchestration-shape). The findings list is the floor, not the ceiling, for command lines: the pull request fixes every invocation the test reports.

The test cannot see everything the findings list names. devops_cli/cli_command_reference.md holds its 25 high findings in a table whose cells read `review patch`, `scaffold`, `tidy` with the group in a separate column, and the file contains no devops -prefixed code span at all (rg -c 'devops ' src/devops_cli/ai/knowledge_base/devops_cli/cli_command_reference.mdmatches nothing), so an invocation extractor reports nothing there. Settings classes, env vars, pinned versions, module paths and relative links are likewise invisible to the test; those stay hand-fixed from the list and are held by therg` criteria below.

Proposed Solution

  1. Correct every finding in the list below and every further invocation the new test reports, so each devops … command line in the knowledge base resolves against the real command tree. Where a described feature does not exist (ai review patch, scan kubelinter, argo rollback), describe what exists instead of inventing an option; where the article is about a third-party tool with no devops wrapper (popeye, pluto, semgrep as separate scan subcommands), name the real wrapper (devops scan report, devops scan sast, devops k8s lint) or drop the devops prefix and show the tool's own command. Never write a count that the code can change (gate count, command-group count, MCP tool count, ruff rule list): AGENTS.md:73-75 prohibits numbered gates, and the replacements below were corrected to name the source instead.
  2. Add a markdown argv collector next to the MCP one (src/devops_cli/docs/mcp_argv_collector.py, from fix(mcp): mcp tools and resources call commands and options that exist #836): it reads every src/devops_cli/ai/knowledge_base/**/*.md, extracts devops … command lines from fenced code blocks and inline code spans, tokenises them, turns placeholders into ArgvPlaceholder, and resolves each with resolve_devops_argv (src/devops_cli/docs/command_resolver.py:77). Unresolved lines are reported as <path>:<line> through MESSAGES.docs.argv_unresolved (src/devops_cli/lang/en/messages.py:322), as the MCP check already does (mcp_argv_collector.py:79).
  3. Add a test that asserts the collector reports nothing, following tests/test_docs_mcp_argv_collector.py::test_every_mcp_server_argv_resolves (build each module's command tree first, then patch subprocess.Popen so resolving can never spawn). The test fails on today's knowledge base.
  4. Wire the collector into DocGenerator.check_docs (src/devops_cli/docs/generator.py:1080-1087) beside check_mcp_server_argv, so devops docs check and the docs gate of devops ci catch a future regression without waiting for pytest. This is the owner's answer to the first key question and the deliverable of the hand-written roadmap entry "Phantom Command, Option and Tool Reference Gate (devops docs check)" (docs/ROADMAP.md:917), which this item absorbs; the entry is retired at the next roadmap render, not by this pull request.
  5. Make cli_command_reference.md visible to the test by writing each subcommand cell as a full devops <group> <subcommand> span (the owner's answer to the second key question); the options column stays hand-checked.
  6. Fix the non-command claims in the findings list (settings classes, env vars, pinned versions, module paths, relative links) by hand; the test cannot see these. Lines that feat(cli): extend the ruff rule set to the correctness families #420 and refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26) rewrite are kept as those items wrote them (see Scope); fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 (v0.2.26) edits no article but changes the extractor rule, so the replacements for libraries/tldextract.md:19 and python_packages.md:199 describe the rule fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 ships.
  7. Take every remaining wording fix under src/devops_cli/ai/knowledge_base/**, including the it_domains/ lines docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 names (the owner's answer to the third key question). This item branches after docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 has merged, so tasks/agent_instructions_scaffolding.md:36 documents devops ai agents --force as docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 defines it and the collector proves the line resolves.
  8. Record the change in changelog.d/920.md and the task file docs/agent/tasks/task-920-knowledge-base-names-only-what-exists.md, which carries the full findings list with every replacement text.

Scope

Key Questions

Acceptance Criteria

  • Every finding in the fact-check list (129 knowledge-base findings; the high findings and every corrected replacement are reproduced below, the rest follow the rules below and are carried in full in the task file) is corrected, using the replacement texts corrected during refinement and at apply time (marked) instead of the originals. Shown by: each cited line reads as its replacement (git diff of the pull request) and the new test passes.
  • A new collector in src/devops_cli/docs/ extracts every devops …, uv run devops … and $ devops … command line from fenced code blocks and inline code spans in src/devops_cli/ai/knowledge_base/**/*.md, maps <…>, {…}, […] and ... tokens to ArgvPlaceholder, and resolves each with resolve_devops_argv. Shown by: a unit test on a fixture markdown string that returns the expected references with their path:line, including one fenced line, one inline span, one placeholder and one line with a trailing comment.
  • tests/test_docs_knowledge_base_argv.py::test_every_knowledge_base_argv_resolves asserts the collector reports no unresolved line, runs with subprocess.Popen patched to raise (no command runs, no network, no DNS), and completes in under 5 s on the gate. Shown by: uv run pytest tests/test_docs_knowledge_base_argv.py -q. On today's knowledge base the same test reports about 118 lines in 41 files (prototype runs during refinement); the pull request's branch reports none.
  • devops docs check reports an unresolved knowledge-base argv as <path>:<line> and exits non-zero. Shown by: a test in the style of test_docs_check_reports_an_unresolved_mcp_argv (tests/test_docs_mcp_argv_collector.py:157) that patches the collector to return one defective reference.
  • Every subcommand cell in devops_cli/cli_command_reference.md is a devops <group> <subcommand> span the collector resolves. Shown by: the collector reports at least 60 references with path ending cli_command_reference.md and none unresolved.
  • rg -n '10-point|10 gates|10 quality gates|10/10|all 10 (checks|quality|local)|[0-9]+-check|[0-9]+-point' src/devops_cli/ai/knowledge_base returns nothing, over devops_cli/ and it_domains/ alike (this covers the it_domains/ lines docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 names, including all 10 local CI gates at continuous_integration_and_progressive_verification.md:70, which the (checks|quality) alternation alone misses). Shown by: the command.
  • rg -n 'DEVOPS_CLI_CONFIG_PATH|DEVOPS_CLI_LOG_LEVEL|UnifiedLLMClient|keyring_vault|devops-cli/config\.json|nomic-embed-text|--post-pr|devops tofu|devops rag |telemetry probe|ai tokens|review patch|scan security|scan image|release bump|release create-pr|devcontainer.*scaffold|tls generate-ca|tls bundle' src/devops_cli/ai/knowledge_base returns nothing. Shown by: the command. (The pattern is devops-cli/config\.json, not config\.json: tasks/devcontainer_lifecycle.md:58 names .gemini/config/mcp_config.json, which src/devops_cli/commands/devcontainer.py really writes.)
  • This item reintroduces none of the names refactor(github): one github session per identity owning token, quota and transport #767 removes: rg -n 'github\.token|github_token|DEVOPS_CLI_GITHUB_TOKEN|get_github_token' src/devops_cli/ai/knowledge_base returns nothing at the pull request's tip. The one line refactor(github): one github session per identity owning token, quota and transport #767 does not list, the example field github_token in libraries/pydantic.md:56 (under env_prefix="DEVOPS_CLI_", so it spells the removed variable), is renamed by this item. Shown by: the command.
  • Every pinned version named in python_packages.md and libraries/*.md:9 equals the pin in pyproject.toml at the pull request's tip (at HEAD: click==8.5.0, typer==0.27.2, pydantic==2.13.5, gitpython==3.1.62, httpx2==2.13.0, qdrant-client==1.19.1, tldextract==5.3.2, fastapi==0.141.1, uvicorn==0.53.0, ruff==0.16.8). Shown by: a test that reads pyproject.toml and asserts each <name>==<version> string the two files name for a dependency matches, or, if the owner prefers fewer brittle assertions, by rg -n '==[0-9]' src/devops_cli/ai/knowledge_base reviewed against pyproject.toml in the pull request description.
  • tests/test_kb.py still passes with 80 articles. Shown by: uv run pytest tests/test_kb.py -q.
  • changelog.d/920.md exists and CHANGELOG.md and docs/ROADMAP.md are untouched. Shown by: devops pr check-readiness.
  • uv run devops ci passes.

Out of Scope

Dependencies

Findings (verified)

Line numbers are those of the release/v0.2.25 tip c279c18 and still hold at HEAD, except in tasks/rag_context_indexing.md, where lines from :52 on are one lower after 6e5bb1f (#945). Paths are relative to src/devops_cli/ai/knowledge_base/. The fact-check's 129 knowledge-base findings (50 high, 31 medium, 48 low) sit in: README.md (6), devops_cli/architecture.md (9), devops_cli/cli_command_reference.md (27: 25 high, 2 medium), devops_cli/configuration_and_settings.md (9: 6 high), devops_cli/python_packages.md (24: 1 medium, 23 low), devops_cli/libraries/*.md (2 aggregate findings over all 23 library articles plus 21 findings in 17 of them), devops_cli/tasks/*.md (31 findings in 12 task articles). Fourteen replacement texts were mis-pasted, stale or count-bearing in the original body and are corrected inline (each marked "corrected during refinement"); five more (libraries/keyring.md:52, libraries/pygithub.md:75, libraries/tldextract.md:19, python_packages.md:199, tasks/agent_instructions_scaffolding.md:36) were corrected at apply time to follow #767, #431 and #840, which land first (each marked). The list is the floor for command lines: the test above also reports 60 to 71 lines in it_domains/ not listed here.

To fit this body, the 50 high findings and every finding whose replacement was corrected are reproduced below in full; the remaining medium and low findings are given as the rules that generate them, with the lines each rule covers. The full list with every replacement text belongs in the delivering pull request's task file, not here.

High findings (all 50)

devops_cli/cli_command_reference.md (25 high; every row is also rewritten as a devops <group> <subcommand> span per the second key question):

  • :11 review branch options --target, --persona, --all, --summary, --no-<stage>, --<stage>-only → branch_name, --base, --repo, --persona, --all, --summary, --no-<stage>, --<stage>-only
  • :16 review patch "Interactive preview and patch application" --session, --index, --apply, --dry-run → delete the row (or replace with review benchmark | Review the same files several times and report median time/tokens per stage | targets, --runs, --pattern, --persona, --all)
  • :17 review export-feedback "Export findings to fine-tuning/RAG dataset" --session, --status, --output → "Export findings to a JSONL feedback dataset" --output, --reviews-dir, --status
  • :19 chat "Interactive multi-turn AI terminal assistant" prompt, --provider, --model, --system → "Interactive chat with a Pydantic AI persona" --persona, --model, --context, --rag, --tools, --thinking
  • :20 repomap --output, --max-depth, --exclude (and :21 diagram target, --output, --theme; :22 test-gen target_file, --output, --framework) → repomap: --target, --max-files, --include-tests, --multilingual, --json; diagram: diagram_type (arch|threat), --target, --json; test-gen: target_file, --function, --json
  • :24 rag query query, --collection, --limit → query, --collection, --top-k, --min-score
  • :28 deploy-stack "Deploy infra, otel, llm, or all stacks" --stack, --dir, --context → "Deploy infra, llm, logging, or all stacks" --stack, --k8s-dir, --context, --wait, --timeout; :29 --stack, --k8s-dir, --context
  • :41 diff path, --context → "Diff hydrated manifests against cluster (kubectl diff -k)" path
  • :47 notify-plan "Post plan output to GitHub PR or Slack" dir, --target → "Post plan output as a GitHub PR comment" --plan-file, --pr, --dry-run, --json (the row stays in the tf group: devops tf notify-plan is defined at src/devops_cli/commands/tf.py:738; there is no devops k8s notify-plan)
  • :48 scan | scan "Vulnerability & secret scanning with Trivy" → scan | trivy "Vulnerability & misconfiguration scanning with Trivy" target, --type, --severity, --json (plus rows for secrets/sast/iac/report as needed)
  • :49 uv | audit "Scan Python virtualenv for CVEs via pip-audit" --strict, --fix → uv | sync "Sync project dependencies" --frozen; the CVE audit moves to ci | audit "Check dependencies for known CVEs (uv audit)"
  • :50 repos clone-org org, --dest, --concurrency; :51 sync "Sync repos & generate .code-workspace" --root, --prune; :52 list --root → clone-org: org, --base-dir, --private, --forks; sync: "Fetch (and optionally pull) tracking branches across repos" --base-dir, --pull, --dry-run; list: --base-dir
  • :53 workspace init --root; :54 workspace sync --root → workspace | generate "Regenerate the .code-workspace from all repos" --base-dir, --workspace; add / remove "Add or remove a folder" repo_path, --workspace
  • :55 branches list --remote, --merged; :56 tidy --force → list: --base-dir, --all; clean "Delete local branches merged into main/master" --base-dir, --dry-run
  • :57 pr list --repo, --author; :59 checkout number, --repo → list: --state, --limit, --repo; replace the checkout row with e.g. check-readiness "Validate PR merge readiness" number, --repo
  • :61 docker ps --all; :63 clean --force → images "List local Docker images" --name; prune "Remove unused containers, images, networks" --volumes, --force
  • :64 argo apps --server, --auth-token → argo | cd apps list "List ArgoCD applications", no options
  • :66 grafana dashboards --server, --api-key; :67 export uid, --out → dashboards list "List Grafana dashboards"; dashboards export "Export a dashboard to JSON" uid, --output
  • :68 prometheus query query, --server; :69 alerts --server → query: expr, --time; replace alerts with rules "List recording and alerting rules"
  • :70 ssh generate "Generate Ed25519 or RSA SSH key pair" name, --type, --bits, --comment → "Generate an SSH key pair" --key-dir, --prefix, --comment (corrected during refinement: the original pasted the ai agents --template text; devops ssh generate takes no name argument and no --type/--bits, see src/devops_cli/commands/ssh.py)
  • :74 tls ca --output-dir, --cn, --org, --days; :75 cert domain, --output-dir, --days; :76 homelab --output-dir, --domains, --ips → ca: --output-dir, --common-name, --organization, --validity-days; cert: --common-name, --san, --ca-cert, --ca-key, --validity-days; homelab: --output-dir, --domain, --ip
  • :79 telemetry test "Send test trace spans" --spans → "Emit a test span and metric to the collector" --name, --logfire
  • :87 ci | ci "Execute 10-point local quality gate" --quick, --skip-tests → "Run every check of the local quality gate" --fix/--no-fix, --check, --cache, --force, --files; and a second row run "Same as devops ci" --fix (corrected during refinement: the original put --check, --force, --files on ci run; those options belong to the ci group callback and the resolver rejects devops ci run --check (unknown option '--check' for 'devops ci run'); ci run takes --fix only)
  • :88 release | release "Bump version & cut release branch" bump_type, --push, --dry-run → prepare "Bump version, update changelog, sync docs" version, --create-pr, --type; pr "Create release branch and release PR" --version, --base, --push
  • :90 devcontainer | scaffold --dest, --template → init "Scaffold .devcontainer configuration" path, --force (corrected during refinement: the original pasted the devops tf block; devops devcontainer has init, update, validate, list, unlock-keyring, post-create, post-start, run-lifecycle, bootstrap-k8s and no scaffold)

devops_cli/configuration_and_settings.md (6 high):

  • :24 settings schema table (:24-34) naming AISettings, GitHubSettings, K8sSettings, SSHSettings, TLSSettings, TelemetrySettings, PrometheusSettings, GrafanaSettings, ArgoSettings, QdrantSettings, … → rewrite the table from settings.py: ai/AIConfig (provider, model, reasoning_effort, temperature, max_tokens, ollama_urls, ollama_max_parallel, tasks, rag, cache); github/GitHubConfig (default_org; token in keyring); k8s/KubernetesConfig (context, domain, addressing); ssh/SSHConfig (key_dir, key_prefix, rotation_days); telemetry/TelemetryConfig (enabled, endpoint, logfire); prometheus/… and the remaining sections as settings.py defines them
  • :44 DEVOPS_CLI_CONFIG_PATH "Path to persistent configuration file" → DEVOPS_CLI_CONFIG | System | Absolute path to the configuration file to use instead of the project/global lookup (global default ~/.config/devops-cli/config.yaml)
  • :47 DEVOPS_CLI_LOG_LEVEL row → delete the row (for server logging use devops serve --log-level)
  • :48 DEVOPS_CLI_AI_PROVIDER (ollama, openai, anthropic, deepseek) → (ollama, claude, copilot, openai, gateway)
  • :51 DEVOPS_CLI_AI_TEMPERATURE and :52 DEVOPS_CLI_AI_MAX_TOKENS rows (with :40 "All configuration values can be overridden via DEVOPS_CLI_* …") → delete both rows; line 40 becomes "The configuration keys listed in docs/ENV_VARS.md can be overridden via DEVOPS_CLI_* environment variables:"
  • :72 YAML ai.tasks.review: {temperature, max_tokens, reasoning_effort, timeout_seconds: 240} and ai.tasks.diagram (:72-76, :84-86) → review: becomes analysis: (and verification: for the verify pass), timeout_seconds: 240 becomes timeout: 240, the diagram: block is dropped

devops_cli/libraries/ (5 high):

  • cryptography.md:19 devops tls generate-ca, generate-cert, bundle → devops tls ca, devops tls cert, devops tls homelab
  • opentelemetry.md:65 devops telemetry profile --last (also :21) and :68 devops telemetry test-span → devops telemetry profile "devops k8s status" (or devops telemetry profile --trace-id <id>); devops telemetry test
  • pydantic_ai.md:109 prompts under src/devops_cli/ai/prompts/ → src/devops_cli/ai/tasks/ via load_task_prompt()
  • pygithub.md:20 devops review pr <num> --post-pr → devops review pr <num> --post (corrected during refinement: the original pasted an argo table row; the option is --post, see devops review pr --help)
  • tiktoken.md:21 devops ai tokens <target> → devops ai token-count <target>

devops_cli/tasks/ (14 high):

  • agent_instructions_scaffolding.md:36 # Overwrite existing instruction files with force flag / devops ai agents --repo repos/my-org/my-project --force → # Regenerate instruction files from the template without the LLM / devops ai agents --repo repos/my-org/my-project --template, then # Overwrite an existing AGENTS.md (refused without --force) / devops ai agents --repo repos/my-org/my-project --force (corrected at apply time: at HEAD devops ai agents takes --repo, --template, --file and no --force, so the line fails today; docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 (v0.2.27) adds --force as the only way to overwrite an existing AGENTS.md and this item lands after docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 (owner decision), so the article keeps the --force example with docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840's wording and the collector test proves it resolves at the tip)
  • ai_code_review.md:50 "drop-in remediation code patches … (devops ai review patch)" → drop the devops ai review patch reference; findings are fixed by hand and recorded with devops review verify <session> --index <n> --status MITIGATED
  • ai_code_review.md:80 devops ai review branch --persona devsecops --provider ollama --model qwen3.8:27b (and :143 "use --provider ollama to keep all code analysis strictly on the local machine") → devops ai config --provider ollama --model qwen3.8:27b then devops ai review branch --persona devsecops; :143: "configure a local provider with devops ai config --provider ollama"
  • ai_code_review.md:101 devops review verify 20260910-143644 1 --status MITIGATED --reason "..." (also :104, and :59 devops review verify <session> <index> --status INVALIDATED) → devops review verify 20260910-143644 --index 1 --status MITIGATED --reason "..." (same for :59 and :104: devops review verify <session> --index <n> ...)
  • ai_code_review.md:107 devops review branch --export-md .data/reviews/review-report.md → delete the example and say "Each review writes its Markdown report to .data/reviews//review.md."
  • infrastructure_provisioning.md:31 devops tofu init --path tf/aws / devops tofu plan --path tf/aws -v ... -o dev.tfplan / devops tofu apply --path tf/aws --plan dev.tfplan / devops tofu output --path tf/aws --json / devops tofu status --path tf/aws → devops tf init tf/aws / devops tf plan tf/aws -v tf/environments/dev.tfvars -o dev.tfplan / devops tf apply tf/aws --plan-file dev.tfplan / devops tf output tf/aws --json / devops tf status tf/aws; :20: "devops tf detects the tofu or terraform binary automatically"
  • k8s_stack_deployment.md:46 devops k8s deploy-stack monitoring / gitops / llm / otel / all; devops k8s teardown-stack llm (stacks monitoring, gitops, tracing, otel, llm, all listed at :22-28) → devops k8s deploy-stack --stack infra (ArgoCD, k8s-monitoring (Alloy) + prometheus + grafana charts, OTel collector/Jaeger) / --stack llm / --stack logging / --stack all; devops k8s teardown-stack --stack llm; rewrite the stack list at :22-28 as infra/llm/logging/all
  • rag_context_indexing.md:32 devops rag index docs/ / devops rag query "..." / devops rag status / devops rag clear ("Clear and rebuild RAG index") → devops ai rag index docs/ / devops ai rag query "..." / devops ai rag status / devops ai rag clear, the last under the comment "Clear the RAG index (re-run devops ai rag index to rebuild)"
  • release_management.md:37 devops release bump minor (also diagram :14 devops release bump --minor / --patch) → # Bump version, update CHANGELOG.md and sync docs / devops release prepare 0.2.25
  • release_management.md:43 devops release create-pr --version 0.2.0 (also diagram :17) → devops release pr --version 0.2.0
  • release_management.md:56 "Document all notable additions … under docs/commands/release.md under the corresponding version header" (also :25 release check verifies version consistency …) → "Document all notable changes in CHANGELOG.md under the version header; devops release check verifies pyproject.toml, src/devops_cli/init.py and CHANGELOG.md agree." (Point the :82 reference at CHANGELOG.md.)
  • repo_and_workspace_management.md:36 devops repos status (also :24 "Git Status Matrix"); devops workspace sync (:42, also :23); devops workspace list (:45) → devops repos list (list cloned repositories) / devops branches list (branches across all repos) / devops workspace generate (regenerate .code-workspace from repos/); remove devops workspace list; update :23-24 to name workspace generate
  • security_audit_and_scanning.md:33 devops scan security src/ (also :49) and :36 devops scan image <image> → # Run every registered scanner / devops scan report src/; # Scan container image / devops scan trivy <the same image> --type image; :49: "Execute devops scan report or devops ci"
  • telemetry_and_observability.md:39 devops telemetry probe → devops telemetry test (comment "Emit test trace span to verify ingestion" stays)

Medium and low findings (79): the rules that generate them

Each rule names the lines it covers and the replacement; one finding per rule is quoted in full as the sample.

  • Counts become sources (README.md:32 (medium), :33, :72 (medium), :95 (medium); cli_command_reference.md:3 (medium); python_packages.md:11 (medium); tasks/ci_quality_gate.md:5 (medium; also :9, :31, and libraries/ruff_mypy_pytest.md:16,53 "10-point devops ci quality gate"); libraries/typer.md:21; tasks/github_project_management.md:187): "10-point" becomes "every check devops ci runs" (or is simply dropped, python_packages.md:11); "19 command groups" / "19 distinct sub-applications" become "the command groups listed in _COMMAND_SPECS (src/devops_cli/main.py; aliases tui, format, lint included) … the root callback handles --version and --dry-run"; "22 production runtime dependencies and 11 development quality tools" becomes "the core production runtime dependencies and development quality tools"; README.md:32 and cli_command_reference.md:3 describe an overview of the main command groups with "the complete generated reference is docs/CLI_REFERENCE.md (devops docs generate)"; github_project_management.md:187 "16 FastMCP tools and 4 dynamic system resources" becomes "the FastMCP gh_* tools (including those listed below) and the server's resources". Sample, tasks/ci_quality_gate.md:5: "a comprehensive, 10-point local quality inspection suite" → a local quality gate that runs every check devops ci reports (Python version, tests, coverage, ruff lint, ruff format, mypy --strict, uv audit, bandit, actionlint, docs, uv check, uv lock --check, outdated deps) (corrected during refinement: the original wrote a 13-check local quality gate; AGENTS.md:73-75 prohibits numbered gates and docs(agents): instruction surfaces state only what is true, and devops ai agents never overwrites AGENTS.md #840 removes every such count). Also corrected during refinement: typer.md:21 (the original wrote 37 command groups; _COMMAND_SPECS has 38 entries at HEAD and at c279c18) and github_project_management.md:187 (the original wrote 27 FastMCP gh_* tools; src/devops_cli/ai/mcp/server.py defines 24 at HEAD and at c279c18); both replacements name no count.
  • Pinned versions equal pyproject.toml (python_packages.md:57,91,149,167,177,236,261; libraries/*.md:9: uvicorn 0.52.4 in fastapi_uvicorn.md, GitPython 3.1.60 in gitpython.md, httpx2 2.9.0 in httpx2.md:9 and :21, pydantic 2.13.4 in pydantic.md, qdrant-client 1.19.0 in qdrant_client.md, ruff, typer and click likewise): each version string becomes the pin named in the acceptance criterion. Sample, python_packages.md:261: "| ruff | 0.16.4 | … checking py314 rules (E, F, I, N, W, UP). |" → | ruff | 0.16.8 | Extreme-speed linter and code formatter running the rule families selected in pyproject.toml [tool.ruff.lint]. | (corrected during refinement: the original pasted the ten codes selected today; feat(cli): extend the ruff rule set to the correctness families #420 (v0.2.26) changes the selection, so the row points at pyproject.toml)
  • Relative links (libraries/*.md:10, all 23 library articles; ruff_mypy_pytest.md also links ../../../../../pyproject.toml): links of the form ../../../../../src/devops_cli/... → six ../ segments (../../../../../../src/devops_cli/..., ../../../../../../pyproject.toml) or the task-doc form ../../../../core/cli.py.
  • Lines owned by earlier items, kept as those items write them (libraries/keyring.md:52 (medium; "github.token" in set/get/delete on :52,55,58) and libraries/pygithub.md:75 (keyring_vault / get_github_token()): owned by refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26), which removes github.token, the github_token keyring key, DEVOPS_CLI_GITHUB_TOKEN and get_github_token (config/settings.py:977) and corrects keyring.md:52-64 and pygithub.md:38,75 itself (both corrected at apply time: the refined replacements wrote "github_token", devops config set github.token and get_github_token(), all of which refactor(github): one github session per identity owning token, quota and transport #767 deletes one release earlier); libraries/ruff_mypy_pytest.md:39 ([tool.ruff.lint] select = ["E", "F", "I", "N", "W", "UP"]): owned by feat(cli): extend the ruff rule set to the correctness families #420, whose deliverable rewrites :36-40; this item leaves them alone and, if feat(cli): extend the ruff rule set to the correctness families #420 has not merged when this item does, writes select as "the families and codes selected in pyproject.toml [tool.ruff.lint]" without listing them (corrected during refinement: the original pasted today's ten codes; feat(cli): extend the ruff rule set to the correctness families #420 drops B017, RUF022, RUF043, RUF068 and selects B, RUF, ASYNC and more).
  • The extractor rule fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 ships (libraries/tldextract.md:19 (medium; also :10 integration src/devops_cli/http/broker.py, :65), python_packages.md:199, README.md:57): "Zero-Trust Egress Defense … mitigating SSRF" → Network Reference Extraction: security/reference_extractor.py reports only hosts that the URL parser (urllib.parse) and ipaddress recognise, and uses a snapshot-only TLDExtract(suffix_list_urls=(), fallback_to_snapshot=True) for the public-suffix and RFC 2606 / special-use checks on those hosts; HTTP egress validation (http/broker.py) uses ipaddress-based checks (corrected at apply time: the refined text said "domains found in scanned code"; fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 (v0.2.26, lands first) makes the extractor report only hosts parsed from URLs and IP literals); python_packages.md:199 → devops_cli.security.reference_extractor: Parses hosts from URLs and IP literals referenced in code (never bare words) for threat-intel lookups (same correction); README.md:57 → | TLDExtract | Domain Parsing | Public Suffix List domain parsing for network references extracted from code. |
  • Configuration storage and resolution (architecture.md:108 (medium), configuration_and_settings.md:11,13 (medium), libraries/keyring.md:21 (medium)): ~/.config/devops-cli/config.json → ~/.config/devops-cli/config.yaml (plus an optional project config.yaml), secrets (tokens, API keys) in the OS keyring; resolution order → Secrets: 1. OS Keyring 2. Vault 3. Environment variables 4. config.yaml. Other settings: 1. CLI flags 2. DEVOPS_CLI_* environment variables 3. project config.yaml 4. ~/.config/devops-cli/config.yaml 5. defaults; keyring.md:21 "Env Vars → OS Keyring → Config File" → OS Keyring → Vault → Env Vars → Config File.
  • Module paths and class names (libraries/httpx2.md:19 and python_packages.md:152: UnifiedLLMClient → devops_cli.ai.client.unified.LLMClient … (Ollama, Claude, OpenAI-compatible, Copilot, the LLM gateway); python_packages.md:123: devops_cli.config.keyring_vault → devops_cli.config.settings (keyring helpers) and devops_cli.security.secrets (provider chain); :164: ai.review.runner & ai.agents → devops_cli.ai.response_repair & devops_cli.ai.client.structured; :170: ai.rag.engine → devops_cli.ai.rag.qdrant, .indexer and .retriever; :186: devops_cli.commands.pr (PyGithub) → devops_cli.github.client: Fetches PR details and posts review findings through the GitHub REST API; :211: devops_cli.commands.release (packaging) → devops_cli.core.validation: Validates version strings and specifiers (PEP 440 / SemVer); :233: devops_cli.mcp → devops_cli.ai.mcp.server; :239: devops_cli.service → devops_cli.server: Powers devops serve, providing REST endpoints for health probes (/health, /healthz), Prometheus metrics (/metrics), status, workspaces, config and an SSE event stream; architecture.md:120: ThinkingStreamProcessor under ai.response_repair → devops_cli.ai.thinking_stream.ThinkingStreamProcessor; :123: MESSAGES, HELP, PERSONAS_CONFIG under lang.en.messages → MESSAGES in devops_cli.lang.en.messages, HELP in devops_cli.lang.en.help, re-exported from devops_cli.lang; :124 "Zero raw user-facing string literals in command dispatchers" → User-facing strings are kept in the language catalog rather than in command dispatchers; libraries/pygithub.md:19 "Powers devops pr list|view|diff|checks" → Powers the GitHub REST client (github/client.py) used by devops gh, devops repos clone-org, and devops review pr --post; devops pr * commands use the gh CLI; libraries/fastapi_uvicorn.md:21 → Implements /health, /healthz, /api/v1/status, and /metrics; python_packages.md:74 HELP.options.target → HELP.options.target_dir; :83 → print_table, print_success, print_error, print_info, print_warning, print_muted). Sample, python_packages.md:205 (pathspec): "devops_cli.ai.diff & devops_cli.commands.review: Excludes build directories … from code review passes" → devops_cli.core.gitignore & devops_cli.core.repo: compile .gitignore patterns with PathSpec.from_lines("gitignore", ...) so ignored files are excluded from scans and review passes (corrected during refinement: the original pasted the FastMCP gh_* text that belongs to github_project_management.md:187; see src/devops_cli/core/gitignore.py:56-60 and src/devops_cli/core/repo.py:22); libraries/pathspec.md:38 (medium) likewise → PathSpec.from_lines("gitignore", lines) (CONST_GITIGNORE_PATTERN_STYLE); integration lives in src/devops_cli/core/gitignore.py and core/repo.py.
  • Pydantic and Pydantic AI API names (libraries/pydantic_ai.md:46 (medium; examples at :41,55,64) and python_packages.md:139): result_type= → output_type=ReviewOutputModel, MCPToolset(server_url=...) → MCPToolset(url="http://localhost:8000/sse"), from devops_cli.models.review import Finding → from devops_cli.ai.review_schema import Finding, toolset.register_tool(...) → toolset.add_tool(AgentTool(...)). Finding model: libraries/pydantic.md:19 (Finding, ReviewSession, AgentUsage, TLSBundle, K8sPodStatus) → (Finding, ReviewSessionPayload, AgentUsage, ...); python_packages.md:94 (with the class Finding example at :101-111) → Domain models (devops_cli.models), review findings (devops_cli.ai.review_schema.Finding), tool schemas, and AI agent outputs inherit from BaseModel; tasks/ai_code_review.md:150 (medium) ReviewFinding with id, file_path, line_start, line_end, … → Pydantic Finding (src/devops_cli/ai/review_schema.py) with finding_id, severity, location (path:start-end), title, description, fix, status, and confidence_score.
  • RAG and Qdrant (libraries/qdrant_client.md:21 (medium; also :19,42,91), tasks/rag_context_indexing.md:21 (medium; also :15, :64), :66 (medium; was :65 at c279c18; also :22, diagram :14)): "embedded QdrantClient(path=".data/qdrant")" and "file-backed .data/rag/vector_store.json" → Connects to a Qdrant server by URL (qdrant.url, default http://localhost:6333, or the in-cluster llm/qdrant service via the Kubernetes API proxy); no embedded mode is used; .data/rag/ holds only the local index cache; nomic-embed-text:latest (768-dimensional) → qwen3-embedding:0.6b (Ollama; override via the rag embedding task model).
  • Review personas and outputs (README.md:67, architecture.md:82, :95 (with diagram :65)): add challenger: Adversarial challenger that contests other personas' findings to the persona list and diagram; "(review.md, findings.json, Rich Terminal Table)" → (-review.md, summary.md, findings.json, Rich Terminal Table).
  • Remaining single-line corrections: architecture.md:112 (medium) → Data lives under the workspace data directory (DEVOPS_CLI_DATA_DIR / data.dir, default ./.data): reviews in <data_dir>/reviews, logs in <data_dir>/logs, analysis in <data_dir>/analysis; <data_dir>/agent holds controller and gateway state; :148 (medium) "local inference (Ollama, vLLM)" → local inference (Ollama profiles behind the LLM gateway); :150 (medium; also :33) → devops scan aibom flags models that use trust_remote_code and compiles AI Bill of Materials (AIBOM) records; cli_command_reference.md:86 (medium) and configuration_and_settings.md:101 (medium): config output "Output raw YAML or JSON configuration" → List configuration environment variables (--export, --json); libraries/opentelemetry.md:38 (medium; also :16) → The devops-cli tracer (telemetry/tracer.py) exports spans as OTLP http/json to http://localhost:4318/v1/traces by default, switching to gRPC for :4317/grpc:// endpoints; libraries/pyyaml_jinja2.md:38 (medium; also :20, :39) → core/templating.py uses a cached SandboxedEnvironment(FileSystemLoader, undefined=StrictUndefined); values are encoded with | tojson and output is re-parsed as JSON. Templates scaffold devcontainer.json and MCP configs; AGENTS.md is generated in Python; libraries/rich.md:21 devops rag index → devops ai rag index; python_packages.md:278 "scan_uv_audit and pip-audit" → via uv audit; :279 "under 80ms" → to keep CLI cold-start latency low; tasks/ai_code_review.md:51 → the JSONL feedback dataset (default .data/feedback_dataset.jsonl; --status ALL for every verdict) via devops ai review export-feedback; :95 (medium) devops review findings --session latest --details → devops review findings --details; :131 (medium) devops benchmark suite → devops ai benchmark --suite; tasks/ci_quality_gate.md:76 "Fail-Fast Policy: Any failure in security scanning (bandit, uv audit) immediately aborts the CI pipeline" → Every check runs and is reported; the gate exits non-zero when any check failed (commands/ci.py:665-673). There is no fail-fast abort (corrected during refinement: the original pasted the challenger persona text that belongs to architecture.md:95); tasks/devcontainer_lifecycle.md:29 (also diagram :17) → persistent bash history (zsh gets completion and the dot alias only); tasks/github_project_management.md:8 → card lifecycle reconciliation against docs/agent/tasks/ (drop docs/agent/task.md); tasks/infrastructure_provisioning.md:52 (medium) "tofu fmt -recursive … (enforced by devops ci)" → Run devops tf fmt tf/ --check (not enforced by devops ci); :75 (layout :69-77, also :21 tf/k8s) → tf/{aws,azure,gcp}/ and tf/environments/{aws,azure,gcp}.tfvars.example (e.g. tf/aws, tf/gcp); tasks/k8s_stack_deployment.md:27 (medium) → llm: Ollama per-VRAM-tier profiles behind the LLM gateway, Open-WebUI, Qdrant and Valkey in the llm namespace; :73 (medium) "helm upgrade --install --atomic" → helm upgrade --install --wait --timeout <t> (plus --force-conflicts on Helm 4) and recovers stuck releases, so it can be re-run safely; :84 NodePort 31434 → NodePort (e.g. registry 30500); tasks/release_management.md:73 "chore(release): prepare v0.2.0 release" → release commits/PRs are titled feat(release): v0.2.0 (fix(release) via --type fix, ! for breaking).

Evidence from review session 20261001-224227 (comment of 2026-10-02)

Each finding below was triaged against release/v0.2.25 (c279c18), judged real and covered by this issue, and upheld by a second agent that tried to refute it.

  • Incomplete SSRF Mitigation Logic (libraries/tldextract.md:43-59, re-rated LOW): the example "Validating Outbound Request Safety" is wrong. With the pinned tldextract 5.3.2, ext.suffix is '' for evil.internal, x.local, foo.lan and localhost, so the if ext.suffix in ("local","internal","lan","localhost") branch is dead and 'evil.internal' returns False; return bool(registered_domain) returns True for any public domain; registered_domain is deprecated; ipaddress is imported but unused. The article's premise is also false: tldextract is used by security/reference_extractor.py to classify domains found in scanned code, and egress validation in http/broker.py uses ipaddress-based checks (see the tldextract.md:19 finding).
  • Inaccurate Pinned Versions for FastAPI and Uvicorn (python_packages.md:236, re-rated LOW): fastapi==0.141.1 is correct; uvicorn==0.52.4 is stale (pyproject pins 0.53.0). typer, click, pydantic, qdrant-client and gitpython are stale in python_packages.md and libraries/*.md:9 too.
  • Inaccurate Pinned Version for httpx2 (python_packages.md:149, re-rated LOW): the doc says httpx2==2.9.0; pyproject.toml and uv.lock pin httpx2==2.13.0.

Readiness check (2026-10-04)

Checked at the release/v0.2.26 tip, b61e5a0.

Corrections

Amended acceptance criteria

Activity

  1. added
    type/bug
    scope/ai
    priority/p1-high
    on Oct 2, 2026
  2. added this to the v0.2.27 milestone on Oct 2, 2026
  3. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    More evidence for this issue from the devsecops review session 20261001-224227 (2026-10-02). Each finding below was triaged against release/v0.2.25 (c279c18), judged real and covered by this issue, and then upheld by a second agent that tried to refute it.

    • Incomplete SSRF Mitigation Logic (src/devops_cli/ai/knowledge_base/devops_cli/libraries/tldextract.md:43-59, re-rated LOW): The example 'Validating Outbound Request Safety' is wrong, though not for the finding's reason. With the pinned tldextract 5.3.2, ext.suffix is '' for evil.internal, x.local, foo.lan and localhost, so the if ext.suffix in ("local","internal","lan","localhost") branch is dead and 'evil.internal' actually returns False. Meanwhile return bool(registered_domain) returns True for any public domain, despite the comment 'Block arbitrary unexpected external domains'. registered_domain is deprecated, and ipaddress is imported but unused. The article's premise is also false: tldextract is …
    • Inaccurate Pinned Versions for FastAPI and Uvicorn (src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md:236, re-rated LOW): The doc says fastapi==0.141.1, uvicorn==0.52.4, but pyproject.toml:34-35 and uv.lock pin fastapi==0.141.1 and uvicorn==0.53.0. FastAPI is correct; uvicorn is stale. The finding's reasoning (that the versions are 'too new' compared with 0.115) is wrong. A full comparison also found typer, click, pydantic, qdrant-client and gitpython stale in python_packages.md and libraries/*.md:9. fix(ai): the knowledge base names only commands, options and components that exist #920 lists python_packages.md:236 explicitly, along with the other pins.
    • Inaccurate Pinned Version for httpx2 (src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md:149, re-rated LOW): The doc says httpx2==2.9.0. pyproject.toml:19 and uv.lock pin httpx2==2.13.0, and the installed version reports 2.13.0. The finding's 'should be 2.10.0' is wrong, but the doc is stale. fix(ai): the knowledge base names only commands, options and components that exist #920 lists python_packages.md:149 (and httpx2.md:9/:21) explicitly.
  4. dan-petty-bot commented on Oct 6, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1249, merged into release/v0.2.27 as db6c77f.

    Description

    Implements #920: Ensures the bundled offline AI knowledge base under src/devops_cli/ai/knowledge_base/ names only CLI commands, subcommands, options, settings, and components that exist in devops-cli.

    69 file(s) changed.

    How it was verified

    Check runs at 31c6321:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-920-knowledge-base-names-only-what-exists.md:

    • Markdown command lines and inline code spans in src/devops_cli/ai/knowledge_base/**/*.md are extracted and tokenized, mapping bracketed placeholders to ArgvPlaceholder.
    • Extracted argv tuples are statically resolved against CLI Click command trees using resolve_devops_argv().
    • Markdown argv check is integrated into DocGenerator.check_docs() and reported by devops docs check.
    • tests/test_docs_knowledge_base_argv.py verifies extraction fixtures, check failure reporting, and that every knowledge base command line resolves without subprocess execution.
    • All 80 knowledge base articles name only real commands, options, settings, environment variables, and pinned library versions.
    • Negative invariants satisfied: zero numbered gate terminology, zero phantom settings (DEVOPS_CLI_CONFIG_PATH, DEVOPS_CLI_LOG_LEVEL), zero obsolete models (nomic-embed-text), zero removed #767 names (github.token).
    • uv run devops ci completes with 100% passing status and $\ge 90%$ code coverage.
  5. added a commit that references this issue on Oct 6, 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

    priority/p1-highscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions