Skip to content

refactor(docs): writing and checking docs consume a generated doc set instead of regenerating it #774

Closed

Description

@dan-petty

Context & Rationale

DocGenerator.write_all_docs (docs/generator.py:1020) and check_docs (:1038) each regenerate the whole doc set, and generation imports 37 command modules and the live MCP server (:349, :367): 9.5s the first time and about 1.7s after. tests/test_docs.py::test_write_and_check_docs (~26s) and test_doc_generator_write_all_and_check (~20s) only test writing and stale or missing files, yet run four and three full generations. The gate already checks the real docs as its own stage (commands/ci.py:440). The gate's test stage took 5m 26s on the 9p workspace mount (2026-09-30) and 1m 42s after the workspace moved to ext4 (2026-10-01), so it is within its 5-minute budget; the per-test timings below were measured on 9p.

Scope & Deliverables

  • Deliverable: the {path: content} doc set that generate_all_docs already returns becomes the seam. Writing, checking and README sync consume a doc set, from real introspection or from a fixture, and each check generates once.
    • The two mechanics tests run on a two-entry fixture.
    • Introspection is tested by the gate's docs stage and one integration test.
  • Constraint: devops docs output is unchanged.

Strategic Alignment

  • Milestone: Backlog (no release)
  • Design: none
  • Depends on: none

Update 2026-10-08: refinement

check_docs (docs/generator.py:1155-1189) now also resolves every devops argv (:1168-1170).

  • The mechanics tests (tests/test_docs.py:164, :305) run on a two-entry set, without introspection or argv checks.
  • One check_docs call introspects once.

Proposed design

Problem statement

The current documentation generation and validation process regenerates the entire doc set multiple times per test, which is slow and redundant. Tests like test_write_and_check_docs and test_doc_generator_write_all_and_check run full generations four and three times respectively, consuming 26s and 20s of test time each. The check_docs function also resolves every devops argv and regenerates the docs set.

Acceptance criteria

  • Criterion 1: The write_all_docs and check_docs functions consume a pre-generated doc set instead of regenerating it.
    Verification: Run tests that use write_all_docs and check_docs and verify they no longer regenerate the full doc set.
  • Criterion 2: Mechanics tests run on a two-entry fixture without introspection or argv checks.
    Verification: Execute tests/test_docs.py::test_write_and_check_docs and tests/test_docs.py::test_doc_generator_write_all_and_check with fixtures and confirm they do not perform full introspection.
  • Criterion 3: The devops docs CLI output remains unchanged.
    Verification: Run devops docs generate and compare the output against a known good baseline to ensure no functional changes.

Key questions

  • What is the current behavior of DocGenerator.write_all_docs and check_docs?: DocGenerator.write_all_docs and check_docs each regenerate the whole doc set, which includes importing 37 command modules and the live MCP server. [sources: src/devops_cli/docs/generator.py:1020, src/devops_cli/docs/generator.py:1038]
  • How much time does a full regeneration take?: The first time, generation takes 9.5s; after that, it takes about 1.7s. [sources: src/devops_cli/docs/generator.py:349, src/devops_cli/docs/generator.py:367]
  • What is the intended delivery for this refactor?: The {path: content} doc set that generate_all_docs already returns becomes the seam. Writing, checking and README sync consume a doc set from real introspection or from a fixture. [sources: src/devops_cli/docs/generator.py:1155]
  • Should the devops docs CLI output be changed?: No, the constraint states that devops docs output is unchanged. (proposed) [sources: src/devops_cli/docs/generator.py:1168]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added this to the v0.2.25 milestone on Oct 1, 2026
  2. added
    type/refactor
    priority/p0-critical
    scope/docs
    on Oct 1, 2026
  3. removed this from the v0.2.25 milestone on Oct 1, 2026
  4. added
    priority/p2-medium
    and removed
    priority/p0-critical
    on Oct 1, 2026
  5. added this to the milestone on Oct 17, 2026
  6. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 25e2cda (see proposed design in issue body).

  7. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Amendment (2026-10-18): folded here by intake as a duplicate

    devops roadmap intake judged the candidate below a duplicate of this item and filed nothing, so its findings are recorded here for whoever plans or delivers this item. Candidate title: "perf(ci): the gate starts its checks while the docs pre-fix runs, and only docs check waits for it".

    Friction

    • devops ci runs three pre-fixes one after another before any check starts: ruff format ., ruff check --fix ., then devops docs generate --sync-readme. The docs pre-fix is the largest serial step on every cache-miss push.
    • Measured on the release tip: 5.5 / 5.6 / 6.5 / 6.8 s in 4 gate runs at load 14-23, and 13-34 s (median 14.9 s, about 11 CPU-s) at load 30-37. pytest, the critical path, waits for it every time.
    • Making devops import less does not shorten this step: docs generate imports the MCP server (src/devops_cli/docs/generator.py:430) and needs pydantic_ai for real.

    Evidence

    Checked at release/v0.2.37 30b8fdd.

    • The pre-fixes are awaited one at a time (src/devops_cli/commands/ci.py:688-731), at :848, before the 14 checks start together in one asyncio.gather (:867-875).
    • pytest was the longest check in 176 of 177 saved verdicts.
    • The ruff pre-fixes must stay first and serial: both rewrite the same *.py files, every check reads them, and docs generate imports them. Each takes 0.1-0.8 s.
    • Three tests read files that docs generate writes: tests/test_docs.py:499 and :691 read docs/commands/*.md, and tests/test_review_exporter.py:259-268 reads README.md and every docs/**/*.md. pytest cannot start before docs generate until they stop depending on those files.
    • Generator writes are atomic (src/devops_cli/output/file_writer.py:174-185), and a run whose pre-fix changed the tree saves no verdict (src/devops_cli/commands/ci.py:998-1004).
    • --dry-run prints the requests as one list "in order" (:787-818) and does not show which run serially.

    Remedy

    • Make tests/test_docs.py:499, :691 and tests/test_review_exporter.py:259-268 read the generator's in-memory output (DocGenerator.generate_all_docs) instead of the committed files. docs check already verifies the committed files match.
    • In devops ci, keep the ruff pre-fixes first and serial, then start the docs pre-fix and the checks as tasks together. Only docs check awaits the docs pre-fix.
    • --dry-run labels the pre-fix block serial and the check block concurrent.
    • Every check and pre-fix stays.

    Acceptance criteria

    • Tests first, offline: a test of the pipeline with fake check runners records start times and shows that pytest starts before the docs pre-fix ends, and that docs check starts after it.
    • A test shows a run whose docs pre-fix rewrites a file still saves no verdict.
    • The three named tests pass with the committed docs removed from a tmp_path copy.
    • --dry-run output shows the serial and concurrent blocks.
  8. modified the milestones: , v0.2.38 on Oct 20, 2026
  9. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1762, merged into release/v0.2.38 as 1d87095.

    Resolves #774

    Fail-to-pass: not applicable: refactoring without defect reproduction

    4 file(s) changed.

    How it was verified

    Check runs at 31bb9f1:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Rule Pack Tests: pass
    • Fail-to-Pass Self-Check: pass
    • Changed-Test Independence: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Dependency Freshness: skipping
    • DevContainer Image: skipping
    • Service Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-774-docs-consume-generated-doc-set.md:

    No Acceptance Criteria section.

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/p2-mediumscope/docstype/refactor

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions