Add dotagent doc-coverage CLI for hand-maintained docs gating (0.4.12)#42
Merged
Merged
Conversation
Read-only command that returns the hand-maintained docs an agent should consider updating for a given changed-file set. Designed as the dotagent-side piece of the Coda doc-maintenance orchestration gate (Prompt 2 field #4); also useful standalone for git hooks / PR-review workflows. ### What it does Given `--files X,Y,Z` (and optionally `--commit-msg`), reads: - docs/feature_master/*.md (the FM-### feature records) - the changed-file path list - the commit message (for DA-BUG-LAYER-NNN routing) …and returns a structured checklist of docs to update, severity-tagged: - 🔴 HARD — file is in an FM-###'s `files:` section - 🟡 SUGGESTED — heuristic match (DB/Redis/host/route path patterns) - 🟢 CHECK — always-applicable (anti-patterns + bug-registry on bug-fix commits) ### Hard boundary Read-only by design. Test `test_doc_coverage_never_writes_anything` snapshots the entire repo's file mtimes + contents before invoking and asserts nothing changed after. ### Modules - src/dotagent/coverage.py (new) — pure functions: · parse_fm_index / parse_fm_index_multi — tolerant Markdown parser that walks `docs/feature_master/FM-*.md`, finds the `## files` heading (case-insensitive, alternate forms), and extracts backtick-quoted path tokens. Glob support (* and **). · doc_coverage(repo, files, commit_msg) — orchestrates HARD + SUGGESTED (regex heuristics) + CHECK (anti-patterns + bug-registry routing) into a CoverageReport. - src/dotagent/commands/doc_coverage_cmd.py (new) — click command wired into cli.py next to `dotagent manifest`. Flags: --files (required, comma- or newline-separated) --format json (default) | markdown | text --commit-msg (for bug-id routing) --severity all | hard | suggested+ --repo (override auto-discovery) ### Output (markdown example) # Doc-coverage checklist ## `src/auth.py` **FM-###:** `FM-014` - 🔴 HARD — `docs/feature_master/FM-014-auth.md` - `src/auth.py` is declared in FM-014's `files:` section … - 🟢 CHECK — `docs/anti-patterns.md` - Always: review whether this change introduces or fixes … - 🟢 CHECK — `docs/bug-registry-infrastructure.md` - Commit message cites a bug id — mark `status: fixed` … ## Unmapped files - `src/redis/cache.py` (heuristic suggested redis-key-registry-* but no FM-### claims it) ### Heuristic rules DB path → db-impact-map-{master,tenant,vector}.md Redis path → redis-key-registry-{tenant,global,events}.md Route path → feature_master/FM-###-<slug>.md (files: confirmation) Host file → ops/service-registry.md Bug commit → bug-registry-{matching-layer}.md (via --commit-msg) Always → anti-patterns.md (cheap invariant scan reminder) ### Tests (29 new) - Parser: 5 tests (extraction, missing dir, token-shape filtering, heading-boundary detection, case variants) - Multi-claim: 1 test (multiple FMs claiming same path) - HARD: 2 tests (matched / unmapped) - SUGGESTED: 4 tests (db / redis / route / host heuristics) - CHECK: 4 tests (anti-patterns always · bug-INFRA · bug-AGT · non-bug) - Warnings + dedup: 2 tests - Glob support: 2 tests (single * · double **) - CLI: 8 tests (json · text · markdown · 2× severity filter · file separator parsing · no-agent error · empty-files error) - Hard boundary: 1 test (full FS snapshot before/after → no writes) ### Docs docs/DOC_COVERAGE_CLI.md — usage, severity model, mapping rules, output shapes (json/markdown/text), how Coda consumes it, limitations. Full suite: 732 passed, 2 skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Read-only CLI that returns the hand-maintained docs an agent should consider updating for a given changed-file set. The dotagent-side piece of Coda's doc-maintenance orchestration gate (Prompt 2 field #4). Also useful standalone for git hooks / PR-review workflows.
dotagent doc-coverage \ --files "src/auth.py,src/redis/cache.py" \ --commit-msg "fix(DA-BUG-INFRA-042): refresh token race" \ --format jsonSeverity model
hardfiles:sectionsuggestedcheckHow the mapping works
docs/feature_master/FM-*.md, finds each file's## filesheading, extracts backtick-quoted paths. Builds path→[FM-###] map. Glob support (*and**).db/→db-impact-map-*,redis/→redis-key-registry-*,routes/api/controllers/→feature_master/FM-###-<slug>.md,pm2/ecosystem/server.py→ops/service-registry.md.anti-patterns.md. Addsbug-registry-{infra,agents,orch}.mdwhen--commit-msgcontainsDA-BUG-LAYER-NNN.Hard boundary — never writes
Test
test_doc_coverage_never_writes_anythingsnapshots the entire repo's mtimes + contents before invoking, then asserts nothing changed after. If the CLI ever writes a file, that's a bug.Output formats
json(default) — for orchestrator consumptionmarkdown— pasteable into Prompt 2 / PR commenttext— terminal-friendlyTest plan
*and**)How Coda uses this
Inside the orchestrator's
doc_maintenance_runningstage, call:…and inject the parsed checklist into Prompt 2 field #4. Claude either updates each HARD doc + reviews SUGGESTED + skims CHECK and posts
coverage_complete: true, or postscoverage_complete: falsewith per-fileskipped_files[]+ rationale.The Coda-side FSM stage / hook handler / failure semantics are out of scope here.
Docs
docs/DOC_COVERAGE_CLI.md— usage, severity model, mapping rules, output shapes, how Coda consumes it, limitations.Version
0.4.11 → 0.4.12Generated by Claude Code