@principal-ai/principal-view-core 0.28.12 → 0.28.13

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.
@@ -0,0 +1,762 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://principal-ai.dev/schemas/subsystem-graph.schema.json",
4
+ "title": "Subsystem Graph",
5
+ "description": "Portable subsystem component graph — the shareable standard. Construct-tagged components (nodes) plus typed edges describing one subsystem of a codebase. Ontology: construct = what a node is, framework + stereotype = which framework pattern it plays, role = where it sits, process = where it runs. Symbol is the code identity; name is the display label (often derived from symbol). Host-only fields (local path binding, provenance, store ids, verification) are NOT part of this document; they belong on a hydrated envelope around it.",
6
+ "type": "object",
7
+ "required": [
8
+ "title",
9
+ "components",
10
+ "edges"
11
+ ],
12
+ "additionalProperties": false,
13
+ "properties": {
14
+ "$schema": {
15
+ "type": "string",
16
+ "description": "Pointer to this schema for editor autocomplete and validation."
17
+ },
18
+ "title": {
19
+ "type": "string",
20
+ "minLength": 1,
21
+ "description": "Human-readable graph title."
22
+ },
23
+ "description": {
24
+ "type": "string",
25
+ "description": "Optional one-liner about the subsystem."
26
+ },
27
+ "components": {
28
+ "type": "array",
29
+ "description": "Graph nodes — named units anchored to a real exported symbol (or external targets). Prefer 4–15 components per graph; split sprawling subsystems. Each component's `purl` identifies its repo/package; there is no document-level repo field.",
30
+ "items": {
31
+ "$ref": "#/$defs/component"
32
+ }
33
+ },
34
+ "edges": {
35
+ "type": "array",
36
+ "description": "Typed interactions between components. `from` / `to` reference component `id`s.",
37
+ "items": {
38
+ "$ref": "#/$defs/edge"
39
+ }
40
+ },
41
+ "throughlines": {
42
+ "type": "array",
43
+ "description": "Ordered execution stories over existing edges (one throughline per flow). Each step names an edge id, the concrete file:line where that seam fires, and an optional frame symbol.",
44
+ "items": {
45
+ "$ref": "#/$defs/throughline"
46
+ }
47
+ }
48
+ },
49
+ "$defs": {
50
+ "construct": {
51
+ "type": "string",
52
+ "description": "What the node IS as a declaration — drives node anatomy, color, badge, and verification. A module is its own subsystem: do not use a module construct; anchor to a concrete export (`symbol` + `file`) or publish the module as a separate graph. Runtime occurrences (variables, instances) are not constructs.",
53
+ "enum": [
54
+ "class",
55
+ "function",
56
+ "method",
57
+ "interface",
58
+ "type_alias",
59
+ "enum",
60
+ "store",
61
+ "external"
62
+ ]
63
+ },
64
+ "role": {
65
+ "type": "string",
66
+ "description": "Where the node sits in the topology, orthogonal to construct. Boundary-crossing edges should terminate at an entry or a service. Retained state is `construct: store`, not a role.",
67
+ "enum": [
68
+ "entry",
69
+ "service"
70
+ ]
71
+ },
72
+ "framework": {
73
+ "type": "string",
74
+ "minLength": 1,
75
+ "description": "Framework that owns the stereotype vocabulary (open string). Examples: react, vue, nestjs, django, spring. Empty when the node is language-only. Pair with stereotype when the unit plays a framework pattern (e.g. framework: react + stereotype: component on construct: function)."
76
+ },
77
+ "stereotype": {
78
+ "type": "string",
79
+ "minLength": 1,
80
+ "description": "Framework-level pattern stamped on a language construct (open string). Examples: component, hook, middleware, controller, guard. Prefer this over inventing framework-specific constructs. Pair with framework when set."
81
+ },
82
+ "capture": {
83
+ "type": "string",
84
+ "description": "How the authoring session occupied this component.",
85
+ "enum": [
86
+ "edited",
87
+ "analyzed",
88
+ "referenced"
89
+ ]
90
+ },
91
+ "declarationProvenance": {
92
+ "type": "string",
93
+ "description": "Where `declaration` came from. `verified` is reserved for tool-extracted data; hand-authored declarations must be `authored` (also the default when declaration is present without provenance).",
94
+ "enum": [
95
+ "verified",
96
+ "authored"
97
+ ]
98
+ },
99
+ "mechanism": {
100
+ "type": "string",
101
+ "description": "How `from` relates to `to`. Pick the closest label; put specifics in `refs`. `uses` = general dependency; `feeds` = data-flow into a processor; `produces` = emits an output; `references` = type/symbol reference that is not a call; `writes`/`reads`/`watches` = retained-state interactions.",
102
+ "enum": [
103
+ "imports",
104
+ "imports_from",
105
+ "re_exports",
106
+ "defines",
107
+ "calls",
108
+ "extends",
109
+ "inherits",
110
+ "implements",
111
+ "mixes_in",
112
+ "uses",
113
+ "method",
114
+ "references",
115
+ "contains",
116
+ "feeds",
117
+ "produces",
118
+ "writes",
119
+ "reads",
120
+ "watches",
121
+ "registers-into"
122
+ ]
123
+ },
124
+ "component": {
125
+ "type": "object",
126
+ "required": [
127
+ "id",
128
+ "name",
129
+ "construct",
130
+ "file",
131
+ "purl"
132
+ ],
133
+ "additionalProperties": false,
134
+ "properties": {
135
+ "id": {
136
+ "type": "string",
137
+ "minLength": 1,
138
+ "description": "Stable unique id. Referenced by edge `from` / `to`; never rename on update."
139
+ },
140
+ "name": {
141
+ "type": "string",
142
+ "minLength": 1,
143
+ "description": "Display label on the node. Prefer deriving from `symbol` (renderers often do). Required on the wire; when `symbol` is set, name may simply match it."
144
+ },
145
+ "construct": {
146
+ "$ref": "#/$defs/construct"
147
+ },
148
+ "file": {
149
+ "type": "string",
150
+ "description": "Repo-root-relative path of the source location this component lives in. Joins onto `repoRoot` / `repoRoots` for reads. Empty string allowed for pure externals."
151
+ },
152
+ "purl": {
153
+ "type": "string",
154
+ "minLength": 1,
155
+ "description": "PURL identifying the repo or package (for subgraph grouping), e.g. `pkg:github/owner/name#path/to/file.ts`."
156
+ },
157
+ "symbol": {
158
+ "type": "string",
159
+ "description": "Code identity — a real declaration in `file` (function/class/const/interface/type/enum). Verified on create/update; mentions, imports, and call sites do not count. For standalone methods use `ClassName.methodName`. Source of truth for display when present."
160
+ },
161
+ "purpose": {
162
+ "type": "string",
163
+ "description": "One plain-text sentence shown on the node / as a doc comment under the declaration. Verb-first; no markdown."
164
+ },
165
+ "role": {
166
+ "$ref": "#/$defs/role"
167
+ },
168
+ "framework": {
169
+ "$ref": "#/$defs/framework"
170
+ },
171
+ "stereotype": {
172
+ "$ref": "#/$defs/stereotype"
173
+ },
174
+ "process": {
175
+ "type": "string",
176
+ "description": "Runtime process / deployment unit membership (e.g. `trail-viewer/host`). Nodes sharing a process are drawn in one boundary region; nodes without one sit outside every boundary."
177
+ },
178
+ "layer": {
179
+ "type": "integer",
180
+ "description": "Semantic layout layer/phase (lower = closer to entry). When set, layout places the component in this layer for a left-to-right pipeline."
181
+ },
182
+ "capture": {
183
+ "$ref": "#/$defs/capture"
184
+ },
185
+ "declaration": {
186
+ "$ref": "#/$defs/constructDeclaration",
187
+ "description": "Structured declaration shape of the construct for the click panel (parameters, members, etc.). Hand-author when highlighting specific inputs/outputs; set `declarationProvenance` accordingly."
188
+ },
189
+ "declarationProvenance": {
190
+ "$ref": "#/$defs/declarationProvenance"
191
+ },
192
+ "tokens": {
193
+ "type": "array",
194
+ "description": "Pre-tokenized source text for the declaration panel. When present, the renderer skips client-side tokenization.",
195
+ "items": {
196
+ "$ref": "#/$defs/declToken"
197
+ }
198
+ },
199
+ "declarationRef": {
200
+ "$ref": "#/$defs/declarationRef",
201
+ "description": "Anchored declaration location (start line + line hash). Usually populated by verify tooling, not hand-authored. Distinct from `declaration`, which is the structured shape."
202
+ }
203
+ }
204
+ },
205
+ "edge": {
206
+ "type": "object",
207
+ "required": [
208
+ "id",
209
+ "from",
210
+ "to",
211
+ "mechanism"
212
+ ],
213
+ "additionalProperties": false,
214
+ "properties": {
215
+ "id": {
216
+ "type": "string",
217
+ "minLength": 1,
218
+ "description": "Stable unique edge id. Referenced by throughline steps."
219
+ },
220
+ "from": {
221
+ "type": "string",
222
+ "minLength": 1,
223
+ "description": "Source component `id`."
224
+ },
225
+ "to": {
226
+ "type": "string",
227
+ "minLength": 1,
228
+ "description": "Target component `id` (or external target label)."
229
+ },
230
+ "mechanism": {
231
+ "$ref": "#/$defs/mechanism"
232
+ },
233
+ "refs": {
234
+ "type": "array",
235
+ "description": "Concrete file/symbol evidence backing the edge (often purl refs).",
236
+ "items": {
237
+ "type": "string",
238
+ "minLength": 1
239
+ }
240
+ }
241
+ }
242
+ },
243
+ "throughlineStep": {
244
+ "type": "object",
245
+ "required": [
246
+ "edgeId",
247
+ "file",
248
+ "line"
249
+ ],
250
+ "additionalProperties": false,
251
+ "properties": {
252
+ "edgeId": {
253
+ "type": "string",
254
+ "minLength": 1,
255
+ "description": "Id of an existing edge this hop traverses."
256
+ },
257
+ "file": {
258
+ "type": "string",
259
+ "minLength": 1,
260
+ "description": "Repo-root-relative path where the edge fires for this flow."
261
+ },
262
+ "line": {
263
+ "type": "integer",
264
+ "minimum": 1,
265
+ "description": "1-based line of the site within `file`."
266
+ },
267
+ "symbol": {
268
+ "type": "string",
269
+ "minLength": 1,
270
+ "description": "Frame name for this hop (function/method/symbol). Optional; when omitted the viewer falls back to mechanism + filename."
271
+ }
272
+ }
273
+ },
274
+ "throughline": {
275
+ "type": "object",
276
+ "required": [
277
+ "id",
278
+ "title",
279
+ "steps"
280
+ ],
281
+ "additionalProperties": false,
282
+ "properties": {
283
+ "id": {
284
+ "type": "string",
285
+ "minLength": 1,
286
+ "description": "Stable unique throughline id."
287
+ },
288
+ "title": {
289
+ "type": "string",
290
+ "minLength": 1,
291
+ "description": "Flow name (e.g. save flow, load flow)."
292
+ },
293
+ "steps": {
294
+ "type": "array",
295
+ "description": "Ordered hops; array order is execution order.",
296
+ "items": {
297
+ "$ref": "#/$defs/throughlineStep"
298
+ }
299
+ }
300
+ }
301
+ },
302
+ "declToken": {
303
+ "type": "object",
304
+ "required": [
305
+ "text",
306
+ "kind"
307
+ ],
308
+ "additionalProperties": false,
309
+ "properties": {
310
+ "text": {
311
+ "type": "string"
312
+ },
313
+ "kind": {
314
+ "type": "string",
315
+ "enum": [
316
+ "keyword",
317
+ "name",
318
+ "member",
319
+ "type",
320
+ "punctuation",
321
+ "string",
322
+ "newline"
323
+ ]
324
+ },
325
+ "color": {
326
+ "type": "string",
327
+ "description": "Optional foreground color when pre-tokenized for a theme."
328
+ }
329
+ }
330
+ },
331
+ "declarationRef": {
332
+ "type": "object",
333
+ "required": [
334
+ "file",
335
+ "startLine",
336
+ "lineHash",
337
+ "capturedAt"
338
+ ],
339
+ "additionalProperties": false,
340
+ "properties": {
341
+ "file": {
342
+ "type": "string",
343
+ "description": "Repo-root-relative path (matches component.file)."
344
+ },
345
+ "startLine": {
346
+ "type": "integer",
347
+ "minimum": 1,
348
+ "description": "1-based declaration start line."
349
+ },
350
+ "lineHash": {
351
+ "type": "string",
352
+ "description": "Hash of the normalized declaration line at capture time (drift detection)."
353
+ },
354
+ "graphifyNodeId": {
355
+ "type": "string",
356
+ "description": "Graphify node id when captured from an exact anchor."
357
+ },
358
+ "capturedAt": {
359
+ "type": "string",
360
+ "description": "ISO timestamp when this ref was recorded."
361
+ },
362
+ "revision": {
363
+ "type": "object",
364
+ "required": [
365
+ "headSha"
366
+ ],
367
+ "additionalProperties": false,
368
+ "properties": {
369
+ "headSha": {
370
+ "type": "string"
371
+ },
372
+ "dirtyHash": {
373
+ "type": [
374
+ "string",
375
+ "null"
376
+ ]
377
+ }
378
+ }
379
+ }
380
+ }
381
+ },
382
+ "paramInfo": {
383
+ "type": "object",
384
+ "required": [
385
+ "type"
386
+ ],
387
+ "additionalProperties": false,
388
+ "properties": {
389
+ "name": {
390
+ "type": "string"
391
+ },
392
+ "type": {
393
+ "type": "string"
394
+ },
395
+ "ref": {
396
+ "$ref": "#/$defs/referenceInfo"
397
+ }
398
+ }
399
+ },
400
+ "propertyInfo": {
401
+ "type": "object",
402
+ "required": [
403
+ "name"
404
+ ],
405
+ "additionalProperties": false,
406
+ "properties": {
407
+ "name": {
408
+ "type": "string"
409
+ },
410
+ "type": {
411
+ "type": "string"
412
+ },
413
+ "typeRef": {
414
+ "$ref": "#/$defs/referenceInfo"
415
+ },
416
+ "nodeId": {
417
+ "type": "string"
418
+ }
419
+ }
420
+ },
421
+ "methodInfo": {
422
+ "type": "object",
423
+ "required": [
424
+ "nodeId",
425
+ "name"
426
+ ],
427
+ "additionalProperties": false,
428
+ "properties": {
429
+ "nodeId": {
430
+ "type": "string"
431
+ },
432
+ "name": {
433
+ "type": "string"
434
+ },
435
+ "parameters": {
436
+ "type": "array",
437
+ "items": {
438
+ "$ref": "#/$defs/paramInfo"
439
+ }
440
+ },
441
+ "returnType": {
442
+ "type": "string"
443
+ },
444
+ "returnTypeRef": {
445
+ "$ref": "#/$defs/referenceInfo"
446
+ }
447
+ }
448
+ },
449
+ "callInfo": {
450
+ "type": "object",
451
+ "required": [
452
+ "nodeId",
453
+ "name"
454
+ ],
455
+ "additionalProperties": false,
456
+ "properties": {
457
+ "nodeId": {
458
+ "type": "string"
459
+ },
460
+ "name": {
461
+ "type": "string"
462
+ },
463
+ "source_location": {
464
+ "type": "string"
465
+ }
466
+ }
467
+ },
468
+ "referenceInfo": {
469
+ "type": "object",
470
+ "required": [
471
+ "nodeId",
472
+ "name"
473
+ ],
474
+ "additionalProperties": false,
475
+ "properties": {
476
+ "nodeId": {
477
+ "type": "string"
478
+ },
479
+ "name": {
480
+ "type": "string"
481
+ },
482
+ "context": {
483
+ "type": "string"
484
+ },
485
+ "source_location": {
486
+ "type": "string"
487
+ }
488
+ }
489
+ },
490
+ "importInfo": {
491
+ "type": "object",
492
+ "required": [
493
+ "nodeId",
494
+ "name"
495
+ ],
496
+ "additionalProperties": false,
497
+ "properties": {
498
+ "nodeId": {
499
+ "type": "string"
500
+ },
501
+ "name": {
502
+ "type": "string"
503
+ },
504
+ "relation": {
505
+ "type": "string"
506
+ },
507
+ "source_location": {
508
+ "type": "string"
509
+ }
510
+ }
511
+ },
512
+ "constructDeclaration": {
513
+ "description": "Discriminated structured declaration of a construct (`kind`). Hand-authored declarations should set component.declarationProvenance to authored.",
514
+ "oneOf": [
515
+ {
516
+ "$ref": "#/$defs/classDeclaration"
517
+ },
518
+ {
519
+ "$ref": "#/$defs/functionDeclaration"
520
+ },
521
+ {
522
+ "$ref": "#/$defs/methodDeclaration"
523
+ },
524
+ {
525
+ "$ref": "#/$defs/typeDeclaration"
526
+ },
527
+ {
528
+ "$ref": "#/$defs/moduleDeclaration"
529
+ },
530
+ {
531
+ "$ref": "#/$defs/externalDeclaration"
532
+ },
533
+ {
534
+ "$ref": "#/$defs/storeDeclaration"
535
+ }
536
+ ]
537
+ },
538
+ "classDeclaration": {
539
+ "type": "object",
540
+ "required": [
541
+ "kind",
542
+ "methods",
543
+ "properties",
544
+ "extends",
545
+ "implements",
546
+ "instantiations",
547
+ "references"
548
+ ],
549
+ "additionalProperties": false,
550
+ "properties": {
551
+ "kind": {
552
+ "const": "class"
553
+ },
554
+ "methods": {
555
+ "type": "array",
556
+ "items": {
557
+ "$ref": "#/$defs/methodInfo"
558
+ }
559
+ },
560
+ "properties": {
561
+ "type": "array",
562
+ "items": {
563
+ "$ref": "#/$defs/propertyInfo"
564
+ }
565
+ },
566
+ "extends": {
567
+ "type": "array",
568
+ "items": {
569
+ "type": "string"
570
+ }
571
+ },
572
+ "implements": {
573
+ "type": "array",
574
+ "items": {
575
+ "type": "string"
576
+ }
577
+ },
578
+ "instantiations": {
579
+ "type": "array",
580
+ "items": {
581
+ "$ref": "#/$defs/callInfo"
582
+ }
583
+ },
584
+ "references": {
585
+ "type": "array",
586
+ "items": {
587
+ "$ref": "#/$defs/referenceInfo"
588
+ }
589
+ }
590
+ }
591
+ },
592
+ "functionDeclaration": {
593
+ "type": "object",
594
+ "required": [
595
+ "kind",
596
+ "parameters",
597
+ "callers",
598
+ "callees"
599
+ ],
600
+ "additionalProperties": false,
601
+ "properties": {
602
+ "kind": {
603
+ "const": "function"
604
+ },
605
+ "parameters": {
606
+ "type": "array",
607
+ "items": {
608
+ "$ref": "#/$defs/paramInfo"
609
+ }
610
+ },
611
+ "returnType": {
612
+ "type": "string"
613
+ },
614
+ "returnTypeRef": {
615
+ "$ref": "#/$defs/referenceInfo"
616
+ },
617
+ "callers": {
618
+ "type": "array",
619
+ "items": {
620
+ "$ref": "#/$defs/callInfo"
621
+ }
622
+ },
623
+ "callees": {
624
+ "type": "array",
625
+ "items": {
626
+ "$ref": "#/$defs/callInfo"
627
+ }
628
+ }
629
+ }
630
+ },
631
+ "methodDeclaration": {
632
+ "type": "object",
633
+ "required": [
634
+ "kind",
635
+ "hostClass"
636
+ ],
637
+ "additionalProperties": false,
638
+ "properties": {
639
+ "kind": {
640
+ "const": "method"
641
+ },
642
+ "hostClass": {
643
+ "type": "string",
644
+ "description": "Owning class name. Required for standalone method components."
645
+ },
646
+ "parameters": {
647
+ "type": "array",
648
+ "items": {
649
+ "$ref": "#/$defs/paramInfo"
650
+ }
651
+ },
652
+ "returnType": {
653
+ "type": "string"
654
+ }
655
+ }
656
+ },
657
+ "typeDeclaration": {
658
+ "type": "object",
659
+ "required": [
660
+ "kind",
661
+ "properties",
662
+ "usedBy",
663
+ "implementors"
664
+ ],
665
+ "additionalProperties": false,
666
+ "properties": {
667
+ "kind": {
668
+ "const": "type"
669
+ },
670
+ "properties": {
671
+ "type": "array",
672
+ "items": {
673
+ "$ref": "#/$defs/propertyInfo"
674
+ }
675
+ },
676
+ "usedBy": {
677
+ "type": "array",
678
+ "items": {
679
+ "$ref": "#/$defs/referenceInfo"
680
+ }
681
+ },
682
+ "implementors": {
683
+ "type": "array",
684
+ "items": {
685
+ "type": "string"
686
+ }
687
+ }
688
+ }
689
+ },
690
+ "moduleDeclaration": {
691
+ "type": "object",
692
+ "required": [
693
+ "kind",
694
+ "exports",
695
+ "imports",
696
+ "symbols"
697
+ ],
698
+ "additionalProperties": false,
699
+ "description": "Declaration shape for module-like drill-down. Prefer not authoring module *components*; this payload may still appear from tooling.",
700
+ "properties": {
701
+ "kind": {
702
+ "const": "module"
703
+ },
704
+ "exports": {
705
+ "type": "array",
706
+ "items": {
707
+ "type": "string"
708
+ }
709
+ },
710
+ "imports": {
711
+ "type": "array",
712
+ "items": {
713
+ "$ref": "#/$defs/importInfo"
714
+ }
715
+ },
716
+ "symbols": {
717
+ "type": "array",
718
+ "items": {
719
+ "type": "string"
720
+ }
721
+ }
722
+ }
723
+ },
724
+ "externalDeclaration": {
725
+ "type": "object",
726
+ "required": [
727
+ "kind",
728
+ "label"
729
+ ],
730
+ "additionalProperties": false,
731
+ "properties": {
732
+ "kind": {
733
+ "const": "external"
734
+ },
735
+ "label": {
736
+ "type": "string",
737
+ "description": "Facet-only label; no backing source declaration."
738
+ }
739
+ }
740
+ },
741
+ "storeDeclaration": {
742
+ "type": "object",
743
+ "required": [
744
+ "kind",
745
+ "properties"
746
+ ],
747
+ "additionalProperties": false,
748
+ "properties": {
749
+ "kind": {
750
+ "const": "store"
751
+ },
752
+ "properties": {
753
+ "type": "array",
754
+ "description": "Retained state members (module-level consts or fields).",
755
+ "items": {
756
+ "$ref": "#/$defs/propertyInfo"
757
+ }
758
+ }
759
+ }
760
+ }
761
+ }
762
+ }