@principal-ai/subsystems-core 0.29.0 → 0.31.0
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/README.md +15 -110
- package/dist/index.d.ts +7 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -205
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +5 -61
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +9 -131
- package/dist/node.js.map +1 -1
- package/dist/types/index.d.ts +3 -348
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/subsystem-model.d.ts +34 -3
- package/dist/types/subsystem-model.d.ts.map +1 -1
- package/dist/types/subsystem-model.js.map +1 -1
- package/package.json +7 -24
- package/schemas/subsystem-model.schema.json +52 -1
- package/src/index.ts +7 -580
- package/src/node.ts +21 -262
- package/src/types/index.ts +3 -456
- package/src/types/subsystem-model.ts +39 -3
- package/dist/ConfigurationLoader.d.ts +0 -76
- package/dist/ConfigurationLoader.d.ts.map +0 -1
- package/dist/ConfigurationLoader.js +0 -148
- package/dist/ConfigurationLoader.js.map +0 -1
- package/dist/ConfigurationValidator.d.ts +0 -31
- package/dist/ConfigurationValidator.d.ts.map +0 -1
- package/dist/ConfigurationValidator.js +0 -239
- package/dist/ConfigurationValidator.js.map +0 -1
- package/dist/EventProcessor.d.ts +0 -49
- package/dist/EventProcessor.d.ts.map +0 -1
- package/dist/EventProcessor.js +0 -220
- package/dist/EventProcessor.js.map +0 -1
- package/dist/EventRecorderService.d.ts +0 -305
- package/dist/EventRecorderService.d.ts.map +0 -1
- package/dist/EventRecorderService.js +0 -467
- package/dist/EventRecorderService.js.map +0 -1
- package/dist/LibraryLoader.d.ts +0 -65
- package/dist/LibraryLoader.d.ts.map +0 -1
- package/dist/LibraryLoader.js +0 -197
- package/dist/LibraryLoader.js.map +0 -1
- package/dist/PathBasedEventProcessor.d.ts +0 -77
- package/dist/PathBasedEventProcessor.d.ts.map +0 -1
- package/dist/PathBasedEventProcessor.js +0 -136
- package/dist/PathBasedEventProcessor.js.map +0 -1
- package/dist/SessionManager.d.ts +0 -194
- package/dist/SessionManager.d.ts.map +0 -1
- package/dist/SessionManager.js +0 -302
- package/dist/SessionManager.js.map +0 -1
- package/dist/ValidationEngine.d.ts +0 -31
- package/dist/ValidationEngine.d.ts.map +0 -1
- package/dist/ValidationEngine.js +0 -162
- package/dist/ValidationEngine.js.map +0 -1
- package/dist/auxiliary/AuxiliaryManifestValidator.d.ts +0 -41
- package/dist/auxiliary/AuxiliaryManifestValidator.d.ts.map +0 -1
- package/dist/auxiliary/AuxiliaryManifestValidator.js +0 -100
- package/dist/auxiliary/AuxiliaryManifestValidator.js.map +0 -1
- package/dist/auxiliary/index.d.ts +0 -9
- package/dist/auxiliary/index.d.ts.map +0 -1
- package/dist/auxiliary/index.js +0 -14
- package/dist/auxiliary/index.js.map +0 -1
- package/dist/auxiliary/validateAreaScopeDisjoint.d.ts +0 -24
- package/dist/auxiliary/validateAreaScopeDisjoint.d.ts.map +0 -1
- package/dist/auxiliary/validateAreaScopeDisjoint.js +0 -61
- package/dist/auxiliary/validateAreaScopeDisjoint.js.map +0 -1
- package/dist/cli/codegen.d.ts +0 -41
- package/dist/cli/codegen.d.ts.map +0 -1
- package/dist/cli/codegen.js +0 -257
- package/dist/cli/codegen.js.map +0 -1
- package/dist/codegen/type-generator.d.ts +0 -123
- package/dist/codegen/type-generator.d.ts.map +0 -1
- package/dist/codegen/type-generator.js +0 -433
- package/dist/codegen/type-generator.js.map +0 -1
- package/dist/codegen/usage-example.d.ts +0 -103
- package/dist/codegen/usage-example.d.ts.map +0 -1
- package/dist/codegen/usage-example.js +0 -258
- package/dist/codegen/usage-example.js.map +0 -1
- package/dist/dashboard/DashboardValidator.d.ts +0 -85
- package/dist/dashboard/DashboardValidator.d.ts.map +0 -1
- package/dist/dashboard/DashboardValidator.js +0 -775
- package/dist/dashboard/DashboardValidator.js.map +0 -1
- package/dist/dashboard/index.d.ts +0 -6
- package/dist/dashboard/index.d.ts.map +0 -1
- package/dist/dashboard/index.js +0 -10
- package/dist/dashboard/index.js.map +0 -1
- package/dist/discovery/CanvasDiscovery.d.ts +0 -160
- package/dist/discovery/CanvasDiscovery.d.ts.map +0 -1
- package/dist/discovery/CanvasDiscovery.js +0 -865
- package/dist/discovery/CanvasDiscovery.js.map +0 -1
- package/dist/discovery/CanvasFileManifest.d.ts +0 -86
- package/dist/discovery/CanvasFileManifest.d.ts.map +0 -1
- package/dist/discovery/CanvasFileManifest.js +0 -338
- package/dist/discovery/CanvasFileManifest.js.map +0 -1
- package/dist/discovery/LibraryDiscovery.d.ts +0 -108
- package/dist/discovery/LibraryDiscovery.d.ts.map +0 -1
- package/dist/discovery/LibraryDiscovery.js +0 -263
- package/dist/discovery/LibraryDiscovery.js.map +0 -1
- package/dist/discovery/types.d.ts +0 -403
- package/dist/discovery/types.d.ts.map +0 -1
- package/dist/discovery/types.js +0 -6
- package/dist/discovery/types.js.map +0 -1
- package/dist/events/EventsCanvasValidator.d.ts +0 -139
- package/dist/events/EventsCanvasValidator.d.ts.map +0 -1
- package/dist/events/EventsCanvasValidator.js +0 -281
- package/dist/events/EventsCanvasValidator.js.map +0 -1
- package/dist/events/NamespacePathIndex.d.ts +0 -61
- package/dist/events/NamespacePathIndex.d.ts.map +0 -1
- package/dist/events/NamespacePathIndex.js +0 -74
- package/dist/events/NamespacePathIndex.js.map +0 -1
- package/dist/events/OtelEventPathsValidator.d.ts +0 -75
- package/dist/events/OtelEventPathsValidator.d.ts.map +0 -1
- package/dist/events/OtelEventPathsValidator.js +0 -126
- package/dist/events/OtelEventPathsValidator.js.map +0 -1
- package/dist/events/ScopeEventsValidator.d.ts +0 -68
- package/dist/events/ScopeEventsValidator.d.ts.map +0 -1
- package/dist/events/ScopeEventsValidator.js +0 -91
- package/dist/events/ScopeEventsValidator.js.map +0 -1
- package/dist/events/index.d.ts +0 -9
- package/dist/events/index.d.ts.map +0 -1
- package/dist/events/index.js +0 -12
- package/dist/events/index.js.map +0 -1
- package/dist/events/path-helpers.d.ts +0 -33
- package/dist/events/path-helpers.d.ts.map +0 -1
- package/dist/events/path-helpers.js +0 -59
- package/dist/events/path-helpers.js.map +0 -1
- package/dist/execution/ExecutionLoader.d.ts +0 -135
- package/dist/execution/ExecutionLoader.d.ts.map +0 -1
- package/dist/execution/ExecutionLoader.js +0 -266
- package/dist/execution/ExecutionLoader.js.map +0 -1
- package/dist/execution/ExecutionValidator.d.ts +0 -94
- package/dist/execution/ExecutionValidator.d.ts.map +0 -1
- package/dist/execution/ExecutionValidator.js +0 -503
- package/dist/execution/ExecutionValidator.js.map +0 -1
- package/dist/generated/graph-converter-execution.types.d.ts +0 -177
- package/dist/generated/graph-converter-execution.types.d.ts.map +0 -1
- package/dist/generated/graph-converter-execution.types.js +0 -12
- package/dist/generated/graph-converter-execution.types.js.map +0 -1
- package/dist/helpers/GraphInstrumentationHelper.d.ts +0 -93
- package/dist/helpers/GraphInstrumentationHelper.d.ts.map +0 -1
- package/dist/helpers/GraphInstrumentationHelper.js +0 -252
- package/dist/helpers/GraphInstrumentationHelper.js.map +0 -1
- package/dist/matchers/SpanMatcher.d.ts +0 -107
- package/dist/matchers/SpanMatcher.d.ts.map +0 -1
- package/dist/matchers/SpanMatcher.js +0 -274
- package/dist/matchers/SpanMatcher.js.map +0 -1
- package/dist/orchestration/TraceOrchestrator.d.ts +0 -71
- package/dist/orchestration/TraceOrchestrator.d.ts.map +0 -1
- package/dist/orchestration/TraceOrchestrator.js +0 -416
- package/dist/orchestration/TraceOrchestrator.js.map +0 -1
- package/dist/parsers/OtlpTraceParser.d.ts +0 -131
- package/dist/parsers/OtlpTraceParser.d.ts.map +0 -1
- package/dist/parsers/OtlpTraceParser.js +0 -310
- package/dist/parsers/OtlpTraceParser.js.map +0 -1
- package/dist/registry/CompositeRegistry.d.ts +0 -71
- package/dist/registry/CompositeRegistry.d.ts.map +0 -1
- package/dist/registry/CompositeRegistry.js +0 -113
- package/dist/registry/CompositeRegistry.js.map +0 -1
- package/dist/registry/EventRegistry.d.ts +0 -79
- package/dist/registry/EventRegistry.d.ts.map +0 -1
- package/dist/registry/EventRegistry.js +0 -165
- package/dist/registry/EventRegistry.js.map +0 -1
- package/dist/registry/LocalRegistry.d.ts +0 -111
- package/dist/registry/LocalRegistry.d.ts.map +0 -1
- package/dist/registry/LocalRegistry.js +0 -335
- package/dist/registry/LocalRegistry.js.map +0 -1
- package/dist/registry/RemoteRegistry.d.ts +0 -122
- package/dist/registry/RemoteRegistry.d.ts.map +0 -1
- package/dist/registry/RemoteRegistry.js +0 -399
- package/dist/registry/RemoteRegistry.js.map +0 -1
- package/dist/registry/VersionRegistry.d.ts +0 -51
- package/dist/registry/VersionRegistry.d.ts.map +0 -1
- package/dist/registry/VersionRegistry.js +0 -105
- package/dist/registry/VersionRegistry.js.map +0 -1
- package/dist/rules/config.d.ts +0 -57
- package/dist/rules/config.d.ts.map +0 -1
- package/dist/rules/config.js +0 -382
- package/dist/rules/config.js.map +0 -1
- package/dist/rules/engine.d.ts +0 -70
- package/dist/rules/engine.d.ts.map +0 -1
- package/dist/rules/engine.js +0 -373
- package/dist/rules/engine.js.map +0 -1
- package/dist/rules/implementations/connection-type-references.d.ts +0 -7
- package/dist/rules/implementations/connection-type-references.d.ts.map +0 -1
- package/dist/rules/implementations/connection-type-references.js +0 -107
- package/dist/rules/implementations/connection-type-references.js.map +0 -1
- package/dist/rules/implementations/dead-end-states.d.ts +0 -17
- package/dist/rules/implementations/dead-end-states.d.ts.map +0 -1
- package/dist/rules/implementations/dead-end-states.js +0 -75
- package/dist/rules/implementations/dead-end-states.js.map +0 -1
- package/dist/rules/implementations/index.d.ts +0 -23
- package/dist/rules/implementations/index.d.ts.map +0 -1
- package/dist/rules/implementations/index.js +0 -73
- package/dist/rules/implementations/index.js.map +0 -1
- package/dist/rules/implementations/minimum-node-sources.d.ts +0 -24
- package/dist/rules/implementations/minimum-node-sources.d.ts.map +0 -1
- package/dist/rules/implementations/minimum-node-sources.js +0 -59
- package/dist/rules/implementations/minimum-node-sources.js.map +0 -1
- package/dist/rules/implementations/no-unknown-fields.d.ts +0 -7
- package/dist/rules/implementations/no-unknown-fields.d.ts.map +0 -1
- package/dist/rules/implementations/no-unknown-fields.js +0 -216
- package/dist/rules/implementations/no-unknown-fields.js.map +0 -1
- package/dist/rules/implementations/orphaned-edge-types.d.ts +0 -7
- package/dist/rules/implementations/orphaned-edge-types.d.ts.map +0 -1
- package/dist/rules/implementations/orphaned-edge-types.js +0 -50
- package/dist/rules/implementations/orphaned-edge-types.js.map +0 -1
- package/dist/rules/implementations/orphaned-node-types.d.ts +0 -7
- package/dist/rules/implementations/orphaned-node-types.d.ts.map +0 -1
- package/dist/rules/implementations/orphaned-node-types.js +0 -53
- package/dist/rules/implementations/orphaned-node-types.js.map +0 -1
- package/dist/rules/implementations/required-metadata.d.ts +0 -7
- package/dist/rules/implementations/required-metadata.d.ts.map +0 -1
- package/dist/rules/implementations/required-metadata.js +0 -48
- package/dist/rules/implementations/required-metadata.js.map +0 -1
- package/dist/rules/implementations/state-transition-references.d.ts +0 -7
- package/dist/rules/implementations/state-transition-references.d.ts.map +0 -1
- package/dist/rules/implementations/state-transition-references.js +0 -138
- package/dist/rules/implementations/state-transition-references.js.map +0 -1
- package/dist/rules/implementations/unreachable-states.d.ts +0 -7
- package/dist/rules/implementations/unreachable-states.d.ts.map +0 -1
- package/dist/rules/implementations/unreachable-states.js +0 -83
- package/dist/rules/implementations/unreachable-states.js.map +0 -1
- package/dist/rules/implementations/valid-action-patterns.d.ts +0 -17
- package/dist/rules/implementations/valid-action-patterns.d.ts.map +0 -1
- package/dist/rules/implementations/valid-action-patterns.js +0 -112
- package/dist/rules/implementations/valid-action-patterns.js.map +0 -1
- package/dist/rules/implementations/valid-color-format.d.ts +0 -7
- package/dist/rules/implementations/valid-color-format.d.ts.map +0 -1
- package/dist/rules/implementations/valid-color-format.js +0 -94
- package/dist/rules/implementations/valid-color-format.js.map +0 -1
- package/dist/rules/implementations/valid-edge-types.d.ts +0 -7
- package/dist/rules/implementations/valid-edge-types.d.ts.map +0 -1
- package/dist/rules/implementations/valid-edge-types.js +0 -248
- package/dist/rules/implementations/valid-edge-types.js.map +0 -1
- package/dist/rules/implementations/valid-node-types.d.ts +0 -7
- package/dist/rules/implementations/valid-node-types.d.ts.map +0 -1
- package/dist/rules/implementations/valid-node-types.js +0 -187
- package/dist/rules/implementations/valid-node-types.js.map +0 -1
- package/dist/rules/index.d.ts +0 -28
- package/dist/rules/index.d.ts.map +0 -1
- package/dist/rules/index.js +0 -70
- package/dist/rules/index.js.map +0 -1
- package/dist/rules/types.d.ts +0 -309
- package/dist/rules/types.d.ts.map +0 -1
- package/dist/rules/types.js +0 -40
- package/dist/rules/types.js.map +0 -1
- package/dist/scopes/ScopePathIndex.d.ts +0 -56
- package/dist/scopes/ScopePathIndex.d.ts.map +0 -1
- package/dist/scopes/ScopePathIndex.js +0 -67
- package/dist/scopes/ScopePathIndex.js.map +0 -1
- package/dist/scopes/ScopesCanvasValidator.d.ts +0 -76
- package/dist/scopes/ScopesCanvasValidator.d.ts.map +0 -1
- package/dist/scopes/ScopesCanvasValidator.js +0 -221
- package/dist/scopes/ScopesCanvasValidator.js.map +0 -1
- package/dist/scopes/index.d.ts +0 -12
- package/dist/scopes/index.d.ts.map +0 -1
- package/dist/scopes/index.js +0 -30
- package/dist/scopes/index.js.map +0 -1
- package/dist/scopes/utils.d.ts +0 -85
- package/dist/scopes/utils.d.ts.map +0 -1
- package/dist/scopes/utils.js +0 -143
- package/dist/scopes/utils.js.map +0 -1
- package/dist/scopes/validateScopeNamespaceNesting.d.ts +0 -38
- package/dist/scopes/validateScopeNamespaceNesting.d.ts.map +0 -1
- package/dist/scopes/validateScopeNamespaceNesting.js +0 -69
- package/dist/scopes/validateScopeNamespaceNesting.js.map +0 -1
- package/dist/spans/index.d.ts +0 -12
- package/dist/spans/index.d.ts.map +0 -1
- package/dist/spans/index.js +0 -25
- package/dist/spans/index.js.map +0 -1
- package/dist/spans/utils.d.ts +0 -70
- package/dist/spans/utils.d.ts.map +0 -1
- package/dist/spans/utils.js +0 -205
- package/dist/spans/utils.js.map +0 -1
- package/dist/storyboard/builder.d.ts +0 -135
- package/dist/storyboard/builder.d.ts.map +0 -1
- package/dist/storyboard/builder.js +0 -235
- package/dist/storyboard/builder.js.map +0 -1
- package/dist/storyboard/index.d.ts +0 -9
- package/dist/storyboard/index.d.ts.map +0 -1
- package/dist/storyboard/index.js +0 -18
- package/dist/storyboard/index.js.map +0 -1
- package/dist/storyboard/types.d.ts +0 -101
- package/dist/storyboard/types.d.ts.map +0 -1
- package/dist/storyboard/types.js +0 -10
- package/dist/storyboard/types.js.map +0 -1
- package/dist/telemetry/coverage.d.ts +0 -92
- package/dist/telemetry/coverage.d.ts.map +0 -1
- package/dist/telemetry/coverage.js +0 -335
- package/dist/telemetry/coverage.js.map +0 -1
- package/dist/telemetry/event-validator.d.ts +0 -86
- package/dist/telemetry/event-validator.d.ts.map +0 -1
- package/dist/telemetry/event-validator.js +0 -257
- package/dist/telemetry/event-validator.js.map +0 -1
- package/dist/types/audit.d.ts +0 -236
- package/dist/types/audit.d.ts.map +0 -1
- package/dist/types/audit.js +0 -53
- package/dist/types/audit.js.map +0 -1
- package/dist/types/auxiliary.d.ts +0 -54
- package/dist/types/auxiliary.d.ts.map +0 -1
- package/dist/types/auxiliary.js +0 -27
- package/dist/types/auxiliary.js.map +0 -1
- package/dist/types/canvas-scope.d.ts +0 -156
- package/dist/types/canvas-scope.d.ts.map +0 -1
- package/dist/types/canvas-scope.js +0 -62
- package/dist/types/canvas-scope.js.map +0 -1
- package/dist/types/canvas.d.ts +0 -1138
- package/dist/types/canvas.d.ts.map +0 -1
- package/dist/types/canvas.js +0 -178
- package/dist/types/canvas.js.map +0 -1
- package/dist/types/dashboard.d.ts +0 -170
- package/dist/types/dashboard.d.ts.map +0 -1
- package/dist/types/dashboard.js +0 -14
- package/dist/types/dashboard.js.map +0 -1
- package/dist/types/library.d.ts +0 -227
- package/dist/types/library.d.ts.map +0 -1
- package/dist/types/library.js +0 -16
- package/dist/types/library.js.map +0 -1
- package/dist/types/otel.d.ts +0 -465
- package/dist/types/otel.d.ts.map +0 -1
- package/dist/types/otel.js +0 -163
- package/dist/types/otel.js.map +0 -1
- package/dist/types/path-based-config.d.ts +0 -235
- package/dist/types/path-based-config.d.ts.map +0 -1
- package/dist/types/path-based-config.js +0 -11
- package/dist/types/path-based-config.js.map +0 -1
- package/dist/types/registered-trace.d.ts +0 -337
- package/dist/types/registered-trace.d.ts.map +0 -1
- package/dist/types/registered-trace.js +0 -16
- package/dist/types/registered-trace.js.map +0 -1
- package/dist/types/resource-match.d.ts +0 -207
- package/dist/types/resource-match.d.ts.map +0 -1
- package/dist/types/resource-match.js +0 -74
- package/dist/types/resource-match.js.map +0 -1
- package/dist/types/version-registry.d.ts +0 -137
- package/dist/types/version-registry.d.ts.map +0 -1
- package/dist/types/version-registry.js +0 -10
- package/dist/types/version-registry.js.map +0 -1
- package/dist/utils/CanvasConverter.d.ts +0 -148
- package/dist/utils/CanvasConverter.d.ts.map +0 -1
- package/dist/utils/CanvasConverter.js +0 -530
- package/dist/utils/CanvasConverter.js.map +0 -1
- package/dist/utils/GraphConverter.d.ts +0 -18
- package/dist/utils/GraphConverter.d.ts.map +0 -1
- package/dist/utils/GraphConverter.js +0 -80
- package/dist/utils/GraphConverter.js.map +0 -1
- package/dist/utils/PathMatcher.d.ts +0 -55
- package/dist/utils/PathMatcher.d.ts.map +0 -1
- package/dist/utils/PathMatcher.js +0 -178
- package/dist/utils/PathMatcher.js.map +0 -1
- package/dist/utils/TraceToCanvas.d.ts +0 -83
- package/dist/utils/TraceToCanvas.d.ts.map +0 -1
- package/dist/utils/TraceToCanvas.js +0 -336
- package/dist/utils/TraceToCanvas.js.map +0 -1
- package/dist/utils/YamlParser.d.ts +0 -36
- package/dist/utils/YamlParser.d.ts.map +0 -1
- package/dist/utils/YamlParser.js +0 -92
- package/dist/utils/YamlParser.js.map +0 -1
- package/dist/utils/registeredTraceHelpers.d.ts +0 -76
- package/dist/utils/registeredTraceHelpers.d.ts.map +0 -1
- package/dist/utils/registeredTraceHelpers.js +0 -203
- package/dist/utils/registeredTraceHelpers.js.map +0 -1
- package/dist/utils/traceAggregation.d.ts +0 -25
- package/dist/utils/traceAggregation.d.ts.map +0 -1
- package/dist/utils/traceAggregation.js +0 -140
- package/dist/utils/traceAggregation.js.map +0 -1
- package/dist/validation/OtelCanvasValidator.d.ts +0 -40
- package/dist/validation/OtelCanvasValidator.d.ts.map +0 -1
- package/dist/validation/OtelCanvasValidator.js +0 -59
- package/dist/validation/OtelCanvasValidator.js.map +0 -1
- package/dist/validation/index.d.ts +0 -8
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js +0 -13
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/libraryValidation.d.ts +0 -53
- package/dist/validation/libraryValidation.d.ts.map +0 -1
- package/dist/validation/libraryValidation.js +0 -115
- package/dist/validation/libraryValidation.js.map +0 -1
- package/dist/workflow/edge-derivation.d.ts +0 -111
- package/dist/workflow/edge-derivation.d.ts.map +0 -1
- package/dist/workflow/edge-derivation.js +0 -174
- package/dist/workflow/edge-derivation.js.map +0 -1
- package/dist/workflow/edge-validation.d.ts +0 -170
- package/dist/workflow/edge-validation.d.ts.map +0 -1
- package/dist/workflow/edge-validation.js +0 -332
- package/dist/workflow/edge-validation.js.map +0 -1
- package/dist/workflow/example.d.ts +0 -11
- package/dist/workflow/example.d.ts.map +0 -1
- package/dist/workflow/example.js +0 -310
- package/dist/workflow/example.js.map +0 -1
- package/dist/workflow/index.d.ts +0 -20
- package/dist/workflow/index.d.ts.map +0 -1
- package/dist/workflow/index.js +0 -49
- package/dist/workflow/index.js.map +0 -1
- package/dist/workflow/scenario-matcher.d.ts +0 -63
- package/dist/workflow/scenario-matcher.d.ts.map +0 -1
- package/dist/workflow/scenario-matcher.js +0 -215
- package/dist/workflow/scenario-matcher.js.map +0 -1
- package/dist/workflow/template-parser.d.ts +0 -73
- package/dist/workflow/template-parser.d.ts.map +0 -1
- package/dist/workflow/template-parser.js +0 -280
- package/dist/workflow/template-parser.js.map +0 -1
- package/dist/workflow/template-renderer.d.ts +0 -45
- package/dist/workflow/template-renderer.d.ts.map +0 -1
- package/dist/workflow/template-renderer.js +0 -401
- package/dist/workflow/template-renderer.js.map +0 -1
- package/dist/workflow/types.d.ts +0 -393
- package/dist/workflow/types.d.ts.map +0 -1
- package/dist/workflow/types.js +0 -40
- package/dist/workflow/types.js.map +0 -1
- package/dist/workflow/validator.d.ts +0 -363
- package/dist/workflow/validator.d.ts.map +0 -1
- package/dist/workflow/validator.js +0 -2283
- package/dist/workflow/validator.js.map +0 -1
- package/schemas/auxiliary.manifest.schema.json +0 -56
- package/src/ConfigurationLoader.test.ts +0 -466
- package/src/ConfigurationLoader.ts +0 -184
- package/src/ConfigurationValidator.test.ts +0 -200
- package/src/ConfigurationValidator.ts +0 -273
- package/src/EventProcessor.test.ts +0 -405
- package/src/EventProcessor.ts +0 -256
- package/src/EventRecorderService.test.ts +0 -543
- package/src/EventRecorderService.ts +0 -741
- package/src/LibraryLoader.ts +0 -194
- package/src/PathBasedEventProcessor.test.ts +0 -336
- package/src/PathBasedEventProcessor.ts +0 -196
- package/src/SessionManager.test.ts +0 -424
- package/src/SessionManager.ts +0 -471
- package/src/ValidationEngine.test.ts +0 -520
- package/src/ValidationEngine.ts +0 -200
- package/src/auxiliary/AuxiliaryManifestValidator.test.ts +0 -93
- package/src/auxiliary/AuxiliaryManifestValidator.ts +0 -132
- package/src/auxiliary/index.ts +0 -18
- package/src/auxiliary/validateAreaScopeDisjoint.test.ts +0 -85
- package/src/auxiliary/validateAreaScopeDisjoint.ts +0 -72
- package/src/cli/codegen.ts +0 -286
- package/src/codegen/type-generator.test.ts +0 -219
- package/src/codegen/type-generator.ts +0 -560
- package/src/codegen/usage-example.ts +0 -357
- package/src/dashboard/DashboardValidator.ts +0 -904
- package/src/dashboard/index.ts +0 -14
- package/src/discovery/CanvasDiscovery.test.ts +0 -691
- package/src/discovery/CanvasDiscovery.ts +0 -1114
- package/src/discovery/CanvasFileManifest.test.ts +0 -521
- package/src/discovery/CanvasFileManifest.ts +0 -419
- package/src/discovery/LibraryDiscovery.test.ts +0 -329
- package/src/discovery/LibraryDiscovery.ts +0 -386
- package/src/discovery/types.ts +0 -453
- package/src/events/EventsCanvasValidator.test.ts +0 -191
- package/src/events/EventsCanvasValidator.ts +0 -428
- package/src/events/NamespacePathIndex.test.ts +0 -97
- package/src/events/NamespacePathIndex.ts +0 -100
- package/src/events/OtelEventPathsValidator.test.ts +0 -243
- package/src/events/OtelEventPathsValidator.ts +0 -191
- package/src/events/ScopeEventsValidator.test.ts +0 -173
- package/src/events/ScopeEventsValidator.ts +0 -158
- package/src/events/index.ts +0 -27
- package/src/events/path-helpers.ts +0 -53
- package/src/execution/ExecutionLoader.test.ts +0 -378
- package/src/execution/ExecutionLoader.ts +0 -331
- package/src/execution/ExecutionValidator.test.ts +0 -503
- package/src/execution/ExecutionValidator.ts +0 -617
- package/src/generated/graph-converter-execution.types.ts +0 -193
- package/src/helpers/GraphInstrumentationHelper.test.ts +0 -364
- package/src/helpers/GraphInstrumentationHelper.ts +0 -323
- package/src/matchers/SpanMatcher.test.ts +0 -1105
- package/src/matchers/SpanMatcher.ts +0 -381
- package/src/orchestration/TraceOrchestrator.ts +0 -560
- package/src/orchestration/__tests__/TraceOrchestrator.test.ts +0 -1098
- package/src/parsers/OtlpTraceParser.ts +0 -401
- package/src/parsers/__tests__/OtlpTraceParser.test.ts +0 -197
- package/src/registry/CompositeRegistry.ts +0 -140
- package/src/registry/EventRegistry.test.ts +0 -387
- package/src/registry/EventRegistry.ts +0 -191
- package/src/registry/LocalRegistry.ts +0 -416
- package/src/registry/RemoteRegistry.ts +0 -499
- package/src/registry/VersionRegistry.test.ts +0 -223
- package/src/registry/VersionRegistry.ts +0 -121
- package/src/rules/config.test.ts +0 -277
- package/src/rules/config.ts +0 -450
- package/src/rules/engine.test.ts +0 -331
- package/src/rules/engine.ts +0 -448
- package/src/rules/implementations/connection-type-references.ts +0 -117
- package/src/rules/implementations/dead-end-states.ts +0 -101
- package/src/rules/implementations/index.ts +0 -66
- package/src/rules/implementations/minimum-node-sources.ts +0 -84
- package/src/rules/implementations/no-unknown-fields.ts +0 -372
- package/src/rules/implementations/orphaned-edge-types.ts +0 -55
- package/src/rules/implementations/orphaned-node-types.ts +0 -58
- package/src/rules/implementations/required-metadata.ts +0 -52
- package/src/rules/implementations/state-transition-references.ts +0 -155
- package/src/rules/implementations/unreachable-states.ts +0 -94
- package/src/rules/implementations/valid-action-patterns.ts +0 -140
- package/src/rules/implementations/valid-color-format.ts +0 -152
- package/src/rules/implementations/valid-edge-types.ts +0 -273
- package/src/rules/implementations/valid-node-types.ts +0 -200
- package/src/rules/index.ts +0 -92
- package/src/rules/types.ts +0 -426
- package/src/scopes/ScopePathIndex.test.ts +0 -94
- package/src/scopes/ScopePathIndex.ts +0 -89
- package/src/scopes/ScopesCanvasValidator.test.ts +0 -127
- package/src/scopes/ScopesCanvasValidator.ts +0 -305
- package/src/scopes/__tests__/utils.test.ts +0 -383
- package/src/scopes/index.ts +0 -42
- package/src/scopes/utils.ts +0 -182
- package/src/scopes/validateScopeNamespaceNesting.test.ts +0 -127
- package/src/scopes/validateScopeNamespaceNesting.ts +0 -88
- package/src/spans/index.ts +0 -24
- package/src/spans/utils.ts +0 -249
- package/src/storyboard/builder.ts +0 -308
- package/src/storyboard/index.ts +0 -26
- package/src/storyboard/types.ts +0 -117
- package/src/telemetry/coverage.ts +0 -480
- package/src/telemetry/event-validator.ts +0 -312
- package/src/types/audit.ts +0 -314
- package/src/types/auxiliary.ts +0 -63
- package/src/types/canvas-scope.ts +0 -190
- package/src/types/canvas.test.ts +0 -199
- package/src/types/canvas.ts +0 -1395
- package/src/types/dashboard.ts +0 -257
- package/src/types/library.ts +0 -283
- package/src/types/otel.test.ts +0 -219
- package/src/types/otel.ts +0 -620
- package/src/types/path-based-config.ts +0 -285
- package/src/types/registered-trace.ts +0 -432
- package/src/types/resource-match.ts +0 -263
- package/src/types/version-registry.ts +0 -150
- package/src/utils/CanvasConverter.ts +0 -670
- package/src/utils/GraphConverter.test.ts +0 -322
- package/src/utils/GraphConverter.ts +0 -84
- package/src/utils/PathMatcher.test.ts +0 -139
- package/src/utils/PathMatcher.ts +0 -185
- package/src/utils/TraceToCanvas.test.ts +0 -310
- package/src/utils/TraceToCanvas.ts +0 -510
- package/src/utils/YamlParser.ts +0 -77
- package/src/utils/registeredTraceHelpers.ts +0 -251
- package/src/utils/traceAggregation.test.ts +0 -385
- package/src/utils/traceAggregation.ts +0 -173
- package/src/validation/OtelCanvasValidator.ts +0 -86
- package/src/validation/index.ts +0 -17
- package/src/validation/libraryValidation.ts +0 -206
- package/src/workflow/README.md +0 -408
- package/src/workflow/__tests__/edge-derivation.test.ts +0 -449
- package/src/workflow/__tests__/edge-validation.test.ts +0 -417
- package/src/workflow/__tests__/scenario-matcher.test.ts +0 -225
- package/src/workflow/__tests__/template-parser.test.ts +0 -276
- package/src/workflow/__tests__/template-renderer.test.ts +0 -509
- package/src/workflow/__tests__/types.test.ts +0 -187
- package/src/workflow/__tests__/validator.test.ts +0 -3225
- package/src/workflow/edge-derivation.ts +0 -265
- package/src/workflow/edge-validation.ts +0 -503
- package/src/workflow/example.ts +0 -330
- package/src/workflow/index.ts +0 -86
- package/src/workflow/scenario-matcher.ts +0 -253
- package/src/workflow/template-parser.ts +0 -350
- package/src/workflow/template-renderer.ts +0 -453
- package/src/workflow/types.ts +0 -511
- package/src/workflow/validator.ts +0 -2737
|
@@ -1,865 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Unified discovery system for canvas and execution files in a package-aware way
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CanvasDiscovery = void 0;
|
|
7
|
-
const codebase_composition_1 = require("@principal-ai/codebase-composition");
|
|
8
|
-
const edge_derivation_1 = require("../workflow/edge-derivation");
|
|
9
|
-
const canvas_1 = require("../types/canvas");
|
|
10
|
-
const OtelCanvasValidator_1 = require("../validation/OtelCanvasValidator");
|
|
11
|
-
/**
|
|
12
|
-
* Unified discovery system for canvas and execution files in a package-aware way
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // Basic usage without content parsing
|
|
16
|
-
* const discovery = new CanvasDiscovery();
|
|
17
|
-
* const result = await discovery.discover(fileTree);
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // With content parsing (CLI)
|
|
21
|
-
* const result = await discovery.discover(fileTree, {
|
|
22
|
-
* fileReader: async (path) => fs.promises.readFile(path, 'utf-8'),
|
|
23
|
-
* includeContent: true
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // With content parsing (panels)
|
|
28
|
-
* const result = await discovery.discover(fileTree, {
|
|
29
|
-
* fileReader: async (path) => context.getSlice('fileCache').read(path),
|
|
30
|
-
* includeContent: true
|
|
31
|
-
* });
|
|
32
|
-
*/
|
|
33
|
-
class CanvasDiscovery {
|
|
34
|
-
constructor() {
|
|
35
|
-
this.packageCache = new Map();
|
|
36
|
-
this.packageModule = new codebase_composition_1.PackageLayerModule();
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Build a lookup map from span pattern to span info from spans.canvas files
|
|
40
|
-
*
|
|
41
|
-
* @param canvases - Discovered canvases (must include content for spans.canvas)
|
|
42
|
-
* @returns Map of spanPattern → { label?, scope? }
|
|
43
|
-
*/
|
|
44
|
-
buildSpanLookup(canvases) {
|
|
45
|
-
const lookup = new Map();
|
|
46
|
-
for (const canvas of canvases) {
|
|
47
|
-
// Only process spans.canvas files with content
|
|
48
|
-
if (canvas.type !== 'spans')
|
|
49
|
-
continue;
|
|
50
|
-
const canvasWithContent = canvas;
|
|
51
|
-
const content = canvasWithContent.content;
|
|
52
|
-
if (!content?.nodes)
|
|
53
|
-
continue;
|
|
54
|
-
// Extract span patterns, labels, and scopes from otel-span-convention nodes
|
|
55
|
-
for (const node of content.nodes) {
|
|
56
|
-
if ((0, canvas_1.isOtelSpanConventionNode)(node)) {
|
|
57
|
-
const spanPattern = node.otel?.spanPattern;
|
|
58
|
-
if (spanPattern) {
|
|
59
|
-
lookup.set(spanPattern, {
|
|
60
|
-
label: node.label,
|
|
61
|
-
scope: node.otel?.scope,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return lookup;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Build a lookup map from scope name to display label from scopes.canvas files
|
|
71
|
-
*
|
|
72
|
-
* @param canvases - Discovered canvases (must include content for scopes.canvas)
|
|
73
|
-
* @returns Map of scopeName → label
|
|
74
|
-
*/
|
|
75
|
-
buildScopeLabelLookup(canvases) {
|
|
76
|
-
const lookup = new Map();
|
|
77
|
-
for (const canvas of canvases) {
|
|
78
|
-
// Only process scopes.canvas files with content
|
|
79
|
-
if (canvas.type !== 'scopes')
|
|
80
|
-
continue;
|
|
81
|
-
const canvasWithContent = canvas;
|
|
82
|
-
const content = canvasWithContent.content;
|
|
83
|
-
if (!content?.nodes)
|
|
84
|
-
continue;
|
|
85
|
-
// Extract scope names and labels from otel-scope nodes
|
|
86
|
-
for (const node of content.nodes) {
|
|
87
|
-
if ((0, canvas_1.isOtelScopeNode)(node)) {
|
|
88
|
-
const scopeName = node.otel.scope;
|
|
89
|
-
const label = node.label;
|
|
90
|
-
if (scopeName && label) {
|
|
91
|
-
lookup.set(scopeName, label);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return lookup;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Discover all canvas, workflow, and test trace files in the file tree
|
|
100
|
-
*
|
|
101
|
-
* @param fileTree - FileTree from repository-abstraction
|
|
102
|
-
* @param options - Discovery options (fileReader, includeContent)
|
|
103
|
-
* @returns Discovery result with canvases, testTraces, storyboards, and errors
|
|
104
|
-
*/
|
|
105
|
-
async discover(fileTree, options = {}) {
|
|
106
|
-
const errors = [];
|
|
107
|
-
const warnings = [];
|
|
108
|
-
// 1. Discover packages (with caching by fileTree.sha)
|
|
109
|
-
const packages = await this.discoverPackagesWithCache(fileTree, options.fileReader);
|
|
110
|
-
// 2. Build package lookup map for efficient path matching
|
|
111
|
-
const packageMap = this.buildPackageMap(packages);
|
|
112
|
-
// 3. Discover canvas files
|
|
113
|
-
const canvases = await this.discoverCanvasFiles(fileTree, packageMap, options, errors);
|
|
114
|
-
// 3.5. Build span lookup from spans.canvas files (for enriching workflow referencedSpans with labels and scopes)
|
|
115
|
-
const spanLookup = this.buildSpanLookup(canvases);
|
|
116
|
-
// 3.6. Build scope label lookup from scopes.canvas files (for resolving scope display names)
|
|
117
|
-
const scopeLabelLookup = this.buildScopeLabelLookup(canvases);
|
|
118
|
-
// 4. Discover storyboards (hierarchical organization)
|
|
119
|
-
// Note: Test traces are discovered as part of workflows, not separately
|
|
120
|
-
const storyboards = await this.discoverStoryboards(fileTree, packageMap, canvases, options, errors, spanLookup, scopeLabelLookup);
|
|
121
|
-
// 5. Collect all test traces from workflows for backward compatibility
|
|
122
|
-
const testTraces = [];
|
|
123
|
-
for (const storyboard of storyboards) {
|
|
124
|
-
for (const workflow of storyboard.workflows) {
|
|
125
|
-
testTraces.push(...workflow.testTraces);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// 6. Discover dashboard files from .principal-views/dashboards/
|
|
129
|
-
const dashboards = await this.discoverDashboards(fileTree, packageMap, options, errors);
|
|
130
|
-
// 7. Detect legacy flat canvas structures and add deprecation errors
|
|
131
|
-
this.detectLegacyStructures(canvases, storyboards, errors);
|
|
132
|
-
// 8. Validate required canvas types
|
|
133
|
-
this.validateRequiredCanvases(canvases, storyboards, errors);
|
|
134
|
-
// 8.5. Validate scope hierarchy (when content is loaded)
|
|
135
|
-
if (options.includeContent) {
|
|
136
|
-
this.validateScopeHierarchy(storyboards, spanLookup, scopeLabelLookup, errors);
|
|
137
|
-
}
|
|
138
|
-
// 9. Sort results
|
|
139
|
-
canvases.sort(this.compareByPackageThenName);
|
|
140
|
-
testTraces.sort(this.compareByPackageThenName);
|
|
141
|
-
storyboards.sort(this.compareByPackageThenName);
|
|
142
|
-
dashboards.sort(this.compareByPackageThenName);
|
|
143
|
-
return { canvases, testTraces, storyboards, dashboards, errors, warnings };
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Clear package cache (useful when file tree changes)
|
|
147
|
-
*/
|
|
148
|
-
clearCache() {
|
|
149
|
-
this.packageCache.clear();
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Check if a file path is relevant to canvas discovery
|
|
153
|
-
* Uses package-aware path matching for .principal-views directories
|
|
154
|
-
*/
|
|
155
|
-
isRelevantPath(path) {
|
|
156
|
-
// Canvas files (.canvas, .otel.canvas)
|
|
157
|
-
if (this.isInCanvasDir(path) && this.parseCanvasPath(path)) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
// Workflow files (.workflow.json) in .principal-views
|
|
161
|
-
if (path.includes(CanvasDiscovery.CANVAS_DIR) && path.endsWith(CanvasDiscovery.WORKFLOW_EXTENSION)) {
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
// Dashboard files (.dashboard.json) in .principal-views
|
|
165
|
-
if (path.includes(CanvasDiscovery.CANVAS_DIR) && path.endsWith(CanvasDiscovery.DASHBOARD_EXTENSION)) {
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
// Test trace files (.otel.json) in .principal-views
|
|
169
|
-
if (path.includes(CanvasDiscovery.CANVAS_DIR) && path.endsWith('.otel.json')) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Get all file paths in the FileTree that are relevant to canvas discovery
|
|
176
|
-
* Uses package-aware path matching (respects packages/\*\/.principal-views/ etc.)
|
|
177
|
-
*
|
|
178
|
-
* @param fileTree - FileTree from repository-abstraction
|
|
179
|
-
* @returns Set of relevant file paths
|
|
180
|
-
*/
|
|
181
|
-
getRelevantPaths(fileTree) {
|
|
182
|
-
const paths = new Set();
|
|
183
|
-
for (const file of fileTree.allFiles) {
|
|
184
|
-
const path = file.relativePath || file.path || '';
|
|
185
|
-
if (this.isRelevantPath(path)) {
|
|
186
|
-
paths.add(path);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return paths;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Filter git status to only include changes relevant to canvas discovery
|
|
193
|
-
*
|
|
194
|
-
* For existing/modified/deleted files: filters to paths in the current FileTree's relevant paths
|
|
195
|
-
* For new/untracked files: checks if they match discovery patterns (could be new canvas files)
|
|
196
|
-
*
|
|
197
|
-
* @param fileTree - FileTree from repository-abstraction
|
|
198
|
-
* @param gitStatus - Git status with file lists
|
|
199
|
-
* @returns Filtered git status containing only relevant changes, or null if no relevant changes
|
|
200
|
-
*/
|
|
201
|
-
filterRelevantGitChanges(fileTree, gitStatus) {
|
|
202
|
-
const relevantPaths = this.getRelevantPaths(fileTree);
|
|
203
|
-
// For existing files: filter to paths we know about
|
|
204
|
-
const filterExisting = (paths) => paths.filter(p => relevantPaths.has(p));
|
|
205
|
-
// For new/untracked files: check if they match discovery patterns
|
|
206
|
-
const filterNew = (paths) => paths.filter(p => this.isRelevantPath(p));
|
|
207
|
-
const filtered = {
|
|
208
|
-
...gitStatus,
|
|
209
|
-
modifiedFiles: filterExisting(gitStatus.modifiedFiles),
|
|
210
|
-
stagedFiles: filterNew(gitStatus.stagedFiles),
|
|
211
|
-
untrackedFiles: filterNew(gitStatus.untrackedFiles),
|
|
212
|
-
deletedFiles: filterExisting(gitStatus.deletedFiles),
|
|
213
|
-
createdFiles: filterNew(gitStatus.createdFiles || []),
|
|
214
|
-
};
|
|
215
|
-
// Return null if no relevant changes
|
|
216
|
-
const hasChanges = filtered.modifiedFiles.length > 0 ||
|
|
217
|
-
filtered.stagedFiles.length > 0 ||
|
|
218
|
-
filtered.untrackedFiles.length > 0 ||
|
|
219
|
-
filtered.deletedFiles.length > 0 ||
|
|
220
|
-
filtered.createdFiles.length > 0;
|
|
221
|
-
return hasChanges ? filtered : null;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Discover storyboards (hierarchical organization of canvas + workflows + executions)
|
|
225
|
-
*/
|
|
226
|
-
async discoverStoryboards(fileTree, packageMap, canvases, options, errors, spanLookup, scopeLabelLookup) {
|
|
227
|
-
const storyboards = [];
|
|
228
|
-
// Build a map of directories to check for storyboards
|
|
229
|
-
const storyboardDirs = new Map();
|
|
230
|
-
// Find all directories in .principal-views/ that have subdirectories
|
|
231
|
-
for (const file of fileTree.allFiles) {
|
|
232
|
-
const path = file.relativePath || file.path || '';
|
|
233
|
-
const parts = path.split('/');
|
|
234
|
-
// Look for paths like: .principal-views/storyboard-name/workflow-name/...
|
|
235
|
-
// Or: packages/subsystems-core/.principal-views/storyboard-name/workflow-name/...
|
|
236
|
-
const pvIndex = parts.indexOf(CanvasDiscovery.CANVAS_DIR);
|
|
237
|
-
if (pvIndex === -1 || parts.length < pvIndex + 3)
|
|
238
|
-
continue;
|
|
239
|
-
const storyboardName = parts[pvIndex + 1];
|
|
240
|
-
const storyboardPath = parts.slice(0, pvIndex + 2).join('/');
|
|
241
|
-
if (!storyboardDirs.has(storyboardPath)) {
|
|
242
|
-
storyboardDirs.set(storyboardPath, new Set());
|
|
243
|
-
}
|
|
244
|
-
storyboardDirs.get(storyboardPath).add(storyboardName);
|
|
245
|
-
}
|
|
246
|
-
// For each potential storyboard directory, check if it has a canvas
|
|
247
|
-
for (const [storyboardPath, storyboardNames] of storyboardDirs) {
|
|
248
|
-
for (const storyboardName of storyboardNames) {
|
|
249
|
-
// Skip __executions__ directory (legacy pattern, should not exist)
|
|
250
|
-
if (storyboardName === '__executions__')
|
|
251
|
-
continue;
|
|
252
|
-
// Find canvas for this storyboard
|
|
253
|
-
const storyboardCanvas = canvases.find(c => {
|
|
254
|
-
const canvasDir = c.path.split('/').slice(0, -1).join('/');
|
|
255
|
-
return canvasDir === storyboardPath && c.basename === storyboardName;
|
|
256
|
-
});
|
|
257
|
-
if (!storyboardCanvas)
|
|
258
|
-
continue;
|
|
259
|
-
// This is a storyboard! Now discover workflows
|
|
260
|
-
const workflows = await this.discoverWorkflowsInStoryboard(fileTree, storyboardPath, storyboardName, packageMap, options, spanLookup, scopeLabelLookup, errors);
|
|
261
|
-
// Determine package context
|
|
262
|
-
const packageInfo = this.findPackageForPath(storyboardPath, packageMap);
|
|
263
|
-
// Generate unique ID
|
|
264
|
-
const id = packageInfo
|
|
265
|
-
? `${packageInfo.packageData.name}/${storyboardName}`
|
|
266
|
-
: storyboardName;
|
|
267
|
-
// Create discovered storyboard
|
|
268
|
-
const storyboard = {
|
|
269
|
-
id,
|
|
270
|
-
name: this.toDisplayName(storyboardName),
|
|
271
|
-
path: storyboardPath,
|
|
272
|
-
basename: storyboardName,
|
|
273
|
-
canvas: storyboardCanvas,
|
|
274
|
-
workflows,
|
|
275
|
-
packageName: packageInfo?.packageData.name,
|
|
276
|
-
packagePath: packageInfo?.packageData.path,
|
|
277
|
-
scope: packageInfo ? 'package' : 'root',
|
|
278
|
-
};
|
|
279
|
-
storyboards.push(storyboard);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
// Add standalone canvas files (flat structure without workflows)
|
|
283
|
-
// These are typically .canvas files used for documentation/architecture diagrams
|
|
284
|
-
const storyboardCanvasIds = new Set(storyboards.map(s => s.canvas.id));
|
|
285
|
-
for (const canvas of canvases) {
|
|
286
|
-
// Skip if already part of a hierarchical storyboard
|
|
287
|
-
if (storyboardCanvasIds.has(canvas.id))
|
|
288
|
-
continue;
|
|
289
|
-
// Check if canvas is in flat structure (.principal-views/file.canvas)
|
|
290
|
-
const canvasDir = canvas.path.split('/').slice(0, -1).join('/');
|
|
291
|
-
const parts = canvasDir.split('/');
|
|
292
|
-
const pvIndex = parts.indexOf(CanvasDiscovery.CANVAS_DIR);
|
|
293
|
-
// Only include flat .canvas files (for documentation)
|
|
294
|
-
// Exclude .otel.canvas files which must use storyboard structure
|
|
295
|
-
if (pvIndex !== -1 && parts.length === pvIndex + 1 && canvas.type !== 'otel') {
|
|
296
|
-
const packageInfo = this.findPackageForPath(canvas.path, packageMap);
|
|
297
|
-
// Create a standalone storyboard with no workflows
|
|
298
|
-
const storyboard = {
|
|
299
|
-
id: canvas.id,
|
|
300
|
-
name: canvas.name,
|
|
301
|
-
path: canvasDir,
|
|
302
|
-
basename: canvas.basename,
|
|
303
|
-
canvas: canvas,
|
|
304
|
-
workflows: [],
|
|
305
|
-
packageName: packageInfo?.packageData.name,
|
|
306
|
-
packagePath: packageInfo?.packageData.path,
|
|
307
|
-
scope: packageInfo ? 'package' : 'root',
|
|
308
|
-
};
|
|
309
|
-
storyboards.push(storyboard);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return storyboards;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Discover workflows within a storyboard folder
|
|
316
|
-
*/
|
|
317
|
-
async discoverWorkflowsInStoryboard(fileTree, storyboardPath, storyboardName, packageMap, options, spanLookup, scopeLabelLookup, errors) {
|
|
318
|
-
const workflows = [];
|
|
319
|
-
// Find all workflow files in this storyboard
|
|
320
|
-
for (const file of fileTree.allFiles) {
|
|
321
|
-
const path = file.relativePath || file.path || '';
|
|
322
|
-
// Check if file is in this storyboard
|
|
323
|
-
if (!path.startsWith(storyboardPath + '/'))
|
|
324
|
-
continue;
|
|
325
|
-
// Check if it's a workflow file
|
|
326
|
-
if (!path.endsWith(CanvasDiscovery.WORKFLOW_EXTENSION))
|
|
327
|
-
continue;
|
|
328
|
-
// Extract workflow info
|
|
329
|
-
const filename = path.split('/').pop();
|
|
330
|
-
if (!filename)
|
|
331
|
-
continue;
|
|
332
|
-
const basename = filename.replace(CanvasDiscovery.WORKFLOW_EXTENSION, '');
|
|
333
|
-
const workflowDir = path.split('/').slice(0, -1).join('/');
|
|
334
|
-
// Determine package context
|
|
335
|
-
const packageInfo = this.findPackageForPath(path, packageMap);
|
|
336
|
-
// Generate unique ID (basename only - storyboard context is in storyboardId)
|
|
337
|
-
const id = basename;
|
|
338
|
-
// Discover test traces co-located in the same directory as workflow.json
|
|
339
|
-
const workflowTestTraces = await this.discoverTestTracesInWorkflowDir(fileTree, workflowDir, packageMap, options, errors);
|
|
340
|
-
// Create discovered workflow
|
|
341
|
-
let workflow = {
|
|
342
|
-
id,
|
|
343
|
-
name: this.toDisplayName(basename),
|
|
344
|
-
path,
|
|
345
|
-
basename,
|
|
346
|
-
storyboardId: packageInfo
|
|
347
|
-
? `${packageInfo.packageData.name}/${storyboardName}`
|
|
348
|
-
: storyboardName,
|
|
349
|
-
packageName: packageInfo?.packageData.name,
|
|
350
|
-
packagePath: packageInfo?.packageData.path,
|
|
351
|
-
scope: packageInfo ? 'package' : 'root',
|
|
352
|
-
testTraces: workflowTestTraces,
|
|
353
|
-
};
|
|
354
|
-
// Optionally load content
|
|
355
|
-
if (options.includeContent && options.fileReader) {
|
|
356
|
-
try {
|
|
357
|
-
const content = await options.fileReader(path);
|
|
358
|
-
const parsedContent = JSON.parse(content);
|
|
359
|
-
// Extract referenced spans from workflow content
|
|
360
|
-
const edgeResult = (0, edge_derivation_1.deriveWorkflowEdges)(parsedContent, path);
|
|
361
|
-
// Convert span patterns to ReferencedSpan objects with labels and scopes
|
|
362
|
-
const referencedSpans = edgeResult.referencedSpans.map((pattern) => {
|
|
363
|
-
const spanInfo = spanLookup.get(pattern);
|
|
364
|
-
return {
|
|
365
|
-
pattern,
|
|
366
|
-
label: spanInfo?.label,
|
|
367
|
-
scope: spanInfo?.scope,
|
|
368
|
-
};
|
|
369
|
-
});
|
|
370
|
-
// Derive workflow instrumentation scope from rootSpan's scope
|
|
371
|
-
const rootSpan = parsedContent.rootSpan;
|
|
372
|
-
const rootSpanInfo = rootSpan ? spanLookup.get(rootSpan) : undefined;
|
|
373
|
-
const instrumentationScope = rootSpanInfo?.scope;
|
|
374
|
-
const instrumentationScopeLabel = instrumentationScope
|
|
375
|
-
? scopeLabelLookup.get(instrumentationScope)
|
|
376
|
-
: undefined;
|
|
377
|
-
workflow = {
|
|
378
|
-
...workflow,
|
|
379
|
-
content: parsedContent,
|
|
380
|
-
referencedSpans,
|
|
381
|
-
instrumentationScope,
|
|
382
|
-
instrumentationScopeLabel,
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
catch (error) {
|
|
386
|
-
errors.push({
|
|
387
|
-
path,
|
|
388
|
-
error: `Failed to parse workflow content: ${error.message}`,
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
workflows.push(workflow);
|
|
393
|
-
}
|
|
394
|
-
return workflows;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Discover execution files co-located in a workflow directory
|
|
398
|
-
*/
|
|
399
|
-
async discoverTestTracesInWorkflowDir(fileTree, workflowDir, packageMap, options, errors) {
|
|
400
|
-
const testTraces = [];
|
|
401
|
-
// Find all .otel.json files in the workflow directory
|
|
402
|
-
for (const file of fileTree.allFiles) {
|
|
403
|
-
const path = file.relativePath || file.path || '';
|
|
404
|
-
// Check if file is in this workflow directory
|
|
405
|
-
const fileDir = path.split('/').slice(0, -1).join('/');
|
|
406
|
-
if (fileDir !== workflowDir)
|
|
407
|
-
continue;
|
|
408
|
-
// Check if it's a test trace file (.otel.json)
|
|
409
|
-
if (!path.endsWith('.otel.json')) {
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
// Extract test trace metadata
|
|
413
|
-
const filename = path.split('/').pop();
|
|
414
|
-
if (!filename)
|
|
415
|
-
continue;
|
|
416
|
-
const basename = filename.replace('.otel.json', '');
|
|
417
|
-
// Determine package context
|
|
418
|
-
const packageInfo = this.findPackageForPath(path, packageMap);
|
|
419
|
-
// Generate unique ID (workflow-scoped)
|
|
420
|
-
const workflowBasename = workflowDir.split('/').pop() || '';
|
|
421
|
-
const id = packageInfo
|
|
422
|
-
? `${packageInfo.packageData.name}/${workflowBasename}/${basename}`
|
|
423
|
-
: `${workflowBasename}/${basename}`;
|
|
424
|
-
// Create discovered test trace
|
|
425
|
-
let testTrace = {
|
|
426
|
-
id,
|
|
427
|
-
name: this.toDisplayName(basename),
|
|
428
|
-
path,
|
|
429
|
-
basename,
|
|
430
|
-
type: 'otel',
|
|
431
|
-
canvasBasename: basename,
|
|
432
|
-
packageName: packageInfo?.packageData.name,
|
|
433
|
-
packagePath: packageInfo?.packageData.path,
|
|
434
|
-
scope: packageInfo ? 'package' : 'root',
|
|
435
|
-
};
|
|
436
|
-
// Optionally load content
|
|
437
|
-
if (options.includeContent && options.fileReader) {
|
|
438
|
-
try {
|
|
439
|
-
const content = await options.fileReader(path);
|
|
440
|
-
testTrace = { ...testTrace, content: JSON.parse(content) };
|
|
441
|
-
}
|
|
442
|
-
catch (error) {
|
|
443
|
-
errors.push({
|
|
444
|
-
path,
|
|
445
|
-
error: `Failed to parse test trace content: ${error.message}`,
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
testTraces.push(testTrace);
|
|
450
|
-
}
|
|
451
|
-
return testTraces;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Discover packages with caching by fileTree SHA
|
|
455
|
-
*/
|
|
456
|
-
async discoverPackagesWithCache(fileTree, fileReader) {
|
|
457
|
-
const cacheKey = fileTree.sha;
|
|
458
|
-
if (this.packageCache.has(cacheKey)) {
|
|
459
|
-
return this.packageCache.get(cacheKey);
|
|
460
|
-
}
|
|
461
|
-
const packages = await this.packageModule.discoverPackages(fileTree, fileReader);
|
|
462
|
-
this.packageCache.set(cacheKey, packages);
|
|
463
|
-
return packages;
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Build package lookup map for efficient path matching
|
|
467
|
-
*/
|
|
468
|
-
buildPackageMap(packages) {
|
|
469
|
-
const map = new Map();
|
|
470
|
-
for (const pkg of packages) {
|
|
471
|
-
// Normalize package path for lookup (replace backslashes with forward slashes)
|
|
472
|
-
const normalizedPath = pkg.packageData.path.replace(/\\/g, '/');
|
|
473
|
-
map.set(normalizedPath, pkg);
|
|
474
|
-
}
|
|
475
|
-
return map;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Discover canvas files in the file tree
|
|
479
|
-
*/
|
|
480
|
-
async discoverCanvasFiles(fileTree, packageMap, options, errors) {
|
|
481
|
-
const canvases = [];
|
|
482
|
-
for (const file of fileTree.allFiles) {
|
|
483
|
-
const path = file.relativePath || file.path || '';
|
|
484
|
-
// Check if in .principal-views directory
|
|
485
|
-
if (!this.isInCanvasDir(path))
|
|
486
|
-
continue;
|
|
487
|
-
// Extract canvas metadata
|
|
488
|
-
const metadata = this.parseCanvasPath(path);
|
|
489
|
-
if (!metadata)
|
|
490
|
-
continue;
|
|
491
|
-
// Determine package context
|
|
492
|
-
const packageInfo = this.findPackageForPath(path, packageMap);
|
|
493
|
-
// Generate unique ID
|
|
494
|
-
// Include canvas type suffix for non-regular types to avoid collisions
|
|
495
|
-
// e.g., "architecture" vs "architecture.scopes"
|
|
496
|
-
const idSuffix = metadata.type !== 'regular' ? `.${metadata.type}` : '';
|
|
497
|
-
const id = packageInfo
|
|
498
|
-
? `${packageInfo.packageData.name}/${metadata.basename}${idSuffix}`
|
|
499
|
-
: `${metadata.basename}${idSuffix}`;
|
|
500
|
-
// Create discovered canvas
|
|
501
|
-
const canvas = {
|
|
502
|
-
id,
|
|
503
|
-
name: this.toDisplayName(metadata.basename),
|
|
504
|
-
path,
|
|
505
|
-
basename: metadata.basename,
|
|
506
|
-
type: metadata.type,
|
|
507
|
-
packageName: packageInfo?.packageData.name,
|
|
508
|
-
packagePath: packageInfo?.packageData.path,
|
|
509
|
-
scope: packageInfo ? 'package' : 'root',
|
|
510
|
-
};
|
|
511
|
-
// Optionally load content
|
|
512
|
-
if (options.includeContent && options.fileReader) {
|
|
513
|
-
try {
|
|
514
|
-
const content = await options.fileReader(path);
|
|
515
|
-
const parsedContent = JSON.parse(content);
|
|
516
|
-
// Cast to DiscoveredCanvasWithContent when adding content
|
|
517
|
-
const canvasWithContent = canvas;
|
|
518
|
-
canvasWithContent.content = parsedContent;
|
|
519
|
-
// Validate OTEL canvas nodes for explicit color usage (only for .otel.canvas files)
|
|
520
|
-
if (metadata.type === 'otel') {
|
|
521
|
-
const otelValidator = new OtelCanvasValidator_1.OtelCanvasValidator();
|
|
522
|
-
const violations = otelValidator.validate(parsedContent, path);
|
|
523
|
-
for (const violation of violations) {
|
|
524
|
-
errors.push({
|
|
525
|
-
path: violation.file,
|
|
526
|
-
error: `[${violation.ruleId}] ${violation.message}. ${violation.impact} ${violation.suggestion}`,
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
// Extract markdown path from canvas metadata if it exists
|
|
531
|
-
if (parsedContent.markdown) {
|
|
532
|
-
canvas.markdownPath = parsedContent.markdown;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
catch (error) {
|
|
536
|
-
errors.push({
|
|
537
|
-
path,
|
|
538
|
-
error: `Failed to parse canvas content: ${error.message}`,
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
canvases.push(canvas);
|
|
543
|
-
}
|
|
544
|
-
return canvases;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Discover execution files in the file tree
|
|
548
|
-
*/
|
|
549
|
-
/**
|
|
550
|
-
* Check if path is in .principal-views directory
|
|
551
|
-
* Supports both flat (.principal-views/file.canvas) and hierarchical (.principal-views/storyboard/file.canvas) structures
|
|
552
|
-
*/
|
|
553
|
-
isInCanvasDir(path) {
|
|
554
|
-
const parts = path.split('/');
|
|
555
|
-
// Root flat: .principal-views/file.canvas (2 parts)
|
|
556
|
-
if (parts[0] === CanvasDiscovery.CANVAS_DIR && parts.length === 2) {
|
|
557
|
-
return true;
|
|
558
|
-
}
|
|
559
|
-
// Root hierarchical: .principal-views/storyboard/file.canvas (3 parts)
|
|
560
|
-
if (parts[0] === CanvasDiscovery.CANVAS_DIR && parts.length === 3) {
|
|
561
|
-
return true;
|
|
562
|
-
}
|
|
563
|
-
// Package structures
|
|
564
|
-
if (parts.includes(CanvasDiscovery.CANVAS_DIR)) {
|
|
565
|
-
const idx = parts.indexOf(CanvasDiscovery.CANVAS_DIR);
|
|
566
|
-
// Package flat: packages/subsystems-core/.principal-views/file.canvas (idx + 2 parts)
|
|
567
|
-
// Package hierarchical: packages/subsystems-core/.principal-views/storyboard/file.canvas (idx + 3 parts)
|
|
568
|
-
return parts.length === idx + 2 || parts.length === idx + 3;
|
|
569
|
-
}
|
|
570
|
-
return false;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Parse canvas file path to extract metadata
|
|
574
|
-
*/
|
|
575
|
-
parseCanvasPath(path) {
|
|
576
|
-
const filename = path.split('/').pop();
|
|
577
|
-
if (!filename)
|
|
578
|
-
return null;
|
|
579
|
-
// Check for .scopes.canvas first (must come before .canvas check)
|
|
580
|
-
if (filename.endsWith('.scopes.canvas')) {
|
|
581
|
-
return {
|
|
582
|
-
basename: filename.replace(/\.scopes\.canvas$/, ''),
|
|
583
|
-
type: 'scopes',
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
// Check for .resources.canvas (must come before .canvas check)
|
|
587
|
-
if (filename.endsWith('.resources.canvas')) {
|
|
588
|
-
return {
|
|
589
|
-
basename: filename.replace(/\.resources\.canvas$/, ''),
|
|
590
|
-
type: 'resources',
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
// Check for .spans.canvas (must come before .canvas check)
|
|
594
|
-
if (filename.endsWith('.spans.canvas')) {
|
|
595
|
-
return {
|
|
596
|
-
basename: filename.replace(/\.spans\.canvas$/, ''),
|
|
597
|
-
type: 'spans',
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
// Check for .events.canvas (must come before .canvas check)
|
|
601
|
-
if (filename.endsWith('.events.canvas')) {
|
|
602
|
-
return {
|
|
603
|
-
basename: filename.replace(/\.events\.canvas$/, ''),
|
|
604
|
-
type: 'events',
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
// Check for .otel.canvas (must come before .canvas check)
|
|
608
|
-
if (filename.endsWith('.otel.canvas')) {
|
|
609
|
-
return {
|
|
610
|
-
basename: filename.replace(/\.otel\.canvas$/, ''),
|
|
611
|
-
type: 'otel',
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
// Check for .canvas (but not .otel.canvas, .scopes.canvas, .resources.canvas, .spans.canvas, or .events.canvas)
|
|
615
|
-
if (filename.endsWith('.canvas')) {
|
|
616
|
-
const basename = filename.replace(/\.canvas$/, '');
|
|
617
|
-
// Handle special case: files named exactly "resources.canvas" or "spans.canvas"
|
|
618
|
-
// These are architecture canvases despite using .canvas extension
|
|
619
|
-
if (basename === 'resources') {
|
|
620
|
-
return { basename, type: 'resources' };
|
|
621
|
-
}
|
|
622
|
-
if (basename === 'spans') {
|
|
623
|
-
return { basename, type: 'spans' };
|
|
624
|
-
}
|
|
625
|
-
if (basename === 'scopes') {
|
|
626
|
-
return { basename, type: 'scopes' };
|
|
627
|
-
}
|
|
628
|
-
if (basename === 'events') {
|
|
629
|
-
return { basename, type: 'events' };
|
|
630
|
-
}
|
|
631
|
-
return { basename, type: 'regular' };
|
|
632
|
-
}
|
|
633
|
-
return null;
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Find package for a given path using longest-path matching
|
|
637
|
-
*/
|
|
638
|
-
findPackageForPath(path, packageMap) {
|
|
639
|
-
// Find the longest matching package path
|
|
640
|
-
let bestMatch = null;
|
|
641
|
-
let bestMatchLength = 0;
|
|
642
|
-
for (const [pkgPath, pkg] of packageMap) {
|
|
643
|
-
if (path.startsWith(pkgPath + '/')) {
|
|
644
|
-
if (pkgPath.length > bestMatchLength) {
|
|
645
|
-
bestMatch = pkg;
|
|
646
|
-
bestMatchLength = pkgPath.length;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
return bestMatch;
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Convert basename to display name (Title Case)
|
|
654
|
-
*/
|
|
655
|
-
toDisplayName(basename) {
|
|
656
|
-
return basename
|
|
657
|
-
.split('-')
|
|
658
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
659
|
-
.join(' ');
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Sort by package then name
|
|
663
|
-
*/
|
|
664
|
-
compareByPackageThenName(a, b) {
|
|
665
|
-
// Package files first, then root
|
|
666
|
-
if (a.packageName && !b.packageName)
|
|
667
|
-
return -1;
|
|
668
|
-
if (!a.packageName && b.packageName)
|
|
669
|
-
return 1;
|
|
670
|
-
// If both have packages, sort by package name
|
|
671
|
-
if (a.packageName && b.packageName) {
|
|
672
|
-
const pkgCompare = a.packageName.localeCompare(b.packageName);
|
|
673
|
-
if (pkgCompare !== 0)
|
|
674
|
-
return pkgCompare;
|
|
675
|
-
}
|
|
676
|
-
// Within same package/root, sort by name
|
|
677
|
-
return a.name.localeCompare(b.name);
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Validate required canvas types based on dependency chain:
|
|
681
|
-
* - resources.canvas is required (foundation)
|
|
682
|
-
* - spans.canvas is required when resources.canvas exists
|
|
683
|
-
* - .otel.canvas is required when spans.canvas exists
|
|
684
|
-
*/
|
|
685
|
-
validateRequiredCanvases(canvases, storyboards, errors) {
|
|
686
|
-
// Check canvas types by category
|
|
687
|
-
const hasResourcesCanvas = canvases.some(c => c.type === 'resources');
|
|
688
|
-
const hasSpansCanvas = canvases.some(c => c.type === 'spans');
|
|
689
|
-
// Check for otel canvases specifically (not just any storyboard, since standalone canvases also create storyboards)
|
|
690
|
-
const hasOtelCanvas = canvases.some(c => c.type === 'otel');
|
|
691
|
-
// If no canvases at all, nothing to validate (no .principal-views directory)
|
|
692
|
-
if (canvases.length === 0 && storyboards.length === 0) {
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
// 1. resources.canvas is required (foundation)
|
|
696
|
-
if (!hasResourcesCanvas) {
|
|
697
|
-
errors.push({
|
|
698
|
-
path: '.principal-views',
|
|
699
|
-
error: 'Missing required resources.canvas: A resources canvas documenting OTEL resources and scopes is required. ' +
|
|
700
|
-
'Create .principal-views/resources.canvas (or architecture.resources.canvas) with nodes showing service.name and instrumentation scopes.',
|
|
701
|
-
});
|
|
702
|
-
// Don't check further dependencies if foundation is missing
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
// 2. spans.canvas is required when resources.canvas exists
|
|
706
|
-
if (!hasSpansCanvas) {
|
|
707
|
-
errors.push({
|
|
708
|
-
path: '.principal-views',
|
|
709
|
-
error: 'Missing required spans.canvas: When resources.canvas exists, a spans canvas documenting span conventions is required. ' +
|
|
710
|
-
'Create .principal-views/architecture.spans.canvas with nodes for each span pattern (e.g., validate.*, http.request) and edges showing valid parent-child relationships.',
|
|
711
|
-
});
|
|
712
|
-
// Don't check further dependencies
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
// 3. .otel.canvas is required when spans.canvas exists
|
|
716
|
-
if (!hasOtelCanvas) {
|
|
717
|
-
errors.push({
|
|
718
|
-
path: '.principal-views',
|
|
719
|
-
error: 'Missing required .otel.canvas: When spans.canvas exists, at least one feature-level OTEL canvas is required. ' +
|
|
720
|
-
'Create a storyboard with an .otel.canvas file (e.g., .principal-views/my-feature/my-feature.otel.canvas) documenting events for a specific feature.',
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Discover dashboard files from .principal-views/dashboards/ folder
|
|
726
|
-
*/
|
|
727
|
-
async discoverDashboards(fileTree, packageMap, options, errors) {
|
|
728
|
-
const dashboards = [];
|
|
729
|
-
for (const file of fileTree.allFiles) {
|
|
730
|
-
const path = file.relativePath || file.path || '';
|
|
731
|
-
// Only look for .dashboard.json files in dashboards/ folder
|
|
732
|
-
if (!path.endsWith(CanvasDiscovery.DASHBOARD_EXTENSION))
|
|
733
|
-
continue;
|
|
734
|
-
// Must be in .principal-views/dashboards/ folder
|
|
735
|
-
const parts = path.split('/');
|
|
736
|
-
const pvIndex = parts.indexOf(CanvasDiscovery.CANVAS_DIR);
|
|
737
|
-
if (pvIndex === -1)
|
|
738
|
-
continue;
|
|
739
|
-
// Check if it's in the dashboards/ folder (directly after .principal-views/)
|
|
740
|
-
const nextPart = parts[pvIndex + 1];
|
|
741
|
-
if (nextPart !== 'dashboards')
|
|
742
|
-
continue;
|
|
743
|
-
const filename = parts[parts.length - 1];
|
|
744
|
-
const basename = filename.replace(/\.dashboard\.json$/, '');
|
|
745
|
-
// Determine package context
|
|
746
|
-
const packageInfo = this.findPackageForPath(path, packageMap);
|
|
747
|
-
// Generate unique ID
|
|
748
|
-
const id = packageInfo
|
|
749
|
-
? `${packageInfo.packageData.name}/${basename}`
|
|
750
|
-
: basename;
|
|
751
|
-
const dashboard = {
|
|
752
|
-
id,
|
|
753
|
-
name: this.toDisplayName(basename),
|
|
754
|
-
path,
|
|
755
|
-
basename,
|
|
756
|
-
packageName: packageInfo?.packageData.name,
|
|
757
|
-
packagePath: packageInfo?.packageData.path,
|
|
758
|
-
scope: packageInfo ? 'package' : 'root',
|
|
759
|
-
};
|
|
760
|
-
// Optionally load content
|
|
761
|
-
if (options.includeContent && options.fileReader) {
|
|
762
|
-
try {
|
|
763
|
-
const content = await options.fileReader(path);
|
|
764
|
-
const parsed = JSON.parse(content);
|
|
765
|
-
dashboard.content = parsed;
|
|
766
|
-
}
|
|
767
|
-
catch (e) {
|
|
768
|
-
errors.push({
|
|
769
|
-
path,
|
|
770
|
-
error: `Failed to parse dashboard: ${e instanceof Error ? e.message : String(e)}`,
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
dashboards.push(dashboard);
|
|
775
|
-
}
|
|
776
|
-
return dashboards;
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* Detect legacy flat canvas structures and add deprecation errors
|
|
780
|
-
* Note: Flat .canvas and .scopes.canvas files are supported
|
|
781
|
-
* Only .otel.canvas files in flat structure are deprecated
|
|
782
|
-
*/
|
|
783
|
-
detectLegacyStructures(canvases, storyboards, errors) {
|
|
784
|
-
// Build a set of storyboard canvas IDs for quick lookup
|
|
785
|
-
const storyboardCanvasIds = new Set(storyboards.map(s => s.canvas.id));
|
|
786
|
-
// Check for legacy flat .otel.canvas files (not part of any storyboard)
|
|
787
|
-
// Note: Flat .canvas and .scopes.canvas files are supported
|
|
788
|
-
for (const canvas of canvases) {
|
|
789
|
-
if (!storyboardCanvasIds.has(canvas.id)) {
|
|
790
|
-
// This canvas is not part of any storyboard
|
|
791
|
-
const canvasDir = canvas.path.split('/').slice(0, -1).join('/');
|
|
792
|
-
const parts = canvasDir.split('/');
|
|
793
|
-
const pvIndex = parts.indexOf(CanvasDiscovery.CANVAS_DIR);
|
|
794
|
-
// Only error if it's a .otel.canvas file in flat structure
|
|
795
|
-
// Regular .canvas and .scopes.canvas files in flat structure are supported
|
|
796
|
-
if (pvIndex !== -1 && parts.length === pvIndex + 1 && canvas.type === 'otel') {
|
|
797
|
-
errors.push({
|
|
798
|
-
path: canvas.path,
|
|
799
|
-
error: 'DEPRECATED: Flat .otel.canvas files are no longer supported. .otel.canvas files must use the storyboard structure (.principal-views/storyboard-name/storyboard-name.otel.canvas). For static documentation, use .canvas files instead.',
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Validate scope hierarchy for hierarchical filtering
|
|
807
|
-
*
|
|
808
|
-
* Validates:
|
|
809
|
-
* 1. Workflow rootSpan exists in spans.canvas
|
|
810
|
-
* 2. Span conventions have otel.scope defined
|
|
811
|
-
* 3. Scope references exist in scopes.canvas (warning)
|
|
812
|
-
*/
|
|
813
|
-
validateScopeHierarchy(storyboards, spanLookup, scopeLabelLookup, errors) {
|
|
814
|
-
// Track scopes that have been warned about (to avoid duplicate warnings)
|
|
815
|
-
const warnedScopes = new Set();
|
|
816
|
-
for (const storyboard of storyboards) {
|
|
817
|
-
// Only validate otel storyboards
|
|
818
|
-
if (storyboard.canvas.type !== 'otel')
|
|
819
|
-
continue;
|
|
820
|
-
for (const workflow of storyboard.workflows) {
|
|
821
|
-
const workflowWithContent = workflow;
|
|
822
|
-
const content = workflowWithContent.content;
|
|
823
|
-
if (!content)
|
|
824
|
-
continue;
|
|
825
|
-
const rootSpan = content.rootSpan;
|
|
826
|
-
if (!rootSpan)
|
|
827
|
-
continue;
|
|
828
|
-
// 1. Validate rootSpan exists in spans.canvas
|
|
829
|
-
const rootSpanInfo = spanLookup.get(rootSpan);
|
|
830
|
-
if (!rootSpanInfo) {
|
|
831
|
-
errors.push({
|
|
832
|
-
path: workflow.path,
|
|
833
|
-
error: `Workflow "${workflow.basename}" has rootSpan "${rootSpan}" but no matching span convention ` +
|
|
834
|
-
`was found in spans.canvas. Add an otel-span-convention node with spanPattern: "${rootSpan}".`,
|
|
835
|
-
});
|
|
836
|
-
continue; // Skip further validation for this workflow
|
|
837
|
-
}
|
|
838
|
-
// 2. Validate span convention has otel.scope defined
|
|
839
|
-
if (!rootSpanInfo.scope) {
|
|
840
|
-
errors.push({
|
|
841
|
-
path: workflow.path,
|
|
842
|
-
error: `Span convention "${rootSpan}" in spans.canvas does not declare a scope. ` +
|
|
843
|
-
`Add otel.scope to specify which instrumentation scope creates this span.`,
|
|
844
|
-
});
|
|
845
|
-
continue; // Skip further validation for this workflow
|
|
846
|
-
}
|
|
847
|
-
// 3. Warn if scope doesn't exist in scopes.canvas
|
|
848
|
-
const scopeName = rootSpanInfo.scope;
|
|
849
|
-
if (!scopeLabelLookup.has(scopeName) && !warnedScopes.has(scopeName)) {
|
|
850
|
-
warnedScopes.add(scopeName);
|
|
851
|
-
errors.push({
|
|
852
|
-
path: workflow.path,
|
|
853
|
-
error: `Span convention "${rootSpan}" references scope "${scopeName}" but no matching ` +
|
|
854
|
-
`otel-scope node was found in scopes.canvas. Consider adding it for documentation.`,
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
CanvasDiscovery.CANVAS_DIR = '.principal-views';
|
|
862
|
-
CanvasDiscovery.WORKFLOW_EXTENSION = '.workflow.json';
|
|
863
|
-
CanvasDiscovery.DASHBOARD_EXTENSION = '.dashboard.json';
|
|
864
|
-
exports.CanvasDiscovery = CanvasDiscovery;
|
|
865
|
-
//# sourceMappingURL=CanvasDiscovery.js.map
|