@documentation-robotics/cli 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (510) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +466 -693
  3. package/dist/analysis/data-model-analyzer.js +189 -0
  4. package/dist/analysis/data-model-analyzer.js.map +7 -0
  5. package/dist/analysis/index.js +3 -0
  6. package/dist/analysis/index.js.map +7 -0
  7. package/dist/analysis/relationship-classifier.js +181 -0
  8. package/dist/analysis/relationship-classifier.js.map +7 -0
  9. package/dist/analyzers/base-analyzer.js +1 -0
  10. package/dist/analyzers/base-analyzer.js.map +7 -0
  11. package/dist/analyzers/call-graph-utils.js +39 -0
  12. package/dist/analyzers/call-graph-utils.js.map +7 -0
  13. package/dist/analyzers/cbm-analyzer.js +1205 -0
  14. package/dist/analyzers/cbm-analyzer.js.map +7 -0
  15. package/dist/analyzers/heuristic-utils.js +55 -0
  16. package/dist/analyzers/heuristic-utils.js.map +7 -0
  17. package/dist/analyzers/mapping-loader.js +146 -0
  18. package/dist/analyzers/mapping-loader.js.map +7 -0
  19. package/dist/analyzers/registry.js +124 -0
  20. package/dist/analyzers/registry.js.map +7 -0
  21. package/dist/analyzers/session-state.js +176 -0
  22. package/dist/analyzers/session-state.js.map +7 -0
  23. package/dist/analyzers/stdio-client.js +206 -0
  24. package/dist/analyzers/stdio-client.js.map +7 -0
  25. package/dist/analyzers/types.js +15 -0
  26. package/dist/analyzers/types.js.map +7 -0
  27. package/dist/analyzers/verify-engine.js +209 -0
  28. package/dist/analyzers/verify-engine.js.map +7 -0
  29. package/dist/analyzers/verify-ignore.js +130 -0
  30. package/dist/analyzers/verify-ignore.js.map +7 -0
  31. package/dist/analyzers/version.js +8 -0
  32. package/dist/analyzers/version.js.map +7 -0
  33. package/dist/audit/ai/runner.js +41 -0
  34. package/dist/audit/ai/runner.js.map +7 -0
  35. package/dist/audit/differential-analyzer.js +183 -0
  36. package/dist/audit/differential-analyzer.js.map +7 -0
  37. package/dist/audit/index.js +32 -0
  38. package/dist/audit/index.js.map +7 -0
  39. package/dist/audit/nodes/ai/evaluator.js +49 -0
  40. package/dist/audit/nodes/ai/evaluator.js.map +7 -0
  41. package/dist/audit/nodes/ai/parser.js +55 -0
  42. package/dist/audit/nodes/ai/parser.js.map +7 -0
  43. package/dist/audit/nodes/ai/prompts.js +103 -0
  44. package/dist/audit/nodes/ai/prompts.js.map +7 -0
  45. package/dist/audit/nodes/analysis/node-completeness-checker.js +32 -0
  46. package/dist/audit/nodes/analysis/node-completeness-checker.js.map +7 -0
  47. package/dist/audit/nodes/analysis/node-definition-analyzer.js +47 -0
  48. package/dist/audit/nodes/analysis/node-definition-analyzer.js.map +7 -0
  49. package/dist/audit/nodes/analysis/node-overlap-detector.js +79 -0
  50. package/dist/audit/nodes/analysis/node-overlap-detector.js.map +7 -0
  51. package/dist/audit/nodes/model/orchestrator.js +82 -0
  52. package/dist/audit/nodes/model/orchestrator.js.map +7 -0
  53. package/dist/audit/nodes/spec/loader.js +116 -0
  54. package/dist/audit/nodes/spec/loader.js.map +7 -0
  55. package/dist/audit/nodes/spec/orchestrator.js +68 -0
  56. package/dist/audit/nodes/spec/orchestrator.js.map +7 -0
  57. package/dist/audit/nodes/types.js +1 -0
  58. package/dist/audit/nodes/types.js.map +7 -0
  59. package/dist/audit/pipeline/index.js +5 -0
  60. package/dist/audit/pipeline/index.js.map +7 -0
  61. package/dist/audit/pipeline/pipeline-orchestrator.js +218 -0
  62. package/dist/audit/pipeline/pipeline-orchestrator.js.map +7 -0
  63. package/dist/audit/relationships/ai/evaluator.js +235 -0
  64. package/dist/audit/relationships/ai/evaluator.js.map +7 -0
  65. package/dist/audit/relationships/ai/parser.js +197 -0
  66. package/dist/audit/relationships/ai/parser.js.map +7 -0
  67. package/dist/audit/relationships/ai/prompts.js +274 -0
  68. package/dist/audit/relationships/ai/prompts.js.map +7 -0
  69. package/dist/audit/relationships/analysis/balance-assessor.js +115 -0
  70. package/dist/audit/relationships/analysis/balance-assessor.js.map +7 -0
  71. package/dist/audit/relationships/analysis/coverage-analyzer.js +99 -0
  72. package/dist/audit/relationships/analysis/coverage-analyzer.js.map +7 -0
  73. package/dist/audit/relationships/analysis/duplicate-detector.js +95 -0
  74. package/dist/audit/relationships/analysis/duplicate-detector.js.map +7 -0
  75. package/dist/audit/relationships/analysis/gap-analyzer.js +99 -0
  76. package/dist/audit/relationships/analysis/gap-analyzer.js.map +7 -0
  77. package/dist/audit/relationships/analysis/layer-templates.js +294 -0
  78. package/dist/audit/relationships/analysis/layer-templates.js.map +7 -0
  79. package/dist/audit/relationships/graph/connectivity.js +129 -0
  80. package/dist/audit/relationships/graph/connectivity.js.map +7 -0
  81. package/dist/audit/relationships/graph/relationship-graph.js +179 -0
  82. package/dist/audit/relationships/graph/relationship-graph.js.map +7 -0
  83. package/dist/audit/relationships/model/balance-assessor.js +49 -0
  84. package/dist/audit/relationships/model/balance-assessor.js.map +7 -0
  85. package/dist/audit/relationships/model/coverage-analyzer.js +34 -0
  86. package/dist/audit/relationships/model/coverage-analyzer.js.map +7 -0
  87. package/dist/audit/relationships/model/duplicate-detector.js +68 -0
  88. package/dist/audit/relationships/model/duplicate-detector.js.map +7 -0
  89. package/dist/audit/relationships/model/gap-analyzer.js +41 -0
  90. package/dist/audit/relationships/model/gap-analyzer.js.map +7 -0
  91. package/dist/audit/relationships/model/orchestrator.js +126 -0
  92. package/dist/audit/relationships/model/orchestrator.js.map +7 -0
  93. package/dist/audit/relationships/spec/orchestrator.js +157 -0
  94. package/dist/audit/relationships/spec/orchestrator.js.map +7 -0
  95. package/dist/audit/reports/index.js +5 -0
  96. package/dist/audit/reports/index.js.map +7 -0
  97. package/dist/audit/reports/report-generator.js +118 -0
  98. package/dist/audit/reports/report-generator.js.map +7 -0
  99. package/dist/audit/snapshot-storage.js +163 -0
  100. package/dist/audit/snapshot-storage.js.map +7 -0
  101. package/dist/audit/types.js +21 -0
  102. package/dist/audit/types.js.map +7 -0
  103. package/dist/cli.js +223 -92
  104. package/dist/cli.js.map +3 -3
  105. package/dist/coding-agents/agents/claude-code.js +147 -0
  106. package/dist/coding-agents/agents/claude-code.js.map +7 -0
  107. package/dist/coding-agents/agents/index.js +5 -0
  108. package/dist/coding-agents/agents/index.js.map +7 -0
  109. package/dist/coding-agents/agents/types.js +1 -0
  110. package/dist/coding-agents/agents/types.js.map +7 -0
  111. package/dist/coding-agents/base-chat-client.js +45 -0
  112. package/dist/coding-agents/base-chat-client.js.map +7 -0
  113. package/dist/coding-agents/chat-utils.js +23 -0
  114. package/dist/coding-agents/chat-utils.js.map +7 -0
  115. package/dist/coding-agents/claude-code-client.js +246 -0
  116. package/dist/coding-agents/claude-code-client.js.map +7 -0
  117. package/dist/coding-agents/copilot-client.js +209 -0
  118. package/dist/coding-agents/copilot-client.js.map +7 -0
  119. package/dist/commands/add.js +95 -33
  120. package/dist/commands/add.js.map +2 -2
  121. package/dist/commands/analyzer.js +511 -0
  122. package/dist/commands/analyzer.js.map +7 -0
  123. package/dist/commands/audit-diff.js +49 -0
  124. package/dist/commands/audit-diff.js.map +7 -0
  125. package/dist/commands/audit-snapshots.js +62 -0
  126. package/dist/commands/audit-snapshots.js.map +7 -0
  127. package/dist/commands/audit.js +81 -0
  128. package/dist/commands/audit.js.map +7 -0
  129. package/dist/commands/catalog.js +248 -0
  130. package/dist/commands/catalog.js.map +7 -0
  131. package/dist/commands/changeset.js +577 -66
  132. package/dist/commands/changeset.js.map +2 -2
  133. package/dist/commands/chat.js +106 -83
  134. package/dist/commands/chat.js.map +2 -2
  135. package/dist/commands/claude.js +74 -0
  136. package/dist/commands/claude.js.map +7 -0
  137. package/dist/commands/conformance.js +71 -68
  138. package/dist/commands/conformance.js.map +2 -2
  139. package/dist/commands/copilot.js +75 -0
  140. package/dist/commands/copilot.js.map +7 -0
  141. package/dist/commands/delete.js +125 -11
  142. package/dist/commands/delete.js.map +3 -3
  143. package/dist/commands/discover-logic.js +44 -0
  144. package/dist/commands/discover-logic.js.map +7 -0
  145. package/dist/commands/docs.js +87 -0
  146. package/dist/commands/docs.js.map +7 -0
  147. package/dist/commands/element.js +14 -20
  148. package/dist/commands/element.js.map +2 -2
  149. package/dist/commands/export.js +13 -3
  150. package/dist/commands/export.js.map +2 -2
  151. package/dist/commands/import.js +51 -0
  152. package/dist/commands/import.js.map +7 -0
  153. package/dist/commands/info.js +30 -24
  154. package/dist/commands/info.js.map +2 -2
  155. package/dist/commands/init.js +27 -11
  156. package/dist/commands/init.js.map +2 -2
  157. package/dist/commands/list.js +63 -13
  158. package/dist/commands/list.js.map +3 -3
  159. package/dist/commands/relationship.js +225 -37
  160. package/dist/commands/relationship.js.map +2 -2
  161. package/dist/commands/report.js +54 -0
  162. package/dist/commands/report.js.map +7 -0
  163. package/dist/commands/reports.js +45 -0
  164. package/dist/commands/reports.js.map +7 -0
  165. package/dist/commands/schema.js +135 -0
  166. package/dist/commands/schema.js.map +7 -0
  167. package/dist/commands/search.js +40 -12
  168. package/dist/commands/search.js.map +2 -2
  169. package/dist/commands/show.js +58 -27
  170. package/dist/commands/show.js.map +2 -2
  171. package/dist/commands/stats.js +35 -0
  172. package/dist/commands/stats.js.map +7 -0
  173. package/dist/commands/trace.js +39 -16
  174. package/dist/commands/trace.js.map +2 -2
  175. package/dist/commands/update.js +141 -14
  176. package/dist/commands/update.js.map +2 -2
  177. package/dist/commands/upgrade.js +210 -46
  178. package/dist/commands/upgrade.js.map +3 -3
  179. package/dist/commands/validate.js +142 -23
  180. package/dist/commands/validate.js.map +3 -3
  181. package/dist/commands/version.js +8 -12
  182. package/dist/commands/version.js.map +2 -2
  183. package/dist/commands/visualize.js +155 -25
  184. package/dist/commands/visualize.js.map +2 -2
  185. package/dist/core/base-snapshot-manager.js +84 -0
  186. package/dist/core/base-snapshot-manager.js.map +7 -0
  187. package/dist/core/changeset-exporter.js +305 -0
  188. package/dist/core/changeset-exporter.js.map +7 -0
  189. package/dist/core/changeset-validator.js +41 -0
  190. package/dist/core/changeset-validator.js.map +7 -0
  191. package/dist/core/changeset.js +88 -173
  192. package/dist/core/changeset.js.map +2 -2
  193. package/dist/core/dependency-tracker.js +4 -2
  194. package/dist/core/dependency-tracker.js.map +2 -2
  195. package/dist/core/element.js +98 -27
  196. package/dist/core/element.js.map +2 -2
  197. package/dist/core/golden-copy-cache.js +290 -0
  198. package/dist/core/golden-copy-cache.js.map +7 -0
  199. package/dist/core/graph-model.js +266 -0
  200. package/dist/core/graph-model.js.map +7 -0
  201. package/dist/core/layer.js +159 -16
  202. package/dist/core/layer.js.map +2 -2
  203. package/dist/core/layers.js +32 -0
  204. package/dist/core/layers.js.map +7 -0
  205. package/dist/core/manifest.js +32 -11
  206. package/dist/core/manifest.js.map +2 -2
  207. package/dist/core/migration-registry.js +56 -1
  208. package/dist/core/migration-registry.js.map +2 -2
  209. package/dist/core/model.js +424 -217
  210. package/dist/core/model.js.map +3 -3
  211. package/dist/core/mutation-handler.js +179 -0
  212. package/dist/core/mutation-handler.js.map +7 -0
  213. package/dist/core/reference-registry.js +29 -21
  214. package/dist/core/reference-registry.js.map +2 -2
  215. package/dist/core/relationship-catalog.js +189 -0
  216. package/dist/core/relationship-catalog.js.map +7 -0
  217. package/dist/core/relationship-registry.js.map +2 -2
  218. package/dist/core/relationships.js.map +1 -1
  219. package/dist/core/report-data-model.js +285 -0
  220. package/dist/core/report-data-model.js.map +7 -0
  221. package/dist/core/spec-data-service.js +185 -0
  222. package/dist/core/spec-data-service.js.map +7 -0
  223. package/dist/core/spec-loader-types.js +1 -0
  224. package/dist/core/spec-loader-types.js.map +7 -0
  225. package/dist/core/spec-loader.js +234 -0
  226. package/dist/core/spec-loader.js.map +7 -0
  227. package/dist/core/staged-changeset-storage.js +282 -0
  228. package/dist/core/staged-changeset-storage.js.map +7 -0
  229. package/dist/core/staging-area.js +1002 -0
  230. package/dist/core/staging-area.js.map +7 -0
  231. package/dist/core/stats-collector.js +169 -0
  232. package/dist/core/stats-collector.js.map +7 -0
  233. package/dist/core/virtual-projection.js +443 -0
  234. package/dist/core/virtual-projection.js.map +7 -0
  235. package/dist/export/archimate-exporter.js +99 -60
  236. package/dist/export/archimate-exporter.js.map +2 -2
  237. package/dist/export/audit-formatters.js +479 -0
  238. package/dist/export/audit-formatters.js.map +7 -0
  239. package/dist/export/diff-formatters.js +99 -0
  240. package/dist/export/diff-formatters.js.map +7 -0
  241. package/dist/export/export-manager.js.map +2 -2
  242. package/dist/export/graphml-exporter.js +44 -27
  243. package/dist/export/graphml-exporter.js.map +2 -2
  244. package/dist/export/index.js +4 -0
  245. package/dist/export/index.js.map +2 -2
  246. package/dist/export/json-schema-exporter.js +55 -42
  247. package/dist/export/json-schema-exporter.js.map +2 -2
  248. package/dist/export/markdown-exporter.js +92 -70
  249. package/dist/export/markdown-exporter.js.map +2 -2
  250. package/dist/export/markdown-generator.js +248 -0
  251. package/dist/export/markdown-generator.js.map +7 -0
  252. package/dist/export/markdown-utils.js +30 -0
  253. package/dist/export/markdown-utils.js.map +7 -0
  254. package/dist/export/mermaid-markdown-exporter.js +37 -0
  255. package/dist/export/mermaid-markdown-exporter.js.map +7 -0
  256. package/dist/export/openapi-exporter.js +119 -71
  257. package/dist/export/openapi-exporter.js.map +2 -2
  258. package/dist/export/plantuml-exporter.js +104 -39
  259. package/dist/export/plantuml-exporter.js.map +2 -2
  260. package/dist/export/report-formatters.js +111 -0
  261. package/dist/export/report-formatters.js.map +7 -0
  262. package/dist/export/stats-formatters.js +98 -0
  263. package/dist/export/stats-formatters.js.map +7 -0
  264. package/dist/export/types.js +2 -14
  265. package/dist/export/types.js.map +2 -2
  266. package/dist/export/verify-formatters.js +153 -0
  267. package/dist/export/verify-formatters.js.map +7 -0
  268. package/dist/generated/compiled-validators.js +17 -0
  269. package/dist/generated/compiled-validators.js.map +7 -0
  270. package/dist/generated/index.js +31 -0
  271. package/dist/generated/index.js.map +7 -0
  272. package/dist/generated/layer-registry.js +190 -0
  273. package/dist/generated/layer-registry.js.map +7 -0
  274. package/dist/generated/layer-types.js +7 -0
  275. package/dist/generated/layer-types.js.map +7 -0
  276. package/dist/generated/node-types.js +1719 -0
  277. package/dist/generated/node-types.js.map +7 -0
  278. package/dist/generated/relationship-index.js +14552 -0
  279. package/dist/generated/relationship-index.js.map +7 -0
  280. package/dist/import/archimate-importer.js +166 -0
  281. package/dist/import/archimate-importer.js.map +7 -0
  282. package/dist/import/index.js +47 -0
  283. package/dist/import/index.js.map +7 -0
  284. package/dist/import/openapi-importer.js +143 -0
  285. package/dist/import/openapi-importer.js.map +7 -0
  286. package/dist/import/types.js +1 -0
  287. package/dist/import/types.js.map +7 -0
  288. package/dist/integrations/base-manager.js +311 -0
  289. package/dist/integrations/base-manager.js.map +7 -0
  290. package/dist/integrations/claude-manager.js +360 -0
  291. package/dist/integrations/claude-manager.js.map +7 -0
  292. package/dist/integrations/claude_code/agents/dr-advisor.md +253 -0
  293. package/dist/integrations/claude_code/agents/dr-architect.md +278 -0
  294. package/dist/integrations/claude_code/agents/dr-extractor.md +286 -0
  295. package/dist/integrations/claude_code/commands/dr-changeset.md +657 -0
  296. package/dist/integrations/claude_code/commands/dr-design.md +373 -0
  297. package/dist/integrations/claude_code/commands/dr-info.md +132 -0
  298. package/dist/integrations/claude_code/commands/dr-init.md +251 -0
  299. package/dist/integrations/claude_code/commands/dr-map.md +936 -0
  300. package/dist/integrations/claude_code/commands/dr-model.md +493 -0
  301. package/dist/integrations/claude_code/commands/dr-relate.md +814 -0
  302. package/dist/integrations/claude_code/commands/dr-sync.md +279 -0
  303. package/dist/integrations/claude_code/commands/dr-validate.md +654 -0
  304. package/dist/integrations/claude_code/commands/dr-verify.md +559 -0
  305. package/dist/integrations/claude_code/docs/END_TO_END_WALKTHROUGH.md +903 -0
  306. package/dist/integrations/claude_code/docs/QUICK_START.md +271 -0
  307. package/dist/integrations/claude_code/docs/README.md +347 -0
  308. package/dist/integrations/claude_code/skills/dr_01_motivation_layer/SKILL.md +550 -0
  309. package/dist/integrations/claude_code/skills/dr_02_business_layer/SKILL.md +620 -0
  310. package/dist/integrations/claude_code/skills/dr_03_security_layer/SKILL.md +642 -0
  311. package/dist/integrations/claude_code/skills/dr_04_application_layer/SKILL.md +911 -0
  312. package/dist/integrations/claude_code/skills/dr_05_technology_layer/SKILL.md +836 -0
  313. package/dist/integrations/claude_code/skills/dr_06_api_layer/SKILL.md +933 -0
  314. package/dist/integrations/claude_code/skills/dr_07_data_model_layer/SKILL.md +210 -0
  315. package/dist/integrations/claude_code/skills/dr_08_dataset_layer/SKILL.md +319 -0
  316. package/dist/integrations/claude_code/skills/dr_09_ux_layer/SKILL.md +319 -0
  317. package/dist/integrations/claude_code/skills/dr_10_navigation_layer/SKILL.md +318 -0
  318. package/dist/integrations/claude_code/skills/dr_11_apm_layer/SKILL.md +273 -0
  319. package/dist/integrations/claude_code/skills/dr_12_testing_layer/SKILL.md +273 -0
  320. package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +187 -0
  321. package/dist/integrations/claude_code/skills/dr_codebase_memory/SKILL.md +590 -0
  322. package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +295 -0
  323. package/dist/integrations/copilot-manager.js +328 -0
  324. package/dist/integrations/copilot-manager.js.map +7 -0
  325. package/dist/integrations/github_copilot/agents/dr-advisor.md +243 -0
  326. package/dist/integrations/github_copilot/agents/dr-architect.md +1567 -0
  327. package/dist/integrations/github_copilot/skills/dr_01_motivation_layer/SKILL.md +491 -0
  328. package/dist/integrations/github_copilot/skills/dr_02_business_layer/SKILL.md +539 -0
  329. package/dist/integrations/github_copilot/skills/dr_03_security_layer/SKILL.md +667 -0
  330. package/dist/integrations/github_copilot/skills/dr_04_application_layer/SKILL.md +670 -0
  331. package/dist/integrations/github_copilot/skills/dr_05_technology_layer/SKILL.md +660 -0
  332. package/dist/integrations/github_copilot/skills/dr_06_api_layer/SKILL.md +855 -0
  333. package/dist/integrations/github_copilot/skills/dr_07_data_model_layer/SKILL.md +171 -0
  334. package/dist/integrations/github_copilot/skills/dr_08_dataset_layer/SKILL.md +216 -0
  335. package/dist/integrations/github_copilot/skills/dr_09_ux_layer/SKILL.md +230 -0
  336. package/dist/integrations/github_copilot/skills/dr_10_navigation_layer/SKILL.md +228 -0
  337. package/dist/integrations/github_copilot/skills/dr_11_apm_layer/SKILL.md +234 -0
  338. package/dist/integrations/github_copilot/skills/dr_12_testing_layer/SKILL.md +230 -0
  339. package/dist/integrations/github_copilot/skills/dr_changeset_reviewer/SKILL.md +187 -0
  340. package/dist/integrations/hash-utils.js +51 -0
  341. package/dist/integrations/hash-utils.js.map +7 -0
  342. package/dist/integrations/types.js +16 -0
  343. package/dist/integrations/types.js.map +7 -0
  344. package/dist/reports/model-layer-report-generator.js +278 -0
  345. package/dist/reports/model-layer-report-generator.js.map +7 -0
  346. package/dist/reports/model-report-data.js +57 -0
  347. package/dist/reports/model-report-data.js.map +7 -0
  348. package/dist/reports/model-report-orchestrator.js +103 -0
  349. package/dist/reports/model-report-orchestrator.js.map +7 -0
  350. package/dist/schemas/bundled/analyzers/cbm.json +595 -0
  351. package/dist/schemas/bundled/analyzers/manifest.json +9 -0
  352. package/dist/schemas/bundled/api.json +3411 -0
  353. package/dist/schemas/bundled/apm.json +2371 -0
  354. package/dist/schemas/bundled/application.json +1253 -0
  355. package/dist/schemas/bundled/base.json +1622 -0
  356. package/dist/schemas/bundled/business.json +1279 -0
  357. package/dist/schemas/bundled/data-model.json +1298 -0
  358. package/dist/schemas/bundled/data-store.json +2025 -0
  359. package/dist/schemas/bundled/manifest.json +93 -0
  360. package/dist/schemas/bundled/motivation.json +1360 -0
  361. package/dist/schemas/bundled/navigation.json +1874 -0
  362. package/dist/schemas/bundled/security.json +3488 -0
  363. package/dist/schemas/bundled/technology.json +2067 -0
  364. package/dist/schemas/bundled/testing.json +3120 -0
  365. package/dist/schemas/bundled/ux.json +3592 -0
  366. package/dist/server/schemas.js +202 -0
  367. package/dist/server/schemas.js.map +7 -0
  368. package/dist/server/server.js +1336 -252
  369. package/dist/server/server.js.map +3 -3
  370. package/dist/server/telemetry-middleware.js +22 -15
  371. package/dist/server/telemetry-middleware.js.map +2 -2
  372. package/dist/server-entry.js +65 -0
  373. package/dist/server-entry.js.map +7 -0
  374. package/dist/telemetry/config.js +89 -0
  375. package/dist/telemetry/config.js.map +7 -0
  376. package/dist/telemetry/console-interceptor.js.map +1 -1
  377. package/dist/telemetry/detect.js +24 -0
  378. package/dist/telemetry/detect.js.map +7 -0
  379. package/dist/telemetry/fetch-otlp-exporter.js +112 -0
  380. package/dist/telemetry/fetch-otlp-exporter.js.map +7 -0
  381. package/dist/telemetry/index.js +153 -3
  382. package/dist/telemetry/index.js.map +2 -2
  383. package/dist/telemetry/resilient-exporter.js +22 -8
  384. package/dist/telemetry/resilient-exporter.js.map +2 -2
  385. package/dist/telemetry/resilient-log-exporter.js +17 -8
  386. package/dist/telemetry/resilient-log-exporter.js.map +2 -2
  387. package/dist/telemetry/test-instrumentation.js.map +2 -2
  388. package/dist/types/index.js +84 -0
  389. package/dist/types/index.js.map +3 -3
  390. package/dist/types/source-reference.js +1 -0
  391. package/dist/types/source-reference.js.map +7 -0
  392. package/dist/utils/chat-logger.js +292 -0
  393. package/dist/utils/chat-logger.js.map +7 -0
  394. package/dist/utils/claude-stream.js +8 -0
  395. package/dist/utils/claude-stream.js.map +7 -0
  396. package/dist/utils/date-utils.js +7 -0
  397. package/dist/utils/date-utils.js.map +7 -0
  398. package/dist/utils/element-utils.js.map +1 -1
  399. package/dist/utils/errors.js +88 -15
  400. package/dist/utils/errors.js.map +3 -3
  401. package/dist/utils/export-python-annotations.js +82 -0
  402. package/dist/utils/export-python-annotations.js.map +7 -0
  403. package/dist/utils/file-io.js +7 -2
  404. package/dist/utils/file-io.js.map +2 -2
  405. package/dist/utils/file-lock.js +156 -0
  406. package/dist/utils/file-lock.js.map +7 -0
  407. package/dist/utils/id-generator.js +18 -0
  408. package/dist/utils/id-generator.js.map +7 -0
  409. package/dist/utils/layer-name-formatter.js +16 -0
  410. package/dist/utils/layer-name-formatter.js.map +7 -0
  411. package/dist/utils/markdown-anchor.js +7 -0
  412. package/dist/utils/markdown-anchor.js.map +7 -0
  413. package/dist/utils/markdown-link.js +12 -0
  414. package/dist/utils/markdown-link.js.map +7 -0
  415. package/dist/utils/markdown-table.js +17 -0
  416. package/dist/utils/markdown-table.js.map +7 -0
  417. package/dist/utils/mermaid-utils.js +11 -0
  418. package/dist/utils/mermaid-utils.js.map +7 -0
  419. package/dist/utils/project-paths.js.map +2 -2
  420. package/dist/utils/source-reference.js +52 -0
  421. package/dist/utils/source-reference.js.map +7 -0
  422. package/dist/utils/spec-installer.js +40 -53
  423. package/dist/utils/spec-installer.js.map +2 -2
  424. package/dist/utils/spec-version.js +5 -1
  425. package/dist/utils/spec-version.js.map +2 -2
  426. package/dist/utils/string-utils.js +12 -0
  427. package/dist/utils/string-utils.js.map +7 -0
  428. package/dist/utils/table-formatting.js +19 -0
  429. package/dist/utils/table-formatting.js.map +7 -0
  430. package/dist/validators/index.js +4 -0
  431. package/dist/validators/index.js.map +2 -2
  432. package/dist/validators/naming-validator.js +20 -23
  433. package/dist/validators/naming-validator.js.map +2 -2
  434. package/dist/validators/reference-validator.js +23 -38
  435. package/dist/validators/reference-validator.js.map +2 -2
  436. package/dist/validators/relationship-schema-validator.js +243 -0
  437. package/dist/validators/relationship-schema-validator.js.map +7 -0
  438. package/dist/validators/schema-validator.js +168 -68
  439. package/dist/validators/schema-validator.js.map +2 -2
  440. package/dist/validators/semantic-validator.js +36 -60
  441. package/dist/validators/semantic-validator.js.map +2 -2
  442. package/dist/validators/types.js.map +2 -2
  443. package/dist/validators/validation-formatter.js +159 -0
  444. package/dist/validators/validation-formatter.js.map +7 -0
  445. package/dist/validators/validator.js +24 -38
  446. package/dist/validators/validator.js.map +2 -2
  447. package/dist/viewer/README.md +139 -0
  448. package/dist/viewer/assets/main-CY0Xufuj.css +1 -0
  449. package/dist/viewer/assets/main-DtgErnwF.js +81 -0
  450. package/dist/viewer/assets/vendor-CxKvDp2x.js +17 -0
  451. package/dist/viewer/favicon.svg +11 -0
  452. package/dist/viewer/fonts/inter/Inter-Black.woff2 +0 -0
  453. package/dist/viewer/fonts/inter/Inter-Bold.woff2 +0 -0
  454. package/dist/viewer/fonts/inter/Inter-ExtraBold.woff2 +0 -0
  455. package/dist/viewer/fonts/inter/Inter-Light.woff2 +0 -0
  456. package/dist/viewer/fonts/inter/Inter-Medium.woff2 +0 -0
  457. package/dist/viewer/fonts/inter/Inter-Regular.woff2 +0 -0
  458. package/dist/viewer/fonts/inter/Inter-SemiBold.woff2 +0 -0
  459. package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2 +0 -0
  460. package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
  461. package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2 +0 -0
  462. package/dist/viewer/index.html +15 -0
  463. package/dist/viewer/manifest.json +99 -0
  464. package/dist/viewer/version.json +1 -0
  465. package/package.json +37 -13
  466. package/PYTHON_CLI_PARITY.md +0 -265
  467. package/PYTHON_CLI_STRUCTURE_UPDATE.md +0 -246
  468. package/biome.json +0 -42
  469. package/bunfig.toml +0 -3
  470. package/dist/ai/claude-client.js +0 -71
  471. package/dist/ai/claude-client.js.map +0 -7
  472. package/dist/ai/context-provider.js +0 -129
  473. package/dist/ai/context-provider.js.map +0 -7
  474. package/dist/ai/tools.js +0 -231
  475. package/dist/ai/tools.js.map +0 -7
  476. package/dist/commands/migrate.js +0 -36
  477. package/dist/commands/migrate.js.map +0 -7
  478. package/dist/commands/project.js +0 -74
  479. package/dist/commands/project.js.map +0 -7
  480. package/dist/core/active-changeset.js +0 -52
  481. package/dist/core/active-changeset.js.map +0 -7
  482. package/dist/core/projection-engine.js +0 -288
  483. package/dist/core/projection-engine.js.map +0 -7
  484. package/dist/schemas/bundled/01-motivation-layer.schema.json +0 -942
  485. package/dist/schemas/bundled/02-business-layer.schema.json +0 -1293
  486. package/dist/schemas/bundled/03-security-layer.schema.json +0 -2177
  487. package/dist/schemas/bundled/04-application-layer.schema.json +0 -1328
  488. package/dist/schemas/bundled/05-technology-layer.schema.json +0 -1465
  489. package/dist/schemas/bundled/06-api-layer.schema.json +0 -1743
  490. package/dist/schemas/bundled/07-data-model-layer.schema.json +0 -1253
  491. package/dist/schemas/bundled/08-datastore-layer.schema.json +0 -892
  492. package/dist/schemas/bundled/09-ux-layer.schema.json +0 -1506
  493. package/dist/schemas/bundled/10-navigation-layer.schema.json +0 -843
  494. package/dist/schemas/bundled/11-apm-observability-layer.schema.json +0 -1430
  495. package/dist/schemas/bundled/12-testing-layer.schema.json +0 -1091
  496. package/dist/schemas/bundled/common/layer-extensions.schema.json +0 -266
  497. package/dist/schemas/bundled/common/predicates.schema.json +0 -493
  498. package/dist/schemas/bundled/common/relationships.schema.json +0 -791
  499. package/dist/schemas/bundled/common/source-references.schema.json +0 -71
  500. package/dist/schemas/bundled/link-registry.json +0 -1839
  501. package/dist/schemas/bundled/link-registry.schema.json +0 -339
  502. package/dist/schemas/bundled/relationship-catalog.json +0 -1302
  503. package/dist/schemas/bundled/relationship-type.schema.json +0 -221
  504. package/dist/utils/model-path.js +0 -22
  505. package/dist/utils/model-path.js.map +0 -7
  506. package/docs/TEST-INSTRUMENTATION.md +0 -405
  507. package/docs/telemetry.md +0 -427
  508. package/test-debug.js +0 -33
  509. package/test-special.mjs +0 -46
  510. package/test_runner.ts +0 -7
@@ -0,0 +1,642 @@
1
+ ---
2
+ name: LAYER_03_SECURITY
3
+ description: Expert knowledge for Security Layer modeling in Documentation Robotics
4
+ triggers:
5
+ [
6
+ "security",
7
+ "authentication",
8
+ "authorization",
9
+ "role",
10
+ "permission",
11
+ "RBAC",
12
+ "ABAC",
13
+ "policy",
14
+ "threat",
15
+ "actor objective",
16
+ "STS-ml"
17
+ ]
18
+ version: 0.8.3
19
+ ---
20
+
21
+ # Security Layer Skill
22
+
23
+ **Layer Number:** 03
24
+ **Specification:** Metadata Model Spec v0.8.3
25
+ **Purpose:** Defines authentication, authorization, access control, data classification, and security policies including STS-ml concepts for goal-oriented security modeling.
26
+
27
+ ---
28
+
29
+ ## Layer Overview
30
+
31
+ The Security Layer provides **comprehensive security modeling** spanning:
32
+
33
+ - **Authentication & Authorization** - RBAC, ABAC, field-level access control
34
+ - **Goal-Oriented Security** - Actor objectives, social dependencies (STS-ml inspired)
35
+ - **Information Flow Rights** - Fine-grained rights: produce, read, modify, distribute
36
+ - **Security Patterns** - Separation of duty, binding of duty, need-to-know
37
+ - **Threat Modeling** - Threats, countermeasures, accountability
38
+
39
+ This layer uses a **custom YAML specification** designed to cover authentication, authorization, data classification, threat modeling, and goal-oriented security in a unified model.
40
+
41
+ **Key Innovation:** Integrates STS-ml 2.0 concepts (goal-oriented security, information flow, delegation, social dependencies) with modern RBAC/ABAC patterns.
42
+
43
+ ---
44
+
45
+ ## Entity Types
46
+
47
+ > **CLI Introspection:** Run `dr schema types security` for the authoritative, always-current list of node types.
48
+ > Run `dr schema node <type-id>` for full attribute details on any type.
49
+
50
+ ### Authentication & Authorization (14 entities)
51
+
52
+ | Entity Type | Description |
53
+ | ------------------------ | --------------------------------------------------------------------------------------------------- |
54
+ | **SecurityModel** | Root container for complete security model |
55
+ | **AuthenticationConfig** | Authentication providers (OAuth2, OIDC, SAML, JWT, session, API key, certificate) |
56
+ | **PasswordPolicy** | Password requirements and policies |
57
+ | **Role** | User role definition with inheritance and hierarchy |
58
+ | **Permission** | Permission definition with scopes (global, resource, attribute, owner) and format "resource.action" |
59
+ | **SecureResource** | Protected resource (types: api, screen, data, file, service) |
60
+ | **ResourceOperation** | Operation on a resource with role-based access, conditions, rate limits, audit |
61
+ | **AccessCondition** | Conditional access rule with operators and data sources |
62
+ | **FieldAccessControl** | Field-level access control with read/write permissions and masking |
63
+ | **SecurityPolicy** | Declarative security policy with rules and actions |
64
+ | **PolicyRule** | Individual policy rule with conditions and effects (allow, deny, audit, warn) |
65
+ | **PolicyAction** | Action to take when policy rule matches |
66
+ | **DataClassification** | Data classification and protection policies (levels: public, internal, confidential, restricted) |
67
+ | **RateLimit** | Throttling constraints for API/service access |
68
+
69
+ ### STS-ml Inspired Security (17 entities)
70
+
71
+ | Entity Type | Description |
72
+ | ----------------------------- | ------------------------------------------------------------------------------------------ |
73
+ | **Actor** | Security actor (types: role, agent, organization, system) with objectives and dependencies |
74
+ | **ActorObjective** | Security-related goal of an actor (links to motivation layer goals) |
75
+ | **ActorDependency** | Dependency between actors on resources |
76
+ | **InformationEntity** | Information asset with fine-grained rights (produce, read, modify, distribute) |
77
+ | **InformationRight** | Fine-grained information access rights per actor |
78
+ | **Delegation** | Explicit delegation of permissions or goals (types: execution, permission, approval) |
79
+ | **SecurityConstraints** | Container for security patterns (separation/binding of duty, need-to-know) |
80
+ | **SeparationOfDuty** | Pattern requiring different actors to perform related tasks |
81
+ | **BindingOfDuty** | Pattern requiring same actor to complete related tasks |
82
+ | **NeedToKnow** | Information access based on objective/purpose requirements |
83
+ | **SocialDependency** | Dependencies and trust between actors with verification levels |
84
+ | **AccountabilityRequirement** | Accountability and non-repudiation requirements |
85
+ | **Evidence** | Evidence required for accountability (digital-signature, timestamp, IP, biometric, etc.) |
86
+ | **Threat** | Security threat with likelihood, impact, and countermeasures |
87
+ | **Countermeasure** | Security countermeasure for a threat |
88
+ | **AuditConfig** | Security audit logging configuration |
89
+ | **RetentionPolicy** | Data retention and deletion policies |
90
+
91
+ ---
92
+
93
+ ## Intra-Layer Relationships
94
+
95
+ Security layer uses **containment relationships** rather than explicit ArchiMate-style relationships:
96
+
97
+ ### Containment Hierarchy
98
+
99
+ ```
100
+ SecurityModel
101
+ ├── contains → AuthenticationConfig
102
+ ├── contains → Actors []
103
+ │ └── each Actor contains → ActorObjectives [], ActorDependencies []
104
+ ├── contains → Roles []
105
+ ├── contains → Permissions []
106
+ ├── contains → SecureResources []
107
+ │ └── each SecureResource contains → ResourceOperations []
108
+ │ └── each ResourceOperation contains → AccessConditions [], FieldAccessControls []
109
+ ├── contains → InformationEntities []
110
+ │ └── each InformationEntity contains → InformationRights []
111
+ ├── contains → Delegations []
112
+ ├── contains → SecurityConstraints
113
+ │ ├── contains → SeparationOfDuty []
114
+ │ ├── contains → BindingOfDuty []
115
+ │ └── contains → NeedToKnow []
116
+ ├── contains → SecurityPolicies []
117
+ │ └── each SecurityPolicy contains → PolicyRules []
118
+ │ └── each PolicyRule contains → PolicyActions []
119
+ ├── contains → DataClassification
120
+ ├── contains → SocialDependencies []
121
+ ├── contains → AccountabilityRequirements []
122
+ │ └── each AccountabilityRequirement contains → Evidence []
123
+ └── contains → Threats []
124
+ └── each Threat contains → Countermeasures []
125
+ ```
126
+
127
+ ### Key Relationship Patterns
128
+
129
+ | Source | Relationship | Target | Example |
130
+ | ---------------- | ------------- | ------------------- | -------------------------------------------------------- |
131
+ | Actor | has-objective | ActorObjective | "Support Agent" has objective "Resolve Customer Issues" |
132
+ | Actor | depends-on | InformationEntity | Actor depends on information to achieve objectives |
133
+ | Actor | delegates-to | Actor | "Manager" delegates "Approval Permission" to "Team Lead" |
134
+ | Role | inherits-from | Role | "Admin" inherits from "User" |
135
+ | Permission | applies-to | SecureResource | "users.read" applies to "UserData" resource |
136
+ | PolicyRule | evaluates | AccessCondition | Rule evaluates ABAC conditions |
137
+ | Threat | mitigated-by | Countermeasure | "SQL Injection" mitigated by "Input Validation" |
138
+ | ActorObjective | references | Goal (Layer 1) | Security objective links to business goal |
139
+ | SocialDependency | defines | Actor → Actor trust | "Vendor" depends on "Company" for payment |
140
+
141
+ ---
142
+
143
+ ## Cross-Layer References
144
+
145
+ ### Outgoing References (Security → Other Layers)
146
+
147
+ | Target Layer | Reference Type | Example |
148
+ | ------------------------- | ------------------------------------------------ | --------------------------------------------------------- |
149
+ | **Layer 1 (Motivation)** | Actor references **Stakeholder** | Security actor maps to business stakeholder |
150
+ | **Layer 1 (Motivation)** | ActorObjective references **Goal** | "Protect Customer Data" objective links to "Privacy Goal" |
151
+ | **Layer 1 (Motivation)** | Threat references **Assessment** | Threat is a risk assessment |
152
+ | **Layer 1 (Motivation)** | Countermeasure implements **Requirement** | Security control fulfills security requirement |
153
+ | **Layer 1 (Motivation)** | SocialDependency references **Constraint** | Trust commitments are constraints |
154
+ | **Layer 2 (Business)** | Actor references **BusinessActor** | Security actor maps to business role |
155
+ | **Layer 2 (Business)** | SecurityConstraints apply to **BusinessProcess** | Separation of duty applies to business tasks |
156
+ | **Layer 4 (Application)** | SecureResource references **ApplicationService** | Protects application components |
157
+ | **Layer 4 (Application)** | SecureResource references **DataObject** | Protects application data |
158
+ | **Layer 6 (API)** | SecureResource references **API Operations** | API endpoint security |
159
+ | **Layer 6 (API)** | SecurityScheme maps to **API SecurityScheme** | OAuth2 config maps to OpenAPI security |
160
+ | **Layer 5 (Technology)** | Artifact **encryption** property | Data-at-rest encryption |
161
+ | **Layer 5 (Technology)** | Artifact **classification** property | Data classification levels |
162
+ | **Layer 11 (APM)** | AuditConfig **retention** | Audit log retention policies |
163
+ | **Layer 11 (APM)** | AuditConfig **monitoring** | Security event monitoring |
164
+
165
+ ### Incoming References (Lower Layers → Security)
166
+
167
+ Lower layers reference Security layer to:
168
+
169
+ - Apply authentication/authorization to services and APIs
170
+ - Enforce data classification on artifacts and data objects
171
+ - Implement security policies and access controls
172
+
173
+ ---
174
+
175
+ ## Codebase Detection Patterns
176
+
177
+ ### Pattern 1: Role-Based Access Control (RBAC)
178
+
179
+ ```python
180
+ # FastAPI with role-based authorization
181
+ from enum import Enum
182
+
183
+ class Role(Enum):
184
+ ADMIN = "admin"
185
+ USER = "user"
186
+ GUEST = "guest"
187
+
188
+ def require_role(role: Role):
189
+ def decorator(func):
190
+ @wraps(func)
191
+ async def wrapper(*args, **kwargs):
192
+ # Check user role
193
+ pass
194
+ return wrapper
195
+ return decorator
196
+
197
+ @app.get("/admin/users")
198
+ @require_role(Role.ADMIN)
199
+ async def list_users():
200
+ pass
201
+ ```
202
+
203
+ **Maps to:**
204
+
205
+ - Role: "Admin", "User", "Guest"
206
+ - SecureResource: "/admin/users" (type: api)
207
+ - ResourceOperation: "list_users" (allowed-roles: [admin])
208
+
209
+ ### Pattern 2: Permission-Based Authorization
210
+
211
+ ```typescript
212
+ // Permission definitions
213
+ export const Permissions = {
214
+ USERS_READ: 'users.read',
215
+ USERS_WRITE: 'users.write',
216
+ USERS_DELETE: 'users.delete',
217
+ ORDERS_READ: 'orders.read',
218
+ ORDERS_WRITE: 'orders.write'
219
+ } as const;
220
+
221
+ @RequirePermission(Permissions.USERS_WRITE)
222
+ async updateUser(userId: string, data: UpdateUserDto) {
223
+ // Implementation
224
+ }
225
+ ```
226
+
227
+ **Maps to:**
228
+
229
+ - Permission entities: "users.read", "users.write", "users.delete", "orders.read", "orders.write"
230
+ - SecureResource: "users", "orders"
231
+ - ResourceOperation: "updateUser" (required-permissions: ["users.write"])
232
+
233
+ ### Pattern 3: Attribute-Based Access Control (ABAC)
234
+
235
+ ```python
236
+ # Policy-based access with conditions
237
+ class AccessPolicy:
238
+ def can_access(self, user, resource, action):
239
+ if action == "read" and resource.classification == "public":
240
+ return True
241
+ if action == "write" and user.department == resource.owner_department:
242
+ return True
243
+ if user.role == "admin":
244
+ return True
245
+ return False
246
+ ```
247
+
248
+ **Maps to:**
249
+
250
+ - AccessCondition with field comparisons
251
+ - PolicyRule with conditions and effects
252
+ - SecurityPolicy containing multiple rules
253
+
254
+ ### Pattern 4: Authentication Configuration
255
+
256
+ ```yaml
257
+ # OAuth2 configuration
258
+ authentication:
259
+ providers:
260
+ - type: oauth2
261
+ name: google
262
+ client_id: ${GOOGLE_CLIENT_ID}
263
+ authorization_url: https://accounts.google.com/o/oauth2/v2/auth
264
+ token_url: https://oauth2.googleapis.com/token
265
+ scopes: [openid, email, profile]
266
+ - type: jwt
267
+ name: internal
268
+ secret: ${JWT_SECRET}
269
+ expiration: 3600
270
+ ```
271
+
272
+ **Maps to:**
273
+
274
+ - AuthenticationConfig with providers array
275
+ - Properties: type, authorization-url, token-url, scopes
276
+
277
+ ### Pattern 5: Field-Level Security
278
+
279
+ ```python
280
+ # Data masking based on role
281
+ class UserSerializer:
282
+ def serialize(self, user: User, requester_role: Role):
283
+ data = {
284
+ "id": user.id,
285
+ "username": user.username,
286
+ "email": user.email if requester_role in [Role.ADMIN, Role.MANAGER] else "***@***.com",
287
+ "ssn": user.ssn if requester_role == Role.ADMIN else "***-**-****"
288
+ }
289
+ return data
290
+ ```
291
+
292
+ **Maps to:**
293
+
294
+ - FieldAccessControl on "email" and "ssn" fields
295
+ - Masking strategies: "email" (partial), "redact" (full)
296
+ - Role-based field access
297
+
298
+ ### Pattern 6: Threat Modeling Comments
299
+
300
+ ```python
301
+ # THREAT: SQL Injection via user input
302
+ # COUNTERMEASURE: Parameterized queries
303
+ def get_user_by_email(email: str):
304
+ # Safe: uses parameterized query
305
+ query = "SELECT * FROM users WHERE email = ?"
306
+ return db.execute(query, [email])
307
+ ```
308
+
309
+ **Maps to:**
310
+
311
+ - Threat: "SQL Injection" (likelihood: high, impact: critical)
312
+ - Countermeasure: "Parameterized Queries"
313
+ - Threat mitigated-by Countermeasure
314
+
315
+ ---
316
+
317
+ ## Modeling Workflow
318
+
319
+ ### Step 1: Define Authentication Configuration
320
+
321
+ ```bash
322
+ # Create security model
323
+ dr add security model "application-security" \
324
+ --description "Complete security model for the application"
325
+
326
+ # Add authentication providers
327
+ dr add security authentication-config "oauth2-google" \
328
+ --description "Google OAuth2 authentication"
329
+
330
+ dr add security authentication-config "jwt-internal" \
331
+ --description "Internal JWT authentication"
332
+ ```
333
+
334
+ ### Step 2: Define Roles and Permissions
335
+
336
+ ```bash
337
+ # Add roles
338
+ dr add security role "admin" \
339
+ --description "System administrator with full access"
340
+
341
+ dr add security role "user" \
342
+ --description "Regular authenticated user"
343
+
344
+ dr add security role "guest" \
345
+ --description "Unauthenticated visitor"
346
+
347
+ # Add permissions
348
+ dr add security permission "users.read" \
349
+ --description "Read access to user data"
350
+
351
+ dr add security permission "users.write" \
352
+ --description "Write access to user data"
353
+
354
+ dr add security permission "admin.all" \
355
+ --description "Full administrative access"
356
+ ```
357
+
358
+ ### Step 3: Define Secure Resources
359
+
360
+ ```bash
361
+ # Protected API endpoint
362
+ dr add security secure-resource "user-api" \
363
+ --description "User management API endpoints"
364
+
365
+ # Add resource operation
366
+ dr add security resource-operation "list-users" \
367
+ --description "List all users operation"
368
+
369
+ dr add security resource-operation "create-user" \
370
+ --description "Create new user operation"
371
+ ```
372
+
373
+ ### Step 4: Define Security Actors and Objectives (STS-ml)
374
+
375
+ ```bash
376
+ # Security actors
377
+ dr add security actor "support-agent" \
378
+ --description "Customer support team member"
379
+
380
+ # Actor objectives (link to motivation goals)
381
+ dr add security actor-objective "resolve-customer-issues" \
382
+ --description "Provide timely customer support"
383
+
384
+ # Link objective to motivation layer
385
+ dr relationship add security.actor-objective.resolve-customer-issues \
386
+ motivation.goal.customer-satisfaction --predicate supports
387
+
388
+ # Actor dependencies
389
+ dr add security actor-dependency "support-needs-customer-data" \
390
+ --description "Support agent requires customer data to resolve issues"
391
+ ```
392
+
393
+ ### Step 5: Define Information Entities and Rights
394
+
395
+ ```bash
396
+ # Information entity (STS-ml)
397
+ dr add security information-entity "customer-pii" \
398
+ --description "Customer personally identifiable information"
399
+
400
+ # Information rights (produce, read, modify, distribute)
401
+ dr add security information-right "support-read-pii" \
402
+ --description "Support can read customer PII"
403
+
404
+ dr add security information-right "admin-full-pii" \
405
+ --description "Admin has full rights to customer PII"
406
+ ```
407
+
408
+ ### Step 6: Define Security Constraints (Patterns)
409
+
410
+ ```bash
411
+ # Separation of duty
412
+ dr add security separation-of-duty "approve-payment-sod" \
413
+ --description "Payment creation and approval must be done by different actors"
414
+
415
+ # Binding of duty
416
+ dr add security binding-of-duty "handle-refund-bod" \
417
+ --description "Same actor must initiate and complete refund process"
418
+
419
+ # Need to know
420
+ dr add security need-to-know "customer-data-ntk" \
421
+ --description "Access to customer PII only when resolving customer issues"
422
+ ```
423
+
424
+ ### Step 7: Model Threats and Countermeasures
425
+
426
+ ```bash
427
+ # Identify threats
428
+ dr add security threat "sql-injection" \
429
+ --description "SQL injection via user input fields"
430
+
431
+ # Add countermeasures
432
+ dr add security countermeasure "parameterized-queries" \
433
+ --description "Use parameterized queries for all database operations"
434
+
435
+ # Link threat to motivation layer
436
+ dr relationship add security.threat.sql-injection \
437
+ motivation.assessment.security-vulnerability-risk --predicate references
438
+ ```
439
+
440
+ ### Step 8: Define Policies (ABAC)
441
+
442
+ ```bash
443
+ # Declarative security policy
444
+ dr add security policy "data-access-policy" \
445
+ --description "Attribute-based data access control"
446
+
447
+ # Policy rule
448
+ dr add security policy-rule "owner-can-write" \
449
+ --description "Resource owner can write to their own resources"
450
+
451
+ # Access condition (ABAC expression)
452
+ dr add security access-condition "is-owner" \
453
+ --description "User is the resource owner"
454
+ ```
455
+
456
+ ### Step 9: Cross-Layer Integration
457
+
458
+ ```bash
459
+ # Link to application layer
460
+ dr relationship add security.secure-resource.user-api \
461
+ application.service.user-management-api --predicate protects
462
+
463
+ # Link to API layer
464
+ dr relationship add security.resource-operation.list-users \
465
+ api.operation.get-users --predicate protects
466
+
467
+ # Link to motivation layer
468
+ dr relationship add security.actor.support-agent \
469
+ motivation.stakeholder.customer-support-team --predicate references
470
+ ```
471
+
472
+ ### Step 10: Validate
473
+
474
+ ```bash
475
+ dr validate --layers security
476
+ dr validate --relationships
477
+ ```
478
+
479
+ ---
480
+
481
+ ## Security Modeling Patterns
482
+
483
+ ### Pattern 1: RBAC with Role Hierarchy
484
+
485
+ ```
486
+ Role: "Admin" (hierarchy: 1)
487
+ ├── inherits-from → Role: "Manager" (hierarchy: 2)
488
+ │ ├── inherits-from → Role: "User" (hierarchy: 3)
489
+ │ │ └── inherits-from → Role: "Guest" (hierarchy: 4)
490
+ │ └── has-permission → Permission: "users.write"
491
+ ├── has-permission → Permission: "admin.all"
492
+ └── allowed-on → ResourceOperation: "delete-user"
493
+ ```
494
+
495
+ ### Pattern 2: Goal-Oriented Security (STS-ml)
496
+
497
+ ```
498
+ Actor: "Data Analyst"
499
+ ├── has-objective → ActorObjective: "Generate Business Reports"
500
+ │ └── supports → Goal: "Data-Driven Decisions" (Layer 1)
501
+ ├── depends-on → InformationEntity: "Sales Data"
502
+ │ ├── has-right → InformationRight: "read" (Data Analyst)
503
+ │ └── classification: "internal"
504
+ └── subject-to → NeedToKnow: "Access sales data only for reporting objectives"
505
+ ```
506
+
507
+ ### Pattern 3: Delegation Chain
508
+
509
+ ```
510
+ Actor: "CEO"
511
+ └── delegates-to → Delegation: "Budget Approval"
512
+ ├── delegatee → Actor: "CFO"
513
+ ├── type: "approval"
514
+ ├── retain-oversight: true
515
+ └── delegates-to → Delegation: "Department Budget"
516
+ ├── delegatee → Actor: "Department Head"
517
+ └── retain-oversight: true
518
+ ```
519
+
520
+ ### Pattern 4: Threat Model with Countermeasures
521
+
522
+ ```
523
+ Threat: "Unauthorized API Access"
524
+ ├── likelihood: "high"
525
+ ├── impact: "critical"
526
+ ├── category: "broken-authentication"
527
+ └── mitigated-by → Countermeasure: "JWT Authentication"
528
+ ├── status: "implemented"
529
+ └── mitigated-by → Countermeasure: "Rate Limiting"
530
+ ├── status: "implemented"
531
+ └── mitigated-by → Countermeasure: "API Key Rotation"
532
+ └── status: "planned"
533
+ ```
534
+
535
+ ---
536
+
537
+ ## STS-ml 2.0 Concepts
538
+
539
+ The Security Layer integrates **STS-ml 2.0** (Socio-Technical Security Modeling Language) concepts:
540
+
541
+ ### 1. Goal-Oriented Security
542
+
543
+ - **Actor Objectives** link to Motivation Layer goals
544
+ - Security is justified by business goals
545
+ - Traceability: Why do we need this security control?
546
+
547
+ ### 2. Information Flow Rights
548
+
549
+ - **Produce** - Create new information
550
+ - **Read** - Access information
551
+ - **Modify** - Update existing information
552
+ - **Distribute** - Share information with others
553
+
554
+ ### 3. Delegation
555
+
556
+ - Explicit delegation chains (execution, permission, approval)
557
+ - Retention of oversight/control
558
+ - Delegation constraints (time-bound, scope-limited)
559
+
560
+ ### 4. Security Patterns
561
+
562
+ - **Separation of Duty** - Prevent fraud by requiring multiple actors
563
+ - **Binding of Duty** - Ensure accountability by requiring same actor
564
+ - **Need to Know** - Limit access based on objectives
565
+
566
+ ### 5. Social Dependencies
567
+
568
+ - Trust relationships between actors
569
+ - Verification levels (low, medium, high)
570
+ - Depender → Dependee relationships
571
+
572
+ ### 6. Accountability
573
+
574
+ - Non-repudiation requirements
575
+ - Evidence collection (digital signatures, timestamps, audit logs)
576
+ - Proof of action
577
+
578
+ ---
579
+
580
+ ## Best Practices
581
+
582
+ 1. **Start with Authentication, Then Authorization** - Get identity right before access control
583
+ 2. **Use RBAC for Coarse-Grained, ABAC for Fine-Grained** - Roles for broad access, attributes for specific conditions
584
+ 3. **Model Threats Early** - Security by design, not afterthought
585
+ 4. **Link to Motivation Layer** - Justify security controls with business goals
586
+ 5. **Use STS-ml for Compliance** - Goal-oriented security helps with SOX, GDPR, HIPAA
587
+ 6. **Separate Authentication from Authorization** - Different concerns, different models
588
+ 7. **Document Delegation Chains** - Explicit delegation prevents confusion
589
+ 8. **Apply Security Patterns** - Use separation/binding of duty where applicable
590
+ 9. **Classify Data Early** - Data classification drives access control
591
+ 10. **Audit Everything Sensitive** - Enable AuditConfig for sensitive operations
592
+
593
+ ---
594
+
595
+ ## Validation Tips
596
+
597
+ | Issue | Cause | Fix |
598
+ | ---------------------------- | ---------------------------------------------- | ------------------------------------ |
599
+ | Orphaned Actor | Actor has no objectives or dependencies | Add actor objectives or remove actor |
600
+ | Unmapped Threat | Threat has no countermeasures | Add countermeasures or accept risk |
601
+ | Unused Permission | Permission not assigned to roles or operations | Assign to roles or remove |
602
+ | Missing Field-Level Security | Sensitive data lacks FieldAccessControl | Add field-level access rules |
603
+ | Unlinked Objective | ActorObjective doesn't link to motivation goal | Add cross-layer link |
604
+ | No Evidence | AccountabilityRequirement lacks evidence | Define required evidence types |
605
+ | Incomplete Delegation | Delegation chain missing delegatee | Complete delegation or remove |
606
+
607
+ ---
608
+
609
+ ## Quick Reference
610
+
611
+ **Add Commands:**
612
+
613
+ ```bash
614
+ dr add security model <name>
615
+ dr add security authentication-config <name> --description <description>
616
+ dr add security role <name> --description <description>
617
+ dr add security permission <name> --description <description>
618
+ dr add security secure-resource <name> --description <description>
619
+ dr add security actor <name> --description <description>
620
+ dr add security actor-objective <name> --description <description>
621
+ dr add security information-entity <name> --description <description>
622
+ dr add security threat <name> --description <description>
623
+ dr add security countermeasure <name> --description <description>
624
+ dr add security delegation <name> --description <description>
625
+ ```
626
+
627
+ **Relationship Commands:**
628
+
629
+ ```bash
630
+ dr relationship add <actor> <objective> --predicate has-objective
631
+ dr relationship add <threat> <countermeasure> --predicate mitigated-by
632
+ dr relationship add <secure-resource> <application-service> --predicate protects
633
+ dr relationship add <actor-objective> <motivation-goal> --predicate supports
634
+ ```
635
+
636
+ **Cross-Layer Commands:**
637
+
638
+ ```bash
639
+ dr relationship add <security-actor> <motivation-stakeholder> --predicate references
640
+ dr relationship add <secure-resource> <application-service> --predicate protects
641
+ dr relationship add <security-resource-operation> <api-operation> --predicate protects
642
+ ```