Skip to content

Add dotagent doc-coverage CLI for hand-maintained docs gating (0.4.12)#42

Merged
dilawarabbas1 merged 1 commit into
mainfrom
claude/push-code-dotagent-SloI4
May 20, 2026
Merged

Add dotagent doc-coverage CLI for hand-maintained docs gating (0.4.12)#42
dilawarabbas1 merged 1 commit into
mainfrom
claude/push-code-dotagent-SloI4

Conversation

@dilawarabbas1

Copy link
Copy Markdown
Owner

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 json

Severity model

Severity Glyph When
hard 🔴 File explicitly 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)

How the mapping works

  1. HARD — walks docs/feature_master/FM-*.md, finds each file's ## files heading, extracts backtick-quoted paths. Builds path→[FM-###] map. Glob support (* and **).
  2. SUGGESTED — pure regex heuristics: db/db-impact-map-*, redis/redis-key-registry-*, routes/api/controllers/feature_master/FM-###-<slug>.md, pm2/ecosystem/server.pyops/service-registry.md.
  3. CHECK — always emits anti-patterns.md. Adds bug-registry-{infra,agents,orch}.md when --commit-msg contains DA-BUG-LAYER-NNN.

Hard boundary — never writes

Test test_doc_coverage_never_writes_anything snapshots 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 consumption
  • markdown — pasteable into Prompt 2 / PR comment
  • text — terminal-friendly

Test plan

  • Parser: 5 tests (extraction · missing dir · path-shape filter · heading-boundary stop · case variants)
  • Multi-claim: 1 test (multiple FMs claiming same file)
  • HARD: 2 tests (matched / unmapped)
  • SUGGESTED: 4 tests (db · redis · route · host)
  • CHECK: 4 tests (anti-patterns · bug-INFRA · bug-AGT · non-bug)
  • Glob support: 2 tests (* and **)
  • Warnings + dedup: 2 tests
  • CLI: 8 tests (json · text · markdown · 2× severity filter · file separator · 2× error path)
  • Hard boundary: 1 test (full FS snapshot pre/post)
  • Full suite: 732 passed, 2 skipped

How Coda uses this

Inside the orchestrator's doc_maintenance_running stage, call:

dotagent doc-coverage --files "<git diff>" --commit-msg "<msg>" --format json

…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 posts coverage_complete: false with per-file skipped_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.12


Generated by Claude Code

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.
@dilawarabbas1 dilawarabbas1 merged commit 6d93cb7 into main May 20, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants