@principal-ai/subsystems-react 0.56.31 → 0.56.33
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/graphify/anchor.d.ts +1 -44
- package/dist/graphify/anchor.d.ts.map +1 -1
- package/dist/graphify/anchor.js +1 -172
- package/dist/graphify/anchor.js.map +1 -1
- package/dist/graphify/consolidated.d.ts +1 -258
- package/dist/graphify/consolidated.d.ts.map +1 -1
- package/dist/graphify/consolidated.js +1 -10
- package/dist/graphify/consolidated.js.map +1 -1
- package/dist/graphify/construct.d.ts +1 -40
- package/dist/graphify/construct.d.ts.map +1 -1
- package/dist/graphify/construct.js +1 -99
- package/dist/graphify/construct.js.map +1 -1
- package/dist/graphify/ids.d.ts +1 -18
- package/dist/graphify/ids.d.ts.map +1 -1
- package/dist/graphify/ids.js +1 -45
- package/dist/graphify/ids.js.map +1 -1
- package/dist/graphify/resolve.d.ts +1 -47
- package/dist/graphify/resolve.d.ts.map +1 -1
- package/dist/graphify/resolve.js +1 -82
- package/dist/graphify/resolve.js.map +1 -1
- package/dist/graphify/signature.d.ts +1 -86
- package/dist/graphify/signature.d.ts.map +1 -1
- package/dist/graphify/signature.js +1 -275
- package/dist/graphify/signature.js.map +1 -1
- package/dist/graphify/types.d.ts +1 -140
- package/dist/graphify/types.d.ts.map +1 -1
- package/dist/graphify/types.js +1 -7
- package/dist/graphify/types.js.map +1 -1
- package/dist/subsystem/IssueList.d.ts.map +1 -1
- package/dist/subsystem/IssueList.js +5 -2
- package/dist/subsystem/IssueList.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +33 -19
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +6 -0
- package/dist/subsystem/containerCard.d.ts.map +1 -1
- package/dist/subsystem/containerCard.js +16 -1
- package/dist/subsystem/containerCard.js.map +1 -1
- package/dist/utils/elkLayout.d.ts +22 -0
- package/dist/utils/elkLayout.d.ts.map +1 -1
- package/dist/utils/elkLayout.js +55 -0
- package/dist/utils/elkLayout.js.map +1 -1
- package/package.json +3 -3
- package/src/graphify/anchor.ts +1 -206
- package/src/graphify/consolidated.ts +1 -298
- package/src/graphify/construct.ts +1 -153
- package/src/graphify/ids.ts +1 -48
- package/src/graphify/resolve.ts +1 -115
- package/src/graphify/signature.ts +1 -354
- package/src/graphify/types.ts +1 -164
- package/src/stories/Canvases/Subsystem/FocusReset.stories.tsx +55 -0
- package/src/stories/Canvases/Subsystem/fixtures/focus-reset-case.json +479 -0
- package/src/subsystem/IssueList.category.test.ts +11 -0
- package/src/subsystem/IssueList.tsx +5 -2
- package/src/subsystem/SubsystemComponentGraph.tsx +47 -19
- package/src/subsystem/containerCard.test.ts +30 -0
- package/src/subsystem/containerCard.tsx +34 -1
- package/src/utils/elkLayout.test.ts +33 -0
- package/src/utils/elkLayout.ts +75 -0
|
@@ -1,354 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Signature / params verification against graphify `references` edges.
|
|
3
|
-
*
|
|
4
|
-
* Graphify does not store arity or parameter names — only `parameter_type` /
|
|
5
|
-
* `return_type` edges to type nodes (unions become multiple edges). Comparison
|
|
6
|
-
* is therefore **named type bags**, not positional arity.
|
|
7
|
-
*
|
|
8
|
-
* Many TS/JS functions have no such edges yet. When graphify has no signature
|
|
9
|
-
* signal, the check is skipped (not a hard fail) so Verify can still gate on
|
|
10
|
-
* kind. When graphify *does* emit types, claimed detail must match.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { GraphifyEdge, GraphifyNode } from './types';
|
|
14
|
-
|
|
15
|
-
/** Inferred signature from graphify edges (no param names). */
|
|
16
|
-
export interface GraphifyInferredSignature {
|
|
17
|
-
parameters: Array<{ type: string; nodeId: string }>;
|
|
18
|
-
returnType?: string;
|
|
19
|
-
returnTypeNodeId?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Types reachable only via `generic_arg` edges (Promise<X>, Array<X>,
|
|
22
|
-
* Omit<X,…>, Map<…>). Kept out of `parameters`/`returnType` — not read
|
|
23
|
-
* by the bag comparison — so skipped cases can be told apart.
|
|
24
|
-
*/
|
|
25
|
-
genericArgs?: Array<{ type: string; nodeId: string }>;
|
|
26
|
-
/**
|
|
27
|
-
* Count of `inline_parameter` self-edges (anonymous object-literal params).
|
|
28
|
-
* Graphify emits one per anon param only with its `--inline-params` flag.
|
|
29
|
-
*/
|
|
30
|
-
inlineParameters?: number;
|
|
31
|
-
/** True when at least one parameter_type or return_type edge exists. */
|
|
32
|
-
hasSignal: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ClaimedSignature {
|
|
36
|
-
parameters?: Array<{ name?: string; type: string }>;
|
|
37
|
-
returnType?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Granular skip classification. `signature_skipped` means "graphify has no
|
|
42
|
-
* parameter_type/return_type edges to compare", but *why* matters for future
|
|
43
|
-
* work:
|
|
44
|
-
* - `no_claimed_types`: authored detail has no named types (primitives/inline).
|
|
45
|
-
* - `generic_arg_only`: claimed types resolve, but only as `generic_arg`
|
|
46
|
-
* (Promise/Omit/Map/Array wrappers) — this extractor does not read them.
|
|
47
|
-
* - `partially_generic_arg`: some, not all, claimed types resolve as generic_arg.
|
|
48
|
-
* - `unresolved_claimed_types`: claimed names have no edges at all
|
|
49
|
-
* (global/npm types, or a dropped same-file label collision).
|
|
50
|
-
*/
|
|
51
|
-
export type SignatureSkipCode =
|
|
52
|
-
| 'no_claimed_types'
|
|
53
|
-
| 'generic_arg_only'
|
|
54
|
-
| 'partially_generic_arg'
|
|
55
|
-
| 'unresolved_claimed_types';
|
|
56
|
-
|
|
57
|
-
export interface SignatureCompareResult {
|
|
58
|
-
match: boolean;
|
|
59
|
-
/** Skipped because graphify had no parameter/return type edges. */
|
|
60
|
-
skipped: boolean;
|
|
61
|
-
reason?: string;
|
|
62
|
-
/** Granular skip classification when `skipped` is true. */
|
|
63
|
-
skipCode?: SignatureSkipCode;
|
|
64
|
-
claimed: { parameterTypes: string[]; returnTypes: string[] };
|
|
65
|
-
inferred: { parameterTypes: string[]; returnTypes: string[] };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const PRIMITIVES = new Set([
|
|
69
|
-
'string',
|
|
70
|
-
'number',
|
|
71
|
-
'boolean',
|
|
72
|
-
'void',
|
|
73
|
-
'null',
|
|
74
|
-
'undefined',
|
|
75
|
-
'any',
|
|
76
|
-
'unknown',
|
|
77
|
-
'never',
|
|
78
|
-
'object',
|
|
79
|
-
'symbol',
|
|
80
|
-
'bigint',
|
|
81
|
-
'true',
|
|
82
|
-
'false',
|
|
83
|
-
'this',
|
|
84
|
-
]);
|
|
85
|
-
|
|
86
|
-
/** Common generic wrappers — keep inner type names, drop the wrapper. */
|
|
87
|
-
const TYPE_WRAPPERS = new Set([
|
|
88
|
-
'Promise',
|
|
89
|
-
'Array',
|
|
90
|
-
'ReadonlyArray',
|
|
91
|
-
'Map',
|
|
92
|
-
'Set',
|
|
93
|
-
'WeakMap',
|
|
94
|
-
'WeakSet',
|
|
95
|
-
'Record',
|
|
96
|
-
'Partial',
|
|
97
|
-
'Required',
|
|
98
|
-
'Readonly',
|
|
99
|
-
'Awaited',
|
|
100
|
-
'NonNullable',
|
|
101
|
-
'ReturnType',
|
|
102
|
-
'Parameters',
|
|
103
|
-
'InstanceType',
|
|
104
|
-
'Pick',
|
|
105
|
-
'Omit',
|
|
106
|
-
'Exclude',
|
|
107
|
-
'Extract',
|
|
108
|
-
]);
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Pull comparable named type identifiers out of an authored / graphify type
|
|
112
|
-
* string. Skips primitives, inline object types, and known wrappers.
|
|
113
|
-
*/
|
|
114
|
-
export function extractNamedTypes(typeStr: string): string[] {
|
|
115
|
-
if (!typeStr || !typeStr.trim()) return [];
|
|
116
|
-
let s = typeStr;
|
|
117
|
-
// Drop string/template literals so their contents aren't tokens.
|
|
118
|
-
s = s.replace(/`(?:\\.|[^`\\])*`/g, ' ');
|
|
119
|
-
s = s.replace(/'(?:\\.|[^'\\])*'/g, ' ');
|
|
120
|
-
s = s.replace(/"(?:\\.|[^"\\])*"/g, ' ');
|
|
121
|
-
// Drop inline object / mapped types (non-greedy, repeated for nesting).
|
|
122
|
-
for (let i = 0; i < 8; i++) {
|
|
123
|
-
const next = s.replace(/\{[^{}]*\}/g, ' ');
|
|
124
|
-
if (next === s) break;
|
|
125
|
-
s = next;
|
|
126
|
-
}
|
|
127
|
-
const found = new Set<string>();
|
|
128
|
-
const re = /[A-Za-z_][A-Za-z0-9_.]*/g;
|
|
129
|
-
let m: RegExpExecArray | null;
|
|
130
|
-
while ((m = re.exec(s)) !== null) {
|
|
131
|
-
const raw = m[0]!;
|
|
132
|
-
const base = raw.includes('.') ? (raw.split('.').pop() ?? raw) : raw;
|
|
133
|
-
if (PRIMITIVES.has(base)) continue;
|
|
134
|
-
if (TYPE_WRAPPERS.has(base)) continue;
|
|
135
|
-
// Skip lone lowercase keywords that aren't types we care about.
|
|
136
|
-
if (base === 'typeof' || base === 'keyof' || base === 'infer' || base === 'extends') {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
found.add(base);
|
|
140
|
-
}
|
|
141
|
-
return [...found].sort();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function labelOf(
|
|
145
|
-
nodeId: string,
|
|
146
|
-
nodesById: ReadonlyMap<string, GraphifyNode>,
|
|
147
|
-
): string {
|
|
148
|
-
const n = nodesById.get(nodeId);
|
|
149
|
-
const label = n && typeof n.label === 'string' ? n.label.trim() : '';
|
|
150
|
-
return label || nodeId;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/** Collect parameter_type / return_type edges for a callable node. */
|
|
154
|
-
export function extractGraphifySignature(
|
|
155
|
-
nodeId: string,
|
|
156
|
-
edges: readonly GraphifyEdge[],
|
|
157
|
-
nodesById: ReadonlyMap<string, GraphifyNode>,
|
|
158
|
-
): GraphifyInferredSignature {
|
|
159
|
-
const id = String(nodeId);
|
|
160
|
-
const parameters: GraphifyInferredSignature['parameters'] = [];
|
|
161
|
-
const genericArgs: GraphifyInferredSignature['genericArgs'] = [];
|
|
162
|
-
let returnType: string | undefined;
|
|
163
|
-
let returnTypeNodeId: string | undefined;
|
|
164
|
-
let inlineParameters = 0;
|
|
165
|
-
|
|
166
|
-
for (const e of edges) {
|
|
167
|
-
if (String(e.source) !== id || e.relation !== 'references') continue;
|
|
168
|
-
const ctx = e.context;
|
|
169
|
-
const target = String(e.target);
|
|
170
|
-
if (ctx === 'parameter_type') {
|
|
171
|
-
parameters.push({ type: labelOf(target, nodesById), nodeId: target });
|
|
172
|
-
} else if (ctx === 'return_type' && returnType === undefined) {
|
|
173
|
-
returnType = labelOf(target, nodesById);
|
|
174
|
-
returnTypeNodeId = target;
|
|
175
|
-
} else if (ctx === 'generic_arg') {
|
|
176
|
-
genericArgs.push({ type: labelOf(target, nodesById), nodeId: target });
|
|
177
|
-
} else if (ctx === 'inline_parameter') {
|
|
178
|
-
inlineParameters += 1;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
parameters,
|
|
184
|
-
genericArgs,
|
|
185
|
-
returnType,
|
|
186
|
-
returnTypeNodeId,
|
|
187
|
-
inlineParameters,
|
|
188
|
-
hasSignal: parameters.length > 0 || returnType !== undefined,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function bagsEqual(a: string[], b: string[]): boolean {
|
|
193
|
-
if (a.length !== b.length) return false;
|
|
194
|
-
for (let i = 0; i < a.length; i++) {
|
|
195
|
-
if (a[i] !== b[i]) return false;
|
|
196
|
-
}
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function claimedBags(claimed: ClaimedSignature | undefined): {
|
|
201
|
-
parameterTypes: string[];
|
|
202
|
-
returnTypes: string[];
|
|
203
|
-
} {
|
|
204
|
-
const parameterTypes = new Set<string>();
|
|
205
|
-
for (const p of claimed?.parameters ?? []) {
|
|
206
|
-
for (const t of extractNamedTypes(p.type)) parameterTypes.add(t);
|
|
207
|
-
}
|
|
208
|
-
const returnTypes = new Set<string>();
|
|
209
|
-
if (claimed?.returnType) {
|
|
210
|
-
for (const t of extractNamedTypes(claimed.returnType)) returnTypes.add(t);
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
parameterTypes: [...parameterTypes].sort(),
|
|
214
|
-
returnTypes: [...returnTypes].sort(),
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function inferredBags(inferred: GraphifyInferredSignature): {
|
|
219
|
-
parameterTypes: string[];
|
|
220
|
-
returnTypes: string[];
|
|
221
|
-
} {
|
|
222
|
-
const parameterTypes = new Set<string>();
|
|
223
|
-
for (const p of inferred.parameters) {
|
|
224
|
-
for (const t of extractNamedTypes(p.type)) parameterTypes.add(t);
|
|
225
|
-
}
|
|
226
|
-
const returnTypes = new Set<string>();
|
|
227
|
-
if (inferred.returnType) {
|
|
228
|
-
for (const t of extractNamedTypes(inferred.returnType)) returnTypes.add(t);
|
|
229
|
-
}
|
|
230
|
-
return {
|
|
231
|
-
parameterTypes: [...parameterTypes].sort(),
|
|
232
|
-
returnTypes: [...returnTypes].sort(),
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Compare authored function/method detail signature to graphify edges.
|
|
238
|
-
*
|
|
239
|
-
* - No graphify signal → skipped (match=true).
|
|
240
|
-
* - Otherwise named-type bags for params and return must match exactly.
|
|
241
|
-
*/
|
|
242
|
-
export function compareSignatures(
|
|
243
|
-
claimed: ClaimedSignature | undefined,
|
|
244
|
-
inferred: GraphifyInferredSignature,
|
|
245
|
-
): SignatureCompareResult {
|
|
246
|
-
const claimedBagsResult = claimedBags(claimed);
|
|
247
|
-
const inferredBagsResult = inferredBags(inferred);
|
|
248
|
-
|
|
249
|
-
// Anonymous object-literal params ("inline") carry no named types, so they
|
|
250
|
-
// only ever surface via graphify's `inline_parameter` markers. A claim of an
|
|
251
|
-
// inline param against a graph with no marker proves nothing (the store
|
|
252
|
-
// graph may predate the flag), so absence alone keeps the skip path. When
|
|
253
|
-
// the graph DOES emit a marker, anon-count parity is compared like any
|
|
254
|
-
// parameter signal.
|
|
255
|
-
const claimedAnonCount = (claimed?.parameters ?? []).filter((p) =>
|
|
256
|
-
(p.type ?? '').trim().startsWith('{'),
|
|
257
|
-
).length;
|
|
258
|
-
const inferredAnonCount = inferred.inlineParameters ?? 0;
|
|
259
|
-
const hasAnonSignal = inferredAnonCount > 0;
|
|
260
|
-
|
|
261
|
-
if (!inferred.hasSignal && !hasAnonSignal) {
|
|
262
|
-
const claimedTypes = new Set<string>([
|
|
263
|
-
...claimedBagsResult.parameterTypes,
|
|
264
|
-
...claimedBagsResult.returnTypes,
|
|
265
|
-
]);
|
|
266
|
-
const genericArgTypes = new Set(
|
|
267
|
-
(inferred.genericArgs ?? []).map((a) => a.type),
|
|
268
|
-
);
|
|
269
|
-
const sorted = [...claimedTypes].sort();
|
|
270
|
-
let skipCode: SignatureSkipCode;
|
|
271
|
-
let reason: string;
|
|
272
|
-
if (sorted.length === 0) {
|
|
273
|
-
skipCode = 'no_claimed_types';
|
|
274
|
-
reason = 'no claimable named types in authored signature (primitives/inline only)';
|
|
275
|
-
} else {
|
|
276
|
-
const found = sorted.filter((t) => genericArgTypes.has(t));
|
|
277
|
-
if (found.length === sorted.length) {
|
|
278
|
-
skipCode = 'generic_arg_only';
|
|
279
|
-
reason = `claimed types ([${sorted.join(', ')}]) present only as generic_arg (wrapper-indirected: Promise/Omit/Map/Array) — extractor does not read generic_arg`;
|
|
280
|
-
} else if (found.length > 0) {
|
|
281
|
-
skipCode = 'partially_generic_arg';
|
|
282
|
-
reason = `claimed types resolve only via generic_arg for ${found.join(', ')}; rest unresolved (${sorted.filter((t) => !genericArgTypes.has(t)).join(', ')})`;
|
|
283
|
-
} else {
|
|
284
|
-
skipCode = 'unresolved_claimed_types';
|
|
285
|
-
reason = `claimed types ([${sorted.join(', ')}]) have no parameter_type/return_type/generic_arg edges (global/npm types or dropped same-file label collision)`;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return {
|
|
289
|
-
match: true,
|
|
290
|
-
skipped: true,
|
|
291
|
-
reason,
|
|
292
|
-
skipCode,
|
|
293
|
-
claimed: claimedBagsResult,
|
|
294
|
-
inferred: inferredBagsResult,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const paramsOk = bagsEqual(
|
|
299
|
-
claimedBagsResult.parameterTypes,
|
|
300
|
-
inferredBagsResult.parameterTypes,
|
|
301
|
-
);
|
|
302
|
-
const anonParamsOk = claimedAnonCount === inferredAnonCount;
|
|
303
|
-
const returnOk = bagsEqual(
|
|
304
|
-
claimedBagsResult.returnTypes,
|
|
305
|
-
inferredBagsResult.returnTypes,
|
|
306
|
-
);
|
|
307
|
-
const match = paramsOk && anonParamsOk && returnOk;
|
|
308
|
-
if (paramsOk && anonParamsOk && !returnOk) {
|
|
309
|
-
// Params verified, but the claimed return types can't be backed. When
|
|
310
|
-
// every claimed return type is either wrapper-indirected (generic_arg:
|
|
311
|
-
// Promise<X>, Omit<X,…>) or entirely unresolved (global/npm/DOM types),
|
|
312
|
-
// that's a coverage gap, not a lie — mark the check skipped instead of
|
|
313
|
-
// hard-failing, mirroring the pre-signal skip classification. A mixed
|
|
314
|
-
// bag (some generic, some unresolved) stays a hard mismatch.
|
|
315
|
-
const claimReturn = claimedBagsResult.returnTypes;
|
|
316
|
-
if (claimReturn.length > 0) {
|
|
317
|
-
const genericArgTypes = new Set(
|
|
318
|
-
(inferred.genericArgs ?? []).map((a) => a.type),
|
|
319
|
-
);
|
|
320
|
-
const gen = claimReturn.filter((t) => genericArgTypes.has(t));
|
|
321
|
-
const unresolved = claimReturn.filter((t) => !genericArgTypes.has(t));
|
|
322
|
-
let skipCode: SignatureSkipCode | undefined;
|
|
323
|
-
let reason: string | undefined;
|
|
324
|
-
if (gen.length === claimReturn.length) {
|
|
325
|
-
skipCode = 'generic_arg_only';
|
|
326
|
-
reason = `claimed return types ([${claimReturn.join(', ')}]) present only as generic_arg (wrapper-indirected: Promise/Omit/Map/Array) — extractor does not read generic_arg; params verified`;
|
|
327
|
-
} else if (unresolved.length === claimReturn.length) {
|
|
328
|
-
skipCode = 'unresolved_claimed_types';
|
|
329
|
-
reason = `claimed return types ([${claimReturn.join(', ')}]) have no parameter_type/return_type/generic_arg edges (global/npm types or dropped same-file label collision); params verified`;
|
|
330
|
-
}
|
|
331
|
-
if (skipCode) {
|
|
332
|
-
return {
|
|
333
|
-
match: true,
|
|
334
|
-
skipped: true,
|
|
335
|
-
reason,
|
|
336
|
-
skipCode,
|
|
337
|
-
claimed: claimedBagsResult,
|
|
338
|
-
inferred: inferredBagsResult,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
match,
|
|
345
|
-
skipped: false,
|
|
346
|
-
reason: match
|
|
347
|
-
? undefined
|
|
348
|
-
: !paramsOk || !anonParamsOk
|
|
349
|
-
? 'parameter_types_mismatch'
|
|
350
|
-
: 'return_type_mismatch',
|
|
351
|
-
claimed: claimedBagsResult,
|
|
352
|
-
inferred: inferredBagsResult,
|
|
353
|
-
};
|
|
354
|
-
}
|
|
1
|
+
export * from '@principal-ai/subsystems-core/graphify/signature';
|
package/src/graphify/types.ts
CHANGED
|
@@ -1,164 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Graphify graph.json schema types.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the graphify data model (graphify/validate.py, graphify/export.py)
|
|
5
|
-
* so graphify output can be consumed by this library in a type-compatible way.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** Any JSON-serializable value carried in node/edge metadata. */
|
|
9
|
-
export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
|
10
|
-
|
|
11
|
-
/** Node classification (graphify/validate.py VALID_FILE_TYPES). */
|
|
12
|
-
export type GraphifyFileType = 'code' | 'document' | 'paper' | 'image' | 'rationale' | 'concept';
|
|
13
|
-
|
|
14
|
-
/** Edge provenance tag (graphify/validate.py VALID_CONFIDENCES). */
|
|
15
|
-
export type GraphifyConfidence = 'EXTRACTED' | 'INFERRED' | 'AMBIGUOUS';
|
|
16
|
-
|
|
17
|
-
/** Optional semantic kind carried on nodes (e.g. `module`, `namespace`). */
|
|
18
|
-
export type GraphifyNodeType = 'module' | 'namespace' | string;
|
|
19
|
-
|
|
20
|
-
/** Canonical relation verbs emitted by graphify extractors and resolvers. */
|
|
21
|
-
export type GraphifyRelation =
|
|
22
|
-
| 'calls'
|
|
23
|
-
| 'imports'
|
|
24
|
-
| 'imports_from'
|
|
25
|
-
| 're_exports'
|
|
26
|
-
| 'references'
|
|
27
|
-
| 'inherits'
|
|
28
|
-
| 'implements'
|
|
29
|
-
| 'mixes_in'
|
|
30
|
-
| 'uses'
|
|
31
|
-
| 'contains'
|
|
32
|
-
| 'defines'
|
|
33
|
-
| 'method'
|
|
34
|
-
| 'decorator'
|
|
35
|
-
| 'rationale_for'
|
|
36
|
-
| 'semantically_similar_to'
|
|
37
|
-
| string;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A graphify node.
|
|
41
|
-
*
|
|
42
|
-
* Required fields are enforced by graphify/validate.py:
|
|
43
|
-
* `id`, `label`, `file_type`, `source_file`. The rest are populated by the
|
|
44
|
-
* extractors (`source_location`, optional `type`/`metadata`) and by the build
|
|
45
|
-
* writer (`community`, `community_name`, `norm_label`).
|
|
46
|
-
*/
|
|
47
|
-
export interface GraphifyNode {
|
|
48
|
-
/** Stable identifier: repo-relative path + symbol names (make_id slug). */
|
|
49
|
-
id: string;
|
|
50
|
-
/** Human-readable name. */
|
|
51
|
-
label: string;
|
|
52
|
-
/** Classification used as the primary node kind. */
|
|
53
|
-
file_type: GraphifyFileType;
|
|
54
|
-
/** Repo-relative path of the source file this node came from. */
|
|
55
|
-
source_file: string;
|
|
56
|
-
/** `L<line>` location, or `''` for sourceless stub nodes. */
|
|
57
|
-
source_location?: string | null;
|
|
58
|
-
/** Optional semantic kind (e.g. `module`, `namespace`). */
|
|
59
|
-
type?: GraphifyNodeType;
|
|
60
|
-
/** Node state / extra node definitions. */
|
|
61
|
-
state?: string;
|
|
62
|
-
/** Arbitrary per-extractor metadata (e.g. `{ kind: "csharp_namespace" }`). */
|
|
63
|
-
metadata?: Record<string, JsonValue>;
|
|
64
|
-
/** Leiden community id, stamped at build time. */
|
|
65
|
-
community?: number | null;
|
|
66
|
-
/** Human-readable community label, stamped at build time. */
|
|
67
|
-
community_name?: string;
|
|
68
|
-
/** Diacritic-stripped lowercased label, stamped at build time. */
|
|
69
|
-
norm_label?: string;
|
|
70
|
-
/** Extra fields tolerated for forward compatibility. */
|
|
71
|
-
[key: string]: unknown;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* A graphify edge.
|
|
76
|
-
*
|
|
77
|
-
* Required fields: `source`, `target`, `relation`, `confidence`, `source_file`.
|
|
78
|
-
* `context` is populated for `references` edges (e.g. `type`, `return_type`,
|
|
79
|
-
* `field`, `generic_arg`).
|
|
80
|
-
*/
|
|
81
|
-
export interface GraphifyEdge {
|
|
82
|
-
/** Source node id. */
|
|
83
|
-
source: string;
|
|
84
|
-
/** Target node id. */
|
|
85
|
-
target: string;
|
|
86
|
-
/** Canonical relation verb. */
|
|
87
|
-
relation: GraphifyRelation;
|
|
88
|
-
/** Provenance: read directly from source vs. resolved by graphify. */
|
|
89
|
-
confidence: GraphifyConfidence;
|
|
90
|
-
/** Float 0.0-1.0; 1.0 for EXTRACTED, discrete rubric for INFERRED. */
|
|
91
|
-
confidence_score?: number;
|
|
92
|
-
/** Repo-relative path where the relationship was found. */
|
|
93
|
-
source_file: string;
|
|
94
|
-
/** `L<line>` location of the relationship. */
|
|
95
|
-
source_location?: string | null;
|
|
96
|
-
/** Edge weight. */
|
|
97
|
-
weight?: number;
|
|
98
|
-
/** Reference context for `references` edges. */
|
|
99
|
-
context?: string;
|
|
100
|
-
/** Arbitrary per-extractor metadata. */
|
|
101
|
-
metadata?: Record<string, JsonValue>;
|
|
102
|
-
/** Extra fields tolerated for forward compatibility. */
|
|
103
|
-
[key: string]: unknown;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* A graphify hyperedge — a group relationship connecting 3+ nodes.
|
|
108
|
-
*
|
|
109
|
-
* Member list is canonical on `nodes` (aliases `members`/`node_ids` are folded
|
|
110
|
-
* by graphify/export.py build normalization).
|
|
111
|
-
*/
|
|
112
|
-
export interface GraphifyHyperedge {
|
|
113
|
-
/** Stable identifier. */
|
|
114
|
-
id: string;
|
|
115
|
-
/** Human-readable label. */
|
|
116
|
-
label?: string;
|
|
117
|
-
/** Member node ids (canonical key). */
|
|
118
|
-
nodes: string[];
|
|
119
|
-
/** Group relation verb (e.g. `participate_in`, `implement`, `form`). */
|
|
120
|
-
relation?: GraphifyRelation;
|
|
121
|
-
/** Provenance tag. */
|
|
122
|
-
confidence?: GraphifyConfidence;
|
|
123
|
-
/** Float 0.0-1.0. */
|
|
124
|
-
confidence_score?: number;
|
|
125
|
-
/** Repo-relative path where the relationship was found. */
|
|
126
|
-
source_file?: string;
|
|
127
|
-
/** Extra fields tolerated for forward compatibility. */
|
|
128
|
-
[key: string]: unknown;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Graph-level metadata stored on the graph (`graph` key). */
|
|
132
|
-
export interface GraphifyGraphMetadata {
|
|
133
|
-
directed?: boolean;
|
|
134
|
-
multigraph?: boolean;
|
|
135
|
-
/** Edges may be serialized under `links` (NetworkX node-link) or `edges`. */
|
|
136
|
-
hyperedges?: GraphifyHyperedge[];
|
|
137
|
-
[key: string]: unknown;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* The full graph.json document.
|
|
142
|
-
*
|
|
143
|
-
* graphify writes NetworkX node-link format: nodes under `nodes`, edges under
|
|
144
|
-
* `links`. Older/legacy payloads may use `edges` instead of `links`.
|
|
145
|
-
*/
|
|
146
|
-
export interface GraphifyGraph {
|
|
147
|
-
/** Graph nodes. */
|
|
148
|
-
nodes: GraphifyNode[];
|
|
149
|
-
/** Graph edges (NetworkX node-link key). */
|
|
150
|
-
links?: GraphifyEdge[];
|
|
151
|
-
/** Legacy alias for `links`. */
|
|
152
|
-
edges?: GraphifyEdge[];
|
|
153
|
-
/** Group relationships connecting 3+ nodes. */
|
|
154
|
-
hyperedges?: GraphifyHyperedge[];
|
|
155
|
-
/** Graph-level metadata (directed, multigraph, hyperedges). */
|
|
156
|
-
graph?: GraphifyGraphMetadata;
|
|
157
|
-
/** Top-level directed flag (NetworkX). */
|
|
158
|
-
directed?: boolean;
|
|
159
|
-
/** Top-level multigraph flag (NetworkX). */
|
|
160
|
-
multigraph?: boolean;
|
|
161
|
-
/** Git HEAD the graph was built against, when available. */
|
|
162
|
-
built_at_commit?: string;
|
|
163
|
-
[key: string]: unknown;
|
|
164
|
-
}
|
|
1
|
+
export * from '@principal-ai/subsystems-core/graphify/types';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import '@xyflow/react/dist/style.css';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
4
|
+
import { SubsystemComponentGraph } from '../../../subsystem/SubsystemComponentGraph';
|
|
5
|
+
import type { SubsystemComponent, SubsystemTrail } from '../../../subsystem/model';
|
|
6
|
+
import fixture from './fixtures/focus-reset-case.json';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Canvases/Subsystem/Regression/Focus reset edge bounds',
|
|
10
|
+
component: SubsystemComponentGraph,
|
|
11
|
+
parameters: { layout: 'fullscreen' },
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
decorators: [
|
|
14
|
+
(Story) => (
|
|
15
|
+
<ThemeProvider theme={defaultEditorTheme}>
|
|
16
|
+
<Story />
|
|
17
|
+
</ThemeProvider>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
} satisfies Meta<typeof SubsystemComponentGraph>;
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
const components = fixture.components as unknown as SubsystemComponent[];
|
|
26
|
+
const trails = fixture.trails as unknown as SubsystemTrail[];
|
|
27
|
+
|
|
28
|
+
export const AuditModel: Story = {
|
|
29
|
+
render: () => (
|
|
30
|
+
<div style={{ width: '100%', height: '100vh', display: 'flex', flexDirection: 'column' }}>
|
|
31
|
+
<div
|
|
32
|
+
style={{
|
|
33
|
+
flex: '0 0 auto',
|
|
34
|
+
padding: '10px 16px',
|
|
35
|
+
borderBottom: '1px solid #333',
|
|
36
|
+
background: '#141414',
|
|
37
|
+
color: '#ddd',
|
|
38
|
+
font: '12px/1.5 monospace',
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
Regression case: focus any trail, then click its <strong>Collapse</strong> chevron
|
|
42
|
+
to clear focus and fit the overview. The route and labels should remain inside the canvas.
|
|
43
|
+
</div>
|
|
44
|
+
<div style={{ flex: 1, minHeight: 0 }}>
|
|
45
|
+
<SubsystemComponentGraph
|
|
46
|
+
components={components}
|
|
47
|
+
trails={trails}
|
|
48
|
+
title="Subsystem audit"
|
|
49
|
+
description="Focus a trail, then collapse it to reset to the full graph."
|
|
50
|
+
showEdgeLabels
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
),
|
|
55
|
+
};
|