@principal-ai/subsystems-core 0.31.4 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/subsystem-model.d.ts +93 -12
- package/dist/types/subsystem-model.d.ts.map +1 -1
- package/dist/types/subsystem-model.js +44 -5
- package/dist/types/subsystem-model.js.map +1 -1
- package/package.json +1 -1
- package/schemas/subsystem-model.schema.json +93 -29
- package/src/types/subsystem-model.ts +144 -19
|
@@ -40,8 +40,21 @@ export type SubsystemFramework = string;
|
|
|
40
40
|
* Empty when no framework pattern applies. Pair with `framework` when set.
|
|
41
41
|
*/
|
|
42
42
|
export type SubsystemStereotype = string;
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Topology relation type — structural / module / type claims between
|
|
45
|
+
* components. Belongs on `relations[]`, not on walkthrough hops.
|
|
46
|
+
*/
|
|
47
|
+
export type SubsystemRelationType = 'imports' | 'imports_from' | 're_exports' | 'defines' | 'extends' | 'inherits' | 'implements' | 'mixes_in' | 'method' | 'references' | 'contains';
|
|
48
|
+
/**
|
|
49
|
+
* Walkthrough hop mechanism — runtime seams with a `file:line` site.
|
|
50
|
+
* Belongs on walkthrough steps; graph edges for these are derived.
|
|
51
|
+
*/
|
|
52
|
+
export type SubsystemWalkthroughMechanism = 'calls' | 'uses' | 'feeds' | 'produces' | 'writes' | 'reads' | 'watches' | 'registers-into';
|
|
53
|
+
/**
|
|
54
|
+
* Union used by derived graph edges / styling (topology relationType or
|
|
55
|
+
* walkthrough hop mechanism).
|
|
56
|
+
*/
|
|
57
|
+
export type SubsystemEdgeMechanism = SubsystemRelationType | SubsystemWalkthroughMechanism;
|
|
45
58
|
export type SubsystemDeclarationProvenance = 'verified' | 'authored';
|
|
46
59
|
export type SubsystemDeclTokenKind = 'keyword' | 'name' | 'member' | 'type' | 'punctuation' | 'string' | 'newline';
|
|
47
60
|
export interface SubsystemDeclToken {
|
|
@@ -120,11 +133,46 @@ export interface SubsystemMethodDeclaration {
|
|
|
120
133
|
parameters?: SubsystemParamInfo[];
|
|
121
134
|
returnType?: string;
|
|
122
135
|
}
|
|
136
|
+
/** One generic type parameter, e.g. `T` or `K extends keyof StudioMessages`. */
|
|
137
|
+
export interface SubsystemTypeParamInfo {
|
|
138
|
+
name: string;
|
|
139
|
+
/** Constraint written after `extends` (or language equivalent). */
|
|
140
|
+
constraint?: string;
|
|
141
|
+
}
|
|
142
|
+
/** A callable/function type: `(params) => returnType`. */
|
|
143
|
+
export interface SubsystemCallableTypeInfo {
|
|
144
|
+
parameters?: SubsystemParamInfo[];
|
|
145
|
+
returnType?: string;
|
|
146
|
+
}
|
|
147
|
+
/** One enum member, with its optional literal value. */
|
|
148
|
+
export interface SubsystemEnumMemberInfo {
|
|
149
|
+
name: string;
|
|
150
|
+
value?: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Type-family declaration (interface / type alias / enum). Structured buckets
|
|
154
|
+
* cover common shapes; `rhs` is the verbatim escape hatch when none fit.
|
|
155
|
+
*/
|
|
123
156
|
export interface SubsystemTypeDeclaration {
|
|
124
157
|
kind: 'type';
|
|
125
158
|
properties: SubsystemPropertyInfo[];
|
|
126
159
|
usedBy: SubsystemReferenceInfo[];
|
|
127
160
|
implementors: string[];
|
|
161
|
+
/** Generic type parameters, e.g. `<K extends keyof StudioMessages>`. */
|
|
162
|
+
generics?: SubsystemTypeParamInfo[];
|
|
163
|
+
/** Callable type — `(params) => returnType`. */
|
|
164
|
+
signature?: SubsystemCallableTypeInfo;
|
|
165
|
+
/** Enum members (name, optional literal value). */
|
|
166
|
+
enumMembers?: SubsystemEnumMemberInfo[];
|
|
167
|
+
/** Alias whose RHS is a plain reference, e.g. `ServerSessionRow[]`. */
|
|
168
|
+
aliasOf?: string;
|
|
169
|
+
/** Simple union of alternatives, e.g. `'started' | 'stopped'`. */
|
|
170
|
+
unionOf?: string[];
|
|
171
|
+
/**
|
|
172
|
+
* Verbatim RHS — escape hatch for shapes the structured fields can't
|
|
173
|
+
* express. Wins over every shape above when set.
|
|
174
|
+
*/
|
|
175
|
+
rhs?: string;
|
|
128
176
|
}
|
|
129
177
|
export interface SubsystemModuleDeclaration {
|
|
130
178
|
kind: 'module';
|
|
@@ -138,6 +186,11 @@ export interface SubsystemExternalDeclaration {
|
|
|
138
186
|
}
|
|
139
187
|
export interface SubsystemStoreDeclaration {
|
|
140
188
|
kind: 'store';
|
|
189
|
+
/** Where retained state lives / who mediates access. Authored, never
|
|
190
|
+
* extracted: `memory` (process-lifetime RAM), `disk` (this process
|
|
191
|
+
* reads/writes files), or `external` (another system — db/service; carries
|
|
192
|
+
* no `process`). */
|
|
193
|
+
storage?: 'memory' | 'disk' | 'external';
|
|
141
194
|
properties: SubsystemPropertyInfo[];
|
|
142
195
|
}
|
|
143
196
|
/** A single authored attribute on a custom entity — free-form key/value. */
|
|
@@ -206,19 +259,35 @@ export interface SubsystemComponent {
|
|
|
206
259
|
/** Location anchor (file/line/hash) — distinct from `declaration` (shape). */
|
|
207
260
|
declarationRef?: SubsystemDeclarationRef;
|
|
208
261
|
}
|
|
209
|
-
/** A
|
|
210
|
-
export interface
|
|
262
|
+
/** A topology relation between components (structural / module / type). */
|
|
263
|
+
export interface SubsystemRelation {
|
|
211
264
|
id: string;
|
|
212
265
|
/** Source component id. */
|
|
213
266
|
from: string;
|
|
214
267
|
/** Target component id (or external label). */
|
|
215
268
|
to: string;
|
|
216
|
-
|
|
269
|
+
relationType: SubsystemRelationType;
|
|
217
270
|
/** Concrete file/symbol evidence (often purls). */
|
|
218
271
|
refs?: string[];
|
|
219
272
|
}
|
|
220
|
-
|
|
221
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Derived / display graph edge used by renderers. Built from `relations`
|
|
275
|
+
* and/or walkthrough hops — not authored as its own document field.
|
|
276
|
+
*/
|
|
277
|
+
export interface SubsystemComponentEdge {
|
|
278
|
+
id: string;
|
|
279
|
+
from: string;
|
|
280
|
+
to: string;
|
|
281
|
+
mechanism: SubsystemEdgeMechanism;
|
|
282
|
+
refs?: string[];
|
|
283
|
+
}
|
|
284
|
+
export interface SubsystemWalkthroughStep {
|
|
285
|
+
/** Source component id. */
|
|
286
|
+
from: string;
|
|
287
|
+
/** Target component id. */
|
|
288
|
+
to: string;
|
|
289
|
+
/** Runtime seam label (Set B). */
|
|
290
|
+
mechanism: SubsystemWalkthroughMechanism;
|
|
222
291
|
file: string;
|
|
223
292
|
/** 1-based line within `file`. */
|
|
224
293
|
line: number;
|
|
@@ -231,11 +300,11 @@ export interface SubsystemThroughlineStep {
|
|
|
231
300
|
*/
|
|
232
301
|
annotation?: string;
|
|
233
302
|
}
|
|
234
|
-
/** Ordered
|
|
235
|
-
export interface
|
|
303
|
+
/** Ordered runtime walkthrough (one named behavior story). */
|
|
304
|
+
export interface SubsystemWalkthrough {
|
|
236
305
|
id: string;
|
|
237
306
|
title: string;
|
|
238
|
-
steps:
|
|
307
|
+
steps: SubsystemWalkthroughStep[];
|
|
239
308
|
}
|
|
240
309
|
export interface SubsystemRepoRef {
|
|
241
310
|
owner: string;
|
|
@@ -255,8 +324,10 @@ export interface SubsystemModelDocument {
|
|
|
255
324
|
title: string;
|
|
256
325
|
description?: string;
|
|
257
326
|
components: SubsystemComponent[];
|
|
258
|
-
|
|
259
|
-
|
|
327
|
+
/** Topology relations (structural / module / type). May be empty. */
|
|
328
|
+
relations: SubsystemRelation[];
|
|
329
|
+
/** Runtime walkthroughs (ordered hops with sites). */
|
|
330
|
+
walkthroughs?: SubsystemWalkthrough[];
|
|
260
331
|
}
|
|
261
332
|
/**
|
|
262
333
|
* Host/machine fields layered onto a portable document for local use.
|
|
@@ -305,4 +376,14 @@ export declare function isSubsystemModelDocument(value: unknown): value is Subsy
|
|
|
305
376
|
* share surface that must stay schema-clean.
|
|
306
377
|
*/
|
|
307
378
|
export declare function toPortableDocument(doc: SubsystemModelDocument): SubsystemModelDocument;
|
|
379
|
+
/** Stable id for a derived graph edge from a relation or walkthrough hop. */
|
|
380
|
+
export declare function derivedGraphEdgeId(from: string, to: string, mechanism: SubsystemEdgeMechanism): string;
|
|
381
|
+
/**
|
|
382
|
+
* Build display edges for the graph canvas from topology relations and
|
|
383
|
+
* walkthrough hops (deduped by from/to/mechanism).
|
|
384
|
+
*/
|
|
385
|
+
export declare function deriveGraphEdges(doc: {
|
|
386
|
+
relations?: SubsystemRelation[];
|
|
387
|
+
walkthroughs?: SubsystemWalkthrough[];
|
|
388
|
+
}): SubsystemComponentEdge[];
|
|
308
389
|
//# sourceMappingURL=subsystem-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subsystem-model.d.ts","sourceRoot":"","sources":["../../src/types/subsystem-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;0CAE0C;AAC1C,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,UAAU,GACV,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,MAAM,GACN,OAAO,GACP,UAAU,GACV,eAAe,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"subsystem-model.d.ts","sourceRoot":"","sources":["../../src/types/subsystem-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;0CAE0C;AAC1C,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,UAAU,GACV,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,MAAM,GACN,OAAO,GACP,UAAU,GACV,eAAe,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,sBAAsB,G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;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAYxF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,sBAAsB,GAC1B,sBAAsB,CAUxB;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,sBAAsB,GAChC,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE;IACpC,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACvC,GAAG,sBAAsB,EAAE,CA4B3B"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* `symbol` is the code identity; `name` is the display label.
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.toPortableDocument = exports.isSubsystemModelDocument = void 0;
|
|
21
|
+
exports.deriveGraphEdges = exports.derivedGraphEdgeId = exports.toPortableDocument = exports.isSubsystemModelDocument = void 0;
|
|
22
22
|
/**
|
|
23
23
|
* Type guard: true when the value plausibly conforms to a portable
|
|
24
24
|
* subsystem model. Shallow check — full validation belongs to the schema /
|
|
@@ -30,7 +30,7 @@ function isSubsystemModelDocument(value) {
|
|
|
30
30
|
const v = value;
|
|
31
31
|
return (typeof v.title === 'string' &&
|
|
32
32
|
Array.isArray(v.components) &&
|
|
33
|
-
Array.isArray(v.
|
|
33
|
+
Array.isArray(v.relations));
|
|
34
34
|
}
|
|
35
35
|
exports.isSubsystemModelDocument = isSubsystemModelDocument;
|
|
36
36
|
/**
|
|
@@ -42,15 +42,54 @@ function toPortableDocument(doc) {
|
|
|
42
42
|
const out = {
|
|
43
43
|
title: doc.title,
|
|
44
44
|
components: doc.components,
|
|
45
|
-
|
|
45
|
+
relations: doc.relations,
|
|
46
46
|
};
|
|
47
47
|
if (doc.$schema)
|
|
48
48
|
out.$schema = doc.$schema;
|
|
49
49
|
if (doc.description)
|
|
50
50
|
out.description = doc.description;
|
|
51
|
-
if (doc.
|
|
52
|
-
out.
|
|
51
|
+
if (doc.walkthroughs)
|
|
52
|
+
out.walkthroughs = doc.walkthroughs;
|
|
53
53
|
return out;
|
|
54
54
|
}
|
|
55
55
|
exports.toPortableDocument = toPortableDocument;
|
|
56
|
+
/** Stable id for a derived graph edge from a relation or walkthrough hop. */
|
|
57
|
+
function derivedGraphEdgeId(from, to, mechanism) {
|
|
58
|
+
return `${from}--${mechanism}-->${to}`;
|
|
59
|
+
}
|
|
60
|
+
exports.derivedGraphEdgeId = derivedGraphEdgeId;
|
|
61
|
+
/**
|
|
62
|
+
* Build display edges for the graph canvas from topology relations and
|
|
63
|
+
* walkthrough hops (deduped by from/to/mechanism).
|
|
64
|
+
*/
|
|
65
|
+
function deriveGraphEdges(doc) {
|
|
66
|
+
const byId = new Map();
|
|
67
|
+
for (const r of doc.relations ?? []) {
|
|
68
|
+
const id = r.id || derivedGraphEdgeId(r.from, r.to, r.relationType);
|
|
69
|
+
if (!byId.has(id)) {
|
|
70
|
+
byId.set(id, {
|
|
71
|
+
id,
|
|
72
|
+
from: r.from,
|
|
73
|
+
to: r.to,
|
|
74
|
+
mechanism: r.relationType,
|
|
75
|
+
refs: r.refs,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const w of doc.walkthroughs ?? []) {
|
|
80
|
+
for (const step of w.steps) {
|
|
81
|
+
const id = derivedGraphEdgeId(step.from, step.to, step.mechanism);
|
|
82
|
+
if (!byId.has(id)) {
|
|
83
|
+
byId.set(id, {
|
|
84
|
+
id,
|
|
85
|
+
from: step.from,
|
|
86
|
+
to: step.to,
|
|
87
|
+
mechanism: step.mechanism,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return [...byId.values()];
|
|
93
|
+
}
|
|
94
|
+
exports.deriveGraphEdges = deriveGraphEdges;
|
|
56
95
|
//# sourceMappingURL=subsystem-model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subsystem-model.js","sourceRoot":"","sources":["../../src/types/subsystem-model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;
|
|
1
|
+
{"version":3,"file":"subsystem-model.js","sourceRoot":"","sources":["../../src/types/subsystem-model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAqbH;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,KAAc;IACrD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,CAAC,GAAG,KAIT,CAAC;IACF,OAAO,CACL,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAC3B,CAAC;AACJ,CAAC;AAZD,4DAYC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,GAA2B;IAE3B,MAAM,GAAG,GAA2B;QAClC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,SAAS,EAAE,GAAG,CAAC,SAAS;KACzB,CAAC;IACF,IAAI,GAAG,CAAC,OAAO;QAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAC3C,IAAI,GAAG,CAAC,WAAW;QAAE,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IACvD,IAAI,GAAG,CAAC,YAAY;QAAE,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAC1D,OAAO,GAAG,CAAC;AACb,CAAC;AAZD,gDAYC;AAED,6EAA6E;AAC7E,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AO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5B,CAAC;AA/BD,4CA+BC"}
|
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://principal-ai.dev/schemas/subsystem-model.schema.json",
|
|
4
4
|
"title": "Subsystem Model",
|
|
5
|
-
"description": "Portable subsystem model — the shareable standard. Construct-tagged components (nodes) plus
|
|
5
|
+
"description": "Portable subsystem model — the shareable standard. Construct-tagged components (nodes) plus topology relations and/or runtime walkthroughs 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
6
|
"type": "object",
|
|
7
7
|
"required": [
|
|
8
8
|
"title",
|
|
9
9
|
"components",
|
|
10
|
-
"
|
|
10
|
+
"relations"
|
|
11
11
|
],
|
|
12
12
|
"additionalProperties": false,
|
|
13
13
|
"properties": {
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"$ref": "#/$defs/component"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
"
|
|
34
|
+
"relations": {
|
|
35
35
|
"type": "array",
|
|
36
|
-
"description": "
|
|
36
|
+
"description": "Topology relations (structural / module / type). `from` / `to` reference component `id`s. Runtime seams belong on walkthrough steps, not here.",
|
|
37
37
|
"items": {
|
|
38
|
-
"$ref": "#/$defs/
|
|
38
|
+
"$ref": "#/$defs/relation"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
"
|
|
41
|
+
"walkthroughs": {
|
|
42
42
|
"type": "array",
|
|
43
|
-
"description": "Ordered
|
|
43
|
+
"description": "Ordered runtime walkthroughs (one per named behavior). Each step names from/to/mechanism and the concrete file:line where that seam fires.",
|
|
44
44
|
"items": {
|
|
45
|
-
"$ref": "#/$defs/
|
|
45
|
+
"$ref": "#/$defs/walkthrough"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
},
|
|
@@ -92,23 +92,29 @@
|
|
|
92
92
|
"authored"
|
|
93
93
|
]
|
|
94
94
|
},
|
|
95
|
-
"
|
|
95
|
+
"relationType": {
|
|
96
96
|
"type": "string",
|
|
97
|
-
"description": "
|
|
97
|
+
"description": "Topology relation type — structural / module / type claim between components.",
|
|
98
98
|
"enum": [
|
|
99
99
|
"imports",
|
|
100
100
|
"imports_from",
|
|
101
101
|
"re_exports",
|
|
102
102
|
"defines",
|
|
103
|
-
"calls",
|
|
104
103
|
"extends",
|
|
105
104
|
"inherits",
|
|
106
105
|
"implements",
|
|
107
106
|
"mixes_in",
|
|
108
|
-
"uses",
|
|
109
107
|
"method",
|
|
110
108
|
"references",
|
|
111
|
-
"contains"
|
|
109
|
+
"contains"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"mechanism": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "Walkthrough hop mechanism — how `from` relates to `to` at a runtime site. `uses` = general dependency; `feeds` = data-flow into a processor; `produces` = emits an output; `writes`/`reads`/`watches` = retained-state interactions.",
|
|
115
|
+
"enum": [
|
|
116
|
+
"calls",
|
|
117
|
+
"uses",
|
|
112
118
|
"feeds",
|
|
113
119
|
"produces",
|
|
114
120
|
"writes",
|
|
@@ -131,7 +137,7 @@
|
|
|
131
137
|
"id": {
|
|
132
138
|
"type": "string",
|
|
133
139
|
"minLength": 1,
|
|
134
|
-
"description": "Stable unique id. Referenced by
|
|
140
|
+
"description": "Stable unique id. Referenced by relation / walkthrough `from` / `to`; never rename on update."
|
|
135
141
|
},
|
|
136
142
|
"name": {
|
|
137
143
|
"type": "string",
|
|
@@ -206,20 +212,20 @@
|
|
|
206
212
|
}
|
|
207
213
|
}
|
|
208
214
|
},
|
|
209
|
-
"
|
|
215
|
+
"relation": {
|
|
210
216
|
"type": "object",
|
|
211
217
|
"required": [
|
|
212
218
|
"id",
|
|
213
219
|
"from",
|
|
214
220
|
"to",
|
|
215
|
-
"
|
|
221
|
+
"relationType"
|
|
216
222
|
],
|
|
217
223
|
"additionalProperties": false,
|
|
218
224
|
"properties": {
|
|
219
225
|
"id": {
|
|
220
226
|
"type": "string",
|
|
221
227
|
"minLength": 1,
|
|
222
|
-
"description": "Stable unique
|
|
228
|
+
"description": "Stable unique relation id."
|
|
223
229
|
},
|
|
224
230
|
"from": {
|
|
225
231
|
"type": "string",
|
|
@@ -231,12 +237,12 @@
|
|
|
231
237
|
"minLength": 1,
|
|
232
238
|
"description": "Target component `id` (or external target label)."
|
|
233
239
|
},
|
|
234
|
-
"
|
|
235
|
-
"$ref": "#/$defs/
|
|
240
|
+
"relationType": {
|
|
241
|
+
"$ref": "#/$defs/relationType"
|
|
236
242
|
},
|
|
237
243
|
"refs": {
|
|
238
244
|
"type": "array",
|
|
239
|
-
"description": "Concrete file/symbol evidence backing the
|
|
245
|
+
"description": "Concrete file/symbol evidence backing the relation (often purl refs).",
|
|
240
246
|
"items": {
|
|
241
247
|
"type": "string",
|
|
242
248
|
"minLength": 1
|
|
@@ -244,24 +250,34 @@
|
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
},
|
|
247
|
-
"
|
|
253
|
+
"walkthroughStep": {
|
|
248
254
|
"type": "object",
|
|
249
255
|
"required": [
|
|
250
|
-
"
|
|
256
|
+
"from",
|
|
257
|
+
"to",
|
|
258
|
+
"mechanism",
|
|
251
259
|
"file",
|
|
252
260
|
"line"
|
|
253
261
|
],
|
|
254
262
|
"additionalProperties": false,
|
|
255
263
|
"properties": {
|
|
256
|
-
"
|
|
264
|
+
"from": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"minLength": 1,
|
|
267
|
+
"description": "Source component `id`."
|
|
268
|
+
},
|
|
269
|
+
"to": {
|
|
257
270
|
"type": "string",
|
|
258
271
|
"minLength": 1,
|
|
259
|
-
"description": "
|
|
272
|
+
"description": "Target component `id`."
|
|
273
|
+
},
|
|
274
|
+
"mechanism": {
|
|
275
|
+
"$ref": "#/$defs/mechanism"
|
|
260
276
|
},
|
|
261
277
|
"file": {
|
|
262
278
|
"type": "string",
|
|
263
279
|
"minLength": 1,
|
|
264
|
-
"description": "Repo-root-relative path where the
|
|
280
|
+
"description": "Repo-root-relative path where the seam fires for this walkthrough."
|
|
265
281
|
},
|
|
266
282
|
"line": {
|
|
267
283
|
"type": "integer",
|
|
@@ -280,7 +296,7 @@
|
|
|
280
296
|
}
|
|
281
297
|
}
|
|
282
298
|
},
|
|
283
|
-
"
|
|
299
|
+
"walkthrough": {
|
|
284
300
|
"type": "object",
|
|
285
301
|
"required": [
|
|
286
302
|
"id",
|
|
@@ -292,18 +308,18 @@
|
|
|
292
308
|
"id": {
|
|
293
309
|
"type": "string",
|
|
294
310
|
"minLength": 1,
|
|
295
|
-
"description": "Stable unique
|
|
311
|
+
"description": "Stable unique walkthrough id."
|
|
296
312
|
},
|
|
297
313
|
"title": {
|
|
298
314
|
"type": "string",
|
|
299
315
|
"minLength": 1,
|
|
300
|
-
"description": "
|
|
316
|
+
"description": "Walkthrough name (e.g. save, load, refresh)."
|
|
301
317
|
},
|
|
302
318
|
"steps": {
|
|
303
319
|
"type": "array",
|
|
304
320
|
"description": "Ordered hops; array order is execution order.",
|
|
305
321
|
"items": {
|
|
306
|
-
"$ref": "#/$defs/
|
|
322
|
+
"$ref": "#/$defs/walkthroughStep"
|
|
307
323
|
}
|
|
308
324
|
}
|
|
309
325
|
}
|
|
@@ -666,6 +682,35 @@
|
|
|
666
682
|
}
|
|
667
683
|
}
|
|
668
684
|
},
|
|
685
|
+
"typeParamInfo": {
|
|
686
|
+
"type": "object",
|
|
687
|
+
"required": ["name"],
|
|
688
|
+
"additionalProperties": false,
|
|
689
|
+
"properties": {
|
|
690
|
+
"name": { "type": "string" },
|
|
691
|
+
"constraint": { "type": "string" }
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
"callableTypeInfo": {
|
|
695
|
+
"type": "object",
|
|
696
|
+
"additionalProperties": false,
|
|
697
|
+
"properties": {
|
|
698
|
+
"parameters": {
|
|
699
|
+
"type": "array",
|
|
700
|
+
"items": { "$ref": "#/$defs/paramInfo" }
|
|
701
|
+
},
|
|
702
|
+
"returnType": { "type": "string" }
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"enumMemberInfo": {
|
|
706
|
+
"type": "object",
|
|
707
|
+
"required": ["name"],
|
|
708
|
+
"additionalProperties": false,
|
|
709
|
+
"properties": {
|
|
710
|
+
"name": { "type": "string" },
|
|
711
|
+
"value": { "type": "string" }
|
|
712
|
+
}
|
|
713
|
+
},
|
|
669
714
|
"typeDeclaration": {
|
|
670
715
|
"type": "object",
|
|
671
716
|
"required": [
|
|
@@ -675,6 +720,7 @@
|
|
|
675
720
|
"implementors"
|
|
676
721
|
],
|
|
677
722
|
"additionalProperties": false,
|
|
723
|
+
"description": "Type-family declaration (interface / type alias / enum). Prefer structured buckets; use `rhs` when none fit.",
|
|
678
724
|
"properties": {
|
|
679
725
|
"kind": {
|
|
680
726
|
"const": "type"
|
|
@@ -696,6 +742,24 @@
|
|
|
696
742
|
"items": {
|
|
697
743
|
"type": "string"
|
|
698
744
|
}
|
|
745
|
+
},
|
|
746
|
+
"generics": {
|
|
747
|
+
"type": "array",
|
|
748
|
+
"items": { "$ref": "#/$defs/typeParamInfo" }
|
|
749
|
+
},
|
|
750
|
+
"signature": { "$ref": "#/$defs/callableTypeInfo" },
|
|
751
|
+
"enumMembers": {
|
|
752
|
+
"type": "array",
|
|
753
|
+
"items": { "$ref": "#/$defs/enumMemberInfo" }
|
|
754
|
+
},
|
|
755
|
+
"aliasOf": { "type": "string" },
|
|
756
|
+
"unionOf": {
|
|
757
|
+
"type": "array",
|
|
758
|
+
"items": { "type": "string" }
|
|
759
|
+
},
|
|
760
|
+
"rhs": {
|
|
761
|
+
"type": "string",
|
|
762
|
+
"description": "Verbatim RHS escape hatch; wins over structured buckets when set."
|
|
699
763
|
}
|
|
700
764
|
}
|
|
701
765
|
},
|
|
@@ -55,21 +55,30 @@ export type SubsystemFramework = string;
|
|
|
55
55
|
*/
|
|
56
56
|
export type SubsystemStereotype = string;
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Topology relation type — structural / module / type claims between
|
|
60
|
+
* components. Belongs on `relations[]`, not on walkthrough hops.
|
|
61
|
+
*/
|
|
62
|
+
export type SubsystemRelationType =
|
|
60
63
|
| 'imports'
|
|
61
64
|
| 'imports_from'
|
|
62
65
|
| 're_exports'
|
|
63
66
|
| 'defines'
|
|
64
|
-
| 'calls'
|
|
65
67
|
| 'extends'
|
|
66
68
|
| 'inherits'
|
|
67
69
|
| 'implements'
|
|
68
70
|
| 'mixes_in'
|
|
69
|
-
| 'uses'
|
|
70
71
|
| 'method'
|
|
71
72
|
| 'references'
|
|
72
|
-
| 'contains'
|
|
73
|
+
| 'contains';
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Walkthrough hop mechanism — runtime seams with a `file:line` site.
|
|
77
|
+
* Belongs on walkthrough steps; graph edges for these are derived.
|
|
78
|
+
*/
|
|
79
|
+
export type SubsystemWalkthroughMechanism =
|
|
80
|
+
| 'calls'
|
|
81
|
+
| 'uses'
|
|
73
82
|
| 'feeds'
|
|
74
83
|
| 'produces'
|
|
75
84
|
| 'writes'
|
|
@@ -77,6 +86,14 @@ export type SubsystemEdgeMechanism =
|
|
|
77
86
|
| 'watches'
|
|
78
87
|
| 'registers-into';
|
|
79
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Union used by derived graph edges / styling (topology relationType or
|
|
91
|
+
* walkthrough hop mechanism).
|
|
92
|
+
*/
|
|
93
|
+
export type SubsystemEdgeMechanism =
|
|
94
|
+
| SubsystemRelationType
|
|
95
|
+
| SubsystemWalkthroughMechanism;
|
|
96
|
+
|
|
80
97
|
export type SubsystemDeclarationProvenance = 'verified' | 'authored';
|
|
81
98
|
|
|
82
99
|
export type SubsystemDeclTokenKind =
|
|
@@ -175,11 +192,49 @@ export interface SubsystemMethodDeclaration {
|
|
|
175
192
|
returnType?: string;
|
|
176
193
|
}
|
|
177
194
|
|
|
195
|
+
/** One generic type parameter, e.g. `T` or `K extends keyof StudioMessages`. */
|
|
196
|
+
export interface SubsystemTypeParamInfo {
|
|
197
|
+
name: string;
|
|
198
|
+
/** Constraint written after `extends` (or language equivalent). */
|
|
199
|
+
constraint?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** A callable/function type: `(params) => returnType`. */
|
|
203
|
+
export interface SubsystemCallableTypeInfo {
|
|
204
|
+
parameters?: SubsystemParamInfo[];
|
|
205
|
+
returnType?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** One enum member, with its optional literal value. */
|
|
209
|
+
export interface SubsystemEnumMemberInfo {
|
|
210
|
+
name: string;
|
|
211
|
+
value?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Type-family declaration (interface / type alias / enum). Structured buckets
|
|
216
|
+
* cover common shapes; `rhs` is the verbatim escape hatch when none fit.
|
|
217
|
+
*/
|
|
178
218
|
export interface SubsystemTypeDeclaration {
|
|
179
219
|
kind: 'type';
|
|
180
220
|
properties: SubsystemPropertyInfo[];
|
|
181
221
|
usedBy: SubsystemReferenceInfo[];
|
|
182
222
|
implementors: string[];
|
|
223
|
+
/** Generic type parameters, e.g. `<K extends keyof StudioMessages>`. */
|
|
224
|
+
generics?: SubsystemTypeParamInfo[];
|
|
225
|
+
/** Callable type — `(params) => returnType`. */
|
|
226
|
+
signature?: SubsystemCallableTypeInfo;
|
|
227
|
+
/** Enum members (name, optional literal value). */
|
|
228
|
+
enumMembers?: SubsystemEnumMemberInfo[];
|
|
229
|
+
/** Alias whose RHS is a plain reference, e.g. `ServerSessionRow[]`. */
|
|
230
|
+
aliasOf?: string;
|
|
231
|
+
/** Simple union of alternatives, e.g. `'started' | 'stopped'`. */
|
|
232
|
+
unionOf?: string[];
|
|
233
|
+
/**
|
|
234
|
+
* Verbatim RHS — escape hatch for shapes the structured fields can't
|
|
235
|
+
* express. Wins over every shape above when set.
|
|
236
|
+
*/
|
|
237
|
+
rhs?: string;
|
|
183
238
|
}
|
|
184
239
|
|
|
185
240
|
export interface SubsystemModuleDeclaration {
|
|
@@ -196,6 +251,11 @@ export interface SubsystemExternalDeclaration {
|
|
|
196
251
|
|
|
197
252
|
export interface SubsystemStoreDeclaration {
|
|
198
253
|
kind: 'store';
|
|
254
|
+
/** Where retained state lives / who mediates access. Authored, never
|
|
255
|
+
* extracted: `memory` (process-lifetime RAM), `disk` (this process
|
|
256
|
+
* reads/writes files), or `external` (another system — db/service; carries
|
|
257
|
+
* no `process`). */
|
|
258
|
+
storage?: 'memory' | 'disk' | 'external';
|
|
199
259
|
properties: SubsystemPropertyInfo[];
|
|
200
260
|
}
|
|
201
261
|
|
|
@@ -277,20 +337,37 @@ export interface SubsystemComponent {
|
|
|
277
337
|
declarationRef?: SubsystemDeclarationRef;
|
|
278
338
|
}
|
|
279
339
|
|
|
280
|
-
/** A
|
|
281
|
-
export interface
|
|
340
|
+
/** A topology relation between components (structural / module / type). */
|
|
341
|
+
export interface SubsystemRelation {
|
|
282
342
|
id: string;
|
|
283
343
|
/** Source component id. */
|
|
284
344
|
from: string;
|
|
285
345
|
/** Target component id (or external label). */
|
|
286
346
|
to: string;
|
|
287
|
-
|
|
347
|
+
relationType: SubsystemRelationType;
|
|
288
348
|
/** Concrete file/symbol evidence (often purls). */
|
|
289
349
|
refs?: string[];
|
|
290
350
|
}
|
|
291
351
|
|
|
292
|
-
|
|
293
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Derived / display graph edge used by renderers. Built from `relations`
|
|
354
|
+
* and/or walkthrough hops — not authored as its own document field.
|
|
355
|
+
*/
|
|
356
|
+
export interface SubsystemComponentEdge {
|
|
357
|
+
id: string;
|
|
358
|
+
from: string;
|
|
359
|
+
to: string;
|
|
360
|
+
mechanism: SubsystemEdgeMechanism;
|
|
361
|
+
refs?: string[];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface SubsystemWalkthroughStep {
|
|
365
|
+
/** Source component id. */
|
|
366
|
+
from: string;
|
|
367
|
+
/** Target component id. */
|
|
368
|
+
to: string;
|
|
369
|
+
/** Runtime seam label (Set B). */
|
|
370
|
+
mechanism: SubsystemWalkthroughMechanism;
|
|
294
371
|
file: string;
|
|
295
372
|
/** 1-based line within `file`. */
|
|
296
373
|
line: number;
|
|
@@ -304,11 +381,11 @@ export interface SubsystemThroughlineStep {
|
|
|
304
381
|
annotation?: string;
|
|
305
382
|
}
|
|
306
383
|
|
|
307
|
-
/** Ordered
|
|
308
|
-
export interface
|
|
384
|
+
/** Ordered runtime walkthrough (one named behavior story). */
|
|
385
|
+
export interface SubsystemWalkthrough {
|
|
309
386
|
id: string;
|
|
310
387
|
title: string;
|
|
311
|
-
steps:
|
|
388
|
+
steps: SubsystemWalkthroughStep[];
|
|
312
389
|
}
|
|
313
390
|
|
|
314
391
|
export interface SubsystemRepoRef {
|
|
@@ -331,8 +408,10 @@ export interface SubsystemModelDocument {
|
|
|
331
408
|
title: string;
|
|
332
409
|
description?: string;
|
|
333
410
|
components: SubsystemComponent[];
|
|
334
|
-
|
|
335
|
-
|
|
411
|
+
/** Topology relations (structural / module / type). May be empty. */
|
|
412
|
+
relations: SubsystemRelation[];
|
|
413
|
+
/** Runtime walkthroughs (ordered hops with sites). */
|
|
414
|
+
walkthroughs?: SubsystemWalkthrough[];
|
|
336
415
|
}
|
|
337
416
|
|
|
338
417
|
/**
|
|
@@ -383,12 +462,12 @@ export function isSubsystemModelDocument(value: unknown): value is SubsystemMode
|
|
|
383
462
|
const v = value as {
|
|
384
463
|
title?: unknown;
|
|
385
464
|
components?: unknown;
|
|
386
|
-
|
|
465
|
+
relations?: unknown;
|
|
387
466
|
};
|
|
388
467
|
return (
|
|
389
468
|
typeof v.title === 'string' &&
|
|
390
469
|
Array.isArray(v.components) &&
|
|
391
|
-
Array.isArray(v.
|
|
470
|
+
Array.isArray(v.relations)
|
|
392
471
|
);
|
|
393
472
|
}
|
|
394
473
|
|
|
@@ -403,10 +482,56 @@ export function toPortableDocument(
|
|
|
403
482
|
const out: SubsystemModelDocument = {
|
|
404
483
|
title: doc.title,
|
|
405
484
|
components: doc.components,
|
|
406
|
-
|
|
485
|
+
relations: doc.relations,
|
|
407
486
|
};
|
|
408
487
|
if (doc.$schema) out.$schema = doc.$schema;
|
|
409
488
|
if (doc.description) out.description = doc.description;
|
|
410
|
-
if (doc.
|
|
489
|
+
if (doc.walkthroughs) out.walkthroughs = doc.walkthroughs;
|
|
411
490
|
return out;
|
|
412
491
|
}
|
|
492
|
+
|
|
493
|
+
/** Stable id for a derived graph edge from a relation or walkthrough hop. */
|
|
494
|
+
export function derivedGraphEdgeId(
|
|
495
|
+
from: string,
|
|
496
|
+
to: string,
|
|
497
|
+
mechanism: SubsystemEdgeMechanism,
|
|
498
|
+
): string {
|
|
499
|
+
return `${from}--${mechanism}-->${to}`;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Build display edges for the graph canvas from topology relations and
|
|
504
|
+
* walkthrough hops (deduped by from/to/mechanism).
|
|
505
|
+
*/
|
|
506
|
+
export function deriveGraphEdges(doc: {
|
|
507
|
+
relations?: SubsystemRelation[];
|
|
508
|
+
walkthroughs?: SubsystemWalkthrough[];
|
|
509
|
+
}): SubsystemComponentEdge[] {
|
|
510
|
+
const byId = new Map<string, SubsystemComponentEdge>();
|
|
511
|
+
for (const r of doc.relations ?? []) {
|
|
512
|
+
const id = r.id || derivedGraphEdgeId(r.from, r.to, r.relationType);
|
|
513
|
+
if (!byId.has(id)) {
|
|
514
|
+
byId.set(id, {
|
|
515
|
+
id,
|
|
516
|
+
from: r.from,
|
|
517
|
+
to: r.to,
|
|
518
|
+
mechanism: r.relationType,
|
|
519
|
+
refs: r.refs,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
for (const w of doc.walkthroughs ?? []) {
|
|
524
|
+
for (const step of w.steps) {
|
|
525
|
+
const id = derivedGraphEdgeId(step.from, step.to, step.mechanism);
|
|
526
|
+
if (!byId.has(id)) {
|
|
527
|
+
byId.set(id, {
|
|
528
|
+
id,
|
|
529
|
+
from: step.from,
|
|
530
|
+
to: step.to,
|
|
531
|
+
mechanism: step.mechanism,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return [...byId.values()];
|
|
537
|
+
}
|