@principal-ai/subsystems-core 0.29.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.
Files changed (614) hide show
  1. package/README.md +124 -0
  2. package/dist/ConfigurationLoader.d.ts +76 -0
  3. package/dist/ConfigurationLoader.d.ts.map +1 -0
  4. package/dist/ConfigurationLoader.js +148 -0
  5. package/dist/ConfigurationLoader.js.map +1 -0
  6. package/dist/ConfigurationValidator.d.ts +31 -0
  7. package/dist/ConfigurationValidator.d.ts.map +1 -0
  8. package/dist/ConfigurationValidator.js +239 -0
  9. package/dist/ConfigurationValidator.js.map +1 -0
  10. package/dist/EventProcessor.d.ts +49 -0
  11. package/dist/EventProcessor.d.ts.map +1 -0
  12. package/dist/EventProcessor.js +220 -0
  13. package/dist/EventProcessor.js.map +1 -0
  14. package/dist/EventRecorderService.d.ts +305 -0
  15. package/dist/EventRecorderService.d.ts.map +1 -0
  16. package/dist/EventRecorderService.js +467 -0
  17. package/dist/EventRecorderService.js.map +1 -0
  18. package/dist/LibraryLoader.d.ts +65 -0
  19. package/dist/LibraryLoader.d.ts.map +1 -0
  20. package/dist/LibraryLoader.js +197 -0
  21. package/dist/LibraryLoader.js.map +1 -0
  22. package/dist/PathBasedEventProcessor.d.ts +77 -0
  23. package/dist/PathBasedEventProcessor.d.ts.map +1 -0
  24. package/dist/PathBasedEventProcessor.js +136 -0
  25. package/dist/PathBasedEventProcessor.js.map +1 -0
  26. package/dist/SessionManager.d.ts +194 -0
  27. package/dist/SessionManager.d.ts.map +1 -0
  28. package/dist/SessionManager.js +302 -0
  29. package/dist/SessionManager.js.map +1 -0
  30. package/dist/ValidationEngine.d.ts +31 -0
  31. package/dist/ValidationEngine.d.ts.map +1 -0
  32. package/dist/ValidationEngine.js +162 -0
  33. package/dist/ValidationEngine.js.map +1 -0
  34. package/dist/agent-sessions/fixture.d.ts +80 -0
  35. package/dist/agent-sessions/fixture.d.ts.map +1 -0
  36. package/dist/agent-sessions/fixture.js +130 -0
  37. package/dist/agent-sessions/fixture.js.map +1 -0
  38. package/dist/agent-sessions/index.d.ts +3 -0
  39. package/dist/agent-sessions/index.d.ts.map +1 -0
  40. package/dist/agent-sessions/index.js +6 -0
  41. package/dist/agent-sessions/index.js.map +1 -0
  42. package/dist/auxiliary/AuxiliaryManifestValidator.d.ts +41 -0
  43. package/dist/auxiliary/AuxiliaryManifestValidator.d.ts.map +1 -0
  44. package/dist/auxiliary/AuxiliaryManifestValidator.js +100 -0
  45. package/dist/auxiliary/AuxiliaryManifestValidator.js.map +1 -0
  46. package/dist/auxiliary/index.d.ts +9 -0
  47. package/dist/auxiliary/index.d.ts.map +1 -0
  48. package/dist/auxiliary/index.js +14 -0
  49. package/dist/auxiliary/index.js.map +1 -0
  50. package/dist/auxiliary/validateAreaScopeDisjoint.d.ts +24 -0
  51. package/dist/auxiliary/validateAreaScopeDisjoint.d.ts.map +1 -0
  52. package/dist/auxiliary/validateAreaScopeDisjoint.js +61 -0
  53. package/dist/auxiliary/validateAreaScopeDisjoint.js.map +1 -0
  54. package/dist/cli/codegen.d.ts +41 -0
  55. package/dist/cli/codegen.d.ts.map +1 -0
  56. package/dist/cli/codegen.js +257 -0
  57. package/dist/cli/codegen.js.map +1 -0
  58. package/dist/codegen/type-generator.d.ts +123 -0
  59. package/dist/codegen/type-generator.d.ts.map +1 -0
  60. package/dist/codegen/type-generator.js +433 -0
  61. package/dist/codegen/type-generator.js.map +1 -0
  62. package/dist/codegen/usage-example.d.ts +103 -0
  63. package/dist/codegen/usage-example.d.ts.map +1 -0
  64. package/dist/codegen/usage-example.js +258 -0
  65. package/dist/codegen/usage-example.js.map +1 -0
  66. package/dist/dashboard/DashboardValidator.d.ts +85 -0
  67. package/dist/dashboard/DashboardValidator.d.ts.map +1 -0
  68. package/dist/dashboard/DashboardValidator.js +775 -0
  69. package/dist/dashboard/DashboardValidator.js.map +1 -0
  70. package/dist/dashboard/index.d.ts +6 -0
  71. package/dist/dashboard/index.d.ts.map +1 -0
  72. package/dist/dashboard/index.js +10 -0
  73. package/dist/dashboard/index.js.map +1 -0
  74. package/dist/discovery/CanvasDiscovery.d.ts +160 -0
  75. package/dist/discovery/CanvasDiscovery.d.ts.map +1 -0
  76. package/dist/discovery/CanvasDiscovery.js +865 -0
  77. package/dist/discovery/CanvasDiscovery.js.map +1 -0
  78. package/dist/discovery/CanvasFileManifest.d.ts +86 -0
  79. package/dist/discovery/CanvasFileManifest.d.ts.map +1 -0
  80. package/dist/discovery/CanvasFileManifest.js +338 -0
  81. package/dist/discovery/CanvasFileManifest.js.map +1 -0
  82. package/dist/discovery/LibraryDiscovery.d.ts +108 -0
  83. package/dist/discovery/LibraryDiscovery.d.ts.map +1 -0
  84. package/dist/discovery/LibraryDiscovery.js +263 -0
  85. package/dist/discovery/LibraryDiscovery.js.map +1 -0
  86. package/dist/discovery/types.d.ts +403 -0
  87. package/dist/discovery/types.d.ts.map +1 -0
  88. package/dist/discovery/types.js +6 -0
  89. package/dist/discovery/types.js.map +1 -0
  90. package/dist/events/EventsCanvasValidator.d.ts +139 -0
  91. package/dist/events/EventsCanvasValidator.d.ts.map +1 -0
  92. package/dist/events/EventsCanvasValidator.js +281 -0
  93. package/dist/events/EventsCanvasValidator.js.map +1 -0
  94. package/dist/events/NamespacePathIndex.d.ts +61 -0
  95. package/dist/events/NamespacePathIndex.d.ts.map +1 -0
  96. package/dist/events/NamespacePathIndex.js +74 -0
  97. package/dist/events/NamespacePathIndex.js.map +1 -0
  98. package/dist/events/OtelEventPathsValidator.d.ts +75 -0
  99. package/dist/events/OtelEventPathsValidator.d.ts.map +1 -0
  100. package/dist/events/OtelEventPathsValidator.js +126 -0
  101. package/dist/events/OtelEventPathsValidator.js.map +1 -0
  102. package/dist/events/ScopeEventsValidator.d.ts +68 -0
  103. package/dist/events/ScopeEventsValidator.d.ts.map +1 -0
  104. package/dist/events/ScopeEventsValidator.js +91 -0
  105. package/dist/events/ScopeEventsValidator.js.map +1 -0
  106. package/dist/events/index.d.ts +9 -0
  107. package/dist/events/index.d.ts.map +1 -0
  108. package/dist/events/index.js +12 -0
  109. package/dist/events/index.js.map +1 -0
  110. package/dist/events/path-helpers.d.ts +33 -0
  111. package/dist/events/path-helpers.d.ts.map +1 -0
  112. package/dist/events/path-helpers.js +59 -0
  113. package/dist/events/path-helpers.js.map +1 -0
  114. package/dist/execution/ExecutionLoader.d.ts +135 -0
  115. package/dist/execution/ExecutionLoader.d.ts.map +1 -0
  116. package/dist/execution/ExecutionLoader.js +266 -0
  117. package/dist/execution/ExecutionLoader.js.map +1 -0
  118. package/dist/execution/ExecutionValidator.d.ts +94 -0
  119. package/dist/execution/ExecutionValidator.d.ts.map +1 -0
  120. package/dist/execution/ExecutionValidator.js +503 -0
  121. package/dist/execution/ExecutionValidator.js.map +1 -0
  122. package/dist/generated/graph-converter-execution.types.d.ts +177 -0
  123. package/dist/generated/graph-converter-execution.types.d.ts.map +1 -0
  124. package/dist/generated/graph-converter-execution.types.js +12 -0
  125. package/dist/generated/graph-converter-execution.types.js.map +1 -0
  126. package/dist/helpers/GraphInstrumentationHelper.d.ts +93 -0
  127. package/dist/helpers/GraphInstrumentationHelper.d.ts.map +1 -0
  128. package/dist/helpers/GraphInstrumentationHelper.js +252 -0
  129. package/dist/helpers/GraphInstrumentationHelper.js.map +1 -0
  130. package/dist/index.d.ts +82 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +214 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/matchers/SpanMatcher.d.ts +107 -0
  135. package/dist/matchers/SpanMatcher.d.ts.map +1 -0
  136. package/dist/matchers/SpanMatcher.js +274 -0
  137. package/dist/matchers/SpanMatcher.js.map +1 -0
  138. package/dist/node.d.ts +78 -0
  139. package/dist/node.d.ts.map +1 -0
  140. package/dist/node.js +177 -0
  141. package/dist/node.js.map +1 -0
  142. package/dist/opencode/OpenCodeEventStore.d.ts +25 -0
  143. package/dist/opencode/OpenCodeEventStore.d.ts.map +1 -0
  144. package/dist/opencode/OpenCodeEventStore.js +182 -0
  145. package/dist/opencode/OpenCodeEventStore.js.map +1 -0
  146. package/dist/opencode/agent-sessions.d.ts +46 -0
  147. package/dist/opencode/agent-sessions.d.ts.map +1 -0
  148. package/dist/opencode/agent-sessions.js +302 -0
  149. package/dist/opencode/agent-sessions.js.map +1 -0
  150. package/dist/opencode/index.d.ts +6 -0
  151. package/dist/opencode/index.d.ts.map +1 -0
  152. package/dist/opencode/index.js +15 -0
  153. package/dist/opencode/index.js.map +1 -0
  154. package/dist/opencode/node-path-adapter.d.ts +25 -0
  155. package/dist/opencode/node-path-adapter.d.ts.map +1 -0
  156. package/dist/opencode/node-path-adapter.js +188 -0
  157. package/dist/opencode/node-path-adapter.js.map +1 -0
  158. package/dist/opencode/pipeline.d.ts +42 -0
  159. package/dist/opencode/pipeline.d.ts.map +1 -0
  160. package/dist/opencode/pipeline.js +90 -0
  161. package/dist/opencode/pipeline.js.map +1 -0
  162. package/dist/opencode/types.d.ts +39 -0
  163. package/dist/opencode/types.d.ts.map +1 -0
  164. package/dist/opencode/types.js +3 -0
  165. package/dist/opencode/types.js.map +1 -0
  166. package/dist/orchestration/TraceOrchestrator.d.ts +71 -0
  167. package/dist/orchestration/TraceOrchestrator.d.ts.map +1 -0
  168. package/dist/orchestration/TraceOrchestrator.js +416 -0
  169. package/dist/orchestration/TraceOrchestrator.js.map +1 -0
  170. package/dist/parsers/OtlpTraceParser.d.ts +131 -0
  171. package/dist/parsers/OtlpTraceParser.d.ts.map +1 -0
  172. package/dist/parsers/OtlpTraceParser.js +310 -0
  173. package/dist/parsers/OtlpTraceParser.js.map +1 -0
  174. package/dist/registry/CompositeRegistry.d.ts +71 -0
  175. package/dist/registry/CompositeRegistry.d.ts.map +1 -0
  176. package/dist/registry/CompositeRegistry.js +113 -0
  177. package/dist/registry/CompositeRegistry.js.map +1 -0
  178. package/dist/registry/EventRegistry.d.ts +79 -0
  179. package/dist/registry/EventRegistry.d.ts.map +1 -0
  180. package/dist/registry/EventRegistry.js +165 -0
  181. package/dist/registry/EventRegistry.js.map +1 -0
  182. package/dist/registry/LocalRegistry.d.ts +111 -0
  183. package/dist/registry/LocalRegistry.d.ts.map +1 -0
  184. package/dist/registry/LocalRegistry.js +335 -0
  185. package/dist/registry/LocalRegistry.js.map +1 -0
  186. package/dist/registry/RemoteRegistry.d.ts +122 -0
  187. package/dist/registry/RemoteRegistry.d.ts.map +1 -0
  188. package/dist/registry/RemoteRegistry.js +399 -0
  189. package/dist/registry/RemoteRegistry.js.map +1 -0
  190. package/dist/registry/VersionRegistry.d.ts +51 -0
  191. package/dist/registry/VersionRegistry.d.ts.map +1 -0
  192. package/dist/registry/VersionRegistry.js +105 -0
  193. package/dist/registry/VersionRegistry.js.map +1 -0
  194. package/dist/rules/config.d.ts +57 -0
  195. package/dist/rules/config.d.ts.map +1 -0
  196. package/dist/rules/config.js +382 -0
  197. package/dist/rules/config.js.map +1 -0
  198. package/dist/rules/engine.d.ts +70 -0
  199. package/dist/rules/engine.d.ts.map +1 -0
  200. package/dist/rules/engine.js +373 -0
  201. package/dist/rules/engine.js.map +1 -0
  202. package/dist/rules/implementations/connection-type-references.d.ts +7 -0
  203. package/dist/rules/implementations/connection-type-references.d.ts.map +1 -0
  204. package/dist/rules/implementations/connection-type-references.js +107 -0
  205. package/dist/rules/implementations/connection-type-references.js.map +1 -0
  206. package/dist/rules/implementations/dead-end-states.d.ts +17 -0
  207. package/dist/rules/implementations/dead-end-states.d.ts.map +1 -0
  208. package/dist/rules/implementations/dead-end-states.js +75 -0
  209. package/dist/rules/implementations/dead-end-states.js.map +1 -0
  210. package/dist/rules/implementations/index.d.ts +23 -0
  211. package/dist/rules/implementations/index.d.ts.map +1 -0
  212. package/dist/rules/implementations/index.js +73 -0
  213. package/dist/rules/implementations/index.js.map +1 -0
  214. package/dist/rules/implementations/minimum-node-sources.d.ts +24 -0
  215. package/dist/rules/implementations/minimum-node-sources.d.ts.map +1 -0
  216. package/dist/rules/implementations/minimum-node-sources.js +59 -0
  217. package/dist/rules/implementations/minimum-node-sources.js.map +1 -0
  218. package/dist/rules/implementations/no-unknown-fields.d.ts +7 -0
  219. package/dist/rules/implementations/no-unknown-fields.d.ts.map +1 -0
  220. package/dist/rules/implementations/no-unknown-fields.js +216 -0
  221. package/dist/rules/implementations/no-unknown-fields.js.map +1 -0
  222. package/dist/rules/implementations/orphaned-edge-types.d.ts +7 -0
  223. package/dist/rules/implementations/orphaned-edge-types.d.ts.map +1 -0
  224. package/dist/rules/implementations/orphaned-edge-types.js +50 -0
  225. package/dist/rules/implementations/orphaned-edge-types.js.map +1 -0
  226. package/dist/rules/implementations/orphaned-node-types.d.ts +7 -0
  227. package/dist/rules/implementations/orphaned-node-types.d.ts.map +1 -0
  228. package/dist/rules/implementations/orphaned-node-types.js +53 -0
  229. package/dist/rules/implementations/orphaned-node-types.js.map +1 -0
  230. package/dist/rules/implementations/required-metadata.d.ts +7 -0
  231. package/dist/rules/implementations/required-metadata.d.ts.map +1 -0
  232. package/dist/rules/implementations/required-metadata.js +48 -0
  233. package/dist/rules/implementations/required-metadata.js.map +1 -0
  234. package/dist/rules/implementations/state-transition-references.d.ts +7 -0
  235. package/dist/rules/implementations/state-transition-references.d.ts.map +1 -0
  236. package/dist/rules/implementations/state-transition-references.js +138 -0
  237. package/dist/rules/implementations/state-transition-references.js.map +1 -0
  238. package/dist/rules/implementations/unreachable-states.d.ts +7 -0
  239. package/dist/rules/implementations/unreachable-states.d.ts.map +1 -0
  240. package/dist/rules/implementations/unreachable-states.js +83 -0
  241. package/dist/rules/implementations/unreachable-states.js.map +1 -0
  242. package/dist/rules/implementations/valid-action-patterns.d.ts +17 -0
  243. package/dist/rules/implementations/valid-action-patterns.d.ts.map +1 -0
  244. package/dist/rules/implementations/valid-action-patterns.js +112 -0
  245. package/dist/rules/implementations/valid-action-patterns.js.map +1 -0
  246. package/dist/rules/implementations/valid-color-format.d.ts +7 -0
  247. package/dist/rules/implementations/valid-color-format.d.ts.map +1 -0
  248. package/dist/rules/implementations/valid-color-format.js +94 -0
  249. package/dist/rules/implementations/valid-color-format.js.map +1 -0
  250. package/dist/rules/implementations/valid-edge-types.d.ts +7 -0
  251. package/dist/rules/implementations/valid-edge-types.d.ts.map +1 -0
  252. package/dist/rules/implementations/valid-edge-types.js +248 -0
  253. package/dist/rules/implementations/valid-edge-types.js.map +1 -0
  254. package/dist/rules/implementations/valid-node-types.d.ts +7 -0
  255. package/dist/rules/implementations/valid-node-types.d.ts.map +1 -0
  256. package/dist/rules/implementations/valid-node-types.js +187 -0
  257. package/dist/rules/implementations/valid-node-types.js.map +1 -0
  258. package/dist/rules/index.d.ts +28 -0
  259. package/dist/rules/index.d.ts.map +1 -0
  260. package/dist/rules/index.js +70 -0
  261. package/dist/rules/index.js.map +1 -0
  262. package/dist/rules/types.d.ts +309 -0
  263. package/dist/rules/types.d.ts.map +1 -0
  264. package/dist/rules/types.js +40 -0
  265. package/dist/rules/types.js.map +1 -0
  266. package/dist/scopes/ScopePathIndex.d.ts +56 -0
  267. package/dist/scopes/ScopePathIndex.d.ts.map +1 -0
  268. package/dist/scopes/ScopePathIndex.js +67 -0
  269. package/dist/scopes/ScopePathIndex.js.map +1 -0
  270. package/dist/scopes/ScopesCanvasValidator.d.ts +76 -0
  271. package/dist/scopes/ScopesCanvasValidator.d.ts.map +1 -0
  272. package/dist/scopes/ScopesCanvasValidator.js +221 -0
  273. package/dist/scopes/ScopesCanvasValidator.js.map +1 -0
  274. package/dist/scopes/index.d.ts +12 -0
  275. package/dist/scopes/index.d.ts.map +1 -0
  276. package/dist/scopes/index.js +30 -0
  277. package/dist/scopes/index.js.map +1 -0
  278. package/dist/scopes/utils.d.ts +85 -0
  279. package/dist/scopes/utils.d.ts.map +1 -0
  280. package/dist/scopes/utils.js +143 -0
  281. package/dist/scopes/utils.js.map +1 -0
  282. package/dist/scopes/validateScopeNamespaceNesting.d.ts +38 -0
  283. package/dist/scopes/validateScopeNamespaceNesting.d.ts.map +1 -0
  284. package/dist/scopes/validateScopeNamespaceNesting.js +69 -0
  285. package/dist/scopes/validateScopeNamespaceNesting.js.map +1 -0
  286. package/dist/spans/index.d.ts +12 -0
  287. package/dist/spans/index.d.ts.map +1 -0
  288. package/dist/spans/index.js +25 -0
  289. package/dist/spans/index.js.map +1 -0
  290. package/dist/spans/utils.d.ts +70 -0
  291. package/dist/spans/utils.d.ts.map +1 -0
  292. package/dist/spans/utils.js +205 -0
  293. package/dist/spans/utils.js.map +1 -0
  294. package/dist/storage/topic-types.d.ts +203 -0
  295. package/dist/storage/topic-types.d.ts.map +1 -0
  296. package/dist/storage/topic-types.js +60 -0
  297. package/dist/storage/topic-types.js.map +1 -0
  298. package/dist/storage/topicStore.d.ts +135 -0
  299. package/dist/storage/topicStore.d.ts.map +1 -0
  300. package/dist/storage/topicStore.js +389 -0
  301. package/dist/storage/topicStore.js.map +1 -0
  302. package/dist/storyboard/builder.d.ts +135 -0
  303. package/dist/storyboard/builder.d.ts.map +1 -0
  304. package/dist/storyboard/builder.js +235 -0
  305. package/dist/storyboard/builder.js.map +1 -0
  306. package/dist/storyboard/index.d.ts +9 -0
  307. package/dist/storyboard/index.d.ts.map +1 -0
  308. package/dist/storyboard/index.js +18 -0
  309. package/dist/storyboard/index.js.map +1 -0
  310. package/dist/storyboard/types.d.ts +101 -0
  311. package/dist/storyboard/types.d.ts.map +1 -0
  312. package/dist/storyboard/types.js +10 -0
  313. package/dist/storyboard/types.js.map +1 -0
  314. package/dist/telemetry/coverage.d.ts +92 -0
  315. package/dist/telemetry/coverage.d.ts.map +1 -0
  316. package/dist/telemetry/coverage.js +335 -0
  317. package/dist/telemetry/coverage.js.map +1 -0
  318. package/dist/telemetry/event-validator.d.ts +86 -0
  319. package/dist/telemetry/event-validator.d.ts.map +1 -0
  320. package/dist/telemetry/event-validator.js +257 -0
  321. package/dist/telemetry/event-validator.js.map +1 -0
  322. package/dist/types/audit.d.ts +236 -0
  323. package/dist/types/audit.d.ts.map +1 -0
  324. package/dist/types/audit.js +53 -0
  325. package/dist/types/audit.js.map +1 -0
  326. package/dist/types/auxiliary.d.ts +54 -0
  327. package/dist/types/auxiliary.d.ts.map +1 -0
  328. package/dist/types/auxiliary.js +27 -0
  329. package/dist/types/auxiliary.js.map +1 -0
  330. package/dist/types/canvas-scope.d.ts +156 -0
  331. package/dist/types/canvas-scope.d.ts.map +1 -0
  332. package/dist/types/canvas-scope.js +62 -0
  333. package/dist/types/canvas-scope.js.map +1 -0
  334. package/dist/types/canvas.d.ts +1138 -0
  335. package/dist/types/canvas.d.ts.map +1 -0
  336. package/dist/types/canvas.js +178 -0
  337. package/dist/types/canvas.js.map +1 -0
  338. package/dist/types/dashboard.d.ts +170 -0
  339. package/dist/types/dashboard.d.ts.map +1 -0
  340. package/dist/types/dashboard.js +14 -0
  341. package/dist/types/dashboard.js.map +1 -0
  342. package/dist/types/index.d.ts +352 -0
  343. package/dist/types/index.d.ts.map +1 -0
  344. package/dist/types/index.js +39 -0
  345. package/dist/types/index.js.map +1 -0
  346. package/dist/types/library.d.ts +227 -0
  347. package/dist/types/library.d.ts.map +1 -0
  348. package/dist/types/library.js +16 -0
  349. package/dist/types/library.js.map +1 -0
  350. package/dist/types/otel.d.ts +465 -0
  351. package/dist/types/otel.d.ts.map +1 -0
  352. package/dist/types/otel.js +163 -0
  353. package/dist/types/otel.js.map +1 -0
  354. package/dist/types/path-based-config.d.ts +235 -0
  355. package/dist/types/path-based-config.d.ts.map +1 -0
  356. package/dist/types/path-based-config.js +11 -0
  357. package/dist/types/path-based-config.js.map +1 -0
  358. package/dist/types/registered-trace.d.ts +337 -0
  359. package/dist/types/registered-trace.d.ts.map +1 -0
  360. package/dist/types/registered-trace.js +16 -0
  361. package/dist/types/registered-trace.js.map +1 -0
  362. package/dist/types/resource-match.d.ts +207 -0
  363. package/dist/types/resource-match.d.ts.map +1 -0
  364. package/dist/types/resource-match.js +74 -0
  365. package/dist/types/resource-match.js.map +1 -0
  366. package/dist/types/subsystem-model.d.ts +265 -0
  367. package/dist/types/subsystem-model.d.ts.map +1 -0
  368. package/dist/types/subsystem-model.js +35 -0
  369. package/dist/types/subsystem-model.js.map +1 -0
  370. package/dist/types/version-registry.d.ts +137 -0
  371. package/dist/types/version-registry.d.ts.map +1 -0
  372. package/dist/types/version-registry.js +10 -0
  373. package/dist/types/version-registry.js.map +1 -0
  374. package/dist/utils/CanvasConverter.d.ts +148 -0
  375. package/dist/utils/CanvasConverter.d.ts.map +1 -0
  376. package/dist/utils/CanvasConverter.js +530 -0
  377. package/dist/utils/CanvasConverter.js.map +1 -0
  378. package/dist/utils/GraphConverter.d.ts +18 -0
  379. package/dist/utils/GraphConverter.d.ts.map +1 -0
  380. package/dist/utils/GraphConverter.js +80 -0
  381. package/dist/utils/GraphConverter.js.map +1 -0
  382. package/dist/utils/PathMatcher.d.ts +55 -0
  383. package/dist/utils/PathMatcher.d.ts.map +1 -0
  384. package/dist/utils/PathMatcher.js +178 -0
  385. package/dist/utils/PathMatcher.js.map +1 -0
  386. package/dist/utils/TraceToCanvas.d.ts +83 -0
  387. package/dist/utils/TraceToCanvas.d.ts.map +1 -0
  388. package/dist/utils/TraceToCanvas.js +336 -0
  389. package/dist/utils/TraceToCanvas.js.map +1 -0
  390. package/dist/utils/YamlParser.d.ts +36 -0
  391. package/dist/utils/YamlParser.d.ts.map +1 -0
  392. package/dist/utils/YamlParser.js +92 -0
  393. package/dist/utils/YamlParser.js.map +1 -0
  394. package/dist/utils/registeredTraceHelpers.d.ts +76 -0
  395. package/dist/utils/registeredTraceHelpers.d.ts.map +1 -0
  396. package/dist/utils/registeredTraceHelpers.js +203 -0
  397. package/dist/utils/registeredTraceHelpers.js.map +1 -0
  398. package/dist/utils/traceAggregation.d.ts +25 -0
  399. package/dist/utils/traceAggregation.d.ts.map +1 -0
  400. package/dist/utils/traceAggregation.js +140 -0
  401. package/dist/utils/traceAggregation.js.map +1 -0
  402. package/dist/validation/OtelCanvasValidator.d.ts +40 -0
  403. package/dist/validation/OtelCanvasValidator.d.ts.map +1 -0
  404. package/dist/validation/OtelCanvasValidator.js +59 -0
  405. package/dist/validation/OtelCanvasValidator.js.map +1 -0
  406. package/dist/validation/index.d.ts +8 -0
  407. package/dist/validation/index.d.ts.map +1 -0
  408. package/dist/validation/index.js +13 -0
  409. package/dist/validation/index.js.map +1 -0
  410. package/dist/validation/libraryValidation.d.ts +53 -0
  411. package/dist/validation/libraryValidation.d.ts.map +1 -0
  412. package/dist/validation/libraryValidation.js +115 -0
  413. package/dist/validation/libraryValidation.js.map +1 -0
  414. package/dist/workflow/edge-derivation.d.ts +111 -0
  415. package/dist/workflow/edge-derivation.d.ts.map +1 -0
  416. package/dist/workflow/edge-derivation.js +174 -0
  417. package/dist/workflow/edge-derivation.js.map +1 -0
  418. package/dist/workflow/edge-validation.d.ts +170 -0
  419. package/dist/workflow/edge-validation.d.ts.map +1 -0
  420. package/dist/workflow/edge-validation.js +332 -0
  421. package/dist/workflow/edge-validation.js.map +1 -0
  422. package/dist/workflow/example.d.ts +11 -0
  423. package/dist/workflow/example.d.ts.map +1 -0
  424. package/dist/workflow/example.js +310 -0
  425. package/dist/workflow/example.js.map +1 -0
  426. package/dist/workflow/index.d.ts +20 -0
  427. package/dist/workflow/index.d.ts.map +1 -0
  428. package/dist/workflow/index.js +49 -0
  429. package/dist/workflow/index.js.map +1 -0
  430. package/dist/workflow/scenario-matcher.d.ts +63 -0
  431. package/dist/workflow/scenario-matcher.d.ts.map +1 -0
  432. package/dist/workflow/scenario-matcher.js +215 -0
  433. package/dist/workflow/scenario-matcher.js.map +1 -0
  434. package/dist/workflow/template-parser.d.ts +73 -0
  435. package/dist/workflow/template-parser.d.ts.map +1 -0
  436. package/dist/workflow/template-parser.js +280 -0
  437. package/dist/workflow/template-parser.js.map +1 -0
  438. package/dist/workflow/template-renderer.d.ts +45 -0
  439. package/dist/workflow/template-renderer.d.ts.map +1 -0
  440. package/dist/workflow/template-renderer.js +401 -0
  441. package/dist/workflow/template-renderer.js.map +1 -0
  442. package/dist/workflow/types.d.ts +393 -0
  443. package/dist/workflow/types.d.ts.map +1 -0
  444. package/dist/workflow/types.js +40 -0
  445. package/dist/workflow/types.js.map +1 -0
  446. package/dist/workflow/validator.d.ts +363 -0
  447. package/dist/workflow/validator.d.ts.map +1 -0
  448. package/dist/workflow/validator.js +2283 -0
  449. package/dist/workflow/validator.js.map +1 -0
  450. package/package.json +84 -0
  451. package/schemas/auxiliary.manifest.schema.json +56 -0
  452. package/schemas/subsystem-model.schema.json +767 -0
  453. package/src/ConfigurationLoader.test.ts +466 -0
  454. package/src/ConfigurationLoader.ts +184 -0
  455. package/src/ConfigurationValidator.test.ts +200 -0
  456. package/src/ConfigurationValidator.ts +273 -0
  457. package/src/EventProcessor.test.ts +405 -0
  458. package/src/EventProcessor.ts +256 -0
  459. package/src/EventRecorderService.test.ts +543 -0
  460. package/src/EventRecorderService.ts +741 -0
  461. package/src/LibraryLoader.ts +194 -0
  462. package/src/PathBasedEventProcessor.test.ts +336 -0
  463. package/src/PathBasedEventProcessor.ts +196 -0
  464. package/src/SessionManager.test.ts +424 -0
  465. package/src/SessionManager.ts +471 -0
  466. package/src/ValidationEngine.test.ts +520 -0
  467. package/src/ValidationEngine.ts +200 -0
  468. package/src/agent-sessions/fixture.ts +225 -0
  469. package/src/agent-sessions/index.ts +10 -0
  470. package/src/auxiliary/AuxiliaryManifestValidator.test.ts +93 -0
  471. package/src/auxiliary/AuxiliaryManifestValidator.ts +132 -0
  472. package/src/auxiliary/index.ts +18 -0
  473. package/src/auxiliary/validateAreaScopeDisjoint.test.ts +85 -0
  474. package/src/auxiliary/validateAreaScopeDisjoint.ts +72 -0
  475. package/src/browser-safety.test.ts +170 -0
  476. package/src/cli/codegen.ts +286 -0
  477. package/src/codegen/type-generator.test.ts +219 -0
  478. package/src/codegen/type-generator.ts +560 -0
  479. package/src/codegen/usage-example.ts +357 -0
  480. package/src/dashboard/DashboardValidator.ts +904 -0
  481. package/src/dashboard/index.ts +14 -0
  482. package/src/discovery/CanvasDiscovery.test.ts +691 -0
  483. package/src/discovery/CanvasDiscovery.ts +1114 -0
  484. package/src/discovery/CanvasFileManifest.test.ts +521 -0
  485. package/src/discovery/CanvasFileManifest.ts +419 -0
  486. package/src/discovery/LibraryDiscovery.test.ts +329 -0
  487. package/src/discovery/LibraryDiscovery.ts +386 -0
  488. package/src/discovery/types.ts +453 -0
  489. package/src/events/EventsCanvasValidator.test.ts +191 -0
  490. package/src/events/EventsCanvasValidator.ts +428 -0
  491. package/src/events/NamespacePathIndex.test.ts +97 -0
  492. package/src/events/NamespacePathIndex.ts +100 -0
  493. package/src/events/OtelEventPathsValidator.test.ts +243 -0
  494. package/src/events/OtelEventPathsValidator.ts +191 -0
  495. package/src/events/ScopeEventsValidator.test.ts +173 -0
  496. package/src/events/ScopeEventsValidator.ts +158 -0
  497. package/src/events/index.ts +27 -0
  498. package/src/events/path-helpers.ts +53 -0
  499. package/src/execution/ExecutionLoader.test.ts +378 -0
  500. package/src/execution/ExecutionLoader.ts +331 -0
  501. package/src/execution/ExecutionValidator.test.ts +503 -0
  502. package/src/execution/ExecutionValidator.ts +617 -0
  503. package/src/generated/graph-converter-execution.types.ts +193 -0
  504. package/src/helpers/GraphInstrumentationHelper.test.ts +364 -0
  505. package/src/helpers/GraphInstrumentationHelper.ts +323 -0
  506. package/src/index.ts +587 -0
  507. package/src/matchers/SpanMatcher.test.ts +1105 -0
  508. package/src/matchers/SpanMatcher.ts +381 -0
  509. package/src/node.ts +316 -0
  510. package/src/opencode/EVENT_MAPPING.md +82 -0
  511. package/src/opencode/OpenCodeEventStore.ts +214 -0
  512. package/src/opencode/__fixtures__/event-shapes.json +443 -0
  513. package/src/opencode/__fixtures__/session-events.json +13491 -0
  514. package/src/opencode/agent-sessions.ts +376 -0
  515. package/src/opencode/index.ts +23 -0
  516. package/src/opencode/node-path-adapter.ts +205 -0
  517. package/src/opencode/pipeline.ts +141 -0
  518. package/src/opencode/types.ts +43 -0
  519. package/src/orchestration/TraceOrchestrator.ts +560 -0
  520. package/src/orchestration/__tests__/TraceOrchestrator.test.ts +1098 -0
  521. package/src/parsers/OtlpTraceParser.ts +401 -0
  522. package/src/parsers/__tests__/OtlpTraceParser.test.ts +197 -0
  523. package/src/registry/CompositeRegistry.ts +140 -0
  524. package/src/registry/EventRegistry.test.ts +387 -0
  525. package/src/registry/EventRegistry.ts +191 -0
  526. package/src/registry/LocalRegistry.ts +416 -0
  527. package/src/registry/RemoteRegistry.ts +499 -0
  528. package/src/registry/VersionRegistry.test.ts +223 -0
  529. package/src/registry/VersionRegistry.ts +121 -0
  530. package/src/rules/config.test.ts +277 -0
  531. package/src/rules/config.ts +450 -0
  532. package/src/rules/engine.test.ts +331 -0
  533. package/src/rules/engine.ts +448 -0
  534. package/src/rules/implementations/connection-type-references.ts +117 -0
  535. package/src/rules/implementations/dead-end-states.ts +101 -0
  536. package/src/rules/implementations/index.ts +66 -0
  537. package/src/rules/implementations/minimum-node-sources.ts +84 -0
  538. package/src/rules/implementations/no-unknown-fields.ts +372 -0
  539. package/src/rules/implementations/orphaned-edge-types.ts +55 -0
  540. package/src/rules/implementations/orphaned-node-types.ts +58 -0
  541. package/src/rules/implementations/required-metadata.ts +52 -0
  542. package/src/rules/implementations/state-transition-references.ts +155 -0
  543. package/src/rules/implementations/unreachable-states.ts +94 -0
  544. package/src/rules/implementations/valid-action-patterns.ts +140 -0
  545. package/src/rules/implementations/valid-color-format.ts +152 -0
  546. package/src/rules/implementations/valid-edge-types.ts +273 -0
  547. package/src/rules/implementations/valid-node-types.ts +200 -0
  548. package/src/rules/index.ts +92 -0
  549. package/src/rules/types.ts +426 -0
  550. package/src/scopes/ScopePathIndex.test.ts +94 -0
  551. package/src/scopes/ScopePathIndex.ts +89 -0
  552. package/src/scopes/ScopesCanvasValidator.test.ts +127 -0
  553. package/src/scopes/ScopesCanvasValidator.ts +305 -0
  554. package/src/scopes/__tests__/utils.test.ts +383 -0
  555. package/src/scopes/index.ts +42 -0
  556. package/src/scopes/utils.ts +182 -0
  557. package/src/scopes/validateScopeNamespaceNesting.test.ts +127 -0
  558. package/src/scopes/validateScopeNamespaceNesting.ts +88 -0
  559. package/src/spans/index.ts +24 -0
  560. package/src/spans/utils.ts +249 -0
  561. package/src/storage/topic-types.ts +235 -0
  562. package/src/storage/topicStore.test.ts +193 -0
  563. package/src/storage/topicStore.ts +489 -0
  564. package/src/storyboard/builder.ts +308 -0
  565. package/src/storyboard/index.ts +26 -0
  566. package/src/storyboard/types.ts +117 -0
  567. package/src/telemetry/coverage.ts +480 -0
  568. package/src/telemetry/event-validator.ts +312 -0
  569. package/src/types/audit.ts +314 -0
  570. package/src/types/auxiliary.ts +63 -0
  571. package/src/types/canvas-scope.ts +190 -0
  572. package/src/types/canvas.test.ts +199 -0
  573. package/src/types/canvas.ts +1395 -0
  574. package/src/types/dashboard.ts +257 -0
  575. package/src/types/index.ts +460 -0
  576. package/src/types/library.ts +283 -0
  577. package/src/types/otel.test.ts +219 -0
  578. package/src/types/otel.ts +620 -0
  579. package/src/types/path-based-config.ts +285 -0
  580. package/src/types/registered-trace.ts +432 -0
  581. package/src/types/resource-match.ts +263 -0
  582. package/src/types/subsystem-model.ts +352 -0
  583. package/src/types/version-registry.ts +150 -0
  584. package/src/utils/CanvasConverter.ts +670 -0
  585. package/src/utils/GraphConverter.test.ts +322 -0
  586. package/src/utils/GraphConverter.ts +84 -0
  587. package/src/utils/PathMatcher.test.ts +139 -0
  588. package/src/utils/PathMatcher.ts +185 -0
  589. package/src/utils/TraceToCanvas.test.ts +310 -0
  590. package/src/utils/TraceToCanvas.ts +510 -0
  591. package/src/utils/YamlParser.ts +77 -0
  592. package/src/utils/registeredTraceHelpers.ts +251 -0
  593. package/src/utils/traceAggregation.test.ts +385 -0
  594. package/src/utils/traceAggregation.ts +173 -0
  595. package/src/validation/OtelCanvasValidator.ts +86 -0
  596. package/src/validation/index.ts +17 -0
  597. package/src/validation/libraryValidation.ts +206 -0
  598. package/src/workflow/README.md +408 -0
  599. package/src/workflow/__tests__/edge-derivation.test.ts +449 -0
  600. package/src/workflow/__tests__/edge-validation.test.ts +417 -0
  601. package/src/workflow/__tests__/scenario-matcher.test.ts +225 -0
  602. package/src/workflow/__tests__/template-parser.test.ts +276 -0
  603. package/src/workflow/__tests__/template-renderer.test.ts +509 -0
  604. package/src/workflow/__tests__/types.test.ts +187 -0
  605. package/src/workflow/__tests__/validator.test.ts +3225 -0
  606. package/src/workflow/edge-derivation.ts +265 -0
  607. package/src/workflow/edge-validation.ts +503 -0
  608. package/src/workflow/example.ts +330 -0
  609. package/src/workflow/index.ts +86 -0
  610. package/src/workflow/scenario-matcher.ts +253 -0
  611. package/src/workflow/template-parser.ts +350 -0
  612. package/src/workflow/template-renderer.ts +453 -0
  613. package/src/workflow/types.ts +511 -0
  614. package/src/workflow/validator.ts +2737 -0
@@ -0,0 +1,1395 @@
1
+ /**
2
+ * JSON Canvas Extended Types
3
+ *
4
+ * This module defines types that extend the JSON Canvas spec (https://jsoncanvas.org/spec/1.0/)
5
+ * with Principal View Framework extensions.
6
+ *
7
+ * Design principle: Extensions use top-level fields where possible (name, markdown, edgeType)
8
+ * for simplicity. Node-level extensions use a `pv` field for complex metadata.
9
+ *
10
+ * DEPRECATION: Canvas-level `pv` field and edge-level `pv` field are deprecated.
11
+ * Use top-level `name`, `markdown` fields on canvas, and `edgeType` field on edges.
12
+ *
13
+ * This allows:
14
+ * 1. Authoring layouts visually in Obsidian or other canvas tools
15
+ * 2. Rendering with rich animations and states in React Flow
16
+ * 3. Round-trip editing without data loss
17
+ */
18
+
19
+ import type { CanvasScope, CanvasAuditConfig } from './canvas-scope';
20
+ import type { ResourceMatch } from './resource-match';
21
+ import type { JsonValue } from './index';
22
+
23
+ // ============================================================================
24
+ // JSON Canvas Spec Types (1.0)
25
+ // https://jsoncanvas.org/spec/1.0/
26
+ // ============================================================================
27
+
28
+ /**
29
+ * Canvas color - either a hex string or preset number (1-6)
30
+ * Presets: 1=red, 2=orange, 3=yellow, 4=green, 5=cyan, 6=purple
31
+ *
32
+ * Note: Obsidian Canvas saves numeric presets as strings ("1"-"6"),
33
+ * so we accept both number and string formats.
34
+ */
35
+ export type CanvasColor = string | 1 | 2 | 3 | 4 | 5 | 6;
36
+
37
+ /**
38
+ * Side of a node for edge connections
39
+ */
40
+ export type CanvasSide = 'top' | 'right' | 'bottom' | 'left';
41
+
42
+ /**
43
+ * Edge endpoint shape
44
+ */
45
+ export type CanvasEndpoint = 'none' | 'arrow';
46
+
47
+ /**
48
+ * Background style for group nodes
49
+ */
50
+ export type CanvasBackgroundStyle = 'cover' | 'ratio' | 'repeat';
51
+
52
+ /**
53
+ * Base node properties (common to all node types)
54
+ */
55
+ export interface CanvasNodeBase {
56
+ /** Unique identifier */
57
+ id: string;
58
+ /** X position in pixels */
59
+ x: number;
60
+ /** Y position in pixels */
61
+ y: number;
62
+ /** Width in pixels */
63
+ width: number;
64
+ /** Height in pixels */
65
+ height: number;
66
+ /** Optional color */
67
+ color?: CanvasColor;
68
+ }
69
+
70
+ /**
71
+ * Text node - stores plain text or markdown
72
+ */
73
+ export interface CanvasTextNode extends CanvasNodeBase {
74
+ type: 'text';
75
+ /** Markdown-formatted text content */
76
+ text: string;
77
+ }
78
+
79
+ /**
80
+ * File node - references an external file
81
+ */
82
+ export interface CanvasFileNode extends CanvasNodeBase {
83
+ type: 'file';
84
+ /** Path to the file */
85
+ file: string;
86
+ /** Optional subpath (heading or block link) */
87
+ subpath?: string;
88
+ }
89
+
90
+ /**
91
+ * Link node - references a URL
92
+ */
93
+ export interface CanvasLinkNode extends CanvasNodeBase {
94
+ type: 'link';
95
+ /** URL to link to */
96
+ url: string;
97
+ }
98
+
99
+ /**
100
+ * Group node - visual container for other nodes
101
+ */
102
+ export interface CanvasGroupNode extends CanvasNodeBase {
103
+ type: 'group';
104
+ /** Optional label for the group */
105
+ label?: string;
106
+ /** Optional background image path */
107
+ background?: string;
108
+ /** Background image style */
109
+ backgroundStyle?: CanvasBackgroundStyle;
110
+ }
111
+
112
+ /**
113
+ * Union of all standard canvas node types
114
+ */
115
+ export type CanvasNode = CanvasTextNode | CanvasFileNode | CanvasLinkNode | CanvasGroupNode;
116
+
117
+ /**
118
+ * Canvas edge connecting two nodes
119
+ */
120
+ export interface CanvasEdge {
121
+ /** Unique identifier */
122
+ id: string;
123
+ /** Source node ID */
124
+ fromNode: string;
125
+ /** Target node ID */
126
+ toNode: string;
127
+ /** Side of source node */
128
+ fromSide?: CanvasSide;
129
+ /** Side of target node */
130
+ toSide?: CanvasSide;
131
+ /** Endpoint shape at source (default: 'none') */
132
+ fromEnd?: CanvasEndpoint;
133
+ /** Endpoint shape at target (default: 'arrow') */
134
+ toEnd?: CanvasEndpoint;
135
+ /** Edge color */
136
+ color?: CanvasColor;
137
+ /** Edge label */
138
+ label?: string;
139
+ }
140
+
141
+ /**
142
+ * Standard JSON Canvas document
143
+ */
144
+ export interface Canvas {
145
+ /** Array of nodes (ordered by z-index ascending) */
146
+ nodes?: CanvasNode[];
147
+ /** Array of edges */
148
+ edges?: CanvasEdge[];
149
+ }
150
+
151
+ // ============================================================================
152
+ // Principal View Extensions
153
+ // ============================================================================
154
+
155
+ /**
156
+ * Animation types for edges
157
+ */
158
+ export type PVAnimationType = 'flow' | 'pulse' | 'particle' | 'glow';
159
+
160
+ /**
161
+ * Animation direction
162
+ */
163
+ export type PVAnimationDirection = 'forward' | 'backward' | 'bidirectional';
164
+
165
+ /**
166
+ * Node shape for rendering
167
+ */
168
+ export type PVNodeShape = 'circle' | 'rectangle' | 'hexagon' | 'diamond' | 'custom';
169
+
170
+ /**
171
+ * Edge line style
172
+ */
173
+ export type PVEdgeStyle = 'solid' | 'dashed' | 'dotted' | 'animated';
174
+
175
+ /**
176
+ * Log level for path-based association
177
+ */
178
+ export type PVLogLevel = 'debug' | 'info' | 'warn' | 'error';
179
+
180
+ // PVActionPattern removed - see docs/LEGACY_PATH_BASED_PATTERNS.md
181
+ // Superseded by OTEL event schemas (pv.events)
182
+
183
+ /**
184
+ * State definition for a node
185
+ */
186
+ export interface PVNodeState {
187
+ /** Color when in this state */
188
+ color?: string;
189
+ /** Icon when in this state */
190
+ icon?: string;
191
+ /** Display label */
192
+ label?: string;
193
+ }
194
+
195
+ // PVEdgeActivation removed - see docs/LEGACY_PATH_BASED_PATTERNS.md
196
+ // Edge animations now triggered by OTEL events, not action patterns
197
+
198
+ /**
199
+ * OTEL node classification
200
+ *
201
+ * @deprecated Use `pv.nodeType` instead. Will be removed in a future version.
202
+ * For example, use `nodeType: "scope"` instead of `otel.kind: "type"`.
203
+ */
204
+ export type PVOtelKind = 'type' | 'service' | 'instance';
205
+
206
+ /**
207
+ * OTEL category for type nodes
208
+ *
209
+ * @deprecated Use `pv.nodeType` instead. Will be removed in a future version.
210
+ * For example, use `nodeType: "span-convention"` instead of `otel.category: "span"`.
211
+ */
212
+ export type PVOtelCategory =
213
+ | 'log'
214
+ | 'resource'
215
+ | 'span'
216
+ | 'scope'
217
+ | 'match'
218
+ | 'audit'
219
+ | 'config'
220
+ | 'router'
221
+ | 'collector';
222
+
223
+ /**
224
+ * OTel SpanKind values for span conventions
225
+ *
226
+ * Describes the relationship between a span and its remote parent/children.
227
+ * Standard OTel concept - these values are fixed by the OTel spec.
228
+ *
229
+ * @see https://opentelemetry.io/docs/specs/otel/trace/api/#spankind
230
+ */
231
+ export type PVOtelSpanKind = 'UNSPECIFIED' | 'INTERNAL' | 'SERVER' | 'CLIENT' | 'PRODUCER' | 'CONSUMER';
232
+
233
+ import type { OtelSpanKind } from './otel';
234
+
235
+ /**
236
+ * OTEL span matching criteria
237
+ *
238
+ * Defines rules for matching incoming OTEL spans to this canvas node.
239
+ * Multiple criteria are combined with AND logic (all must match).
240
+ */
241
+ export interface PVOtelSpanMatch {
242
+ /**
243
+ * Match span name
244
+ *
245
+ * Supports:
246
+ * - Exact string: "validateUser"
247
+ * - Array of options: ["GET /api/users", "POST /api/users"]
248
+ * - Glob patterns: "GET /api/*", "*.checkout"
249
+ *
250
+ * @example "validateUser"
251
+ * @example ["GET /api/users", "POST /api/users"]
252
+ * @example "*.checkout"
253
+ */
254
+ name?: string | string[];
255
+
256
+ /**
257
+ * Match span kind
258
+ *
259
+ * @example "SPAN_KIND_SERVER"
260
+ * @example "SPAN_KIND_CLIENT"
261
+ */
262
+ kind?: OtelSpanKind | OtelSpanKind[];
263
+
264
+ /**
265
+ * Match span attributes
266
+ *
267
+ * All specified attributes must match (AND logic).
268
+ * Supports exact values and wildcards.
269
+ *
270
+ * @example
271
+ * {
272
+ * "http.route": "/api/checkout",
273
+ * "http.method": "POST"
274
+ * }
275
+ *
276
+ * @example
277
+ * {
278
+ * "db.system": "postgresql",
279
+ * "db.operation": "*" // Any operation
280
+ * }
281
+ */
282
+ attributes?: Record<string, string | string[]>;
283
+
284
+ /**
285
+ * Match span events
286
+ *
287
+ * If specified, span must contain at least one event matching these criteria.
288
+ *
289
+ * @example
290
+ * {
291
+ * name: "exception",
292
+ * attributes: { "exception.type": "ValidationError" }
293
+ * }
294
+ */
295
+ event?: {
296
+ name?: string | string[];
297
+ attributes?: Record<string, string | string[]>;
298
+ };
299
+ }
300
+
301
+ /**
302
+ * OTEL resource matching criteria
303
+ *
304
+ * Matches against OTEL resource attributes (service.name, deployment.environment, etc.).
305
+ * Multiple attributes are combined with AND logic.
306
+ */
307
+ export interface PVOtelResourceMatch {
308
+ /**
309
+ * Resource attribute patterns to match
310
+ *
311
+ * Supports:
312
+ * - Exact match: { "service.name": "checkout-api" }
313
+ * - Wildcard: { "service.name": "*-api" }
314
+ * - Array of options: { "service.name": ["api-1", "api-2"] }
315
+ *
316
+ * @example
317
+ * {
318
+ * "service.name": "checkout-service",
319
+ * "deployment.environment": "production"
320
+ * }
321
+ */
322
+ [attributeKey: string]: string | string[];
323
+ }
324
+
325
+ /**
326
+ * OTEL-specific node extension
327
+ *
328
+ * Used to mark nodes as representing OTEL concepts in architectural diagrams
329
+ * and to define runtime span matching criteria.
330
+ */
331
+ export interface PVOtelExtension {
332
+ /**
333
+ * Kind of OTEL node
334
+ * - `type`: Represents a TypeScript type/interface (e.g., OtelLog, ResourceMatch)
335
+ * - `service`: Represents a runtime service (e.g., LogRouter, AuditCollector)
336
+ * - `instance`: Represents an actual runtime instance (e.g., a specific pod)
337
+ *
338
+ * @deprecated Use `pv.nodeType` instead. Will be removed in a future version.
339
+ */
340
+ kind?: PVOtelKind;
341
+
342
+ /**
343
+ * Category within OTEL domain
344
+ *
345
+ * @deprecated Use `pv.nodeType` instead. Will be removed in a future version.
346
+ */
347
+ category?: PVOtelCategory;
348
+
349
+ /**
350
+ * Span pattern for span convention nodes
351
+ *
352
+ * Defines the naming pattern for spans that match this convention.
353
+ * Supports wildcards (e.g., "validate.*", "task.create").
354
+ *
355
+ * Used in architecture.spans.canvas to define the vocabulary of operations.
356
+ *
357
+ * @example "validate.*"
358
+ * @example "task.create"
359
+ * @example "http.request"
360
+ */
361
+ spanPattern?: string;
362
+
363
+ /**
364
+ * OTel SpanKind for span convention nodes
365
+ *
366
+ * Specifies what kind of span this convention represents.
367
+ * Implementers should use this when creating spans.
368
+ *
369
+ * @example "SERVER" - for entry points handling incoming requests
370
+ * @example "INTERNAL" - for internal operations
371
+ * @example "CLIENT" - for outgoing calls to external services
372
+ */
373
+ spanKind?: PVOtelSpanKind;
374
+
375
+ /**
376
+ * Resource matching criteria
377
+ *
378
+ * When specified, this node will highlight when spans are received
379
+ * from resources with matching attributes.
380
+ */
381
+ resourceMatch?: PVOtelResourceMatch;
382
+
383
+ /**
384
+ * Span matching criteria
385
+ *
386
+ * When specified, this node will highlight when spans matching
387
+ * these criteria are received.
388
+ */
389
+ spanMatch?: PVOtelSpanMatch;
390
+
391
+ /**
392
+ * Files where this event is instrumented
393
+ *
394
+ * Specifies the exact file paths where this OTEL event should be emitted.
395
+ * Used by coverage tools to validate that events are properly instrumented.
396
+ *
397
+ * @example ["src/app/api/auth/callback/route.ts"]
398
+ */
399
+ files?: string[];
400
+
401
+ /**
402
+ * Instrumentation scope that emits this event
403
+ *
404
+ * Identifies which tracer/instrumentation library creates this span or event.
405
+ * Maps to `getTracer('scope-name')` in the instrumented code.
406
+ *
407
+ * Required when the parent node's status is 'approved' or 'implemented'.
408
+ * Should match an entry in the library.yaml `owned-scopes` list.
409
+ *
410
+ * @example "terminal-activity"
411
+ * @example "auth"
412
+ * @example "quality-panel"
413
+ */
414
+ scope?: string;
415
+
416
+ /** Allow additional properties */
417
+ [key: string]: JsonValue | PVOtelResourceMatch | PVOtelSpanMatch | string[] | undefined;
418
+ }
419
+
420
+ /**
421
+ * Event field schema definition
422
+ */
423
+ export interface PVEventFieldSchema {
424
+ /** Field data type */
425
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
426
+ /** Whether this field is required */
427
+ required?: boolean;
428
+ /** Description of what this field represents */
429
+ description?: string;
430
+ /**
431
+ * Whether this attribute is intended for template display.
432
+ * Set to false for telemetry/analytics-only attributes.
433
+ * Defaults to true.
434
+ */
435
+ display?: boolean;
436
+ }
437
+
438
+ /**
439
+ * Event schema definition for a specific event type
440
+ */
441
+ export interface PVEventSchema {
442
+ /** Event name (e.g., 'conversion.started', 'user.login') */
443
+ name: string;
444
+ /** Description of what this event represents */
445
+ description: string;
446
+ /** Expected attributes/fields for this event */
447
+ attributes: Record<string, PVEventFieldSchema>;
448
+ }
449
+
450
+ /**
451
+ * Node implementation status
452
+ *
453
+ * Tracks the lifecycle of a node from design to implementation.
454
+ */
455
+ export type PVNodeStatus = 'draft' | 'approved' | 'implemented';
456
+
457
+ /**
458
+ * Direction of boundary interaction
459
+ */
460
+ export type PVBoundaryDirection = 'outbound' | 'inbound';
461
+
462
+ /**
463
+ * Node query criteria for boundary resolution
464
+ *
465
+ * Defines what the corresponding node looks like in the external system's traces.
466
+ * Used for cross-repo resolution and live trace correlation.
467
+ */
468
+ export interface PVBoundaryNodeQuery {
469
+ /** Event name to match in external system */
470
+ 'pv.event.name'?: string;
471
+ /** Event namespace to match */
472
+ 'pv.event.namespace'?: string;
473
+ /** Additional attribute matches */
474
+ [key: string]: string | undefined;
475
+ }
476
+
477
+ /**
478
+ * Boundary extension for nodes representing external system interfaces
479
+ *
480
+ * Boundaries define interaction points where control crosses system edges.
481
+ * The `node` field specifies what the corresponding node looks like in the
482
+ * external system, enabling cross-repo resolution and trace correlation.
483
+ *
484
+ * @example Outbound host callback
485
+ * ```typescript
486
+ * boundary: {
487
+ * direction: 'outbound',
488
+ * node: {
489
+ * 'pv.event.name': 'host.batch-layout-initialized',
490
+ * 'pv.event.namespace': 'collection-host'
491
+ * }
492
+ * }
493
+ * ```
494
+ *
495
+ * @example Inbound webhook
496
+ * ```typescript
497
+ * boundary: {
498
+ * direction: 'inbound',
499
+ * node: {
500
+ * 'pv.event.name': 'webhook.repository-created',
501
+ * 'pv.event.namespace': 'github'
502
+ * }
503
+ * }
504
+ * ```
505
+ */
506
+ export interface PVBoundaryExtension {
507
+ /**
508
+ * Direction of the boundary interaction
509
+ *
510
+ * - `outbound`: This system calls out to external system
511
+ * - `inbound`: External system calls into this system
512
+ */
513
+ direction: PVBoundaryDirection;
514
+
515
+ /**
516
+ * Node query for resolving the corresponding node in external system
517
+ *
518
+ * Specifies the expected shape of the matching node for registry lookup
519
+ * and live trace correlation.
520
+ */
521
+ node: PVBoundaryNodeQuery;
522
+ }
523
+
524
+ /**
525
+ * Principal View node extensions
526
+ */
527
+ export interface PVNodeExtension {
528
+ /** Custom node type identifier */
529
+ nodeType: string;
530
+
531
+ /**
532
+ * Display name for this node
533
+ *
534
+ * Preferred over parsing the `text` field. Use this for the node label.
535
+ */
536
+ name?: string;
537
+
538
+ /**
539
+ * Description of what this node represents
540
+ *
541
+ * Shown in tooltips or detail panels.
542
+ */
543
+ description?: string;
544
+
545
+ /**
546
+ * Implementation status of this node
547
+ *
548
+ * - `draft`: Design/proposal phase (requires pv.otel.files if known, otherwise pv.references)
549
+ * - `approved`: Design finalized, ready for implementation (requires pv.otel.files)
550
+ * - `implemented`: Code exists with instrumentation (requires pv.otel.files and events in code)
551
+ *
552
+ * Used by coverage tools to determine validation requirements and coverage tracking.
553
+ */
554
+ status?: PVNodeStatus;
555
+
556
+ /**
557
+ * OTEL-specific metadata
558
+ *
559
+ * Used when this node represents an OTEL concept (type, service, or instance).
560
+ */
561
+ otel?: PVOtelExtension;
562
+
563
+ /** Visual shape */
564
+ shape?: PVNodeShape;
565
+ /** Icon identifier (Lucide icons) */
566
+ icon?: string;
567
+ /** Fill color (hex string) - takes priority over node.color */
568
+ fill?: string;
569
+ /** Stroke/border color (hex string) */
570
+ stroke?: string;
571
+ /** State definitions */
572
+ states?: Record<string, PVNodeState>;
573
+
574
+ /**
575
+ * Origin of the code this node represents
576
+ *
577
+ * - `internal` (default): Code exists in this repository, file paths in `pv.otel.files` will be validated
578
+ * - `external`: Code exists in external packages/libraries, file existence validation is skipped
579
+ *
580
+ * Use `external` for:
581
+ * - npm dependencies (e.g., `@logfire/pydantic-ai`)
582
+ * - Auto-instrumented events from observability libraries
583
+ * - Third-party APIs or services
584
+ * - Cross-repository references
585
+ *
586
+ * When `origin: "external"`, the `references` field is required to document
587
+ * what external package or service this node represents.
588
+ *
589
+ * @example "external"
590
+ */
591
+ origin?: 'internal' | 'external';
592
+
593
+ /**
594
+ * Auxiliary references and related documentation
595
+ *
596
+ * Use for documenting related packages, external dependencies, or supplementary notes.
597
+ * Required when `origin: "external"` to document what external package/service this represents.
598
+ *
599
+ * @example ["@logfire/pydantic-ai"] // external package reference
600
+ * @example ["https://docs.pydantic.dev/logfire/"] // documentation link
601
+ */
602
+ references?: string[];
603
+
604
+ /**
605
+ * @deprecated Use `references` instead. Will be removed in a future version.
606
+ */
607
+ sources?: string[];
608
+
609
+ /**
610
+ * Resource-based matching for OTEL logs
611
+ *
612
+ * When specified, logs with matching OTEL resource attributes
613
+ * will be routed to this node. Takes priority over sources.
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * resourceMatch: {
618
+ * 'service.name': 'checkout-api',
619
+ * 'deployment.environment': 'production'
620
+ * }
621
+ * ```
622
+ */
623
+ resourceMatch?: ResourceMatch;
624
+
625
+ // actions removed - see docs/LEGACY_PATH_BASED_PATTERNS.md
626
+ // Use pv.event for structured event schema instead
627
+
628
+ /**
629
+ * Event schema for type-safe telemetry validation (inline definition)
630
+ *
631
+ * Defines the single event that this node emits during execution.
632
+ * Used for compile-time and runtime validation of telemetry events.
633
+ * Each node should emit exactly one event type.
634
+ *
635
+ * Use this for one-off events specific to this node.
636
+ * For reusable events, use `eventRef` to reference library event schemas.
637
+ *
638
+ * @example
639
+ * ```typescript
640
+ * event: {
641
+ * name: 'conversion.started',
642
+ * description: 'Graph conversion begins',
643
+ * attributes: {
644
+ * 'config.nodeTypes': { type: 'number', required: true },
645
+ * 'config.edgeTypes': { type: 'number', required: true }
646
+ * }
647
+ * }
648
+ * ```
649
+ */
650
+ event?: PVEventSchema;
651
+
652
+ /**
653
+ * Reference to a library event schema
654
+ *
655
+ * References an event schema defined in library.yaml's `eventSchemas` section.
656
+ * This promotes reusability and consistency across canvases.
657
+ *
658
+ * NOTE: A node cannot have both `event` and `eventRef` - choose one.
659
+ * Validators will flag nodes that have both as an error.
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * eventRef: 'auth.callback.started'
664
+ * ```
665
+ */
666
+ eventRef?: string;
667
+
668
+ /** Data schema for typed fields */
669
+ dataSchema?: Record<
670
+ string,
671
+ {
672
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
673
+ required?: boolean;
674
+ displayInLabel?: boolean;
675
+ /**
676
+ * Human-readable description of what this field represents.
677
+ * Required in .otel.canvas files (enforced by validator).
678
+ */
679
+ description?: string;
680
+ /**
681
+ * Example value for UI previews, mock traces, and testing.
682
+ * Required in .otel.canvas files (enforced by validator).
683
+ */
684
+ placeholder?: unknown;
685
+ }
686
+ >;
687
+ /** Layout hints */
688
+ layout?: {
689
+ layer?: number;
690
+ cluster?: string;
691
+ };
692
+
693
+ /**
694
+ * Boundary extension for nodes representing external system interfaces
695
+ *
696
+ * When `nodeType` is `"boundary"`, this field defines the boundary details.
697
+ * Boundary nodes represent interface points where control crosses system edges.
698
+ * The `node` field specifies what the corresponding node looks like in the
699
+ * external system, enabling cross-repo resolution and trace correlation.
700
+ *
701
+ * When a node has `nodeType: "boundary"`, it does NOT require `event` or `eventRef`
702
+ * fields since the boundary is external and doesn't emit telemetry from our code.
703
+ *
704
+ * @example
705
+ * ```typescript
706
+ * {
707
+ * nodeType: "boundary",
708
+ * boundary: {
709
+ * direction: "outbound",
710
+ * node: {
711
+ * "pv.event.name": "host.batch-layout-initialized",
712
+ * "pv.event.namespace": "collection-host"
713
+ * }
714
+ * }
715
+ * }
716
+ * ```
717
+ */
718
+ boundary?: PVBoundaryExtension;
719
+ }
720
+
721
+ /**
722
+ * Principal View edge extensions
723
+ */
724
+ export interface PVEdgeExtension {
725
+ /** Custom edge type identifier */
726
+ edgeType: string;
727
+ /** Line style */
728
+ style?: PVEdgeStyle;
729
+ /** Line width in pixels */
730
+ width?: number;
731
+ /** Default animation */
732
+ animation?: {
733
+ type: PVAnimationType;
734
+ duration?: number;
735
+ color?: string;
736
+ };
737
+ // activatedBy removed - see docs/LEGACY_PATH_BASED_PATTERNS.md
738
+ }
739
+
740
+ /**
741
+ * Path-based configuration options
742
+ */
743
+ export interface PVPathConfig {
744
+ /** Project root for path normalization */
745
+ projectRoot?: string;
746
+ /** Enable source capture from stack traces */
747
+ captureSource?: boolean;
748
+ /** Enable action pattern matching */
749
+ enableActionPatterns?: boolean;
750
+ /** Minimum log level to process */
751
+ logLevel?: PVLogLevel;
752
+ /** Ignore logs without source info */
753
+ ignoreUnsourced?: boolean;
754
+ }
755
+
756
+ /**
757
+ * Display configuration
758
+ */
759
+ export interface PVDisplayConfig {
760
+ /** Layout algorithm (manual uses canvas positions) */
761
+ layout?: 'hierarchical' | 'force-directed' | 'circular' | 'manual';
762
+ /** Color theme */
763
+ theme?: {
764
+ primary?: string;
765
+ success?: string;
766
+ warning?: string;
767
+ danger?: string;
768
+ info?: string;
769
+ };
770
+ /** Animation settings */
771
+ animations?: {
772
+ enabled?: boolean;
773
+ speed?: number;
774
+ };
775
+ }
776
+
777
+ /**
778
+ * Node type definition (stored at canvas level in pv.nodeTypes)
779
+ */
780
+ export interface PVNodeTypeDefinition {
781
+ /** Display label */
782
+ label?: string;
783
+ /** Description of this node type (required) */
784
+ description: string;
785
+ /** Fill color (hex string) */
786
+ color?: string;
787
+ /** Icon identifier (Lucide icons) */
788
+ icon?: string;
789
+ /** Visual shape */
790
+ shape?: PVNodeShape;
791
+ }
792
+
793
+ /**
794
+ * Edge type definition (stored at canvas level)
795
+ */
796
+ export interface PVEdgeTypeDefinition {
797
+ /** Display label */
798
+ label?: string;
799
+ /** Line style */
800
+ style?: PVEdgeStyle;
801
+ /** Line color */
802
+ color?: string;
803
+ /** Line width */
804
+ width?: number;
805
+ /** Whether edge is directed */
806
+ directed?: boolean;
807
+ /** Default animation */
808
+ animation?: {
809
+ type: PVAnimationType;
810
+ duration?: number;
811
+ color?: string;
812
+ };
813
+ /** Label configuration (for dynamic labels) */
814
+ labelConfig?: {
815
+ field?: string;
816
+ position?: 'start' | 'middle' | 'end';
817
+ };
818
+ // activatedBy removed - see docs/LEGACY_PATH_BASED_PATTERNS.md
819
+ }
820
+
821
+ /**
822
+ * Canvas-level Principal View extensions
823
+ *
824
+ * @deprecated The `pv` field is fully deprecated. All fields have been moved to top-level.
825
+ * This interface will be removed in a future version.
826
+ *
827
+ * Migration - move all fields to top-level:
828
+ * - `pv.name` → `name`
829
+ * - `pv.markdown` → `markdown`
830
+ * - `pv.description` → `description`
831
+ * - `pv.nodeTypes` → `nodeTypes`
832
+ * - `pv.edgeTypes` → `edgeTypes`
833
+ * - `pv.display` → `display`
834
+ * - `pv.pathConfig` → `pathConfig`
835
+ * - `pv.scope` → `scope`
836
+ * - `pv.audit` → `audit`
837
+ * - `pv.version` → removed (not used)
838
+ */
839
+ export interface PVCanvasExtension {
840
+ /** @deprecated Use top-level `name` field instead */
841
+ name?: string;
842
+ /** @deprecated Use top-level `description` field instead */
843
+ description?: string;
844
+ /** @deprecated Use top-level `markdown` field instead */
845
+ markdown?: string;
846
+ /** @deprecated Use top-level `nodeTypes` field instead */
847
+ nodeTypes?: Record<string, PVNodeTypeDefinition>;
848
+ /** @deprecated Use top-level `edgeTypes` field instead */
849
+ edgeTypes?: Record<string, PVEdgeTypeDefinition>;
850
+ /** @deprecated Use top-level `pathConfig` field instead */
851
+ pathConfig?: PVPathConfig;
852
+ /** @deprecated Use top-level `display` field instead */
853
+ display?: PVDisplayConfig;
854
+ /** @deprecated Use top-level `scope` field instead */
855
+ scope?: CanvasScope;
856
+ /** @deprecated Use top-level `audit` field instead */
857
+ audit?: CanvasAuditConfig;
858
+ }
859
+
860
+ // ============================================================================
861
+ // Extended Canvas Types (Canvas + PV Extensions)
862
+ // ============================================================================
863
+
864
+ /**
865
+ * Extended text node with PV extensions
866
+ */
867
+ export interface ExtendedCanvasTextNode extends CanvasTextNode {
868
+ pv?: PVNodeExtension;
869
+ }
870
+
871
+ /**
872
+ * Extended file node with PV extensions
873
+ */
874
+ export interface ExtendedCanvasFileNode extends CanvasFileNode {
875
+ pv?: PVNodeExtension;
876
+ }
877
+
878
+ /**
879
+ * Extended link node with PV extensions
880
+ */
881
+ export interface ExtendedCanvasLinkNode extends CanvasLinkNode {
882
+ pv?: PVNodeExtension;
883
+ }
884
+
885
+ /**
886
+ * Extended group node with PV extensions
887
+ */
888
+ export interface ExtendedCanvasGroupNode extends CanvasGroupNode {
889
+ pv?: PVNodeExtension;
890
+ }
891
+
892
+ // ============================================================================
893
+ // OTEL Node Types (Custom extensions to JSON Canvas)
894
+ // See: docs/NODE_TYPE_MIGRATION.md
895
+ // ============================================================================
896
+
897
+ /**
898
+ * Base interface for all OTEL node types
899
+ *
900
+ * These are custom node types that extend JSON Canvas for OpenTelemetry concepts.
901
+ * Standard canvas tools will not recognize these types.
902
+ */
903
+ export interface OtelNodeBase extends CanvasNodeBase {
904
+ /** Display label shown on canvas node (required) */
905
+ label: string;
906
+ /** Icon identifier (Lucide icons) */
907
+ icon?: string;
908
+ /** Fill color (hex string) */
909
+ fill?: string;
910
+ /** Stroke/border color (hex string) */
911
+ stroke?: string;
912
+ /** Visual shape */
913
+ shape?: PVNodeShape;
914
+ }
915
+
916
+ /**
917
+ * Shared OTEL instrumentation metadata
918
+ *
919
+ * Common fields for tracking implementation status and code location.
920
+ */
921
+ export interface OtelMetadata {
922
+ /** Implementation status */
923
+ status?: PVNodeStatus;
924
+ /** Instrumentation scope (maps to getTracer('scope-name')) */
925
+ scope?: string;
926
+ /** Files where this is instrumented */
927
+ files?: string[];
928
+ /**
929
+ * Origin of the code
930
+ * - 'internal': Code exists in this repository (default)
931
+ * - 'external': Code exists in external packages/libraries
932
+ */
933
+ origin?: 'internal' | 'external';
934
+ /** References/documentation for external code */
935
+ references?: string[];
936
+ }
937
+
938
+ /**
939
+ * OTEL Event Node
940
+ *
941
+ * Represents a telemetry event emitted during workflow execution.
942
+ * The event schema defines the structure of the telemetry data.
943
+ */
944
+ /**
945
+ * OTEL Event Node - represents a telemetry event
946
+ *
947
+ * @remarks
948
+ * IMPORTANT: Event nodes should NOT use fill or color fields.
949
+ * Event nodes use scope-based coloring exclusively for consistency.
950
+ * Set the scope in otel.scope and define scope colors in library.yaml.
951
+ * Using fill or color fields will cause validation errors.
952
+ */
953
+ export interface OtelEventNode extends OtelNodeBase {
954
+ type: 'otel-event';
955
+ /** Inline event schema definition */
956
+ event?: PVEventSchema;
957
+ /** Reference to a library event schema */
958
+ eventRef?: string;
959
+ /** Data schema for typed fields in templates */
960
+ dataSchema?: Record<
961
+ string,
962
+ {
963
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
964
+ required?: boolean;
965
+ description?: string;
966
+ placeholder?: unknown;
967
+ }
968
+ >;
969
+ /** OTEL instrumentation metadata */
970
+ otel?: OtelMetadata;
971
+ }
972
+
973
+ /**
974
+ * Workflow chip displayed on span convention nodes
975
+ * Shows which workflow.json scenarios reference this span
976
+ */
977
+ export interface WorkflowChip {
978
+ /** Workflow scenario ID for selection/filtering */
979
+ id: string;
980
+ /** Display label (may be truncated) */
981
+ label: string;
982
+ /** Optional color for the chip */
983
+ color?: string;
984
+ }
985
+
986
+ /**
987
+ * OTEL Span Convention Node
988
+ *
989
+ * Defines a span naming convention/pattern for consistent instrumentation.
990
+ */
991
+ export interface OtelSpanConventionNode extends OtelNodeBase {
992
+ type: 'otel-span-convention';
993
+ /** Short description of this span convention */
994
+ description?: string;
995
+ /** OTEL metadata including span-specific fields */
996
+ otel: OtelMetadata & {
997
+ /** Span naming pattern (e.g., "validate.*", "http.request") */
998
+ spanPattern: string;
999
+ /** OTel SpanKind */
1000
+ spanKind?: PVOtelSpanKind;
1001
+ /** Span matching criteria for runtime correlation */
1002
+ spanMatch?: PVOtelSpanMatch;
1003
+ };
1004
+ /** Workflow chips showing which workflow.json scenarios use this span */
1005
+ workflowChips?: WorkflowChip[];
1006
+ }
1007
+
1008
+ /**
1009
+ * OTEL Scope Node
1010
+ *
1011
+ * Represents an instrumentation scope (tracer instance).
1012
+ */
1013
+ export interface OtelScopeNode extends OtelNodeBase {
1014
+ type: 'otel-scope';
1015
+ /** Short description of this instrumentation scope */
1016
+ description?: string;
1017
+ /**
1018
+ * Optional source paths that define this scope's code region.
1019
+ * Each entry may be a folder (covers all descendants) or a specific file.
1020
+ * When present, events under this scope may only originate from files
1021
+ * covered by one of these paths, and every `event-namespace` declared in
1022
+ * this scope's events canvas must have its own `paths` nested inside this
1023
+ * region. Scopes without `paths` remain unenforced — enforcement is opt-in
1024
+ * per scope.
1025
+ *
1026
+ * Semantics are "ownership / partition", distinct from `otel.files` on
1027
+ * `otel-event` nodes (which lists specific emission sites). Across scopes,
1028
+ * paths must be disjoint except for strict parent-child nesting by
1029
+ * dotted-scope name (longest-prefix wins).
1030
+ */
1031
+ paths?: string[];
1032
+ /** OTEL metadata - scope name is required */
1033
+ otel: OtelMetadata & {
1034
+ /** Scope name (required - maps to getTracer('scope-name')) */
1035
+ scope: string;
1036
+ };
1037
+ }
1038
+
1039
+ /**
1040
+ * OTEL Resource Node
1041
+ *
1042
+ * Represents a service or deployment resource identified by OTEL resource attributes.
1043
+ */
1044
+ export interface OtelResourceNode extends OtelNodeBase {
1045
+ type: 'otel-resource';
1046
+ /** Short description of this resource */
1047
+ description?: string;
1048
+ /** OTEL metadata including resource matching criteria */
1049
+ otel: OtelMetadata & {
1050
+ /** Resource attribute matching criteria */
1051
+ resourceMatch: PVOtelResourceMatch;
1052
+ };
1053
+ }
1054
+
1055
+ /**
1056
+ * OTEL Boundary Node
1057
+ *
1058
+ * Represents an interface point with an external system.
1059
+ */
1060
+ export interface OtelBoundaryNode extends OtelNodeBase {
1061
+ type: 'otel-boundary';
1062
+ /** Short description of this boundary */
1063
+ description?: string;
1064
+ /** OTEL instrumentation metadata */
1065
+ otel?: OtelMetadata;
1066
+ /** Boundary configuration (required) */
1067
+ boundary: PVBoundaryExtension;
1068
+ }
1069
+
1070
+ /**
1071
+ * Union of all OTEL node types
1072
+ */
1073
+ export type OtelNode =
1074
+ | OtelEventNode
1075
+ | OtelSpanConventionNode
1076
+ | OtelScopeNode
1077
+ | OtelResourceNode
1078
+ | OtelBoundaryNode;
1079
+
1080
+ /**
1081
+ * Union of all extended node types (JSON Canvas + OTEL extensions)
1082
+ */
1083
+ export type ExtendedCanvasNode =
1084
+ | ExtendedCanvasTextNode
1085
+ | ExtendedCanvasFileNode
1086
+ | ExtendedCanvasLinkNode
1087
+ | ExtendedCanvasGroupNode
1088
+ | OtelEventNode
1089
+ | OtelSpanConventionNode
1090
+ | OtelScopeNode
1091
+ | OtelResourceNode
1092
+ | OtelBoundaryNode;
1093
+
1094
+ /**
1095
+ * Extended edge with PV extensions
1096
+ */
1097
+ export interface ExtendedCanvasEdge extends CanvasEdge {
1098
+ /**
1099
+ * Custom edge type identifier
1100
+ *
1101
+ * Used to categorize edges (e.g., "data-flow", "control-flow", "dependency").
1102
+ * Replaces the deprecated `pv.edgeType` field.
1103
+ *
1104
+ * @example "data-flow"
1105
+ * @example "control-flow"
1106
+ */
1107
+ edgeType?: string;
1108
+
1109
+ /**
1110
+ * @deprecated Use top-level `edgeType` field instead.
1111
+ * Validation will error if this field is present.
1112
+ *
1113
+ * Migration:
1114
+ * ```json
1115
+ * // Before (deprecated):
1116
+ * { "id": "e1", "fromNode": "a", "toNode": "b", "pv": { "edgeType": "data-flow" } }
1117
+ *
1118
+ * // After:
1119
+ * { "id": "e1", "fromNode": "a", "toNode": "b", "edgeType": "data-flow" }
1120
+ * ```
1121
+ */
1122
+ pv?: PVEdgeExtension;
1123
+ }
1124
+
1125
+ /**
1126
+ * Extended Canvas document with Principal View support
1127
+ *
1128
+ * This is the primary type for .canvas files used with the Principal View Framework.
1129
+ * It supports both standard JSON Canvas node types (text, file, link, group) and
1130
+ * custom OTEL node types (otel-event, otel-span-convention, etc.).
1131
+ *
1132
+ * Standard canvas tools will only recognize the JSON Canvas node types.
1133
+ */
1134
+ export interface ExtendedCanvas {
1135
+ /**
1136
+ * Canvas display name
1137
+ *
1138
+ * Human-readable name for this canvas, shown in UIs and listings.
1139
+ *
1140
+ * @example "Service Resources"
1141
+ * @example "Checkout Flow"
1142
+ */
1143
+ name?: string;
1144
+
1145
+ /**
1146
+ * Associated markdown documentation file
1147
+ *
1148
+ * Path to a markdown file that documents this canvas.
1149
+ * For .otel.canvas files, this field is required.
1150
+ * The path must be relative to the git repository root.
1151
+ *
1152
+ * Convention: If not specified, defaults to same basename as canvas file.
1153
+ * e.g., `resources.canvas` → `resources.md`
1154
+ *
1155
+ * @example ".principal-views/resources.md"
1156
+ * @example "docs/architecture/checkout-flow.md"
1157
+ */
1158
+ markdown?: string;
1159
+
1160
+ /** Canvas description */
1161
+ description?: string;
1162
+
1163
+ /** Node type definitions (shared across nodes) */
1164
+ nodeTypes?: Record<string, PVNodeTypeDefinition>;
1165
+
1166
+ /** Edge type definitions (shared across edges) */
1167
+ edgeTypes?: Record<string, PVEdgeTypeDefinition>;
1168
+
1169
+ /** Path-based configuration */
1170
+ pathConfig?: PVPathConfig;
1171
+
1172
+ /** Display configuration */
1173
+ display?: PVDisplayConfig;
1174
+
1175
+ /**
1176
+ * Canvas scope for log filtering
1177
+ *
1178
+ * Only logs matching this scope will be considered for node routing.
1179
+ * If not specified, all logs are in scope.
1180
+ *
1181
+ * @example
1182
+ * ```typescript
1183
+ * scope: {
1184
+ * 'deployment.environment': 'production',
1185
+ * 'service.namespace': 'checkout'
1186
+ * }
1187
+ * ```
1188
+ */
1189
+ scope?: CanvasScope;
1190
+
1191
+ /**
1192
+ * Audit configuration for log coverage tracking
1193
+ *
1194
+ * When enabled, tracks which logs are routed vs orphaned,
1195
+ * detects silent nodes, and generates coverage reports.
1196
+ */
1197
+ audit?: CanvasAuditConfig;
1198
+
1199
+ /** Nodes - JSON Canvas types and/or OTEL node types */
1200
+ nodes?: ExtendedCanvasNode[];
1201
+
1202
+ /** Edges with optional PV extensions */
1203
+ edges?: ExtendedCanvasEdge[];
1204
+
1205
+ /**
1206
+ * @deprecated The `pv` field is fully deprecated. All fields have been moved to top-level.
1207
+ * Validation will error if this field is present.
1208
+ *
1209
+ * Migration:
1210
+ * - `pv.name` → `name` (top-level)
1211
+ * - `pv.markdown` → `markdown` (top-level)
1212
+ * - `pv.description` → `description` (top-level)
1213
+ * - `pv.nodeTypes` → `nodeTypes` (top-level)
1214
+ * - `pv.edgeTypes` → `edgeTypes` (top-level)
1215
+ * - `pv.display` → `display` (top-level)
1216
+ * - `pv.pathConfig` → `pathConfig` (top-level)
1217
+ * - `pv.scope` → `scope` (top-level)
1218
+ * - `pv.audit` → `audit` (top-level)
1219
+ * - `pv.version` → removed (not used)
1220
+ */
1221
+ pv?: PVCanvasExtension;
1222
+ }
1223
+
1224
+ // ============================================================================
1225
+ // Utility Types
1226
+ // ============================================================================
1227
+
1228
+ /**
1229
+ * Type guard for text nodes
1230
+ */
1231
+ export function isTextNode(
1232
+ node: CanvasNode | ExtendedCanvasNode
1233
+ ): node is CanvasTextNode | ExtendedCanvasTextNode {
1234
+ return node.type === 'text';
1235
+ }
1236
+
1237
+ /**
1238
+ * Type guard for file nodes
1239
+ */
1240
+ export function isFileNode(
1241
+ node: CanvasNode | ExtendedCanvasNode
1242
+ ): node is CanvasFileNode | ExtendedCanvasFileNode {
1243
+ return node.type === 'file';
1244
+ }
1245
+
1246
+ /**
1247
+ * Type guard for link nodes
1248
+ */
1249
+ export function isLinkNode(
1250
+ node: CanvasNode | ExtendedCanvasNode
1251
+ ): node is CanvasLinkNode | ExtendedCanvasLinkNode {
1252
+ return node.type === 'link';
1253
+ }
1254
+
1255
+ /**
1256
+ * Type guard for group nodes
1257
+ */
1258
+ export function isGroupNode(
1259
+ node: CanvasNode | ExtendedCanvasNode
1260
+ ): node is CanvasGroupNode | ExtendedCanvasGroupNode {
1261
+ return node.type === 'group';
1262
+ }
1263
+
1264
+ /**
1265
+ * Type guard for extended nodes (with PV extension)
1266
+ */
1267
+ export function hasPVExtension(node: CanvasNode | ExtendedCanvasNode): node is ExtendedCanvasNode {
1268
+ return 'pv' in node && node.pv !== undefined;
1269
+ }
1270
+
1271
+ // ============================================================================
1272
+ // OTEL Node Type Guards
1273
+ // ============================================================================
1274
+
1275
+ /**
1276
+ * Type guard for OTEL event nodes
1277
+ */
1278
+ export function isOtelEventNode(node: ExtendedCanvasNode): node is OtelEventNode {
1279
+ return node.type === 'otel-event';
1280
+ }
1281
+
1282
+ /**
1283
+ * Type guard for OTEL span convention nodes
1284
+ */
1285
+ export function isOtelSpanConventionNode(node: ExtendedCanvasNode): node is OtelSpanConventionNode {
1286
+ return node.type === 'otel-span-convention';
1287
+ }
1288
+
1289
+ /**
1290
+ * Type guard for OTEL scope nodes
1291
+ */
1292
+ export function isOtelScopeNode(node: ExtendedCanvasNode): node is OtelScopeNode {
1293
+ return node.type === 'otel-scope';
1294
+ }
1295
+
1296
+ /**
1297
+ * Type guard for OTEL resource nodes
1298
+ */
1299
+ export function isOtelResourceNode(node: ExtendedCanvasNode): node is OtelResourceNode {
1300
+ return node.type === 'otel-resource';
1301
+ }
1302
+
1303
+ /**
1304
+ * Type guard for OTEL boundary nodes
1305
+ */
1306
+ export function isOtelBoundaryNode(node: ExtendedCanvasNode): node is OtelBoundaryNode {
1307
+ return node.type === 'otel-boundary';
1308
+ }
1309
+
1310
+ /**
1311
+ * Type guard for any OTEL node type
1312
+ */
1313
+ export function isOtelNode(node: ExtendedCanvasNode): node is OtelNode {
1314
+ return (
1315
+ node.type === 'otel-event' ||
1316
+ node.type === 'otel-span-convention' ||
1317
+ node.type === 'otel-scope' ||
1318
+ node.type === 'otel-resource' ||
1319
+ node.type === 'otel-boundary'
1320
+ );
1321
+ }
1322
+
1323
+ /**
1324
+ * Type guard for standard canvas nodes (that may have pv extensions)
1325
+ */
1326
+ export function isStandardCanvasNode(
1327
+ node: ExtendedCanvasNode
1328
+ ): node is ExtendedCanvasTextNode | ExtendedCanvasFileNode | ExtendedCanvasLinkNode | ExtendedCanvasGroupNode {
1329
+ return !isOtelNode(node);
1330
+ }
1331
+
1332
+ /**
1333
+ * Get the identifier for an OTEL node (shown below the label)
1334
+ */
1335
+ export function getOtelNodeIdentifier(node: OtelNode): string | undefined {
1336
+ switch (node.type) {
1337
+ case 'otel-event':
1338
+ return node.event?.name || node.eventRef;
1339
+ case 'otel-span-convention':
1340
+ return node.otel?.spanPattern;
1341
+ case 'otel-scope':
1342
+ return node.otel?.scope;
1343
+ case 'otel-resource': {
1344
+ if (!node.otel?.resourceMatch) return undefined;
1345
+ const entries = Object.entries(node.otel.resourceMatch);
1346
+ if (entries.length > 0) {
1347
+ const [key, value] = entries[0];
1348
+ return `${key}: ${Array.isArray(value) ? value[0] : value}`;
1349
+ }
1350
+ return undefined;
1351
+ }
1352
+ case 'otel-boundary':
1353
+ return node.boundary?.direction;
1354
+ default:
1355
+ return undefined;
1356
+ }
1357
+ }
1358
+
1359
+ /**
1360
+ * Color preset mapping
1361
+ */
1362
+ export const CANVAS_COLOR_PRESETS: Record<number, string> = {
1363
+ 1: '#ef4444', // red
1364
+ 2: '#f97316', // orange
1365
+ 3: '#eab308', // yellow
1366
+ 4: '#22c55e', // green
1367
+ 5: '#06b6d4', // cyan
1368
+ 6: '#8b5cf6', // purple
1369
+ };
1370
+
1371
+ /**
1372
+ * Resolve a canvas color to a hex string
1373
+ *
1374
+ * Supports:
1375
+ * - Hex strings: "#22c55e" or "#3f6"
1376
+ * - Numeric presets: 1-6
1377
+ * - Numeric string presets: "1"-"6" (Obsidian Canvas format)
1378
+ */
1379
+ export function resolveCanvasColor(color: CanvasColor | undefined): string | undefined {
1380
+ if (color === undefined) return undefined;
1381
+
1382
+ // Handle numeric presets
1383
+ if (typeof color === 'number') {
1384
+ return CANVAS_COLOR_PRESETS[color];
1385
+ }
1386
+
1387
+ // Handle numeric string presets (from Obsidian Canvas)
1388
+ const numericValue = parseInt(color, 10);
1389
+ if (!isNaN(numericValue) && numericValue >= 1 && numericValue <= 6) {
1390
+ return CANVAS_COLOR_PRESETS[numericValue];
1391
+ }
1392
+
1393
+ // Return hex strings as-is
1394
+ return color;
1395
+ }