@principal-ai/subsystems-react 0.25.0 → 0.25.1
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/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +30 -1
- package/dist/subsystem/model.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Subsystem/ComponentDeclarationAudit.stories.tsx +13 -13
- package/src/stories/Subsystem/ComponentGraph/Appearance.stories.tsx +17 -17
- package/src/stories/Subsystem/ComponentGraph/Basics.stories.tsx +2 -2
- package/src/stories/Subsystem/ComponentGraph/Captures.stories.tsx +3 -3
- package/src/stories/Subsystem/ComponentGraph/Constructs.stories.tsx +6 -6
- package/src/stories/Subsystem/ComponentGraph/CustomEntities.stories.tsx +8 -8
- package/src/stories/Subsystem/ComponentGraph/DetailPanel.stories.tsx +11 -11
- package/src/stories/Subsystem/ComponentGraph/Flows.stories.tsx +6 -6
- package/src/stories/Subsystem/ComponentGraph/FrameworkStereotype.stories.tsx +10 -10
- package/src/stories/Subsystem/ComponentGraph/ModuleBadges.stories.tsx +6 -6
- package/src/stories/Subsystem/ComponentGraph/Modules.stories.tsx +17 -17
- package/src/stories/Subsystem/ComponentGraph/NodeAnatomy.stories.tsx +16 -16
- package/src/stories/Subsystem/ComponentGraph/Packages.stories.tsx +12 -12
- package/src/stories/Subsystem/ComponentGraph/Processes.stories.tsx +1 -1
- package/src/stories/Subsystem/ComponentGraph/Proposed.stories.tsx +10 -10
- package/src/stories/Subsystem/ComponentGraph/Scenarios.stories.tsx +69 -69
- package/src/stories/Subsystem/ComponentGraph/Spotlights.stories.tsx +27 -27
- package/src/subsystem/model.test.ts +46 -0
- package/src/subsystem/model.ts +31 -1
|
@@ -149,7 +149,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
149
149
|
label: 'construct: type_alias — a type alias',
|
|
150
150
|
note: 'the `type` keyword form: `type X = { … }` or a union — anything `=`-assigned',
|
|
151
151
|
component: {
|
|
152
|
-
|
|
152
|
+
alias: 'alias-status',
|
|
153
153
|
name: 'AnalysisStatus',
|
|
154
154
|
construct: 'type_alias',
|
|
155
155
|
file: 'packages/subsystems-studio/src/bun/analysis.ts',
|
|
@@ -170,7 +170,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
170
170
|
label: 'role: entry on construct: type — contract as entry',
|
|
171
171
|
note: 'same role, different inherited anatomy — entries are topology, not shape',
|
|
172
172
|
component: {
|
|
173
|
-
|
|
173
|
+
alias: 'ipc-entry',
|
|
174
174
|
name: 'StudioMessages',
|
|
175
175
|
construct: 'interface',
|
|
176
176
|
file: 'packages/subsystems-studio/src/shared/contract.ts',
|
|
@@ -183,7 +183,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
183
183
|
label: 'construct: enum — runtime values + a type',
|
|
184
184
|
note: 'the one type-family form that exists at runtime; members render in the drill-down',
|
|
185
185
|
component: {
|
|
186
|
-
|
|
186
|
+
alias: 'enum-phase',
|
|
187
187
|
name: 'VerificationPhase',
|
|
188
188
|
construct: 'enum',
|
|
189
189
|
file: 'packages/subsystems-studio/src/bun/verify.ts',
|
|
@@ -201,7 +201,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
201
201
|
label: 'construct: function — plain accessor',
|
|
202
202
|
note: 'indigo; the default for anchored behavior',
|
|
203
203
|
component: {
|
|
204
|
-
|
|
204
|
+
alias: 'create',
|
|
205
205
|
name: 'createSubsystemModel',
|
|
206
206
|
construct: 'function',
|
|
207
207
|
file: 'packages/subsystems-studio/src/bun/subsystem-model-store.ts',
|
|
@@ -213,7 +213,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
213
213
|
label: 'framework: react · stereotype: component — still construct: function',
|
|
214
214
|
note: 'badge reads "react · component"; name renders bare ; color stays function',
|
|
215
215
|
component: {
|
|
216
|
-
|
|
216
|
+
alias: 'analysis-view',
|
|
217
217
|
name: 'AnalysisView',
|
|
218
218
|
construct: 'function',
|
|
219
219
|
file: 'packages/subsystems-studio/src/mainview/views/AnalysisView.tsx',
|
|
@@ -228,7 +228,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
228
228
|
label: 'framework: react · stereotype: hook',
|
|
229
229
|
note: 'same construct, different stereotype — badge "react · hook", keeps ()',
|
|
230
230
|
component: {
|
|
231
|
-
|
|
231
|
+
alias: 'drawings-host',
|
|
232
232
|
name: 'useDrawingsHost',
|
|
233
233
|
construct: 'function',
|
|
234
234
|
file: 'packages/subsystems-studio/src/mainview/hooks/useDrawingsHost.ts',
|
|
@@ -242,7 +242,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
242
242
|
label: 'role: entry on construct: function — boundary element',
|
|
243
243
|
note: 'orange overrides construct:color; anatomy inherited from the function',
|
|
244
244
|
component: {
|
|
245
|
-
|
|
245
|
+
alias: 'http-entry',
|
|
246
246
|
name: 'HTTP bridge :3045',
|
|
247
247
|
construct: 'function',
|
|
248
248
|
file: 'packages/subsystems-studio/src/bun/http-server.ts',
|
|
@@ -255,7 +255,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
255
255
|
label: 'construct: class — declaration anatomy',
|
|
256
256
|
note: 'blue; drill-down renders the real class stub with its methods',
|
|
257
257
|
component: {
|
|
258
|
-
|
|
258
|
+
alias: 'cache',
|
|
259
259
|
name: 'SessionCache',
|
|
260
260
|
construct: 'class',
|
|
261
261
|
file: 'src/session/SessionCache.ts',
|
|
@@ -276,7 +276,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
276
276
|
label: 'construct: method — a function bound to its class',
|
|
277
277
|
note: 'dotted symbol (SessionCache.put) is the identity; drill-down renders it inside a host-class stub',
|
|
278
278
|
component: {
|
|
279
|
-
|
|
279
|
+
alias: 'method-put',
|
|
280
280
|
name: 'put',
|
|
281
281
|
construct: 'method',
|
|
282
282
|
file: 'src/session/SessionCache.ts',
|
|
@@ -293,7 +293,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
293
293
|
label: 'construct: store — state-block anatomy',
|
|
294
294
|
note: 'green = the store construct:color; drill-down renders declare const state, never a class stub',
|
|
295
295
|
component: {
|
|
296
|
-
|
|
296
|
+
alias: 'store',
|
|
297
297
|
name: 'Graph Store',
|
|
298
298
|
construct: 'store',
|
|
299
299
|
file: 'packages/subsystems-studio/src/bun/subsystem-model-store.ts',
|
|
@@ -306,7 +306,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
306
306
|
label: 'construct: external — actor outside every boundary',
|
|
307
307
|
note: 'purple; no process → drawn outside all regions',
|
|
308
308
|
component: {
|
|
309
|
-
|
|
309
|
+
alias: 'agents',
|
|
310
310
|
name: 'agent clients',
|
|
311
311
|
construct: 'external',
|
|
312
312
|
file: '',
|
|
@@ -317,7 +317,7 @@ const nodeSpotlights: Array<{ label: string; component: SubsystemComponent; note
|
|
|
317
317
|
label: 'role: service on construct: external — far-side boundary element',
|
|
318
318
|
note: 'colored by its construct (external); identity via purl, no source at all',
|
|
319
319
|
component: {
|
|
320
|
-
|
|
320
|
+
alias: 'github',
|
|
321
321
|
name: 'api.github.com',
|
|
322
322
|
construct: 'external',
|
|
323
323
|
file: '',
|
|
@@ -332,7 +332,7 @@ function NodeSpotlightsDemo() {
|
|
|
332
332
|
const { mode } = useTheme();
|
|
333
333
|
const constructColors = constructColorsFromPierreTheme(resolvePierreSyntaxThemeName(mode));
|
|
334
334
|
const [activeIds, setActiveIds] = useState<Set<string>>(
|
|
335
|
-
() => new Set(nodeSpotlights.map((n) => n.component.
|
|
335
|
+
() => new Set(nodeSpotlights.map((n) => n.component.alias)),
|
|
336
336
|
);
|
|
337
337
|
const toggle = (id: string) =>
|
|
338
338
|
setActiveIds((prev) => {
|
|
@@ -344,7 +344,7 @@ function NodeSpotlightsDemo() {
|
|
|
344
344
|
}
|
|
345
345
|
return next;
|
|
346
346
|
});
|
|
347
|
-
const visible = nodeSpotlights.filter((n) => activeIds.has(n.component.
|
|
347
|
+
const visible = nodeSpotlights.filter((n) => activeIds.has(n.component.alias));
|
|
348
348
|
|
|
349
349
|
return (
|
|
350
350
|
<div style={{ padding: 20, overflow: 'auto', height: '100vh', boxSizing: 'border-box', background: '#0f1216' }}>
|
|
@@ -358,7 +358,7 @@ function NodeSpotlightsDemo() {
|
|
|
358
358
|
show:
|
|
359
359
|
</span>
|
|
360
360
|
{nodeSpotlights.map(({ component }) => {
|
|
361
|
-
const on = activeIds.has(component.
|
|
361
|
+
const on = activeIds.has(component.alias);
|
|
362
362
|
const color = constructColors[component.construct];
|
|
363
363
|
const chip = component.stereotype
|
|
364
364
|
? component.framework
|
|
@@ -369,9 +369,9 @@ function NodeSpotlightsDemo() {
|
|
|
369
369
|
: component.construct;
|
|
370
370
|
return (
|
|
371
371
|
<button
|
|
372
|
-
key={component.
|
|
372
|
+
key={component.alias}
|
|
373
373
|
type="button"
|
|
374
|
-
onClick={() => toggle(component.
|
|
374
|
+
onClick={() => toggle(component.alias)}
|
|
375
375
|
style={{
|
|
376
376
|
fontFamily: 'monospace',
|
|
377
377
|
fontSize: 11,
|
|
@@ -390,7 +390,7 @@ function NodeSpotlightsDemo() {
|
|
|
390
390
|
})}
|
|
391
391
|
<button
|
|
392
392
|
type="button"
|
|
393
|
-
onClick={() => setActiveIds(new Set(nodeSpotlights.map((n) => n.component.
|
|
393
|
+
onClick={() => setActiveIds(new Set(nodeSpotlights.map((n) => n.component.alias)))}
|
|
394
394
|
style={{ fontFamily: 'monospace', fontSize: 11, cursor: 'pointer', padding: '4px 10px', borderRadius: 999, border: '1px solid #2c313a', background: 'transparent', color: '#9ca3af' }}
|
|
395
395
|
>
|
|
396
396
|
all
|
|
@@ -410,7 +410,7 @@ function NodeSpotlightsDemo() {
|
|
|
410
410
|
</div>
|
|
411
411
|
)}
|
|
412
412
|
{visible.map(({ label, component, note }) => (
|
|
413
|
-
<div key={component.
|
|
413
|
+
<div key={component.alias}>
|
|
414
414
|
<div style={{ fontFamily: 'monospace', fontSize: 11, color: '#6b7280', margin: '10px 2px 6px' }}>
|
|
415
415
|
{label} — {note}
|
|
416
416
|
</div>
|
|
@@ -490,7 +490,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
490
490
|
label: 'store detail → state block',
|
|
491
491
|
note: 'declare const lines — honest to module-level state; no class stub, no methods',
|
|
492
492
|
component: {
|
|
493
|
-
|
|
493
|
+
alias: 'store',
|
|
494
494
|
name: 'Graph Store',
|
|
495
495
|
construct: 'store',
|
|
496
496
|
file: 'packages/subsystems-studio/src/bun/subsystem-model-store.ts',
|
|
@@ -510,7 +510,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
510
510
|
label: 'class detail → class stub',
|
|
511
511
|
note: 'the verifiable access mechanism — methods with typed params + returns',
|
|
512
512
|
component: {
|
|
513
|
-
|
|
513
|
+
alias: 'cache',
|
|
514
514
|
name: 'SessionCache',
|
|
515
515
|
construct: 'class',
|
|
516
516
|
file: 'src/session/SessionCache.ts',
|
|
@@ -534,7 +534,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
534
534
|
label: 'function detail → signature',
|
|
535
535
|
note: 'params + return type, callers/callees intentionally not rendered (edges carry them)',
|
|
536
536
|
component: {
|
|
537
|
-
|
|
537
|
+
alias: 'get',
|
|
538
538
|
name: 'getSubsystemModel',
|
|
539
539
|
construct: 'function',
|
|
540
540
|
file: 'packages/subsystems-studio/src/bun/subsystem-model-store.ts',
|
|
@@ -553,7 +553,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
553
553
|
label: 'type detail → interface fields',
|
|
554
554
|
note: 'the IPC contract as an entry: anatomy inherited from the type',
|
|
555
555
|
component: {
|
|
556
|
-
|
|
556
|
+
alias: 'ipc-entry',
|
|
557
557
|
name: 'StudioMessages',
|
|
558
558
|
construct: 'interface',
|
|
559
559
|
file: 'packages/subsystems-studio/src/shared/contract.ts',
|
|
@@ -575,7 +575,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
575
575
|
label: 'method detail → method in host-class stub',
|
|
576
576
|
note: 'the class is context, the method is the node — same anatomy a standalone function gets, plus the owning class',
|
|
577
577
|
component: {
|
|
578
|
-
|
|
578
|
+
alias: 'anatomy-method',
|
|
579
579
|
name: 'put',
|
|
580
580
|
construct: 'method',
|
|
581
581
|
file: 'src/session/SessionCache.ts',
|
|
@@ -593,7 +593,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
593
593
|
label: 'type_alias detail → braced alias',
|
|
594
594
|
note: 'the alias renders as `type X = { … }` — the honest keyword form',
|
|
595
595
|
component: {
|
|
596
|
-
|
|
596
|
+
alias: 'anatomy-alias',
|
|
597
597
|
name: 'AnalysisStatus',
|
|
598
598
|
construct: 'type_alias',
|
|
599
599
|
file: 'packages/subsystems-studio/src/bun/analysis.ts',
|
|
@@ -611,7 +611,7 @@ const anatomyComponents: Array<{ label: string; component: SubsystemComponent; n
|
|
|
611
611
|
label: 'enum detail → enum declaration',
|
|
612
612
|
note: 'members render inline — the runtime type',
|
|
613
613
|
component: {
|
|
614
|
-
|
|
614
|
+
alias: 'anatomy-enum',
|
|
615
615
|
name: 'VerificationPhase',
|
|
616
616
|
construct: 'enum',
|
|
617
617
|
file: 'packages/subsystems-studio/src/bun/verify.ts',
|
|
@@ -634,7 +634,7 @@ function AnatomySpotlightsDemo() {
|
|
|
634
634
|
anatomy spotlights — data (left) → the drill-down panel you get on click (right).
|
|
635
635
|
</div>
|
|
636
636
|
{anatomyComponents.map(({ label, component, note }) => (
|
|
637
|
-
<div key={component.
|
|
637
|
+
<div key={component.alias}>
|
|
638
638
|
<div style={{ fontFamily: 'monospace', fontSize: 11, color: '#6b7280', margin: '10px 2px 6px' }}>
|
|
639
639
|
{label} — {note}
|
|
640
640
|
</div>
|
|
@@ -626,6 +626,52 @@ describe('subsystem graph model', () => {
|
|
|
626
626
|
expect(groups.filter((g) => g.region.kind === 'package')).toHaveLength(1);
|
|
627
627
|
});
|
|
628
628
|
|
|
629
|
+
test('mixed-process module members live only in the module frame', () => {
|
|
630
|
+
// Same file framed under two processes (composed-model vocabulary drift):
|
|
631
|
+
// the module cannot nest, so its members must not also sit directly in
|
|
632
|
+
// the process frames — ELK throws on double-parented leaves.
|
|
633
|
+
const groups = buildBoundaryLayoutGroups({
|
|
634
|
+
components: [
|
|
635
|
+
{ alias: 'a1', name: 'a1', construct: 'function', file: 'a.ts', purl: 'pkg:github/acme/app', module: 'src/a.ts', process: 'app/host' },
|
|
636
|
+
{ alias: 'a2', name: 'a2', construct: 'function', file: 'a.ts', purl: 'pkg:github/acme/app', module: 'src/a.ts', process: 'app/renderer' },
|
|
637
|
+
{ alias: 'b1', name: 'b1', construct: 'function', file: 'b.ts', purl: 'pkg:github/acme/app', process: 'app/host' },
|
|
638
|
+
],
|
|
639
|
+
});
|
|
640
|
+
const leafHits = new Map<string, string[]>();
|
|
641
|
+
for (const g of groups) {
|
|
642
|
+
for (const id of g.memberAliases) {
|
|
643
|
+
// Nested group ids legitimately appear in parents; only leaves count.
|
|
644
|
+
if (groups.some((h) => h.id === id)) continue;
|
|
645
|
+
leafHits.set(id, [...(leafHits.get(id) ?? []), g.id]);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
for (const [leaf, owners] of leafHits) {
|
|
649
|
+
expect(`${leaf} in ${owners.length} groups: ${owners.join(',')}`).toBe(`${leaf} in 1 groups: ${owners[0]}`);
|
|
650
|
+
}
|
|
651
|
+
const mod = groups.find((g) => g.region.kind === 'module');
|
|
652
|
+
expect(mod?.memberAliases).toEqual(['a1', 'a2']);
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
test('module-less leaf in a mixed-package process lives only in the process frame', () => {
|
|
656
|
+
const groups = buildBoundaryLayoutGroups({
|
|
657
|
+
components: [
|
|
658
|
+
{ alias: 'x', name: 'x', construct: 'function', file: 'x.ts', purl: 'pkg:github/acme/app', process: 'app/host' },
|
|
659
|
+
{ alias: 'y', name: 'y', construct: 'function', file: 'y.ts', purl: 'pkg:github/acme/app', process: 'app/host' },
|
|
660
|
+
{ alias: 'z', name: 'z', construct: 'function', file: 'z.ts', purl: 'pkg:github/other/lib', process: 'app/host' },
|
|
661
|
+
],
|
|
662
|
+
});
|
|
663
|
+
const leafHits = new Map<string, string[]>();
|
|
664
|
+
for (const g of groups) {
|
|
665
|
+
for (const id of g.memberAliases) {
|
|
666
|
+
if (groups.some((h) => h.id === id)) continue;
|
|
667
|
+
leafHits.set(id, [...(leafHits.get(id) ?? []), g.id]);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
for (const [leaf, owners] of leafHits) {
|
|
671
|
+
expect(owners).toHaveLength(1);
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
|
|
629
675
|
test('subsystemGraphLayoutKey ignores declarationRef-only changes', () => {
|
|
630
676
|
const base = doc;
|
|
631
677
|
const withRef = {
|
package/src/subsystem/model.ts
CHANGED
|
@@ -717,6 +717,30 @@ export function buildBoundaryLayoutGroups(
|
|
|
717
717
|
);
|
|
718
718
|
const keptProcessKeys = new Set(processes.map((r) => r.key));
|
|
719
719
|
|
|
720
|
+
// Leaves owned by a multi-member module belong to that module's frame
|
|
721
|
+
// exclusively. Multi-member modules are always built by ELK (never skipped
|
|
722
|
+
// as singletons), so letting a process/package group also list them
|
|
723
|
+
// directly would parent the same leaf twice and ELK throws
|
|
724
|
+
// ("value already present"). Mixed-process modules (common in composed
|
|
725
|
+
// graphs, where models frame one file under different processes) never
|
|
726
|
+
// nest — without this claim they land in both frames.
|
|
727
|
+
const claimedByModule = new Set<string>();
|
|
728
|
+
for (const r of modules) {
|
|
729
|
+
if (r.memberAliases.length >= 2) {
|
|
730
|
+
for (const alias of r.memberAliases) claimedByModule.add(alias);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
// Same rule one level up: a leaf owned by a multi-member process frame
|
|
734
|
+
// must not also sit directly in a package frame. (Singleton processes
|
|
735
|
+
// never claim — ELK skips them and promotes the member upward, so the
|
|
736
|
+
// member has to stay reachable through its package or ungrouped.)
|
|
737
|
+
const claimedByProcess = new Set<string>();
|
|
738
|
+
for (const r of processes) {
|
|
739
|
+
if (r.memberAliases.length >= 2) {
|
|
740
|
+
for (const alias of r.memberAliases) claimedByProcess.add(alias);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
720
744
|
const moduleGroups: BoundaryLayoutGroup[] = modules.map((r) => {
|
|
721
745
|
const processesOfMembers = new Set<string>();
|
|
722
746
|
const packagesOfMembers = new Set<string>();
|
|
@@ -749,6 +773,7 @@ export function buildBoundaryLayoutGroups(
|
|
|
749
773
|
const nestedModules = moduleGroups.filter((m) => m.parentId === processId);
|
|
750
774
|
const nestedModuleKeys = new Set(nestedModules.map((m) => m.region.key));
|
|
751
775
|
const directLeaves = r.memberAliases.filter((alias) => {
|
|
776
|
+
if (claimedByModule.has(alias)) return false;
|
|
752
777
|
const mod = byAlias.get(alias)?.module?.trim();
|
|
753
778
|
if (!mod) return true;
|
|
754
779
|
return !nestedModuleKeys.has(mod);
|
|
@@ -785,7 +810,12 @@ export function buildBoundaryLayoutGroups(
|
|
|
785
810
|
for (const m of nestedModules) {
|
|
786
811
|
for (const alias of m.region.memberAliases) claimed.add(alias);
|
|
787
812
|
}
|
|
788
|
-
const directLeaves = r.memberAliases.filter(
|
|
813
|
+
const directLeaves = r.memberAliases.filter(
|
|
814
|
+
(alias) =>
|
|
815
|
+
!claimed.has(alias) &&
|
|
816
|
+
!claimedByModule.has(alias) &&
|
|
817
|
+
!claimedByProcess.has(alias),
|
|
818
|
+
);
|
|
789
819
|
return {
|
|
790
820
|
id: packageId,
|
|
791
821
|
memberAliases: [
|