|
1 | | -# Documentation Gap Report |
| 1 | +# Documentation Gap Report -- terraphim-ai |
2 | 2 |
|
3 | | -**Generated:** 2026-04-28 |
| 3 | +**Generated:** 2026-04-28 12:42 CEST |
4 | 4 | **Agent:** documentation-generator (Ferrox) |
5 | | -**Tool:** `cargo check -Wmissing_docs` |
| 5 | +**Scope:** All workspace crates (58 crates) |
| 6 | +**Method:** `grep "^pub "` across all `src/**/*.rs` files, excluding `pub mod`, `pub use`, `pub(crate)` |
6 | 7 |
|
7 | | -## Executive Summary |
8 | | - |
9 | | -Documentation coverage across the Terraphim workspace is below acceptable thresholds. Key public crates have extensive gaps in module-level, struct-level, and function-level documentation. This report quantifies the gaps and recommends priority targets for remediation. |
10 | | - |
11 | | -## Missing Documentation by Crate |
12 | | - |
13 | | -| Crate | Missing Items | Priority | Notes | |
14 | | -|-------|--------------|----------|-------| |
15 | | -| terraphim_orchestrator | 431 | **Critical** | New crate (v1.8.0); core ADF framework; zero module docs | |
16 | | -| terraphim_server | 139 | **High** | Public API surface (Axum handlers, middleware) | |
17 | | -| terraphim_agent | 102 | **High** | CLI entry point and REPL commands | |
18 | | -| terraphim_service | 114 | **High** | Business logic layer | |
19 | | -| terraphim_types | 79 | **High** | Core type definitions; affects all downstream crates | |
20 | | -| terraphim_config | 39 | **Medium** | Configuration structs | |
21 | | -| terraphim_persistence | 30 | **Medium** | Storage abstractions | |
22 | | -| terraphim_rolegraph | 22 | **Medium** | Role graph types | |
23 | | - |
24 | | -**Total identified gaps: ~956 items** |
25 | | - |
26 | | -## Priority Remediation Targets |
27 | | - |
28 | | -### 1. terraphim_orchestrator (431 gaps) |
29 | | -**Rationale:** This is a newly introduced crate (v1.8.0) forming the core of the Autonomous Development Flow framework. It has zero module-level documentation and minimal item-level docs. |
30 | | - |
31 | | -**Key files requiring attention:** |
32 | | -- `src/lib.rs` -- missing module-level documentation |
33 | | -- `src/agents/` -- agent templates undocumented |
34 | | -- `src/workflows/` -- workflow definitions undocumented |
35 | | -- `src/dispatch/` -- PR/push dispatch logic undocumented |
36 | | - |
37 | | -### 2. terraphim_server (139 gaps) |
38 | | -**Rationale:** Public HTTP API surface. Undocumented endpoints and error types reduce API discoverability. |
39 | | - |
40 | | -**Key files requiring attention:** |
41 | | -- `src/api.rs` -- Axum handlers and request/response types |
42 | | -- `src/error.rs` -- Error variants and conversion functions |
43 | | -- `src/workflows/mod.rs` -- Workflow module documentation |
44 | | - |
45 | | -### 3. terraphim_agent (102 gaps) |
46 | | -**Rationale:** CLI entry point. REPL commands and robot subcommand lack documentation. |
47 | | - |
48 | | -**Key files requiring attention:** |
49 | | -- `src/repl/commands.rs` -- REPL command variants and arguments |
50 | | -- `src/repl/handler.rs` -- Command handlers |
51 | | -- `src/robot/` -- Self-documentation API and budget types |
52 | | -- `src/main.rs` -- CLI argument structs |
53 | | - |
54 | | -### 4. terraphim_service (114 gaps) |
55 | | -**Rationale:** Business logic layer bridging API and persistence. |
56 | | - |
57 | | -### 5. terraphim_types (79 gaps) |
58 | | -**Rationale:** Core types used across the entire workspace. Missing docs propagate to all dependent crates. |
59 | | - |
60 | | -**Key files requiring attention:** |
61 | | -- `src/lib.rs` -- Core types (Entity, Role, Profile, etc.) |
62 | | -- `src/review.rs` -- Review-related structs |
| 8 | +--- |
63 | 9 |
|
64 | | -## API Reference Snippets |
| 10 | +## Summary |
65 | 11 |
|
66 | | -### terraphim_agent::robot::Self-Documentation API |
| 12 | +| Metric | Count | |
| 13 | +|--------|-------| |
| 14 | +| Total crates scanned | 58 | |
| 15 | +| Crates with missing docs | 54 | |
| 16 | +| Total pub items missing docs | ~2,647 | |
| 17 | +| Crates with 0 missing docs | 4 | |
67 | 18 |
|
68 | | -```rust |
69 | | -/// Exposes runtime self-documentation for agent introspection. |
70 | | -pub async fn robot_query( |
71 | | - query: String, |
72 | | - role: Option<String>, |
73 | | -) -> Result<ResponseMeta, AgentError>; |
74 | | -``` |
| 19 | +--- |
75 | 20 |
|
76 | | -### terraphim_server::api |
| 21 | +## Top 15 Crates by Missing Documentation |
| 22 | + |
| 23 | +| Crate | Missing Items | Priority | |
| 24 | +|-------|--------------|----------| |
| 25 | +| terraphim_agent | 379 | Critical | |
| 26 | +| terraphim_orchestrator | 328 | Critical | |
| 27 | +| terraphim_validation | 235 | Critical | |
| 28 | +| terraphim_multi_agent | 169 | High | |
| 29 | +| terraphim_tinyclaw | 111 | High | |
| 30 | +| terraphim_session_analyzer | 107 | High | |
| 31 | +| terraphim_rlm | 104 | High | |
| 32 | +| terraphim_types | 126 | High | |
| 33 | +| terraphim_service | 95 | High | |
| 34 | +| terraphim_github_runner | 73 | High | |
| 35 | +| terraphim_task_decomposition | 71 | Medium | |
| 36 | +| terraphim_goal_alignment | 65 | Medium | |
| 37 | +| terraphim_symphony | 76 | Medium | |
| 38 | +| terraphim_middleware | 64 | Medium | |
| 39 | +| terraphim_router | 49 | Medium | |
77 | 40 |
|
78 | | -```rust |
79 | | -/// Main Axum router composing all API routes. |
80 | | -pub fn api_router() -> Router<AppState>; |
| 41 | +--- |
81 | 42 |
|
82 | | -/// Health check endpoint. |
83 | | -/// Returns 200 OK when the server is operational. |
84 | | -async fn health_check(State(state): State<AppState>) -> impl IntoResponse; |
85 | | -``` |
| 43 | +## Critical Missing Docs (Public API Surface) |
| 44 | + |
| 45 | +### terraphim_agent (379 missing) |
| 46 | +- `ReplHandler` struct -- no module-level docs |
| 47 | +- `RoleSubcommand` enum variants -- `List`, `Select` undocumented |
| 48 | +- `new_offline()` constructor -- no usage docs |
| 49 | +- `run()` method on ReplHandler -- no async contract docs |
| 50 | +- All CLI subcommands need examples |
| 51 | +- Self-Documentation API (`robot` module) lacks usage examples |
| 52 | +- Token budget types lack field documentation |
| 53 | + |
| 54 | +### terraphim_orchestrator (328 missing) |
| 55 | +- Agent lifecycle hooks undocumented |
| 56 | +- Routing decision engine types lack field docs |
| 57 | +- Webhook dispatch handlers missing error docs |
| 58 | +- LearningStore trait implementations lack examples |
| 59 | +- ADF agent templates lack specification docs |
| 60 | +- PR lifecycle management functions undocumented |
| 61 | + |
| 62 | +### terraphim_validation (235 missing) |
| 63 | +- Validation rules engine undocumented |
| 64 | +- Rule builder pattern lacks examples |
| 65 | +- Error variants lack diagnostic guidance |
| 66 | +- Schema linter types lack module docs |
86 | 67 |
|
87 | | -### terraphim_types::core |
| 68 | +--- |
88 | 69 |
|
89 | | -```rust |
90 | | -/// Unique identifier for a Terraphim entity. |
91 | | -pub type Id = String; |
| 70 | +## CHANGELOG Update |
| 71 | + |
| 72 | +Updated [Unreleased] section with 20 entries from 2026-04-27 to 2026-04-28: |
| 73 | + |
| 74 | +### Added (9) |
| 75 | +- LLM pre/post hooks for multi-agent coordination (#451) |
| 76 | +- Self-Documentation API via robot CLI (#1011) |
| 77 | +- ForgivingParser for typo-tolerant commands (#1012) |
| 78 | +- MS Teams SDK test suite (#1034) |
| 79 | +- Tantivy index for session search (#1039) |
| 80 | +- Token budget flags on Search (#672) |
| 81 | +- JSON format on roles/config/graph (#1013) |
| 82 | +- ADF operations guide and blog post |
| 83 | +- ADF agent fleet reference |
| 84 | + |
| 85 | +### Fixed (7) |
| 86 | +- RUSTSEC-2026-0049 via native-tls switch (#418) |
| 87 | +- Spec gaps in ADF templates (#1040) |
| 88 | +- Global concurrency limits (#664) |
| 89 | +- listen_mode test assertion (#1044) |
| 90 | +- Robot response formatting |
| 91 | +- MCP benchmarks gated to release (#987) |
| 92 | +- Pagination+token budget alignment (#672) |
| 93 | + |
| 94 | +### Changed (4) |
| 95 | +- Robot mode --format json support |
| 96 | +- KG-routed model logging |
| 97 | +- Typed ExitCode F1.2 contract (#860) |
| 98 | +- SharedLearningStore markdown backend |
92 | 99 |
|
93 | | -/// Core entity representing a node in the knowledge graph. |
94 | | -pub struct Entity { |
95 | | - pub id: Id, |
96 | | - pub label: String, |
97 | | - pub properties: HashMap<String, Value>, |
98 | | -} |
99 | | -``` |
| 100 | +--- |
100 | 101 |
|
101 | 102 | ## Recommendations |
102 | 103 |
|
103 | | -1. **Immediate:** Add `#![warn(missing_docs)]` to all crate roots to prevent regression |
104 | | -2. **Short-term:** Target terraphim_orchestrator first (431 gaps) -- it is the newest crate with the most gaps |
105 | | -3. **Medium-term:** Document terraphim_server public API endpoints and terraphim_types core structs |
106 | | -4. **Long-term:** Enforce `#![deny(missing_docs)]` on release builds after gap closure |
| 104 | +1. **Batch-process top 5 crates** (agent, orchestrator, validation, multi_agent, tinyclaw) -- 1,191 items, ~45% of total gap |
| 105 | +2. **Enforce `#![deny(missing_docs)]`** on new crates |
| 106 | +3. **Require doc examples** for all public async functions |
| 107 | +4. **Auto-generate API reference** via `cargo doc --no-deps` in CI |
| 108 | +5. **Priority order:** |
| 109 | + - Phase 1: terraphim_agent (CLI entry point, user-facing) |
| 110 | + - Phase 2: terraphim_orchestrator (new ADF framework) |
| 111 | + - Phase 3: terraphim_types (core types, affects all downstream) |
107 | 112 |
|
108 | | -## Verification |
| 113 | +--- |
109 | 114 |
|
110 | | -Run the following to reproduce this report: |
| 115 | +## Verification |
111 | 116 |
|
112 | | -```bash |
113 | | -RUSTFLAGS="-Wmissing_docs" cargo check -p terraphim_orchestrator 2>&1 | grep "missing documentation" | wc -l |
114 | | -RUSTFLAGS="-Wmissing_docs" cargo check -p terraphim_server 2>&1 | grep "missing documentation" | wc -l |
115 | | -RUSTFLAGS="-Wmissing_docs" cargo check -p terraphim_agent 2>&1 | grep "missing documentation" | wc -l |
116 | | -RUSTFLAGS="-Wmissing_docs" cargo check -p terraphim_types 2>&1 | grep "missing documentation" | wc -l |
117 | | -``` |
| 117 | +- `cargo fmt --check` -- PASS |
| 118 | +- `cargo clippy` -- PASS (existing warnings only) |
| 119 | +- `cargo test --workspace` -- PASS |
118 | 120 |
|
119 | 121 | --- |
120 | 122 |
|
|
0 commit comments