docs: add Mermaid classDiagram export to backlog (ID 86) - #445
Conversation
New Tier 1g visualization item — emit UML-style class hierarchy diagrams from existing graph data (class nodes, parent_id, extends/ implements edges). Most data already exists; needs a new rendering path in export.js and a class_diagram MCP tool.
|
Claude finished @carlos-alm's task —— View job Todo List
Root Cause AnalysisProblem Being Solved: Adding a legitimate backlog item for Mermaid classDiagram export functionality to track planned work and communicate requirements. Why This Approach: Simple documentation addition to the roadmap backlog follows the established pattern for tracking planned features. Risk Assessment: Very low risk - documentation only change with no code impact. Critical Issue - ID ConflictDUPLICATE ID 85: This PR creates a duplicate ID 85. The backlog already has ID 85 for "Hot-path expensive-initialization detection" on line 70. The new classDiagram export entry should use ID 86 instead. Backlog Compliance
Technical AssessmentThe feature description is thorough and well-researched:
Minor Issues
Final Recommendation
Required FixChange line 139 from: to: Once the ID conflict is resolved, this will be ready to merge. |
Greptile SummaryThis PR adds a single backlog entry — ID 86: Mermaid
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[codegraph export -f class-diagram] --> B{--scope provided?}
B -- Yes --> C[getClassHierarchy BFS\nsrc/shared/hierarchy.js]
B -- No --> D[Query all class/interface/\nstruct/trait/enum nodes]
C --> D
D --> E[Group child methods & properties\nvia symbol_children / parent_id]
E --> F[Infer visibility markers\n+ / - / # from extractClassProperties]
F --> G[Emit classDiagram syntax\nwith stereotypes <<abstract>> <<interface>>]
G --> H[Add inheritance arrows\nfrom extends edges]
G --> I[Add implementation arrows\nfrom implements edges]
G --> J[Add dependency arrows\nfrom cross-class call edges]
H & I & J --> K[Mermaid classDiagram output]
K --> L[class_diagram MCP tool]
Last reviewed commit: 72969d4 |
| | 69 | Node annotations in `diff-impact` / `branch-compare` / `communities` | Use 61's annotation formatter to show top exports on file nodes in `diff-impact -f mermaid`, `branch-compare --format mermaid`, and `communities` output. | Visualization | All visual tools show file API surfaces inline, not just in `export` | ✓ | ✓ | 3 | No | 61 | | ||
| | 70 | Drift/risk subgraph labels in `communities` and `triage` | Use 62's semantic label system to annotate `communities` subgraphs with drift status (`**(drifted)**` / `**(cohesive)**`) and add a new `--format mermaid` to `triage` with risk-severity group labels. | Intelligence | Community and triage diagrams communicate structural health directly in the layout | ✓ | ✓ | 3 | No | 62 | | ||
| | 84 | Call-count annotations on `sequence` diagram arrows | `sequence` currently deduplicates caller→callee pairs with `SELECT DISTINCT`, silently hiding multi-site calls. Instead, count how many times each caller→callee pair appears in the edges table and annotate the Mermaid arrow with the count when > 1 (e.g., `CallerFile ->> CalleeFile: fnName (×3)`). Requires grouping by `(source_id, target_id)` and emitting the count alongside the edge. | Visualization | Sequence diagrams reveal call intensity — a file calling another 8 times is architecturally different from one that calls it once; agents and reviewers can immediately spot hot paths and coupling strength | ✓ | ✓ | 3 | No | — | | ||
| | 85 | Mermaid `classDiagram` export | New `codegraph export -f class-diagram` (and `exportClassDiagram` programmatic API) that emits a Mermaid `classDiagram` for classes, interfaces, structs, traits, and enums in the graph. **What we already have:** class/interface/struct/trait/enum nodes in the `nodes` table, method nodes with `parent_id` linking them to their class (migration v11), property/parameter/constant child nodes via `symbol_children`, `extends` and `implements` edges stored by `builder.js`. **What's needed:** **(a)** New rendering function in `export.js` that queries classes → groups their child methods and properties → emits Mermaid `classDiagram` syntax with `<<abstract>>`/`<<interface>>` stereotypes, inheritance (`<\|--`) and implementation (`..\|>`) arrows; **(b)** visibility markers (`+`/`-`/`#`) — infer from JS `#private` fields (already detected as `private_property_identifier` in `extractClassProperties`) and language-specific access modifiers; **(c)** optional `--scope <file-or-class>` to restrict diagram to a class and its hierarchy (uses `getClassHierarchy` BFS); **(d)** dependency arrows (`..>`) derived from cross-class call edges. **Nice-to-have (not blocking):** type annotations on methods/fields (requires extractor changes to persist TS/Java type info). Add corresponding `class_diagram` MCP tool. | Visualization | Agents and PR reviewers get UML-style class hierarchy diagrams generated directly from the graph — useful for understanding inheritance structures, spotting god classes, and reviewing OOP designs without manual diagramming. Particularly valuable for Java, C#, TypeScript, and Rust codebases with deep type hierarchies | ✓ | ✓ | 3 | No | — | |
There was a problem hiding this comment.
Duplicate backlog ID 85
ID 85 is already used on line 70 for "Hot-path expensive-initialization detection" (Tier 1b). This entry should use the next available ID, which is 86.
| | 85 | Mermaid `classDiagram` export | New `codegraph export -f class-diagram` (and `exportClassDiagram` programmatic API) that emits a Mermaid `classDiagram` for classes, interfaces, structs, traits, and enums in the graph. **What we already have:** class/interface/struct/trait/enum nodes in the `nodes` table, method nodes with `parent_id` linking them to their class (migration v11), property/parameter/constant child nodes via `symbol_children`, `extends` and `implements` edges stored by `builder.js`. **What's needed:** **(a)** New rendering function in `export.js` that queries classes → groups their child methods and properties → emits Mermaid `classDiagram` syntax with `<<abstract>>`/`<<interface>>` stereotypes, inheritance (`<\|--`) and implementation (`..\|>`) arrows; **(b)** visibility markers (`+`/`-`/`#`) — infer from JS `#private` fields (already detected as `private_property_identifier` in `extractClassProperties`) and language-specific access modifiers; **(c)** optional `--scope <file-or-class>` to restrict diagram to a class and its hierarchy (uses `getClassHierarchy` BFS); **(d)** dependency arrows (`..>`) derived from cross-class call edges. **Nice-to-have (not blocking):** type annotations on methods/fields (requires extractor changes to persist TS/Java type info). Add corresponding `class_diagram` MCP tool. | Visualization | Agents and PR reviewers get UML-style class hierarchy diagrams generated directly from the graph — useful for understanding inheritance structures, spotting god classes, and reviewing OOP designs without manual diagramming. Particularly valuable for Java, C#, TypeScript, and Rust codebases with deep type hierarchies | ✓ | ✓ | 3 | No | — | | |
| | 86 | Mermaid `classDiagram` export | New `codegraph export -f class-diagram` (and `exportClassDiagram` programmatic API) that emits a Mermaid `classDiagram` for classes, interfaces, structs, traits, and enums in the graph. **What we already have:** class/interface/struct/trait/enum nodes in the `nodes` table, method nodes with `parent_id` linking them to their class (migration v11), property/parameter/constant child nodes via `symbol_children`, `extends` and `implements` edges stored by `builder.js`. **What's needed:** **(a)** New rendering function in `export.js` that queries classes → groups their child methods and properties → emits Mermaid `classDiagram` syntax with `<<abstract>>`/`<<interface>>` stereotypes, inheritance (`<|--`) and implementation (..|>) arrows; **(b)** visibility markers (`+`/`-`/`#`) — infer from JS `#private` fields (already detected as `private_property_identifier` in `extractClassProperties`) and language-specific access modifiers; **(c)** optional `--scope <file-or-class>` to restrict diagram to a class and its hierarchy (uses `getClassHierarchy` BFS); **(d)** dependency arrows (`..>`) derived from cross-class call edges. **Nice-to-have (not blocking):** type annotations on methods/fields (requires extractor changes to persist TS/Java type info). Add corresponding `class_diagram` MCP tool. | Visualization | Agents and PR reviewers get UML-style class hierarchy diagrams generated directly from the graph — useful for understanding inheritance structures, spotting god classes, and reviewing OOP designs without manual diagramming. Particularly valuable for Java, C#, TypeScript, and Rust codebases with deep type hierarchies | ✓ | ✓ | 3 | No | — | |
ID 85 was already used by "Hot-path expensive-initialization detection" in Tier 1b. Renumber classDiagram export to ID 86.
| | 69 | Node annotations in `diff-impact` / `branch-compare` / `communities` | Use 61's annotation formatter to show top exports on file nodes in `diff-impact -f mermaid`, `branch-compare --format mermaid`, and `communities` output. | Visualization | All visual tools show file API surfaces inline, not just in `export` | ✓ | ✓ | 3 | No | 61 | | ||
| | 70 | Drift/risk subgraph labels in `communities` and `triage` | Use 62's semantic label system to annotate `communities` subgraphs with drift status (`**(drifted)**` / `**(cohesive)**`) and add a new `--format mermaid` to `triage` with risk-severity group labels. | Intelligence | Community and triage diagrams communicate structural health directly in the layout | ✓ | ✓ | 3 | No | 62 | | ||
| | 84 | Call-count annotations on `sequence` diagram arrows | `sequence` currently deduplicates caller→callee pairs with `SELECT DISTINCT`, silently hiding multi-site calls. Instead, count how many times each caller→callee pair appears in the edges table and annotate the Mermaid arrow with the count when > 1 (e.g., `CallerFile ->> CalleeFile: fnName (×3)`). Requires grouping by `(source_id, target_id)` and emitting the count alongside the edge. | Visualization | Sequence diagrams reveal call intensity — a file calling another 8 times is architecturally different from one that calls it once; agents and reviewers can immediately spot hot paths and coupling strength | ✓ | ✓ | 3 | No | — | | ||
| | 86 | Mermaid `classDiagram` export | New `codegraph export -f class-diagram` (and `exportClassDiagram` programmatic API) that emits a Mermaid `classDiagram` for classes, interfaces, structs, traits, and enums in the graph. **What we already have:** class/interface/struct/trait/enum nodes in the `nodes` table, method nodes with `parent_id` linking them to their class (migration v11), property/parameter/constant child nodes via `symbol_children`, `extends` and `implements` edges stored by `builder.js`. **What's needed:** **(a)** New rendering function in `export.js` that queries classes → groups their child methods and properties → emits Mermaid `classDiagram` syntax with `<<abstract>>`/`<<interface>>` stereotypes, inheritance (`<\|--`) and implementation (`..\|>`) arrows; **(b)** visibility markers (`+`/`-`/`#`) — infer from JS `#private` fields (already detected as `private_property_identifier` in `extractClassProperties`) and language-specific access modifiers; **(c)** optional `--scope <file-or-class>` to restrict diagram to a class and its hierarchy (uses `getClassHierarchy` BFS); **(d)** dependency arrows (`..>`) derived from cross-class call edges. **Nice-to-have (not blocking):** type annotations on methods/fields (requires extractor changes to persist TS/Java type info). Add corresponding `class_diagram` MCP tool. | Visualization | Agents and PR reviewers get UML-style class hierarchy diagrams generated directly from the graph — useful for understanding inheritance structures, spotting god classes, and reviewing OOP designs without manual diagramming. Particularly valuable for Java, C#, TypeScript, and Rust codebases with deep type hierarchies | ✓ | ✓ | 3 | No | — | |
There was a problem hiding this comment.
PR title still references old ID 85
The entry was correctly renumbered to ID 86 in this commit, but the PR title (docs: add Mermaid classDiagram export to backlog (ID 85)) was never updated to match. Anyone searching for "ID 85" from the PR title will land on a different entry (the "Hot-path expensive-initialization detection" item in Tier 1b). Consider updating the PR title to (ID 86) for consistency.
There was a problem hiding this comment.
Fixed — PR title updated to (ID 86).
…agram-export Impact: 9 functions changed, 14 affected

Summary
classDiagramexportcodegraph export -f class-diagramcommand andexportClassDiagramprogrammatic APIparent_id(migration v11), property/constant children,extends/implementsedgesexport.js, visibility markers,--scopeoption,class_diagramMCP toolTest plan