Repository navigation
Commit da0d40d
feat(diagrams): add UDM caller-supplied structured data path for all 13 diagram types
Every generate_* method on UMLDiagramGenerator previously produced structure
one of two ways: AST-scanning project_root, or (for 8 of 13 types --
activity, state, usecase, object, deployment, communication, composite,
interaction) handing a natural-language summary to an LLM and returning its
freeform output verbatim as the diagram. Neither mode works for a project
whose structure is authoritative but not expressed as scannable source code
(e.g. shakti-os: 458 architecture records, zero .py files), and the LLM path
is a standing violation of any consumer's rule that structural diagrams must
not be LLM-authored.
This adds a second input mode alongside the existing derived mode:
generate_from_data(diagram_type, data) dispatches to a deterministic
renderer for each of the 13 diagram types, never touching an LLM, the
filesystem, or the network. The schema (UDM v1, UDM_PRIMARY_KEY) matches
langgraph_engine.diagrams.drawio.converter.DrawioConverter's existing
analysis_data field names exactly -- that converter was already fully
deterministic and dict-driven for 12 types with zero LLM calls, just never
exposed to a tool caller -- so one JSON payload now renders consistently on
both the Mermaid/PlantUML side (here) and the draw.io side.
class and call_graph reuse existing overrides (classes=, and a new ~12-line
_DictCallGraph adapter around the existing call_graph= override) rather than
duplicating their renderers. package, component, and sequence get dedicated
new renderers instead of reusing their existing dep_graph=/call_chains=
overrides: those predate UDM and use an incompatible shape (flat
{module: set(deps)} adjacency, not UDM's packages/imports or
components/dependencies+provides/requires; literal caller/callee keys only,
not UDM's caller|from|source aliases) -- reusing them would silently drop
caller-supplied structure or KeyError on valid UDM input.
Also, while verifying the existing code against the intended UDM contract:
- generate_component_diagram no longer silently drops every isolated module
when a manually-supplied dep_graph has no matching .py files on disk to
rglob (previously: zero groups resolved -> zero nodes declared -> a
dependency-free module simply vanished, with no diagnostic). It now takes
an optional explicit groups= mapping, and any module that resolves to no
group lands in an "ungrouped" subgraph instead of disappearing.
- generate_component_diagram's Mermaid renderer for UDM `component` data
also renders `requires` as dashed edges to a synthetic interface node --
DrawioConverter reads `requires` but never renders it, so this keeps the
Mermaid side from silently dropping information the payload declared.
- generate_deployment_diagram(infra_files=...) was a dead parameter: passing
it made the method ignore it AND skip auto-detection, falling through to
a generic "Python project with modules: ..." fallback -- strictly worse
than omitting it. Fixed so supplying it is never worse than not supplying
it.
- DrawioConverter gains a 13th builder, _call_graph_diagram, mirroring
generate_call_graph_diagram's subgraph-per-class layout, entry-point bold
border, and cyclomatic>=5 red fill. call_graph was previously absent from
both the base and enriched converters' SUPPORTED_TYPES, so any caller
requesting it silently fell through to _generic_diagram and got a
meaningless flat list of strings, written to disk and reported success.
Backward compatible: every new parameter is optional and appended last;
every existing positional call site is unaffected; the LLM/AST path is
reached exactly when data is not supplied, byte-for-byte unchanged.
call_graph now rendering real content instead of _generic_diagram's
placeholder is a behavior change, but only for callers of a type that
previously produced meaningless output.
35 new tests in tests/test_udm_generate_from_data.py (determinism, no-LLM
via monkeypatch detonators, missing-primary-key rejection per type, the
component/deployment regression fixes). Existing tests/test_uml_generators.py
(67 tests) and the full diagram/drawio/call_graph/component test sweep pass
unmodified.
Implements techdeveloper-org/mcp-uml-diagram#4 and closes
#311.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 53ec3d6 commit da0d40d
5 files changed
Lines changed: 1162 additions & 35 deletions
File tree
- langgraph_engine
- diagrams
- drawio
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| |||
1122 | 1124 | | |
1123 | 1125 | | |
1124 | 1126 | | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
1125 | 1223 | | |
1126 | 1224 | | |
1127 | 1225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
0 commit comments