@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.
- package/LICENSE +21 -0
- package/README.md +466 -693
- package/dist/analysis/data-model-analyzer.js +189 -0
- package/dist/analysis/data-model-analyzer.js.map +7 -0
- package/dist/analysis/index.js +3 -0
- package/dist/analysis/index.js.map +7 -0
- package/dist/analysis/relationship-classifier.js +181 -0
- package/dist/analysis/relationship-classifier.js.map +7 -0
- package/dist/analyzers/base-analyzer.js +1 -0
- package/dist/analyzers/base-analyzer.js.map +7 -0
- package/dist/analyzers/call-graph-utils.js +39 -0
- package/dist/analyzers/call-graph-utils.js.map +7 -0
- package/dist/analyzers/cbm-analyzer.js +1205 -0
- package/dist/analyzers/cbm-analyzer.js.map +7 -0
- package/dist/analyzers/heuristic-utils.js +55 -0
- package/dist/analyzers/heuristic-utils.js.map +7 -0
- package/dist/analyzers/mapping-loader.js +146 -0
- package/dist/analyzers/mapping-loader.js.map +7 -0
- package/dist/analyzers/registry.js +124 -0
- package/dist/analyzers/registry.js.map +7 -0
- package/dist/analyzers/session-state.js +176 -0
- package/dist/analyzers/session-state.js.map +7 -0
- package/dist/analyzers/stdio-client.js +206 -0
- package/dist/analyzers/stdio-client.js.map +7 -0
- package/dist/analyzers/types.js +15 -0
- package/dist/analyzers/types.js.map +7 -0
- package/dist/analyzers/verify-engine.js +209 -0
- package/dist/analyzers/verify-engine.js.map +7 -0
- package/dist/analyzers/verify-ignore.js +130 -0
- package/dist/analyzers/verify-ignore.js.map +7 -0
- package/dist/analyzers/version.js +8 -0
- package/dist/analyzers/version.js.map +7 -0
- package/dist/audit/ai/runner.js +41 -0
- package/dist/audit/ai/runner.js.map +7 -0
- package/dist/audit/differential-analyzer.js +183 -0
- package/dist/audit/differential-analyzer.js.map +7 -0
- package/dist/audit/index.js +32 -0
- package/dist/audit/index.js.map +7 -0
- package/dist/audit/nodes/ai/evaluator.js +49 -0
- package/dist/audit/nodes/ai/evaluator.js.map +7 -0
- package/dist/audit/nodes/ai/parser.js +55 -0
- package/dist/audit/nodes/ai/parser.js.map +7 -0
- package/dist/audit/nodes/ai/prompts.js +103 -0
- package/dist/audit/nodes/ai/prompts.js.map +7 -0
- package/dist/audit/nodes/analysis/node-completeness-checker.js +32 -0
- package/dist/audit/nodes/analysis/node-completeness-checker.js.map +7 -0
- package/dist/audit/nodes/analysis/node-definition-analyzer.js +47 -0
- package/dist/audit/nodes/analysis/node-definition-analyzer.js.map +7 -0
- package/dist/audit/nodes/analysis/node-overlap-detector.js +79 -0
- package/dist/audit/nodes/analysis/node-overlap-detector.js.map +7 -0
- package/dist/audit/nodes/model/orchestrator.js +82 -0
- package/dist/audit/nodes/model/orchestrator.js.map +7 -0
- package/dist/audit/nodes/spec/loader.js +116 -0
- package/dist/audit/nodes/spec/loader.js.map +7 -0
- package/dist/audit/nodes/spec/orchestrator.js +68 -0
- package/dist/audit/nodes/spec/orchestrator.js.map +7 -0
- package/dist/audit/nodes/types.js +1 -0
- package/dist/audit/nodes/types.js.map +7 -0
- package/dist/audit/pipeline/index.js +5 -0
- package/dist/audit/pipeline/index.js.map +7 -0
- package/dist/audit/pipeline/pipeline-orchestrator.js +218 -0
- package/dist/audit/pipeline/pipeline-orchestrator.js.map +7 -0
- package/dist/audit/relationships/ai/evaluator.js +235 -0
- package/dist/audit/relationships/ai/evaluator.js.map +7 -0
- package/dist/audit/relationships/ai/parser.js +197 -0
- package/dist/audit/relationships/ai/parser.js.map +7 -0
- package/dist/audit/relationships/ai/prompts.js +274 -0
- package/dist/audit/relationships/ai/prompts.js.map +7 -0
- package/dist/audit/relationships/analysis/balance-assessor.js +115 -0
- package/dist/audit/relationships/analysis/balance-assessor.js.map +7 -0
- package/dist/audit/relationships/analysis/coverage-analyzer.js +99 -0
- package/dist/audit/relationships/analysis/coverage-analyzer.js.map +7 -0
- package/dist/audit/relationships/analysis/duplicate-detector.js +95 -0
- package/dist/audit/relationships/analysis/duplicate-detector.js.map +7 -0
- package/dist/audit/relationships/analysis/gap-analyzer.js +99 -0
- package/dist/audit/relationships/analysis/gap-analyzer.js.map +7 -0
- package/dist/audit/relationships/analysis/layer-templates.js +294 -0
- package/dist/audit/relationships/analysis/layer-templates.js.map +7 -0
- package/dist/audit/relationships/graph/connectivity.js +129 -0
- package/dist/audit/relationships/graph/connectivity.js.map +7 -0
- package/dist/audit/relationships/graph/relationship-graph.js +179 -0
- package/dist/audit/relationships/graph/relationship-graph.js.map +7 -0
- package/dist/audit/relationships/model/balance-assessor.js +49 -0
- package/dist/audit/relationships/model/balance-assessor.js.map +7 -0
- package/dist/audit/relationships/model/coverage-analyzer.js +34 -0
- package/dist/audit/relationships/model/coverage-analyzer.js.map +7 -0
- package/dist/audit/relationships/model/duplicate-detector.js +68 -0
- package/dist/audit/relationships/model/duplicate-detector.js.map +7 -0
- package/dist/audit/relationships/model/gap-analyzer.js +41 -0
- package/dist/audit/relationships/model/gap-analyzer.js.map +7 -0
- package/dist/audit/relationships/model/orchestrator.js +126 -0
- package/dist/audit/relationships/model/orchestrator.js.map +7 -0
- package/dist/audit/relationships/spec/orchestrator.js +157 -0
- package/dist/audit/relationships/spec/orchestrator.js.map +7 -0
- package/dist/audit/reports/index.js +5 -0
- package/dist/audit/reports/index.js.map +7 -0
- package/dist/audit/reports/report-generator.js +118 -0
- package/dist/audit/reports/report-generator.js.map +7 -0
- package/dist/audit/snapshot-storage.js +163 -0
- package/dist/audit/snapshot-storage.js.map +7 -0
- package/dist/audit/types.js +21 -0
- package/dist/audit/types.js.map +7 -0
- package/dist/cli.js +223 -92
- package/dist/cli.js.map +3 -3
- package/dist/coding-agents/agents/claude-code.js +147 -0
- package/dist/coding-agents/agents/claude-code.js.map +7 -0
- package/dist/coding-agents/agents/index.js +5 -0
- package/dist/coding-agents/agents/index.js.map +7 -0
- package/dist/coding-agents/agents/types.js +1 -0
- package/dist/coding-agents/agents/types.js.map +7 -0
- package/dist/coding-agents/base-chat-client.js +45 -0
- package/dist/coding-agents/base-chat-client.js.map +7 -0
- package/dist/coding-agents/chat-utils.js +23 -0
- package/dist/coding-agents/chat-utils.js.map +7 -0
- package/dist/coding-agents/claude-code-client.js +246 -0
- package/dist/coding-agents/claude-code-client.js.map +7 -0
- package/dist/coding-agents/copilot-client.js +209 -0
- package/dist/coding-agents/copilot-client.js.map +7 -0
- package/dist/commands/add.js +95 -33
- package/dist/commands/add.js.map +2 -2
- package/dist/commands/analyzer.js +511 -0
- package/dist/commands/analyzer.js.map +7 -0
- package/dist/commands/audit-diff.js +49 -0
- package/dist/commands/audit-diff.js.map +7 -0
- package/dist/commands/audit-snapshots.js +62 -0
- package/dist/commands/audit-snapshots.js.map +7 -0
- package/dist/commands/audit.js +81 -0
- package/dist/commands/audit.js.map +7 -0
- package/dist/commands/catalog.js +248 -0
- package/dist/commands/catalog.js.map +7 -0
- package/dist/commands/changeset.js +577 -66
- package/dist/commands/changeset.js.map +2 -2
- package/dist/commands/chat.js +106 -83
- package/dist/commands/chat.js.map +2 -2
- package/dist/commands/claude.js +74 -0
- package/dist/commands/claude.js.map +7 -0
- package/dist/commands/conformance.js +71 -68
- package/dist/commands/conformance.js.map +2 -2
- package/dist/commands/copilot.js +75 -0
- package/dist/commands/copilot.js.map +7 -0
- package/dist/commands/delete.js +125 -11
- package/dist/commands/delete.js.map +3 -3
- package/dist/commands/discover-logic.js +44 -0
- package/dist/commands/discover-logic.js.map +7 -0
- package/dist/commands/docs.js +87 -0
- package/dist/commands/docs.js.map +7 -0
- package/dist/commands/element.js +14 -20
- package/dist/commands/element.js.map +2 -2
- package/dist/commands/export.js +13 -3
- package/dist/commands/export.js.map +2 -2
- package/dist/commands/import.js +51 -0
- package/dist/commands/import.js.map +7 -0
- package/dist/commands/info.js +30 -24
- package/dist/commands/info.js.map +2 -2
- package/dist/commands/init.js +27 -11
- package/dist/commands/init.js.map +2 -2
- package/dist/commands/list.js +63 -13
- package/dist/commands/list.js.map +3 -3
- package/dist/commands/relationship.js +225 -37
- package/dist/commands/relationship.js.map +2 -2
- package/dist/commands/report.js +54 -0
- package/dist/commands/report.js.map +7 -0
- package/dist/commands/reports.js +45 -0
- package/dist/commands/reports.js.map +7 -0
- package/dist/commands/schema.js +135 -0
- package/dist/commands/schema.js.map +7 -0
- package/dist/commands/search.js +40 -12
- package/dist/commands/search.js.map +2 -2
- package/dist/commands/show.js +58 -27
- package/dist/commands/show.js.map +2 -2
- package/dist/commands/stats.js +35 -0
- package/dist/commands/stats.js.map +7 -0
- package/dist/commands/trace.js +39 -16
- package/dist/commands/trace.js.map +2 -2
- package/dist/commands/update.js +141 -14
- package/dist/commands/update.js.map +2 -2
- package/dist/commands/upgrade.js +210 -46
- package/dist/commands/upgrade.js.map +3 -3
- package/dist/commands/validate.js +142 -23
- package/dist/commands/validate.js.map +3 -3
- package/dist/commands/version.js +8 -12
- package/dist/commands/version.js.map +2 -2
- package/dist/commands/visualize.js +155 -25
- package/dist/commands/visualize.js.map +2 -2
- package/dist/core/base-snapshot-manager.js +84 -0
- package/dist/core/base-snapshot-manager.js.map +7 -0
- package/dist/core/changeset-exporter.js +305 -0
- package/dist/core/changeset-exporter.js.map +7 -0
- package/dist/core/changeset-validator.js +41 -0
- package/dist/core/changeset-validator.js.map +7 -0
- package/dist/core/changeset.js +88 -173
- package/dist/core/changeset.js.map +2 -2
- package/dist/core/dependency-tracker.js +4 -2
- package/dist/core/dependency-tracker.js.map +2 -2
- package/dist/core/element.js +98 -27
- package/dist/core/element.js.map +2 -2
- package/dist/core/golden-copy-cache.js +290 -0
- package/dist/core/golden-copy-cache.js.map +7 -0
- package/dist/core/graph-model.js +266 -0
- package/dist/core/graph-model.js.map +7 -0
- package/dist/core/layer.js +159 -16
- package/dist/core/layer.js.map +2 -2
- package/dist/core/layers.js +32 -0
- package/dist/core/layers.js.map +7 -0
- package/dist/core/manifest.js +32 -11
- package/dist/core/manifest.js.map +2 -2
- package/dist/core/migration-registry.js +56 -1
- package/dist/core/migration-registry.js.map +2 -2
- package/dist/core/model.js +424 -217
- package/dist/core/model.js.map +3 -3
- package/dist/core/mutation-handler.js +179 -0
- package/dist/core/mutation-handler.js.map +7 -0
- package/dist/core/reference-registry.js +29 -21
- package/dist/core/reference-registry.js.map +2 -2
- package/dist/core/relationship-catalog.js +189 -0
- package/dist/core/relationship-catalog.js.map +7 -0
- package/dist/core/relationship-registry.js.map +2 -2
- package/dist/core/relationships.js.map +1 -1
- package/dist/core/report-data-model.js +285 -0
- package/dist/core/report-data-model.js.map +7 -0
- package/dist/core/spec-data-service.js +185 -0
- package/dist/core/spec-data-service.js.map +7 -0
- package/dist/core/spec-loader-types.js +1 -0
- package/dist/core/spec-loader-types.js.map +7 -0
- package/dist/core/spec-loader.js +234 -0
- package/dist/core/spec-loader.js.map +7 -0
- package/dist/core/staged-changeset-storage.js +282 -0
- package/dist/core/staged-changeset-storage.js.map +7 -0
- package/dist/core/staging-area.js +1002 -0
- package/dist/core/staging-area.js.map +7 -0
- package/dist/core/stats-collector.js +169 -0
- package/dist/core/stats-collector.js.map +7 -0
- package/dist/core/virtual-projection.js +443 -0
- package/dist/core/virtual-projection.js.map +7 -0
- package/dist/export/archimate-exporter.js +99 -60
- package/dist/export/archimate-exporter.js.map +2 -2
- package/dist/export/audit-formatters.js +479 -0
- package/dist/export/audit-formatters.js.map +7 -0
- package/dist/export/diff-formatters.js +99 -0
- package/dist/export/diff-formatters.js.map +7 -0
- package/dist/export/export-manager.js.map +2 -2
- package/dist/export/graphml-exporter.js +44 -27
- package/dist/export/graphml-exporter.js.map +2 -2
- package/dist/export/index.js +4 -0
- package/dist/export/index.js.map +2 -2
- package/dist/export/json-schema-exporter.js +55 -42
- package/dist/export/json-schema-exporter.js.map +2 -2
- package/dist/export/markdown-exporter.js +92 -70
- package/dist/export/markdown-exporter.js.map +2 -2
- package/dist/export/markdown-generator.js +248 -0
- package/dist/export/markdown-generator.js.map +7 -0
- package/dist/export/markdown-utils.js +30 -0
- package/dist/export/markdown-utils.js.map +7 -0
- package/dist/export/mermaid-markdown-exporter.js +37 -0
- package/dist/export/mermaid-markdown-exporter.js.map +7 -0
- package/dist/export/openapi-exporter.js +119 -71
- package/dist/export/openapi-exporter.js.map +2 -2
- package/dist/export/plantuml-exporter.js +104 -39
- package/dist/export/plantuml-exporter.js.map +2 -2
- package/dist/export/report-formatters.js +111 -0
- package/dist/export/report-formatters.js.map +7 -0
- package/dist/export/stats-formatters.js +98 -0
- package/dist/export/stats-formatters.js.map +7 -0
- package/dist/export/types.js +2 -14
- package/dist/export/types.js.map +2 -2
- package/dist/export/verify-formatters.js +153 -0
- package/dist/export/verify-formatters.js.map +7 -0
- package/dist/generated/compiled-validators.js +17 -0
- package/dist/generated/compiled-validators.js.map +7 -0
- package/dist/generated/index.js +31 -0
- package/dist/generated/index.js.map +7 -0
- package/dist/generated/layer-registry.js +190 -0
- package/dist/generated/layer-registry.js.map +7 -0
- package/dist/generated/layer-types.js +7 -0
- package/dist/generated/layer-types.js.map +7 -0
- package/dist/generated/node-types.js +1719 -0
- package/dist/generated/node-types.js.map +7 -0
- package/dist/generated/relationship-index.js +14552 -0
- package/dist/generated/relationship-index.js.map +7 -0
- package/dist/import/archimate-importer.js +166 -0
- package/dist/import/archimate-importer.js.map +7 -0
- package/dist/import/index.js +47 -0
- package/dist/import/index.js.map +7 -0
- package/dist/import/openapi-importer.js +143 -0
- package/dist/import/openapi-importer.js.map +7 -0
- package/dist/import/types.js +1 -0
- package/dist/import/types.js.map +7 -0
- package/dist/integrations/base-manager.js +311 -0
- package/dist/integrations/base-manager.js.map +7 -0
- package/dist/integrations/claude-manager.js +360 -0
- package/dist/integrations/claude-manager.js.map +7 -0
- package/dist/integrations/claude_code/agents/dr-advisor.md +253 -0
- package/dist/integrations/claude_code/agents/dr-architect.md +278 -0
- package/dist/integrations/claude_code/agents/dr-extractor.md +286 -0
- package/dist/integrations/claude_code/commands/dr-changeset.md +657 -0
- package/dist/integrations/claude_code/commands/dr-design.md +373 -0
- package/dist/integrations/claude_code/commands/dr-info.md +132 -0
- package/dist/integrations/claude_code/commands/dr-init.md +251 -0
- package/dist/integrations/claude_code/commands/dr-map.md +936 -0
- package/dist/integrations/claude_code/commands/dr-model.md +493 -0
- package/dist/integrations/claude_code/commands/dr-relate.md +814 -0
- package/dist/integrations/claude_code/commands/dr-sync.md +279 -0
- package/dist/integrations/claude_code/commands/dr-validate.md +654 -0
- package/dist/integrations/claude_code/commands/dr-verify.md +559 -0
- package/dist/integrations/claude_code/docs/END_TO_END_WALKTHROUGH.md +903 -0
- package/dist/integrations/claude_code/docs/QUICK_START.md +271 -0
- package/dist/integrations/claude_code/docs/README.md +347 -0
- package/dist/integrations/claude_code/skills/dr_01_motivation_layer/SKILL.md +550 -0
- package/dist/integrations/claude_code/skills/dr_02_business_layer/SKILL.md +620 -0
- package/dist/integrations/claude_code/skills/dr_03_security_layer/SKILL.md +642 -0
- package/dist/integrations/claude_code/skills/dr_04_application_layer/SKILL.md +911 -0
- package/dist/integrations/claude_code/skills/dr_05_technology_layer/SKILL.md +836 -0
- package/dist/integrations/claude_code/skills/dr_06_api_layer/SKILL.md +933 -0
- package/dist/integrations/claude_code/skills/dr_07_data_model_layer/SKILL.md +210 -0
- package/dist/integrations/claude_code/skills/dr_08_dataset_layer/SKILL.md +319 -0
- package/dist/integrations/claude_code/skills/dr_09_ux_layer/SKILL.md +319 -0
- package/dist/integrations/claude_code/skills/dr_10_navigation_layer/SKILL.md +318 -0
- package/dist/integrations/claude_code/skills/dr_11_apm_layer/SKILL.md +273 -0
- package/dist/integrations/claude_code/skills/dr_12_testing_layer/SKILL.md +273 -0
- package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +187 -0
- package/dist/integrations/claude_code/skills/dr_codebase_memory/SKILL.md +590 -0
- package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +295 -0
- package/dist/integrations/copilot-manager.js +328 -0
- package/dist/integrations/copilot-manager.js.map +7 -0
- package/dist/integrations/github_copilot/agents/dr-advisor.md +243 -0
- package/dist/integrations/github_copilot/agents/dr-architect.md +1567 -0
- package/dist/integrations/github_copilot/skills/dr_01_motivation_layer/SKILL.md +491 -0
- package/dist/integrations/github_copilot/skills/dr_02_business_layer/SKILL.md +539 -0
- package/dist/integrations/github_copilot/skills/dr_03_security_layer/SKILL.md +667 -0
- package/dist/integrations/github_copilot/skills/dr_04_application_layer/SKILL.md +670 -0
- package/dist/integrations/github_copilot/skills/dr_05_technology_layer/SKILL.md +660 -0
- package/dist/integrations/github_copilot/skills/dr_06_api_layer/SKILL.md +855 -0
- package/dist/integrations/github_copilot/skills/dr_07_data_model_layer/SKILL.md +171 -0
- package/dist/integrations/github_copilot/skills/dr_08_dataset_layer/SKILL.md +216 -0
- package/dist/integrations/github_copilot/skills/dr_09_ux_layer/SKILL.md +230 -0
- package/dist/integrations/github_copilot/skills/dr_10_navigation_layer/SKILL.md +228 -0
- package/dist/integrations/github_copilot/skills/dr_11_apm_layer/SKILL.md +234 -0
- package/dist/integrations/github_copilot/skills/dr_12_testing_layer/SKILL.md +230 -0
- package/dist/integrations/github_copilot/skills/dr_changeset_reviewer/SKILL.md +187 -0
- package/dist/integrations/hash-utils.js +51 -0
- package/dist/integrations/hash-utils.js.map +7 -0
- package/dist/integrations/types.js +16 -0
- package/dist/integrations/types.js.map +7 -0
- package/dist/reports/model-layer-report-generator.js +278 -0
- package/dist/reports/model-layer-report-generator.js.map +7 -0
- package/dist/reports/model-report-data.js +57 -0
- package/dist/reports/model-report-data.js.map +7 -0
- package/dist/reports/model-report-orchestrator.js +103 -0
- package/dist/reports/model-report-orchestrator.js.map +7 -0
- package/dist/schemas/bundled/analyzers/cbm.json +595 -0
- package/dist/schemas/bundled/analyzers/manifest.json +9 -0
- package/dist/schemas/bundled/api.json +3411 -0
- package/dist/schemas/bundled/apm.json +2371 -0
- package/dist/schemas/bundled/application.json +1253 -0
- package/dist/schemas/bundled/base.json +1622 -0
- package/dist/schemas/bundled/business.json +1279 -0
- package/dist/schemas/bundled/data-model.json +1298 -0
- package/dist/schemas/bundled/data-store.json +2025 -0
- package/dist/schemas/bundled/manifest.json +93 -0
- package/dist/schemas/bundled/motivation.json +1360 -0
- package/dist/schemas/bundled/navigation.json +1874 -0
- package/dist/schemas/bundled/security.json +3488 -0
- package/dist/schemas/bundled/technology.json +2067 -0
- package/dist/schemas/bundled/testing.json +3120 -0
- package/dist/schemas/bundled/ux.json +3592 -0
- package/dist/server/schemas.js +202 -0
- package/dist/server/schemas.js.map +7 -0
- package/dist/server/server.js +1336 -252
- package/dist/server/server.js.map +3 -3
- package/dist/server/telemetry-middleware.js +22 -15
- package/dist/server/telemetry-middleware.js.map +2 -2
- package/dist/server-entry.js +65 -0
- package/dist/server-entry.js.map +7 -0
- package/dist/telemetry/config.js +89 -0
- package/dist/telemetry/config.js.map +7 -0
- package/dist/telemetry/console-interceptor.js.map +1 -1
- package/dist/telemetry/detect.js +24 -0
- package/dist/telemetry/detect.js.map +7 -0
- package/dist/telemetry/fetch-otlp-exporter.js +112 -0
- package/dist/telemetry/fetch-otlp-exporter.js.map +7 -0
- package/dist/telemetry/index.js +153 -3
- package/dist/telemetry/index.js.map +2 -2
- package/dist/telemetry/resilient-exporter.js +22 -8
- package/dist/telemetry/resilient-exporter.js.map +2 -2
- package/dist/telemetry/resilient-log-exporter.js +17 -8
- package/dist/telemetry/resilient-log-exporter.js.map +2 -2
- package/dist/telemetry/test-instrumentation.js.map +2 -2
- package/dist/types/index.js +84 -0
- package/dist/types/index.js.map +3 -3
- package/dist/types/source-reference.js +1 -0
- package/dist/types/source-reference.js.map +7 -0
- package/dist/utils/chat-logger.js +292 -0
- package/dist/utils/chat-logger.js.map +7 -0
- package/dist/utils/claude-stream.js +8 -0
- package/dist/utils/claude-stream.js.map +7 -0
- package/dist/utils/date-utils.js +7 -0
- package/dist/utils/date-utils.js.map +7 -0
- package/dist/utils/element-utils.js.map +1 -1
- package/dist/utils/errors.js +88 -15
- package/dist/utils/errors.js.map +3 -3
- package/dist/utils/export-python-annotations.js +82 -0
- package/dist/utils/export-python-annotations.js.map +7 -0
- package/dist/utils/file-io.js +7 -2
- package/dist/utils/file-io.js.map +2 -2
- package/dist/utils/file-lock.js +156 -0
- package/dist/utils/file-lock.js.map +7 -0
- package/dist/utils/id-generator.js +18 -0
- package/dist/utils/id-generator.js.map +7 -0
- package/dist/utils/layer-name-formatter.js +16 -0
- package/dist/utils/layer-name-formatter.js.map +7 -0
- package/dist/utils/markdown-anchor.js +7 -0
- package/dist/utils/markdown-anchor.js.map +7 -0
- package/dist/utils/markdown-link.js +12 -0
- package/dist/utils/markdown-link.js.map +7 -0
- package/dist/utils/markdown-table.js +17 -0
- package/dist/utils/markdown-table.js.map +7 -0
- package/dist/utils/mermaid-utils.js +11 -0
- package/dist/utils/mermaid-utils.js.map +7 -0
- package/dist/utils/project-paths.js.map +2 -2
- package/dist/utils/source-reference.js +52 -0
- package/dist/utils/source-reference.js.map +7 -0
- package/dist/utils/spec-installer.js +40 -53
- package/dist/utils/spec-installer.js.map +2 -2
- package/dist/utils/spec-version.js +5 -1
- package/dist/utils/spec-version.js.map +2 -2
- package/dist/utils/string-utils.js +12 -0
- package/dist/utils/string-utils.js.map +7 -0
- package/dist/utils/table-formatting.js +19 -0
- package/dist/utils/table-formatting.js.map +7 -0
- package/dist/validators/index.js +4 -0
- package/dist/validators/index.js.map +2 -2
- package/dist/validators/naming-validator.js +20 -23
- package/dist/validators/naming-validator.js.map +2 -2
- package/dist/validators/reference-validator.js +23 -38
- package/dist/validators/reference-validator.js.map +2 -2
- package/dist/validators/relationship-schema-validator.js +243 -0
- package/dist/validators/relationship-schema-validator.js.map +7 -0
- package/dist/validators/schema-validator.js +168 -68
- package/dist/validators/schema-validator.js.map +2 -2
- package/dist/validators/semantic-validator.js +36 -60
- package/dist/validators/semantic-validator.js.map +2 -2
- package/dist/validators/types.js.map +2 -2
- package/dist/validators/validation-formatter.js +159 -0
- package/dist/validators/validation-formatter.js.map +7 -0
- package/dist/validators/validator.js +24 -38
- package/dist/validators/validator.js.map +2 -2
- package/dist/viewer/README.md +139 -0
- package/dist/viewer/assets/main-CY0Xufuj.css +1 -0
- package/dist/viewer/assets/main-DtgErnwF.js +81 -0
- package/dist/viewer/assets/vendor-CxKvDp2x.js +17 -0
- package/dist/viewer/favicon.svg +11 -0
- package/dist/viewer/fonts/inter/Inter-Black.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Bold.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-ExtraBold.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Light.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Medium.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Regular.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-SemiBold.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2 +0 -0
- package/dist/viewer/index.html +15 -0
- package/dist/viewer/manifest.json +99 -0
- package/dist/viewer/version.json +1 -0
- package/package.json +37 -13
- package/PYTHON_CLI_PARITY.md +0 -265
- package/PYTHON_CLI_STRUCTURE_UPDATE.md +0 -246
- package/biome.json +0 -42
- package/bunfig.toml +0 -3
- package/dist/ai/claude-client.js +0 -71
- package/dist/ai/claude-client.js.map +0 -7
- package/dist/ai/context-provider.js +0 -129
- package/dist/ai/context-provider.js.map +0 -7
- package/dist/ai/tools.js +0 -231
- package/dist/ai/tools.js.map +0 -7
- package/dist/commands/migrate.js +0 -36
- package/dist/commands/migrate.js.map +0 -7
- package/dist/commands/project.js +0 -74
- package/dist/commands/project.js.map +0 -7
- package/dist/core/active-changeset.js +0 -52
- package/dist/core/active-changeset.js.map +0 -7
- package/dist/core/projection-engine.js +0 -288
- package/dist/core/projection-engine.js.map +0 -7
- package/dist/schemas/bundled/01-motivation-layer.schema.json +0 -942
- package/dist/schemas/bundled/02-business-layer.schema.json +0 -1293
- package/dist/schemas/bundled/03-security-layer.schema.json +0 -2177
- package/dist/schemas/bundled/04-application-layer.schema.json +0 -1328
- package/dist/schemas/bundled/05-technology-layer.schema.json +0 -1465
- package/dist/schemas/bundled/06-api-layer.schema.json +0 -1743
- package/dist/schemas/bundled/07-data-model-layer.schema.json +0 -1253
- package/dist/schemas/bundled/08-datastore-layer.schema.json +0 -892
- package/dist/schemas/bundled/09-ux-layer.schema.json +0 -1506
- package/dist/schemas/bundled/10-navigation-layer.schema.json +0 -843
- package/dist/schemas/bundled/11-apm-observability-layer.schema.json +0 -1430
- package/dist/schemas/bundled/12-testing-layer.schema.json +0 -1091
- package/dist/schemas/bundled/common/layer-extensions.schema.json +0 -266
- package/dist/schemas/bundled/common/predicates.schema.json +0 -493
- package/dist/schemas/bundled/common/relationships.schema.json +0 -791
- package/dist/schemas/bundled/common/source-references.schema.json +0 -71
- package/dist/schemas/bundled/link-registry.json +0 -1839
- package/dist/schemas/bundled/link-registry.schema.json +0 -339
- package/dist/schemas/bundled/relationship-catalog.json +0 -1302
- package/dist/schemas/bundled/relationship-type.schema.json +0 -221
- package/dist/utils/model-path.js +0 -22
- package/dist/utils/model-path.js.map +0 -7
- package/docs/TEST-INSTRUMENTATION.md +0 -405
- package/docs/telemetry.md +0 -427
- package/test-debug.js +0 -33
- package/test-special.mjs +0 -46
- package/test_runner.ts +0 -7
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
const LAYER_TEMPLATES = [
|
|
2
|
+
{
|
|
3
|
+
layer: "motivation",
|
|
4
|
+
standard: "ArchiMate 3.2",
|
|
5
|
+
patterns: [
|
|
6
|
+
{
|
|
7
|
+
sourcePattern: "goal",
|
|
8
|
+
destinationPattern: "principle",
|
|
9
|
+
predicate: "supports",
|
|
10
|
+
description: "Goals support principles"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
sourcePattern: "requirement",
|
|
14
|
+
destinationPattern: "goal",
|
|
15
|
+
predicate: "realizes",
|
|
16
|
+
description: "Requirements realize goals"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
sourcePattern: "constraint",
|
|
20
|
+
destinationPattern: "requirement",
|
|
21
|
+
predicate: "restricts",
|
|
22
|
+
description: "Constraints restrict requirements"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
layer: "business",
|
|
28
|
+
standard: "ArchiMate 3.2",
|
|
29
|
+
patterns: [
|
|
30
|
+
{
|
|
31
|
+
sourcePattern: "process",
|
|
32
|
+
destinationPattern: "process",
|
|
33
|
+
predicate: "triggers",
|
|
34
|
+
description: "Processes trigger other processes"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
sourcePattern: "role",
|
|
38
|
+
destinationPattern: "process",
|
|
39
|
+
predicate: "performs",
|
|
40
|
+
description: "Roles perform processes"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
sourcePattern: "service",
|
|
44
|
+
destinationPattern: "process",
|
|
45
|
+
predicate: "realizes",
|
|
46
|
+
description: "Services realize processes"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
layer: "security",
|
|
52
|
+
standard: "NIST SP 800-53",
|
|
53
|
+
patterns: [
|
|
54
|
+
{
|
|
55
|
+
sourcePattern: "countermeasure",
|
|
56
|
+
destinationPattern: "threat",
|
|
57
|
+
predicate: "mitigates",
|
|
58
|
+
description: "Countermeasures mitigate threats"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
sourcePattern: "role",
|
|
62
|
+
destinationPattern: "permission",
|
|
63
|
+
predicate: "authorizes",
|
|
64
|
+
description: "Roles authorize permissions"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
sourcePattern: "policy",
|
|
68
|
+
destinationPattern: "countermeasure",
|
|
69
|
+
predicate: "mandates",
|
|
70
|
+
description: "Policies mandate countermeasures"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
layer: "application",
|
|
76
|
+
standard: "ArchiMate 3.2",
|
|
77
|
+
patterns: [
|
|
78
|
+
{
|
|
79
|
+
sourcePattern: "component",
|
|
80
|
+
destinationPattern: "service",
|
|
81
|
+
predicate: "realizes",
|
|
82
|
+
description: "Components realize services"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
sourcePattern: "component",
|
|
86
|
+
destinationPattern: "component",
|
|
87
|
+
predicate: "uses",
|
|
88
|
+
description: "Components use other components"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
sourcePattern: "interface",
|
|
92
|
+
destinationPattern: "service",
|
|
93
|
+
predicate: "serves",
|
|
94
|
+
description: "Interfaces serve services"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
layer: "technology",
|
|
100
|
+
standard: "ArchiMate 3.2",
|
|
101
|
+
patterns: [
|
|
102
|
+
{
|
|
103
|
+
sourcePattern: "node",
|
|
104
|
+
destinationPattern: "device",
|
|
105
|
+
predicate: "composes",
|
|
106
|
+
description: "Nodes compose devices"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
sourcePattern: "artifact",
|
|
110
|
+
destinationPattern: "component",
|
|
111
|
+
predicate: "realizes",
|
|
112
|
+
description: "Artifacts realize components"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
sourcePattern: "infrastructure",
|
|
116
|
+
destinationPattern: "node",
|
|
117
|
+
predicate: "hosts",
|
|
118
|
+
description: "Infrastructure hosts nodes"
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
layer: "api",
|
|
124
|
+
standard: "OpenAPI 3.0",
|
|
125
|
+
patterns: [
|
|
126
|
+
{
|
|
127
|
+
sourcePattern: "operation",
|
|
128
|
+
destinationPattern: "schema",
|
|
129
|
+
predicate: "references",
|
|
130
|
+
description: "Operations reference schemas"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
sourcePattern: "securityscheme",
|
|
134
|
+
destinationPattern: "operation",
|
|
135
|
+
predicate: "serves",
|
|
136
|
+
description: "Security schemes serve operations"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
sourcePattern: "response",
|
|
140
|
+
destinationPattern: "schema",
|
|
141
|
+
predicate: "returns",
|
|
142
|
+
description: "Responses return schemas"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
layer: "ux",
|
|
148
|
+
standard: "React/Component",
|
|
149
|
+
patterns: [
|
|
150
|
+
{
|
|
151
|
+
sourcePattern: "component",
|
|
152
|
+
destinationPattern: "component",
|
|
153
|
+
predicate: "renders",
|
|
154
|
+
description: "Components render other components"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
sourcePattern: "component",
|
|
158
|
+
destinationPattern: "entity",
|
|
159
|
+
predicate: "binds-to",
|
|
160
|
+
description: "Components bind to entities"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
sourcePattern: "form",
|
|
164
|
+
destinationPattern: "schema",
|
|
165
|
+
predicate: "validates",
|
|
166
|
+
description: "Forms validate against schemas"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
layer: "navigation",
|
|
172
|
+
standard: "Router patterns",
|
|
173
|
+
patterns: [
|
|
174
|
+
{
|
|
175
|
+
sourcePattern: "route",
|
|
176
|
+
destinationPattern: "screen",
|
|
177
|
+
predicate: "navigates-to",
|
|
178
|
+
description: "Routes navigate to screens"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
sourcePattern: "menuitem",
|
|
182
|
+
destinationPattern: "route",
|
|
183
|
+
predicate: "references",
|
|
184
|
+
description: "Menu items reference routes"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
sourcePattern: "link",
|
|
188
|
+
destinationPattern: "route",
|
|
189
|
+
predicate: "targets",
|
|
190
|
+
description: "Links target routes"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
layer: "data-model",
|
|
196
|
+
standard: "JSON Schema Draft 7",
|
|
197
|
+
patterns: [
|
|
198
|
+
{
|
|
199
|
+
sourcePattern: "entity",
|
|
200
|
+
destinationPattern: "entity",
|
|
201
|
+
predicate: "references",
|
|
202
|
+
description: "Entities reference other entities"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
sourcePattern: "entity",
|
|
206
|
+
destinationPattern: "property",
|
|
207
|
+
predicate: "has",
|
|
208
|
+
description: "Entities have properties"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
sourcePattern: "property",
|
|
212
|
+
destinationPattern: "entity",
|
|
213
|
+
predicate: "references",
|
|
214
|
+
description: "Properties reference entities"
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
layer: "data-store",
|
|
220
|
+
standard: "Database schema patterns",
|
|
221
|
+
patterns: [
|
|
222
|
+
{
|
|
223
|
+
sourcePattern: "table",
|
|
224
|
+
destinationPattern: "table",
|
|
225
|
+
predicate: "references",
|
|
226
|
+
description: "Tables reference other tables via foreign keys"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
sourcePattern: "index",
|
|
230
|
+
destinationPattern: "table",
|
|
231
|
+
predicate: "indexes",
|
|
232
|
+
description: "Indexes apply to tables"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
sourcePattern: "view",
|
|
236
|
+
destinationPattern: "table",
|
|
237
|
+
predicate: "derives-from",
|
|
238
|
+
description: "Views derive from tables"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
layer: "apm",
|
|
244
|
+
standard: "OpenTelemetry",
|
|
245
|
+
patterns: [
|
|
246
|
+
{
|
|
247
|
+
sourcePattern: "trace",
|
|
248
|
+
destinationPattern: "service",
|
|
249
|
+
predicate: "monitors",
|
|
250
|
+
description: "Traces monitor services"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
sourcePattern: "metric",
|
|
254
|
+
destinationPattern: "component",
|
|
255
|
+
predicate: "measures",
|
|
256
|
+
description: "Metrics measure components"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
sourcePattern: "alert",
|
|
260
|
+
destinationPattern: "metric",
|
|
261
|
+
predicate: "triggers-on",
|
|
262
|
+
description: "Alerts trigger on metrics"
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
layer: "testing",
|
|
268
|
+
standard: "Testing best practices",
|
|
269
|
+
patterns: [
|
|
270
|
+
{
|
|
271
|
+
sourcePattern: "testcase",
|
|
272
|
+
destinationPattern: "requirement",
|
|
273
|
+
predicate: "verifies",
|
|
274
|
+
description: "Test cases verify requirements"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
sourcePattern: "testdata",
|
|
278
|
+
destinationPattern: "testcase",
|
|
279
|
+
predicate: "supports",
|
|
280
|
+
description: "Test data supports test cases"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
sourcePattern: "testsuite",
|
|
284
|
+
destinationPattern: "testcase",
|
|
285
|
+
predicate: "contains",
|
|
286
|
+
description: "Test suites contain test cases"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
export {
|
|
292
|
+
LAYER_TEMPLATES
|
|
293
|
+
};
|
|
294
|
+
//# sourceMappingURL=layer-templates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/audit/relationships/analysis/layer-templates.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Layer-specific relationship templates for gap analysis and standard alignment\n */\n\nexport interface LayerTemplate {\n layer: string;\n standard: string;\n patterns: Array<{\n sourcePattern: string;\n destinationPattern: string;\n predicate: string;\n description: string;\n }>;\n}\n\nexport const LAYER_TEMPLATES: LayerTemplate[] = [\n {\n layer: \"motivation\",\n standard: \"ArchiMate 3.2\",\n patterns: [\n {\n sourcePattern: \"goal\",\n destinationPattern: \"principle\",\n predicate: \"supports\",\n description: \"Goals support principles\",\n },\n {\n sourcePattern: \"requirement\",\n destinationPattern: \"goal\",\n predicate: \"realizes\",\n description: \"Requirements realize goals\",\n },\n {\n sourcePattern: \"constraint\",\n destinationPattern: \"requirement\",\n predicate: \"restricts\",\n description: \"Constraints restrict requirements\",\n },\n ],\n },\n {\n layer: \"business\",\n standard: \"ArchiMate 3.2\",\n patterns: [\n {\n sourcePattern: \"process\",\n destinationPattern: \"process\",\n predicate: \"triggers\",\n description: \"Processes trigger other processes\",\n },\n {\n sourcePattern: \"role\",\n destinationPattern: \"process\",\n predicate: \"performs\",\n description: \"Roles perform processes\",\n },\n {\n sourcePattern: \"service\",\n destinationPattern: \"process\",\n predicate: \"realizes\",\n description: \"Services realize processes\",\n },\n ],\n },\n {\n layer: \"security\",\n standard: \"NIST SP 800-53\",\n patterns: [\n {\n sourcePattern: \"countermeasure\",\n destinationPattern: \"threat\",\n predicate: \"mitigates\",\n description: \"Countermeasures mitigate threats\",\n },\n {\n sourcePattern: \"role\",\n destinationPattern: \"permission\",\n predicate: \"authorizes\",\n description: \"Roles authorize permissions\",\n },\n {\n sourcePattern: \"policy\",\n destinationPattern: \"countermeasure\",\n predicate: \"mandates\",\n description: \"Policies mandate countermeasures\",\n },\n ],\n },\n {\n layer: \"application\",\n standard: \"ArchiMate 3.2\",\n patterns: [\n {\n sourcePattern: \"component\",\n destinationPattern: \"service\",\n predicate: \"realizes\",\n description: \"Components realize services\",\n },\n {\n sourcePattern: \"component\",\n destinationPattern: \"component\",\n predicate: \"uses\",\n description: \"Components use other components\",\n },\n {\n sourcePattern: \"interface\",\n destinationPattern: \"service\",\n predicate: \"serves\",\n description: \"Interfaces serve services\",\n },\n ],\n },\n {\n layer: \"technology\",\n standard: \"ArchiMate 3.2\",\n patterns: [\n {\n sourcePattern: \"node\",\n destinationPattern: \"device\",\n predicate: \"composes\",\n description: \"Nodes compose devices\",\n },\n {\n sourcePattern: \"artifact\",\n destinationPattern: \"component\",\n predicate: \"realizes\",\n description: \"Artifacts realize components\",\n },\n {\n sourcePattern: \"infrastructure\",\n destinationPattern: \"node\",\n predicate: \"hosts\",\n description: \"Infrastructure hosts nodes\",\n },\n ],\n },\n {\n layer: \"api\",\n standard: \"OpenAPI 3.0\",\n patterns: [\n {\n sourcePattern: \"operation\",\n destinationPattern: \"schema\",\n predicate: \"references\",\n description: \"Operations reference schemas\",\n },\n {\n sourcePattern: \"securityscheme\",\n destinationPattern: \"operation\",\n predicate: \"serves\",\n description: \"Security schemes serve operations\",\n },\n {\n sourcePattern: \"response\",\n destinationPattern: \"schema\",\n predicate: \"returns\",\n description: \"Responses return schemas\",\n },\n ],\n },\n {\n layer: \"ux\",\n standard: \"React/Component\",\n patterns: [\n {\n sourcePattern: \"component\",\n destinationPattern: \"component\",\n predicate: \"renders\",\n description: \"Components render other components\",\n },\n {\n sourcePattern: \"component\",\n destinationPattern: \"entity\",\n predicate: \"binds-to\",\n description: \"Components bind to entities\",\n },\n {\n sourcePattern: \"form\",\n destinationPattern: \"schema\",\n predicate: \"validates\",\n description: \"Forms validate against schemas\",\n },\n ],\n },\n {\n layer: \"navigation\",\n standard: \"Router patterns\",\n patterns: [\n {\n sourcePattern: \"route\",\n destinationPattern: \"screen\",\n predicate: \"navigates-to\",\n description: \"Routes navigate to screens\",\n },\n {\n sourcePattern: \"menuitem\",\n destinationPattern: \"route\",\n predicate: \"references\",\n description: \"Menu items reference routes\",\n },\n {\n sourcePattern: \"link\",\n destinationPattern: \"route\",\n predicate: \"targets\",\n description: \"Links target routes\",\n },\n ],\n },\n {\n layer: \"data-model\",\n standard: \"JSON Schema Draft 7\",\n patterns: [\n {\n sourcePattern: \"entity\",\n destinationPattern: \"entity\",\n predicate: \"references\",\n description: \"Entities reference other entities\",\n },\n {\n sourcePattern: \"entity\",\n destinationPattern: \"property\",\n predicate: \"has\",\n description: \"Entities have properties\",\n },\n {\n sourcePattern: \"property\",\n destinationPattern: \"entity\",\n predicate: \"references\",\n description: \"Properties reference entities\",\n },\n ],\n },\n {\n layer: \"data-store\",\n standard: \"Database schema patterns\",\n patterns: [\n {\n sourcePattern: \"table\",\n destinationPattern: \"table\",\n predicate: \"references\",\n description: \"Tables reference other tables via foreign keys\",\n },\n {\n sourcePattern: \"index\",\n destinationPattern: \"table\",\n predicate: \"indexes\",\n description: \"Indexes apply to tables\",\n },\n {\n sourcePattern: \"view\",\n destinationPattern: \"table\",\n predicate: \"derives-from\",\n description: \"Views derive from tables\",\n },\n ],\n },\n {\n layer: \"apm\",\n standard: \"OpenTelemetry\",\n patterns: [\n {\n sourcePattern: \"trace\",\n destinationPattern: \"service\",\n predicate: \"monitors\",\n description: \"Traces monitor services\",\n },\n {\n sourcePattern: \"metric\",\n destinationPattern: \"component\",\n predicate: \"measures\",\n description: \"Metrics measure components\",\n },\n {\n sourcePattern: \"alert\",\n destinationPattern: \"metric\",\n predicate: \"triggers-on\",\n description: \"Alerts trigger on metrics\",\n },\n ],\n },\n {\n layer: \"testing\",\n standard: \"Testing best practices\",\n patterns: [\n {\n sourcePattern: \"testcase\",\n destinationPattern: \"requirement\",\n predicate: \"verifies\",\n description: \"Test cases verify requirements\",\n },\n {\n sourcePattern: \"testdata\",\n destinationPattern: \"testcase\",\n predicate: \"supports\",\n description: \"Test data supports test cases\",\n },\n {\n sourcePattern: \"testsuite\",\n destinationPattern: \"testcase\",\n predicate: \"contains\",\n description: \"Test suites contain test cases\",\n },\n ],\n },\n];\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
class ConnectivityAnalyzer {
|
|
2
|
+
graph;
|
|
3
|
+
catalog;
|
|
4
|
+
// Cache to prevent redundant computations
|
|
5
|
+
cachedComponents = null;
|
|
6
|
+
cachedDegrees = null;
|
|
7
|
+
constructor(graph, catalog) {
|
|
8
|
+
this.graph = graph, this.catalog = catalog;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Find connected components using undirected traversal
|
|
12
|
+
*/
|
|
13
|
+
findConnectedComponents() {
|
|
14
|
+
if (this.cachedComponents !== null)
|
|
15
|
+
return this.cachedComponents;
|
|
16
|
+
const visited = /* @__PURE__ */ new Set(), components = [];
|
|
17
|
+
for (const nodeType of this.graph.getNodeTypes()) {
|
|
18
|
+
if (visited.has(nodeType))
|
|
19
|
+
continue;
|
|
20
|
+
const component = this.bfsComponent(nodeType, visited);
|
|
21
|
+
component.length > 0 && components.push({
|
|
22
|
+
nodes: component
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return this.cachedComponents = components.sort((a, b) => b.nodes.length - a.nodes.length), this.cachedComponents;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* BFS to find connected component (undirected)
|
|
29
|
+
*/
|
|
30
|
+
bfsComponent(start, visited) {
|
|
31
|
+
const component = [], queue = [start];
|
|
32
|
+
for (; queue.length > 0; ) {
|
|
33
|
+
const current = queue.shift();
|
|
34
|
+
if (visited.has(current))
|
|
35
|
+
continue;
|
|
36
|
+
visited.add(current), component.push(current);
|
|
37
|
+
const neighbors = this.graph.getNeighbors(current);
|
|
38
|
+
for (const neighbor of neighbors)
|
|
39
|
+
visited.has(neighbor) || queue.push(neighbor);
|
|
40
|
+
}
|
|
41
|
+
return component;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Calculate node degree distribution
|
|
45
|
+
*/
|
|
46
|
+
calculateDegreeDistribution() {
|
|
47
|
+
if (this.cachedDegrees !== null)
|
|
48
|
+
return this.cachedDegrees;
|
|
49
|
+
const degrees = [];
|
|
50
|
+
for (const nodeType of this.graph.getNodeTypes()) {
|
|
51
|
+
const outgoing = this.graph.getOutgoingRelationships(nodeType), incoming = this.graph.getIncomingRelationships(nodeType);
|
|
52
|
+
degrees.push({
|
|
53
|
+
nodeType,
|
|
54
|
+
inDegree: incoming.length,
|
|
55
|
+
outDegree: outgoing.length,
|
|
56
|
+
totalDegree: incoming.length + outgoing.length
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return this.cachedDegrees = degrees.sort((a, b) => b.totalDegree - a.totalDegree), this.cachedDegrees;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Identify isolated nodes (degree === 0)
|
|
63
|
+
*/
|
|
64
|
+
findIsolatedNodes() {
|
|
65
|
+
return this.calculateDegreeDistribution().filter((d) => d.totalDegree === 0).map((d) => d.nodeType);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Find transitive chains for transitive predicates
|
|
69
|
+
*/
|
|
70
|
+
async findTransitiveChains() {
|
|
71
|
+
const chains = [], transitivePredicates = this.catalog.getAllTypes().filter((t) => t.semantics.transitivity).map((t) => t.predicate);
|
|
72
|
+
for (const predicate of transitivePredicates) {
|
|
73
|
+
const predicateChains = this.findChainsForPredicate(predicate);
|
|
74
|
+
chains.push(...predicateChains);
|
|
75
|
+
}
|
|
76
|
+
return chains.sort((a, b) => b.chain.length - a.chain.length);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Find chains for a specific predicate
|
|
80
|
+
*/
|
|
81
|
+
findChainsForPredicate(predicate) {
|
|
82
|
+
const chains = [], visited = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const nodeType of this.graph.getNodeTypes()) {
|
|
84
|
+
if (visited.has(nodeType))
|
|
85
|
+
continue;
|
|
86
|
+
const chain = this.dfsChain(nodeType, predicate, visited, []);
|
|
87
|
+
chain.length > 1 && chains.push({
|
|
88
|
+
predicate,
|
|
89
|
+
chain
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return chains.sort((a, b) => b.chain.length - a.chain.length);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* DFS to find transitive chain
|
|
96
|
+
*/
|
|
97
|
+
dfsChain(current, predicate, visited, path) {
|
|
98
|
+
if (visited.has(current))
|
|
99
|
+
return path;
|
|
100
|
+
visited.add(current), path.push(current);
|
|
101
|
+
const outgoing = this.graph.getOutgoingRelationships(current).filter((e) => e.predicate === predicate);
|
|
102
|
+
if (outgoing.length === 0)
|
|
103
|
+
return path;
|
|
104
|
+
let longestChain = path;
|
|
105
|
+
for (const edge of outgoing) {
|
|
106
|
+
const chain = this.dfsChain(edge.destination, predicate, new Set(visited), [...path]);
|
|
107
|
+
chain.length > longestChain.length && (longestChain = chain);
|
|
108
|
+
}
|
|
109
|
+
return longestChain;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get statistics about connectivity
|
|
113
|
+
*/
|
|
114
|
+
getConnectivityStats() {
|
|
115
|
+
const components = this.findConnectedComponents(), isolated = this.findIsolatedNodes(), degrees = this.calculateDegreeDistribution(), totalDegree = degrees.reduce((sum, d) => sum + d.totalDegree, 0), averageDegree = degrees.length > 0 ? totalDegree / degrees.length : 0;
|
|
116
|
+
return {
|
|
117
|
+
nodeCount: this.graph.getNodeCount(),
|
|
118
|
+
edgeCount: this.graph.getEdgeCount(),
|
|
119
|
+
componentCount: components.length,
|
|
120
|
+
isolatedNodeCount: isolated.length,
|
|
121
|
+
largestComponentSize: components.length > 0 ? components[0].nodes.length : 0,
|
|
122
|
+
averageDegree
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
ConnectivityAnalyzer
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=connectivity.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/audit/relationships/graph/connectivity.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Connectivity Analyzer - Analyzes graph connectivity\n *\n * Provides:\n * - Connected component detection\n * - Node degree distribution\n * - Isolated node identification\n * - Transitive chain detection\n */\n\nimport { RelationshipCatalog } from \"../../../core/relationship-catalog.js\";\nimport { RelationshipGraph } from \"./relationship-graph.js\";\nimport type {\n ConnectedComponent,\n NodeDegree,\n TransitiveChain,\n} from \"../../types.js\";\n\n/**\n * Connectivity analyzer for relationship graphs\n */\nexport class ConnectivityAnalyzer {\n // Cache to prevent redundant computations\n private cachedComponents: ConnectedComponent[] | null = null;\n private cachedDegrees: NodeDegree[] | null = null;\n\n constructor(\n private graph: RelationshipGraph,\n private catalog: RelationshipCatalog\n ) {}\n\n /**\n * Find connected components using undirected traversal\n */\n findConnectedComponents(): ConnectedComponent[] {\n if (this.cachedComponents !== null) {\n return this.cachedComponents;\n }\n\n const visited = new Set<string>();\n const components: ConnectedComponent[] = [];\n\n for (const nodeType of this.graph.getNodeTypes()) {\n if (visited.has(nodeType)) {\n continue;\n }\n\n // BFS to find component\n const component = this.bfsComponent(nodeType, visited);\n if (component.length > 0) {\n components.push({\n nodes: component,\n });\n }\n }\n\n this.cachedComponents = components.sort((a, b) => b.nodes.length - a.nodes.length);\n return this.cachedComponents;\n }\n\n /**\n * BFS to find connected component (undirected)\n */\n private bfsComponent(start: string, visited: Set<string>): string[] {\n const component: string[] = [];\n const queue: string[] = [start];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n\n if (visited.has(current)) {\n continue;\n }\n\n visited.add(current);\n component.push(current);\n\n // Get neighbors (both incoming and outgoing)\n const neighbors = this.graph.getNeighbors(current);\n for (const neighbor of neighbors) {\n if (!visited.has(neighbor)) {\n queue.push(neighbor);\n }\n }\n }\n\n return component;\n }\n\n /**\n * Calculate node degree distribution\n */\n calculateDegreeDistribution(): NodeDegree[] {\n if (this.cachedDegrees !== null) {\n return this.cachedDegrees;\n }\n\n const degrees: NodeDegree[] = [];\n\n for (const nodeType of this.graph.getNodeTypes()) {\n const outgoing = this.graph.getOutgoingRelationships(nodeType);\n const incoming = this.graph.getIncomingRelationships(nodeType);\n\n degrees.push({\n nodeType,\n inDegree: incoming.length,\n outDegree: outgoing.length,\n totalDegree: incoming.length + outgoing.length,\n });\n }\n\n this.cachedDegrees = degrees.sort((a, b) => b.totalDegree - a.totalDegree);\n return this.cachedDegrees;\n }\n\n /**\n * Identify isolated nodes (degree === 0)\n */\n findIsolatedNodes(): string[] {\n const degrees = this.calculateDegreeDistribution();\n return degrees\n .filter((d) => d.totalDegree === 0)\n .map((d) => d.nodeType);\n }\n\n /**\n * Find transitive chains for transitive predicates\n */\n async findTransitiveChains(): Promise<TransitiveChain[]> {\n const chains: TransitiveChain[] = [];\n\n // Get all transitive predicates\n const allTypes = this.catalog.getAllTypes();\n const transitivePredicates = allTypes\n .filter((t) => t.semantics.transitivity)\n .map((t) => t.predicate);\n\n // For each transitive predicate, find chains\n for (const predicate of transitivePredicates) {\n const predicateChains = this.findChainsForPredicate(predicate);\n chains.push(...predicateChains);\n }\n\n return chains.sort((a, b) => b.chain.length - a.chain.length);\n }\n\n /**\n * Find chains for a specific predicate\n */\n private findChainsForPredicate(predicate: string): TransitiveChain[] {\n const chains: TransitiveChain[] = [];\n const visited = new Set<string>();\n\n for (const nodeType of this.graph.getNodeTypes()) {\n if (visited.has(nodeType)) {\n continue;\n }\n\n // DFS to find chain\n const chain = this.dfsChain(nodeType, predicate, visited, []);\n if (chain.length > 1) {\n chains.push({\n predicate,\n chain,\n });\n }\n }\n\n return chains.sort((a, b) => b.chain.length - a.chain.length);\n }\n\n /**\n * DFS to find transitive chain\n */\n private dfsChain(\n current: string,\n predicate: string,\n visited: Set<string>,\n path: string[]\n ): string[] {\n if (visited.has(current)) {\n return path;\n }\n\n visited.add(current);\n path.push(current);\n\n // Find outgoing edges with the predicate\n const outgoing = this.graph\n .getOutgoingRelationships(current)\n .filter((e) => e.predicate === predicate);\n\n if (outgoing.length === 0) {\n return path;\n }\n\n // Follow the first edge (prefer longest chain)\n let longestChain = path;\n for (const edge of outgoing) {\n const chain = this.dfsChain(\n edge.destination,\n predicate,\n new Set(visited),\n [...path]\n );\n if (chain.length > longestChain.length) {\n longestChain = chain;\n }\n }\n\n return longestChain;\n }\n\n /**\n * Get statistics about connectivity\n */\n getConnectivityStats(): {\n nodeCount: number;\n edgeCount: number;\n componentCount: number;\n isolatedNodeCount: number;\n largestComponentSize: number;\n averageDegree: number;\n } {\n const components = this.findConnectedComponents();\n const isolated = this.findIsolatedNodes();\n const degrees = this.calculateDegreeDistribution();\n\n const totalDegree = degrees.reduce(\n (sum, d) => sum + d.totalDegree,\n 0\n );\n const averageDegree =\n degrees.length > 0 ? totalDegree / degrees.length : 0;\n\n return {\n nodeCount: this.graph.getNodeCount(),\n edgeCount: this.graph.getEdgeCount(),\n componentCount: components.length,\n isolatedNodeCount: isolated.length,\n largestComponentSize:\n components.length > 0 ? components[0].nodes.length : 0,\n averageDegree,\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "AAqBM,MAAO,qBAAoB;EAMrB;EACA;;EALF,mBAAgD;EAChD,gBAAqC;EAE7C,YACU,OACA,SAA4B;AAD5B,SAAA,QAAA,OACA,KAAA,UAAA;EACP;;;;EAKH,0BAAuB;AACrB,QAAI,KAAK,qBAAqB;AAC5B,aAAO,KAAK;AAGd,UAAM,UAAU,oBAAI,IAAG,GACjB,aAAmC,CAAA;AAEzC,eAAW,YAAY,KAAK,MAAM,aAAY,GAAI;AAChD,UAAI,QAAQ,IAAI,QAAQ;AACtB;AAIF,YAAM,YAAY,KAAK,aAAa,UAAU,OAAO;AACrD,MAAI,UAAU,SAAS,KACrB,WAAW,KAAK;QACd,OAAO;OACR;IAEL;AAEA,gBAAK,mBAAmB,WAAW,KAAK,CAAC,GAAG,MAAM,EAAE,MAAM,SAAS,EAAE,MAAM,MAAM,GAC1E,KAAK;EACd;;;;EAKQ,aAAa,OAAe,SAAoB;AACtD,UAAM,YAAsB,CAAA,GACtB,QAAkB,CAAC,KAAK;AAE9B,WAAO,MAAM,SAAS,KAAG;AACvB,YAAM,UAAU,MAAM,MAAK;AAE3B,UAAI,QAAQ,IAAI,OAAO;AACrB;AAGF,cAAQ,IAAI,OAAO,GACnB,UAAU,KAAK,OAAO;AAGtB,YAAM,YAAY,KAAK,MAAM,aAAa,OAAO;AACjD,iBAAW,YAAY;AACrB,QAAK,QAAQ,IAAI,QAAQ,KACvB,MAAM,KAAK,QAAQ;IAGzB;AAEA,WAAO;EACT;;;;EAKA,8BAA2B;AACzB,QAAI,KAAK,kBAAkB;AACzB,aAAO,KAAK;AAGd,UAAM,UAAwB,CAAA;AAE9B,eAAW,YAAY,KAAK,MAAM,aAAY,GAAI;AAChD,YAAM,WAAW,KAAK,MAAM,yBAAyB,QAAQ,GACvD,WAAW,KAAK,MAAM,yBAAyB,QAAQ;AAE7D,cAAQ,KAAK;QACX;QACA,UAAU,SAAS;QACnB,WAAW,SAAS;QACpB,aAAa,SAAS,SAAS,SAAS;OACzC;IACH;AAEA,gBAAK,gBAAgB,QAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,EAAE,WAAW,GAClE,KAAK;EACd;;;;EAKA,oBAAiB;AAEf,WADgB,KAAK,4BAA2B,EAE7C,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACjC,IAAI,CAAC,MAAM,EAAE,QAAQ;EAC1B;;;;EAKA,MAAM,uBAAoB;AACxB,UAAM,SAA4B,CAAA,GAI5B,uBADW,KAAK,QAAQ,YAAW,EAEtC,OAAO,CAAC,MAAM,EAAE,UAAU,YAAY,EACtC,IAAI,CAAC,MAAM,EAAE,SAAS;AAGzB,eAAW,aAAa,sBAAsB;AAC5C,YAAM,kBAAkB,KAAK,uBAAuB,SAAS;AAC7D,aAAO,KAAK,GAAG,eAAe;IAChC;AAEA,WAAO,OAAO,KAAK,CAAC,GAAG,MAAM,EAAE,MAAM,SAAS,EAAE,MAAM,MAAM;EAC9D;;;;EAKQ,uBAAuB,WAAiB;AAC9C,UAAM,SAA4B,CAAA,GAC5B,UAAU,oBAAI,IAAG;AAEvB,eAAW,YAAY,KAAK,MAAM,aAAY,GAAI;AAChD,UAAI,QAAQ,IAAI,QAAQ;AACtB;AAIF,YAAM,QAAQ,KAAK,SAAS,UAAU,WAAW,SAAS,CAAA,CAAE;AAC5D,MAAI,MAAM,SAAS,KACjB,OAAO,KAAK;QACV;QACA;OACD;IAEL;AAEA,WAAO,OAAO,KAAK,CAAC,GAAG,MAAM,EAAE,MAAM,SAAS,EAAE,MAAM,MAAM;EAC9D;;;;EAKQ,SACN,SACA,WACA,SACA,MAAc;AAEd,QAAI,QAAQ,IAAI,OAAO;AACrB,aAAO;AAGT,YAAQ,IAAI,OAAO,GACnB,KAAK,KAAK,OAAO;AAGjB,UAAM,WAAW,KAAK,MACnB,yBAAyB,OAAO,EAChC,OAAO,CAAC,MAAM,EAAE,cAAc,SAAS;AAE1C,QAAI,SAAS,WAAW;AACtB,aAAO;AAIT,QAAI,eAAe;AACnB,eAAW,QAAQ,UAAU;AAC3B,YAAM,QAAQ,KAAK,SACjB,KAAK,aACL,WACA,IAAI,IAAI,OAAO,GACf,CAAC,GAAG,IAAI,CAAC;AAEX,MAAI,MAAM,SAAS,aAAa,WAC9B,eAAe;IAEnB;AAEA,WAAO;EACT;;;;EAKA,uBAAoB;AAQlB,UAAM,aAAa,KAAK,wBAAuB,GACzC,WAAW,KAAK,kBAAiB,GACjC,UAAU,KAAK,4BAA2B,GAE1C,cAAc,QAAQ,OAC1B,CAAC,KAAK,MAAM,MAAM,EAAE,aACpB,CAAC,GAEG,gBACJ,QAAQ,SAAS,IAAI,cAAc,QAAQ,SAAS;AAEtD,WAAO;MACL,WAAW,KAAK,MAAM,aAAY;MAClC,WAAW,KAAK,MAAM,aAAY;MAClC,gBAAgB,WAAW;MAC3B,mBAAmB,SAAS;MAC5B,sBACE,WAAW,SAAS,IAAI,WAAW,CAAC,EAAE,MAAM,SAAS;MACvD;;EAEJ;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { GraphModel } from "../../../core/graph-model.js";
|
|
2
|
+
import { RELATIONSHIPS } from "../../../generated/relationship-index.js";
|
|
3
|
+
import { getAllLayers } from "../../../generated/layer-registry.js";
|
|
4
|
+
class RelationshipGraph {
|
|
5
|
+
graph;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.graph = new GraphModel();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Build graph from intra-layer relationships
|
|
11
|
+
*/
|
|
12
|
+
async build(layerId) {
|
|
13
|
+
this.graph.clear();
|
|
14
|
+
const relationships = layerId ? RELATIONSHIPS.filter((r) => r.sourceSpecNodeId.startsWith(`${layerId}.`)) : RELATIONSHIPS, nodeTypes = /* @__PURE__ */ new Set();
|
|
15
|
+
for (const rel of relationships)
|
|
16
|
+
nodeTypes.add(rel.sourceSpecNodeId), nodeTypes.add(rel.destinationSpecNodeId);
|
|
17
|
+
if (layerId) {
|
|
18
|
+
const layer = getAllLayers().find((l) => l.id === layerId);
|
|
19
|
+
if (layer)
|
|
20
|
+
for (const nodeType of layer.nodeTypes)
|
|
21
|
+
nodeTypes.add(nodeType);
|
|
22
|
+
}
|
|
23
|
+
for (const nodeType of nodeTypes) {
|
|
24
|
+
const [layer, type] = nodeType.split(".");
|
|
25
|
+
this.graph.addNode({
|
|
26
|
+
id: nodeType,
|
|
27
|
+
layer: layer || "unknown",
|
|
28
|
+
type: type || "unknown",
|
|
29
|
+
name: nodeType,
|
|
30
|
+
properties: {}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const skippedEdges = [];
|
|
34
|
+
for (const rel of relationships)
|
|
35
|
+
try {
|
|
36
|
+
this.graph.addEdge({
|
|
37
|
+
id: rel.id,
|
|
38
|
+
source: rel.sourceSpecNodeId,
|
|
39
|
+
destination: rel.destinationSpecNodeId,
|
|
40
|
+
predicate: rel.predicate,
|
|
41
|
+
properties: {
|
|
42
|
+
cardinality: rel.cardinality,
|
|
43
|
+
strength: rel.strength,
|
|
44
|
+
required: rel.required
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
49
|
+
skippedEdges.push({
|
|
50
|
+
relationshipId: rel.id,
|
|
51
|
+
source: rel.sourceSpecNodeId,
|
|
52
|
+
destination: rel.destinationSpecNodeId,
|
|
53
|
+
reason
|
|
54
|
+
}), console.error(`\u26A0\uFE0F Data integrity issue: Relationship "${rel.id}" references non-existent node type. ${reason}`);
|
|
55
|
+
}
|
|
56
|
+
skippedEdges.length > 0 && (console.error(`
|
|
57
|
+
\u26A0\uFE0F Warning: ${skippedEdges.length} relationship(s) skipped due to missing node type references.`), console.error("This indicates data integrity issues in the relationship schemas."), console.error(`Run 'dr schema relationships' to validate relationship definitions.
|
|
58
|
+
`));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get node count
|
|
62
|
+
*/
|
|
63
|
+
getNodeCount() {
|
|
64
|
+
return this.graph.getNodeCount();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get edge count
|
|
68
|
+
*/
|
|
69
|
+
getEdgeCount() {
|
|
70
|
+
return this.graph.getEdgeCount();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get all node types in the graph
|
|
74
|
+
*/
|
|
75
|
+
getNodeTypes() {
|
|
76
|
+
return Array.from(this.graph.nodes.keys());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get outgoing relationships for a node type
|
|
80
|
+
*/
|
|
81
|
+
getOutgoingRelationships(nodeType) {
|
|
82
|
+
return this.graph.getEdgesFrom(nodeType);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get incoming relationships for a node type
|
|
86
|
+
*/
|
|
87
|
+
getIncomingRelationships(nodeType) {
|
|
88
|
+
return this.graph.getEdgesTo(nodeType);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get all relationships for a node type
|
|
92
|
+
*/
|
|
93
|
+
getAllRelationships(nodeType) {
|
|
94
|
+
return [
|
|
95
|
+
...this.graph.getEdgesFrom(nodeType),
|
|
96
|
+
...this.graph.getEdgesTo(nodeType)
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Find paths between two node types
|
|
101
|
+
*/
|
|
102
|
+
findPaths(sourceType, destType, maxDepth = 5) {
|
|
103
|
+
const paths = [], visited = /* @__PURE__ */ new Set(), dfs = (current, path, depth) => {
|
|
104
|
+
if (depth > maxDepth)
|
|
105
|
+
return;
|
|
106
|
+
if (current === destType) {
|
|
107
|
+
paths.push([...path, current]);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (visited.has(current))
|
|
111
|
+
return;
|
|
112
|
+
visited.add(current), path.push(current);
|
|
113
|
+
const outgoing = this.graph.getEdgesFrom(current);
|
|
114
|
+
for (const edge of outgoing)
|
|
115
|
+
dfs(edge.destination, [...path], depth + 1);
|
|
116
|
+
visited.delete(current);
|
|
117
|
+
};
|
|
118
|
+
return dfs(sourceType, [], 0), paths;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get neighbors of a node type
|
|
122
|
+
*/
|
|
123
|
+
getNeighbors(nodeType) {
|
|
124
|
+
const neighbors = /* @__PURE__ */ new Set(), outgoing = this.graph.getEdgesFrom(nodeType);
|
|
125
|
+
for (const edge of outgoing)
|
|
126
|
+
neighbors.add(edge.destination);
|
|
127
|
+
const incoming = this.graph.getEdgesTo(nodeType);
|
|
128
|
+
for (const edge of incoming)
|
|
129
|
+
neighbors.add(edge.source);
|
|
130
|
+
return Array.from(neighbors);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get the underlying graph model
|
|
134
|
+
*/
|
|
135
|
+
getGraphModel() {
|
|
136
|
+
return this.graph;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Build graph from actual model relationship instances and elements.
|
|
140
|
+
* Used by ModelAuditOrchestrator to analyse the project model rather than spec schemas.
|
|
141
|
+
*/
|
|
142
|
+
buildFromModel(relationships, elements) {
|
|
143
|
+
this.graph.clear();
|
|
144
|
+
const elementById = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const e of elements)
|
|
146
|
+
elementById.set(e.id, e), e.path && e.path !== e.id && elementById.set(e.path, e);
|
|
147
|
+
const specNodeIds = new Set(elements.map((e) => e.spec_node_id).filter(Boolean));
|
|
148
|
+
for (const specNodeId of specNodeIds) {
|
|
149
|
+
const [layer, type] = specNodeId.split(".");
|
|
150
|
+
this.graph.addNode({
|
|
151
|
+
id: specNodeId,
|
|
152
|
+
layer: layer ?? "unknown",
|
|
153
|
+
type: type ?? "unknown",
|
|
154
|
+
name: specNodeId,
|
|
155
|
+
properties: {}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
let edgeCounter = 0;
|
|
159
|
+
for (const rel of relationships) {
|
|
160
|
+
const srcEl = elementById.get(rel.source), dstEl = elementById.get(rel.target);
|
|
161
|
+
if (!(!srcEl?.spec_node_id || !dstEl?.spec_node_id))
|
|
162
|
+
try {
|
|
163
|
+
this.graph.addEdge({
|
|
164
|
+
id: `model-rel-${edgeCounter++}`,
|
|
165
|
+
source: srcEl.spec_node_id,
|
|
166
|
+
destination: dstEl.spec_node_id,
|
|
167
|
+
predicate: rel.predicate,
|
|
168
|
+
properties: rel.properties,
|
|
169
|
+
category: rel.category
|
|
170
|
+
});
|
|
171
|
+
} catch {
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
RelationshipGraph
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=relationship-graph.js.map
|