@principal-ai/subsystems-react 0.51.1 → 0.51.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/index.d.ts +5 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/subsystem/C4Graph.d.ts +12 -1
  6. package/dist/subsystem/C4Graph.d.ts.map +1 -1
  7. package/dist/subsystem/C4Graph.js +82 -14
  8. package/dist/subsystem/C4Graph.js.map +1 -1
  9. package/dist/subsystem/C4NodeCard.d.ts +29 -14
  10. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  11. package/dist/subsystem/C4NodeCard.js +71 -57
  12. package/dist/subsystem/C4NodeCard.js.map +1 -1
  13. package/dist/subsystem/IssueList.d.ts.map +1 -1
  14. package/dist/subsystem/IssueList.js +11 -2
  15. package/dist/subsystem/IssueList.js.map +1 -1
  16. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  17. package/dist/subsystem/SubsystemComponentGraph.js +66 -3
  18. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  19. package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
  20. package/dist/subsystem/TrailsPanel.js +8 -4
  21. package/dist/subsystem/TrailsPanel.js.map +1 -1
  22. package/dist/subsystem/c4.d.ts +31 -92
  23. package/dist/subsystem/c4.d.ts.map +1 -1
  24. package/dist/subsystem/c4.js +6 -285
  25. package/dist/subsystem/c4.js.map +1 -1
  26. package/dist/subsystem/c4Evidence.d.ts +1 -1
  27. package/dist/subsystem/c4Evidence.js +2 -2
  28. package/dist/subsystem/c4Evidence.js.map +1 -1
  29. package/dist/subsystem/model.d.ts +8 -0
  30. package/dist/subsystem/model.d.ts.map +1 -1
  31. package/dist/subsystem/model.js.map +1 -1
  32. package/dist/subsystem/techIcons/bun.d.ts +11 -0
  33. package/dist/subsystem/techIcons/bun.d.ts.map +1 -0
  34. package/dist/subsystem/techIcons/bun.js +11 -0
  35. package/dist/subsystem/techIcons/bun.js.map +1 -0
  36. package/dist/subsystem/techIcons/index.d.ts +36 -0
  37. package/dist/subsystem/techIcons/index.d.ts.map +1 -0
  38. package/dist/subsystem/techIcons/index.js +55 -0
  39. package/dist/subsystem/techIcons/index.js.map +1 -0
  40. package/dist/subsystem/techIcons/node.d.ts +12 -0
  41. package/dist/subsystem/techIcons/node.d.ts.map +1 -0
  42. package/dist/subsystem/techIcons/node.js +39 -0
  43. package/dist/subsystem/techIcons/node.js.map +1 -0
  44. package/dist/subsystem/techIcons/react.d.ts +12 -0
  45. package/dist/subsystem/techIcons/react.d.ts.map +1 -0
  46. package/dist/subsystem/techIcons/react.js +19 -0
  47. package/dist/subsystem/techIcons/react.js.map +1 -0
  48. package/dist/utils/elkLayout.d.ts.map +1 -1
  49. package/dist/utils/elkLayout.js +16 -5
  50. package/dist/utils/elkLayout.js.map +1 -1
  51. package/package.json +3 -3
  52. package/src/index.ts +4 -6
  53. package/src/stories/Subsystem/C4Graph/C4Container.stories.tsx +212 -0
  54. package/src/stories/Subsystem/C4Graph/C4NodeGallery.stories.tsx +21 -8
  55. package/src/stories/Subsystem/ComponentGraph/IssueOverlay.stories.tsx +4 -2
  56. package/src/stories/Subsystem/ComponentGraph/Issues.stories.tsx +168 -2
  57. package/src/subsystem/C4Graph.tsx +127 -12
  58. package/src/subsystem/C4NodeCard.test.ts +86 -55
  59. package/src/subsystem/C4NodeCard.tsx +92 -71
  60. package/src/subsystem/IssueList.tsx +12 -1
  61. package/src/subsystem/SubsystemComponentGraph.tsx +79 -2
  62. package/src/subsystem/TrailsPanel.tsx +10 -5
  63. package/src/subsystem/c4.ts +30 -363
  64. package/src/subsystem/c4Evidence.test.ts +5 -5
  65. package/src/subsystem/c4Evidence.ts +2 -2
  66. package/src/subsystem/model.ts +8 -0
  67. package/src/subsystem/techIcons/bun.ts +10 -0
  68. package/src/subsystem/techIcons/index.tsx +73 -0
  69. package/src/subsystem/techIcons/node.ts +38 -0
  70. package/src/subsystem/techIcons/react.ts +18 -0
  71. package/src/subsystem/techIcons/techIcons.test.ts +39 -0
  72. package/src/utils/elkLayout.ts +16 -5
  73. package/dist/stories/Subsystem/C4Graph/c4ProposedElements.fixture.d.ts +0 -493
  74. package/dist/stories/Subsystem/C4Graph/c4ProposedElements.fixture.d.ts.map +0 -1
  75. package/dist/stories/Subsystem/C4Graph/c4ProposedElements.fixture.js +0 -329
  76. package/dist/stories/Subsystem/C4Graph/c4ProposedElements.fixture.js.map +0 -1
  77. package/src/stories/Subsystem/C4Graph/ProposedElements.stories.tsx +0 -293
  78. package/src/stories/Subsystem/C4Graph/c4ProposedElements.fixture.ts +0 -366
  79. package/src/subsystem/c4.test.ts +0 -573
@@ -7,9 +7,10 @@
7
7
  * reading `process` strings will produce it — `process` answers "where does
8
8
  * this run", which is a different question.
9
9
  *
10
- * So the element list is authored. An agent proposes it, a person confirms it,
11
- * and `buildC4Model` does the only mechanical job left: draw the boxes the
12
- * author named, and use the trails to draw the lines between them.
10
+ * So the element list is authored, and so is the `C4Model` projected from it.
11
+ * There is no builder here: how edges are determined is still open, so a caller
12
+ * supplies the drawable model directly rather than having trails converted into
13
+ * lines.
13
14
  *
14
15
  * ## Why a union and not one type with two axes
15
16
  *
@@ -31,7 +32,7 @@
31
32
  * [C4 notation]: https://c4model.com/diagrams/notation
32
33
  */
33
34
 
34
- import type { SubsystemComponent, SubsystemModelDocument } from './model';
35
+ import type { SubsystemComponent } from './model';
35
36
 
36
37
  /**
37
38
  * Has anyone signed off on this element yet?
@@ -55,12 +56,9 @@ interface C4ElementBase {
55
56
  * The component aliases that live directly inside this element.
56
57
  *
57
58
  * Named explicitly rather than derived from a `process` value, because two
58
- * runs of code being one container is a judgement, not a lookup. This is also
59
- * the dedup mechanism: two elements that should be one simply end up as one
60
- * element holding both member sets.
59
+ * runs of code being one container is a judgement, not a lookup.
61
60
  *
62
- * Each alias belongs to exactly one element. A container does *not* repeat
63
- * the aliases its components already claim — `buildC4Model` rolls those up.
61
+ * Each alias belongs to exactly one element.
64
62
  */
65
63
  members: string[];
66
64
  /**
@@ -83,12 +81,13 @@ interface C4ElementBase {
83
81
  /**
84
82
  * What kind of thing a container is.
85
83
  *
86
- * `application` is a deployable program; the other two are storage that the
87
- * system reads or writes. Note c4model is explicit that an individual *queue*
88
- * is a data store, not the bus: "model the message bus as a container" is
89
- * listed as incorrect.
84
+ * C4 recognises exactly two: an `application` (a deployable program) or a
85
+ * `data-store` (something the system reads or writes). There is deliberately
86
+ * no `queue` kind — c4model is explicit that an individual queue or topic *is*
87
+ * a data store, and that the message bus itself is not a container at all, so
88
+ * a queue is a `data-store` whose technology/label say "queue".
90
89
  */
91
- export type C4ContainerKind = 'application' | 'data-store' | 'queue';
90
+ export type C4ContainerKind = 'application' | 'data-store';
92
91
 
93
92
  /** A deployable unit or a store — the C4 level 2 box. */
94
93
  export interface C4Container extends C4ElementBase {
@@ -161,7 +160,7 @@ export interface C4Node {
161
160
  technology?: string;
162
161
  description?: string;
163
162
  state: C4ElementState;
164
- /** `application` / `data-store` / `queue`. Set on containers only. */
163
+ /** `application` / `data-store`. Set on containers only. */
165
164
  containerKind?: C4ContainerKind;
166
165
  /** Provenance, when the element consolidated several derived keys. */
167
166
  derivedFrom?: string[];
@@ -184,18 +183,29 @@ export interface C4Group {
184
183
  memberIds: string[];
185
184
  }
186
185
 
187
- /** A line between two elements, rolled up from a trail step. */
186
+ /**
187
+ * A line between two elements. Authored, like the boxes.
188
+ *
189
+ * C4 asks a container-diagram line to say the *technology/protocol* of the
190
+ * interaction (`protocol`), and the label is that plus the trail verbs where
191
+ * known. `label` is what the chip shows; `protocol` and `mechanisms` are kept
192
+ * separate so a caller can render either.
193
+ */
188
194
  export interface C4Edge {
189
195
  id: string;
190
196
  source: string;
191
197
  target: string;
198
+ /** Text the edge chip shows, e.g. `RPC` or `calls (HTTP)`. */
192
199
  label: string;
200
+ /** The interaction's technology/protocol, e.g. `RPC`, `HTTP`, `stdin`. */
201
+ protocol?: string;
202
+ /** Trail verbs that produced this line (`calls`, `writes`, …). */
193
203
  mechanisms: string[];
194
- /** Trail steps that produced this line. */
204
+ /** How many underlying steps this line rolled up. */
195
205
  count: number;
196
206
  }
197
207
 
198
- /** A drawable C4 projection. */
208
+ /** A drawable C4 projection. Authored, not derived. */
199
209
  export interface C4Model {
200
210
  view: C4View;
201
211
  system: { id: string; label: string; repoKey?: string };
@@ -204,355 +214,12 @@ export interface C4Model {
204
214
  edges: C4Edge[];
205
215
  }
206
216
 
207
- /** Something an author should fix before this set is trusted. */
208
- export type C4ProblemKind =
209
- /** a member is claimed by two elements */
210
- | 'conflicting_member'
211
- /** a member is not in the supplied document */
212
- | 'unknown_member'
213
- /** two elements share an id */
214
- | 'duplicate_id'
215
- /** an element that should have contents has none */
216
- | 'empty_element'
217
- /** a component names a container that is missing, or is not a container */
218
- | 'unknown_container';
219
-
220
- export interface C4Problem {
221
- kind: C4ProblemKind;
222
- message: string;
223
- /** Alias for member problems, element id for the rest. */
224
- subject: string;
225
- }
226
-
227
- export interface C4BuildResult {
228
- model: C4Model;
229
- /** Authoring mistakes. An empty array means the set is self-consistent. */
230
- problems: C4Problem[];
231
- /** Component aliases in the document that no element claims. */
232
- unmapped: string[];
233
- }
234
-
235
- export interface C4BuildOptions {
236
- /** The elements. The source of truth — nothing is invented. */
237
- elements: readonly C4Element[];
238
- /** Supply to resolve members and draw lines from trails. */
239
- document?: SubsystemModelDocument;
240
- view?: C4View;
241
- /** Name of the system the elements sit in. */
242
- systemLabel?: string;
243
- /** Override the repo key (defaults to the first member's purl). */
244
- repoKey?: string;
245
- /** Model-id attribution per component alias. */
246
- modelsByAlias?: Record<string, string[]>;
247
- }
248
-
249
217
  /**
250
- * Element kinds drawn inside the system boundary.
251
- *
252
- * A C4 container diagram puts external systems *inside* the boundary: they are
253
- * things this system depends on, drawn as containers we do not own. People go
254
- * outside it, because a person is never part of any system.
218
+ * `owner/name` from a purl, trimmed of scheme and fragment. Used to label the
219
+ * system frame when a repo key is known.
255
220
  */
256
- const IN_BOUNDARY = new Set<C4Element['kind']>(['container', 'external-system']);
257
-
258
- /** True when this element kind is drawn inside the system frame. */
259
- export function isInBoundary(e: C4Element): boolean {
260
- return IN_BOUNDARY.has(e.kind);
261
- }
262
-
263
- function purlRepoKey(purl: string | undefined): string | undefined {
264
- const p = (purl ?? '').split('#')[0]?.trim();
265
- if (!p || p === 'external' || p.startsWith('external:')) return undefined;
266
- return p;
267
- }
268
-
269
- /** `owner/name` from a purl, trimmed of scheme and fragment. */
270
221
  export function labelFromPurl(purl: string): string {
271
222
  const base = purl.replace(/^external:/, '').split('#')[0]?.trim() ?? '';
272
223
  const parts = base.split('/').filter(Boolean);
273
224
  return parts.slice(-2).join('/') || base || purl;
274
225
  }
275
-
276
- /**
277
- * Build the drawable projection from authored elements.
278
- *
279
- * A plain join with no architectural judgement:
280
- *
281
- * boxes ← one per element, named and placed by the author
282
- * lines ← trail steps, with each endpoint mapped to its owning element
283
- *
284
- * Trail steps whose endpoints are not claimed by any element are skipped:
285
- * drawing them would assert a relationship the author did not describe.
286
- */
287
- export function buildC4Model(options: C4BuildOptions): C4BuildResult {
288
- const view = options.view ?? 'container';
289
- const doc = options.document;
290
- const problems: C4Problem[] = [];
291
-
292
- const byAlias = new Map(doc?.components.map((c) => [c.alias, c]) ?? []);
293
- /**
294
- * Alias → owning element, innermost home wins. One owner per alias: this is
295
- * what makes `conflicting_member` mean "two boxes disagree" rather than
296
- * "a container and its components both mention the same code".
297
- */
298
- const membersOf = new Map<string, string[]>();
299
-
300
- // --- accept each element once, and resolve membership --------------------
301
- const seenIds = new Set<string>();
302
- /** alias → element id. One owner per alias; conflicts are reported. */
303
- const ownerOf = new Map<string, string>();
304
- /** Ids in authored order, duplicates dropped. */
305
- const accepted: string[] = [];
306
- const elementById = new Map<string, C4Element>();
307
-
308
- for (const e of options.elements) {
309
- if (seenIds.has(e.id)) {
310
- problems.push({
311
- kind: 'duplicate_id',
312
- subject: e.id,
313
- message: `two elements share the id ${e.id}`,
314
- });
315
- continue;
316
- }
317
- seenIds.add(e.id);
318
- accepted.push(e.id);
319
- elementById.set(e.id, e);
320
-
321
- // A rejected element is not drawn, so its members are inside nothing.
322
- // Leaving them claimed would hide them from `unmapped` and quietly hide
323
- // the fact that rejecting an element orphans whatever was in it.
324
- if (e.state === 'rejected') continue;
325
-
326
- for (const alias of e.members) {
327
- if (doc && !byAlias.has(alias)) {
328
- problems.push({
329
- kind: 'unknown_member',
330
- subject: alias,
331
- message: `element "${e.id}" claims "${alias}", which is not in the supplied document`,
332
- });
333
- continue;
334
- }
335
- const existing = ownerOf.get(alias);
336
- if (existing && existing !== e.id) {
337
- problems.push({
338
- kind: 'conflicting_member',
339
- subject: alias,
340
- message: `"${alias}" is claimed by both ${existing} and ${e.id}; it is drawn inside ${existing}`,
341
- });
342
- continue;
343
- }
344
- ownerOf.set(alias, e.id);
345
- const list = membersOf.get(e.id) ?? [];
346
- list.push(alias);
347
- membersOf.set(e.id, list);
348
- }
349
- }
350
-
351
- // --- the system boundary -------------------------------------------------
352
- const repoKey =
353
- options.repoKey ??
354
- options.elements
355
- .flatMap((e) => e.members)
356
- .map((alias) => purlRepoKey(byAlias.get(alias)?.purl))
357
- .find(Boolean);
358
-
359
- const systemId = `system:${repoKey ?? 'unspecified'}`;
360
- const systemLabel = options.systemLabel ?? (repoKey ? labelFromPurl(repoKey) : 'Software System');
361
-
362
- // --- draw the boxes ------------------------------------------------------
363
- const nodes: C4Node[] = [];
364
- /**
365
- * The aliases an element claimed itself, before any rollup. A component's
366
- * own members and its container's own members are disjoint by construction,
367
- * which is what lets the two be added together below.
368
- */
369
- const ownMembers = new Map<string, string[]>();
370
- for (const id of accepted) {
371
- const e = elementById.get(id)!;
372
- if (e.state === 'rejected') continue;
373
-
374
- const own = membersOf.get(id) ?? [];
375
-
376
- // A component's parent is stated, not inferred. Check it resolves: a
377
- // dangling parent would silently drop the component out of every frame.
378
- let parentId: string | undefined;
379
- if (e.kind === 'component') {
380
- const parent = elementById.get(e.container);
381
- if (!parent || parent.state === 'rejected') {
382
- problems.push({
383
- kind: 'unknown_container',
384
- subject: id,
385
- message: `component "${id}" names container "${e.container}", which is not in this set`,
386
- });
387
- } else if (parent.kind !== 'container') {
388
- problems.push({
389
- kind: 'unknown_container',
390
- subject: id,
391
- message: `component "${id}" names container "${e.container}", which is a ${parent.kind}, not a container`,
392
- });
393
- } else {
394
- parentId = parent.id;
395
- }
396
- } else if (isInBoundary(e)) {
397
- parentId = systemId;
398
- }
399
-
400
- ownMembers.set(id, own);
401
- nodes.push({
402
- id: e.id,
403
- kind: e.kind,
404
- label: e.label,
405
- ...(parentId ? { parentId } : {}),
406
- technology: 'technology' in e ? e.technology : undefined,
407
- description: e.description,
408
- state: e.state,
409
- ...(e.kind === 'container' ? { containerKind: e.containerKind } : {}),
410
- ...(e.derivedFrom && e.derivedFrom.length > 1 ? { derivedFrom: e.derivedFrom } : {}),
411
- members: own,
412
- constructs: [],
413
- });
414
- }
415
-
416
- // --- roll components up into their container ------------------------------
417
- //
418
- // A C4 container diagram draws the container as a whole, so a container
419
- // holds everything inside its components. Membership is still authored
420
- // exactly once: an alias belongs to one element, so a container must not
421
- // repeat what its components already claim — that repetition would read as
422
- // a `conflicting_member` and hide the real question, which is how many
423
- // components a container has.
424
- for (const n of nodes) {
425
- if (n.kind !== 'component' || !n.parentId) continue;
426
- const list = membersOf.get(n.parentId) ?? [];
427
- list.push(...(ownMembers.get(n.id) ?? []));
428
- membersOf.set(n.parentId, list);
429
- }
430
-
431
- for (const n of nodes) {
432
- n.members = membersOf.get(n.id) ?? [];
433
- if (n.members.length === 0) {
434
- problems.push({
435
- kind: 'empty_element',
436
- subject: n.id,
437
- message: `element "${n.id}" (${n.kind}) claims no members, and nothing is inside it either, so there is nothing to draw`,
438
- });
439
- }
440
- const resolved = n.members.map((m) => byAlias.get(m)).filter((c): c is SubsystemComponent => !!c);
441
- const constructs: string[] = [];
442
- for (const c of resolved) if (!constructs.includes(c.construct)) constructs.push(c.construct);
443
- n.constructs = constructs;
444
- if (n.kind === 'component' && resolved[0]) n.component = resolved[0];
445
-
446
- const models = [...new Set(n.members.flatMap((m) => options.modelsByAlias?.[m] ?? []))];
447
- if (models.length > 0) n.models = models;
448
- }
449
-
450
- // --- compound frames -----------------------------------------------------
451
- const groups: C4Group[] = [];
452
-
453
- if (view === 'container') {
454
- const containerIds = nodes.filter((n) => n.kind === 'container').map((n) => n.id);
455
- if (containerIds.length > 0) {
456
- groups.push({ id: systemId, kind: 'system', label: systemLabel, memberIds: containerIds });
457
- }
458
- } else {
459
- const byContainer = new Map<string, string[]>();
460
- for (const n of nodes) {
461
- if (n.kind !== 'component' || !n.parentId) continue;
462
- const list = byContainer.get(n.parentId) ?? [];
463
- list.push(n.id);
464
- byContainer.set(n.parentId, list);
465
- }
466
- const framed: string[] = [];
467
- for (const [id, memberIds] of byContainer) {
468
- const label = nodes.find((n) => n.id === id)?.label ?? id;
469
- groups.push({ id, kind: 'container', label, parentId: systemId, memberIds });
470
- framed.push(id);
471
- }
472
- if (framed.length > 0) {
473
- groups.push({ id: systemId, kind: 'system', label: systemLabel, memberIds: framed });
474
- }
475
- }
476
-
477
- // --- lines, from the trails ---------------------------------------------
478
- const drawn = new Set(nodes.map((n) => n.id));
479
- const edges = new Map<string, C4Edge>();
480
- for (const trail of doc?.trails ?? []) {
481
- for (const step of trail.steps ?? []) {
482
- const source = ownerOf.get(step.from);
483
- const target = ownerOf.get(step.to);
484
- // An endpoint no element claims has no box, so there is no line to draw.
485
- if (!source || !target || source === target) continue;
486
- if (!drawn.has(source) || !drawn.has(target)) continue;
487
- const key = `${source}\0${target}`;
488
- const edge = edges.get(key);
489
- if (edge) {
490
- edge.count += 1;
491
- if (!edge.mechanisms.includes(step.mechanism)) edge.mechanisms.push(step.mechanism);
492
- } else {
493
- edges.set(key, {
494
- id: `flow:${key}`,
495
- source,
496
- target,
497
- label: step.mechanism,
498
- mechanisms: [step.mechanism],
499
- count: 1,
500
- });
501
- }
502
- }
503
- }
504
- for (const e of edges.values()) e.label = [...e.mechanisms].sort().join(' + ');
505
-
506
- const unmapped = (doc?.components ?? []).filter((c) => !ownerOf.has(c.alias)).map((c) => c.alias);
507
-
508
- return {
509
- model: {
510
- view,
511
- system: { id: systemId, label: systemLabel, repoKey },
512
- nodes,
513
- groups,
514
- edges: [...edges.values()],
515
- },
516
- problems,
517
- unmapped,
518
- };
519
- }
520
-
521
- /**
522
- * Tally for the confirm UI: how much is proposed vs accepted, and how much is
523
- * still missing what the C4 notation requires.
524
- *
525
- * Counts the authored set, not the projection — a rejected element is still a
526
- * decision that was made, so it is reported rather than forgotten.
527
- */
528
- export function summarizeElements(elements: readonly C4Element[]): {
529
- containers: number;
530
- components: number;
531
- externals: number;
532
- people: number;
533
- accepted: number;
534
- proposed: number;
535
- rejected: number;
536
- /** Containers missing the technology C4 requires. */
537
- missingTechnology: number;
538
- /** Elements missing a description. */
539
- missingDescription: number;
540
- /** Elements whose state is not yet `accepted`. */
541
- needsDecision: number;
542
- } {
543
- const live = elements.filter((e) => e.state !== 'rejected');
544
- return {
545
- containers: live.filter((e) => e.kind === 'container').length,
546
- components: live.filter((e) => e.kind === 'component').length,
547
- externals: live.filter((e) => e.kind === 'external-system').length,
548
- people: live.filter((e) => e.kind === 'person').length,
549
- accepted: live.filter((e) => e.state === 'accepted').length,
550
- proposed: live.filter((e) => e.state === 'proposed').length,
551
- rejected: elements.filter((e) => e.state === 'rejected').length,
552
- // `technology` is required by the type on containers and components, so a
553
- // missing one can only mean an empty string — still worth reporting.
554
- missingTechnology: live.filter((e) => 'technology' in e && !e.technology).length,
555
- missingDescription: live.filter((e) => !e.description).length,
556
- needsDecision: live.filter((e) => e.state !== 'accepted').length,
557
- };
558
- }
@@ -196,10 +196,10 @@ describe('suggestContainerKind', () => {
196
196
  });
197
197
 
198
198
  test('there is no library answer, even for a library-shaped group', () => {
199
- // The kinds are application | data-store | queue. A package of interfaces
200
- // still comes back `application`, with the question left to a person in
201
- // the `library_shaped` concern. Returning `library` here would put a
202
- // non-C4 concept into the vocabulary.
199
+ // The kinds are application | data-store. A package of interfaces still
200
+ // comes back `application`, with the question left to a person in the
201
+ // `library_shaped` concern. Returning `library` here would put a non-C4
202
+ // concept into the vocabulary.
203
203
  const members = [member({ alias: 'a', construct: 'interface' })];
204
204
  expect(deriveConcerns('x', members).some((c) => c.kind === 'library_shaped')).toBe(true);
205
205
  expect(suggestContainerKind(members)).toBe('application');
@@ -261,7 +261,7 @@ describe('proposeElements', () => {
261
261
  });
262
262
 
263
263
  test('a key with no framework signal gets an empty technology, not a guess', () => {
264
- // `technology` is required by the type, and `summarizeElements` reports the
264
+ // `technology` is required by the type, and an empty one is reported.
265
265
  // gap. Writing "TypeScript" here would be the derivation this module does
266
266
  // not do.
267
267
  const set = proposeElements({ repoKey: REPO, rollup });
@@ -288,7 +288,7 @@ export function proposeElements(
288
288
  label: key,
289
289
  containerKind: suggestContainerKind(members),
290
290
  // C4 requires a technology on every container. With no framework signal
291
- // the honest value is empty and `summarizeElements` reports the gap —
291
+ // the honest value is empty and the notation-gap check reports it —
292
292
  // inventing "TypeScript" here would be exactly the derivation this
293
293
  // module stopped doing.
294
294
  technology: frameworks.length > 0 ? frameworks.join(' + ') : '',
@@ -313,7 +313,7 @@ export function proposeElements(
313
313
  * library is a review comment: the `library_shaped` concern carries the
314
314
  * question, and the element is proposed as `application` for a person to
315
315
  * reject or demote. There is deliberately no `concerns` parameter here for the
316
- * caller to consult — passing one would only invite a fifth kind back into the
316
+ * caller to consult — passing one would only invite another kind back into the
317
317
  * vocabulary.
318
318
  *
319
319
  * The store split is deliberately conservative: only durable storage becomes
@@ -406,6 +406,14 @@ export interface SubsystemTrailStep {
406
406
  * mechanism + filename fallback.
407
407
  */
408
408
  symbol: string;
409
+ /**
410
+ * Planned seam — the step describes intended behavior through code that is
411
+ * not written yet. Orthogonal to (and redundant with) the endpoints' own
412
+ * `proposed` flags: a step is proposed when it says so OR either endpoint
413
+ * is proposed. Verification skips source checks either way, and viewers
414
+ * tint it exactly like a proposed node.
415
+ */
416
+ proposed?: boolean;
409
417
  /**
410
418
  * Free-text note anchored to this step's site line. Optional — informative
411
419
  * only, never verified against source; the Pierre trail code view
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Bun mark — the official logo, vendored verbatim.
3
+ *
4
+ * Source: https://bun.sh/logo.svg.
5
+ * Bun and the Bun logo are trademarks of Oven. Used here for identification
6
+ * only, with no endorsement implied.
7
+ *
8
+ * Root sized to 100% so the card's wrapper controls the box.
9
+ */
10
+ export const bunSvg = `<svg id="Bun" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 80 70"><path id="Shadow" d="M71.09,20.74c-.16-.17-.33-.34-.5-.5s-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5-.33-.34-.5-.5A26.46,26.46,0,0,1,75.5,35.7c0,16.57-16.82,30.05-37.5,30.05-11.58,0-21.94-4.23-28.83-10.86l.5.5.5.5.5.5.5.5.5.5.5.5.5.5C19.55,65.3,30.14,69.75,42,69.75c20.68,0,37.5-13.48,37.5-30C79.5,32.69,76.46,26,71.09,20.74Z"/><g id="Body"><path id="Background" d="M73,35.7c0,15.21-15.67,27.54-35,27.54S3,50.91,3,35.7C3,26.27,9,17.94,18.22,13S33.18,3,38,3s8.94,4.13,19.78,10C67,17.94,73,26.27,73,35.7Z" style="fill:#fbf0df"/><path id="Bottom_Shadow" data-name="Bottom Shadow" d="M73,35.7a21.67,21.67,0,0,0-.8-5.78c-2.73,33.3-43.35,34.9-59.32,24.94A40,40,0,0,0,38,63.24C57.3,63.24,73,50.89,73,35.7Z" style="fill:#f6dece"/><path id="Light_Shine" data-name="Light Shine" d="M24.53,11.17C29,8.49,34.94,3.46,40.78,3.45A9.29,9.29,0,0,0,38,3c-2.42,0-5,1.25-8.25,3.13-1.13.66-2.3,1.39-3.54,2.15-2.33,1.44-5,3.07-8,4.7C8.69,18.13,3,26.62,3,35.7c0,.4,0,.8,0,1.19C9.06,15.48,20.07,13.85,24.53,11.17Z" style="fill:#fffefc"/><path id="Top" d="M35.12,5.53A16.41,16.41,0,0,1,29.49,18c-.28.25-.06.73.3.59,3.37-1.31,7.92-5.23,6-13.14C35.71,5,35.12,5.12,35.12,5.53Zm2.27,0A16.24,16.24,0,0,1,39,19c-.12.35.31.65.55.36C41.74,16.56,43.65,11,37.93,5,37.64,4.74,37.19,5.14,37.39,5.49Zm2.76-.17A16.42,16.42,0,0,1,47,17.12a.33.33,0,0,0,.65.11c.92-3.49.4-9.44-7.17-12.53C40.08,4.54,39.82,5.08,40.15,5.32ZM21.69,15.76a16.94,16.94,0,0,0,10.47-9c.18-.36.75-.22.66.18-1.73,8-7.52,9.67-11.12,9.45C21.32,16.4,21.33,15.87,21.69,15.76Z" style="fill:#ccbea7;fill-rule:evenodd"/><path id="Outline" d="M38,65.75C17.32,65.75.5,52.27.5,35.7c0-10,6.18-19.33,16.53-24.92,3-1.6,5.57-3.21,7.86-4.62,1.26-.78,2.45-1.51,3.6-2.19C32,1.89,35,.5,38,.5s5.62,1.2,8.9,3.14c1,.57,2,1.19,3.07,1.87,2.49,1.54,5.3,3.28,9,5.27C69.32,16.37,75.5,25.69,75.5,35.7,75.5,52.27,58.68,65.75,38,65.75ZM38,3c-2.42,0-5,1.25-8.25,3.13-1.13.66-2.3,1.39-3.54,2.15-2.33,1.44-5,3.07-8,4.7C8.69,18.13,3,26.62,3,35.7,3,50.89,18.7,63.25,38,63.25S73,50.89,73,35.7C73,26.62,67.31,18.13,57.78,13,54,11,51.05,9.12,48.66,7.64c-1.09-.67-2.09-1.29-3-1.84C42.63,4,40.42,3,38,3Z"/></g><g id="Mouth"><g id="Background-2" data-name="Background"><path d="M45.05,43a8.93,8.93,0,0,1-2.92,4.71,6.81,6.81,0,0,1-4,1.88A6.84,6.84,0,0,1,34,47.71,8.93,8.93,0,0,1,31.12,43a.72.72,0,0,1,.8-.81H44.26A.72.72,0,0,1,45.05,43Z" style="fill:#b71422"/></g><g id="Tongue"><path id="Background-3" data-name="Background" d="M34,47.79a6.91,6.91,0,0,0,4.12,1.9,6.91,6.91,0,0,0,4.11-1.9,10.63,10.63,0,0,0,1-1.07,6.83,6.83,0,0,0-4.9-2.31,6.15,6.15,0,0,0-5,2.78C33.56,47.4,33.76,47.6,34,47.79Z" style="fill:#ff6164"/><path id="Outline-2" data-name="Outline" d="M34.16,47a5.36,5.36,0,0,1,4.19-2.08,6,6,0,0,1,4,1.69c.23-.25.45-.51.66-.77a7,7,0,0,0-4.71-1.93,6.36,6.36,0,0,0-4.89,2.36A9.53,9.53,0,0,0,34.16,47Z"/></g><path id="Outline-3" data-name="Outline" d="M38.09,50.19a7.42,7.42,0,0,1-4.45-2,9.52,9.52,0,0,1-3.11-5.05,1.2,1.2,0,0,1,.26-1,1.41,1.41,0,0,1,1.13-.51H44.26a1.44,1.44,0,0,1,1.13.51,1.19,1.19,0,0,1,.25,1h0a9.52,9.52,0,0,1-3.11,5.05A7.42,7.42,0,0,1,38.09,50.19Zm-6.17-7.4c-.16,0-.2.07-.21.09a8.29,8.29,0,0,0,2.73,4.37A6.23,6.23,0,0,0,38.09,49a6.28,6.28,0,0,0,3.65-1.73,8.3,8.3,0,0,0,2.72-4.37.21.21,0,0,0-.2-.09Z"/></g><g id="Face"><ellipse id="Right_Blush" data-name="Right Blush" cx="53.22" cy="40.18" rx="5.85" ry="3.44" style="fill:#febbd0"/><ellipse id="Left_Bluch" data-name="Left Bluch" cx="22.95" cy="40.18" rx="5.85" ry="3.44" style="fill:#febbd0"/><path id="Eyes" d="M25.7,38.8a5.51,5.51,0,1,0-5.5-5.51A5.51,5.51,0,0,0,25.7,38.8Zm24.77,0A5.51,5.51,0,1,0,45,33.29,5.5,5.5,0,0,0,50.47,38.8Z" style="fill-rule:evenodd"/><path id="Iris" d="M24,33.64a2.07,2.07,0,1,0-2.06-2.07A2.07,2.07,0,0,0,24,33.64Zm24.77,0a2.07,2.07,0,1,0-2.06-2.07A2.07,2.07,0,0,0,48.75,33.64Z" style="fill:#fff;fill-rule:evenodd"/></g></svg>`;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Technology marks — official brand SVGs, vendored one per file, matched
3
+ * against an element's free-text `technology`.
4
+ *
5
+ * The rule is deliberately strict: if we do not hold the official mark for a
6
+ * technology, the slot stays empty. We do not substitute a generic glyph or a
7
+ * lookalike — a wrong logo is worse than none. Adding a brand is dropping its
8
+ * SVG in this folder and adding one row to `TECH_BRANDS`.
9
+ *
10
+ * Brand logos remain the property of their owners and are used for
11
+ * identification only, under each owner's trademark policy.
12
+ */
13
+
14
+ import { bunSvg } from './bun';
15
+ import { nodeSvg } from './node';
16
+ import { reactSvg } from './react';
17
+
18
+ export interface TechBrand {
19
+ /** Human name, used for the tooltip / accessible label. */
20
+ name: string;
21
+ /** Where the mark was vendored from. */
22
+ source: string;
23
+ /** The official SVG, with its root sized to 100%. */
24
+ svg: string;
25
+ /** Matched against the technology string. First match in `TECH_BRANDS` wins. */
26
+ match: RegExp;
27
+ }
28
+
29
+ /**
30
+ * Order matters: the first brand whose pattern matches is the one drawn, so
31
+ * put the more specific marks first if two could match the same string.
32
+ */
33
+ export const TECH_BRANDS: readonly TechBrand[] = [
34
+ {
35
+ name: 'React',
36
+ source: 'https://react.dev',
37
+ svg: reactSvg,
38
+ match: /\breact\b/i,
39
+ },
40
+ {
41
+ name: 'Bun',
42
+ source: 'https://bun.sh/logo.svg',
43
+ svg: bunSvg,
44
+ match: /\bbun\b/i,
45
+ },
46
+ {
47
+ name: 'Node.js',
48
+ source: 'https://nodejs.org/static/logos/nodejsHex.svg',
49
+ svg: nodeSvg,
50
+ // Matches "Node" and "Node.js"; "Electrobun" has no word boundary before
51
+ // "bun" and never reaches here.
52
+ match: /\bnode(\.js)?\b/i,
53
+ },
54
+ ];
55
+
56
+ /** The official mark for a technology string, or undefined when we hold none. */
57
+ export function technologyBrand(technology: string | undefined): TechBrand | undefined {
58
+ if (!technology) return undefined;
59
+ return TECH_BRANDS.find((brand) => brand.match.test(technology));
60
+ }
61
+
62
+ /** A brand mark sized to the top row. Full-colour, not tinted by state. */
63
+ export function TechMark({ brand, size = 14 }: { brand: TechBrand; size?: number }) {
64
+ return (
65
+ <span
66
+ title={`${brand.name} — ${brand.source}`}
67
+ aria-label={brand.name}
68
+ style={{ display: 'inline-flex', width: size, height: size, flexShrink: 0 }}
69
+ // The SVG is a static, vendored string — never user input.
70
+ dangerouslySetInnerHTML={{ __html: brand.svg }}
71
+ />
72
+ );
73
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Node.js mark — the official hexagon logo, vendored verbatim.
3
+ *
4
+ * Source: https://nodejs.org/static/logos/nodejsHex.svg (via
5
+ * https://nodejs.org/en/about/branding). Node.js and the Node.js logo are
6
+ * trademarks of the OpenJS Foundation. Used here for identification only,
7
+ * subject to https://trademark-policy.openjsf.org/.
8
+ *
9
+ * Root sized to 100% so the card's wrapper controls the box.
10
+ */
11
+ export const nodeSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 44 50">
12
+ <defs>
13
+ <clipPath id="hexClip">
14
+ <path d="M22.8725 0.4166C22.136 0 21.2616 0 20.5253 0.4166L1.1505 11.6694C0.4142 12.0862 0 12.8733 0 13.707V36.2584C0 37.0921 0.4602 37.8791 1.1505 38.296L20.5253 49.5487C21.2616 49.9653 22.136 49.9653 22.8725 49.5487L42.2471 38.296C42.9836 37.8791 43.3976 37.0921 43.3976 36.2584V13.707C43.3976 12.8733 42.9375 12.0862 42.2471 11.6694L22.8725 0.4166Z" />
15
+ </clipPath>
16
+ <linearGradient id="main" x1="30.33" y1="8.56" x2="14.9" y2="44.7" gradientUnits="userSpaceOnUse">
17
+ <stop stop-color="#3F8B3D"/>
18
+ <stop offset="0.64" stop-color="#3F873F"/>
19
+ <stop offset="0.93" stop-color="#3DA92E"/>
20
+ <stop offset="1" stop-color="#3DAE2B"/>
21
+ </linearGradient>
22
+ <linearGradient id="r1" x1="18.8" y1="26.8" x2="68" y2="0.4" gradientUnits="userSpaceOnUse">
23
+ <stop offset="0.14" stop-color="#3F873F"/>
24
+ <stop offset="0.4" stop-color="#52A044"/>
25
+ <stop offset="0.71" stop-color="#64B749"/>
26
+ <stop offset="0.91" stop-color="#6ABF4B"/>
27
+ </linearGradient>
28
+ <linearGradient id="r2" x1="0.25" y1="24.5" x2="44" y2="24.5" gradientUnits="userSpaceOnUse">
29
+ <stop offset="0.09" stop-color="#6ABF4B"/>
30
+ <stop offset="0.29" stop-color="#64B749"/>
31
+ <stop offset="0.6" stop-color="#52A044"/>
32
+ <stop offset="0.86" stop-color="#3F873F"/>
33
+ </linearGradient>
34
+ </defs>
35
+ <path fill="url(#main)" d="M22.8725 0.4166C22.136 0 21.2616 0 20.5253 0.4166L1.1505 11.6694C0.4142 12.0862 0 12.8733 0 13.707V36.2584C0 37.0921 0.4602 37.8791 1.1505 38.296L20.5253 49.5487C21.2616 49.9653 22.136 49.9653 22.8725 49.5487L42.2471 38.296C42.9836 37.8791 43.3976 37.0921 43.3976 36.2584V13.707C43.3976 12.8733 42.9375 12.0862 42.2471 11.6694L22.8725 0.4166Z" />
36
+ <polygon fill="url(#r1)" clip-path="url(#hexClip)" points="21.698901,-1.046618 43.20532,11.948247 21.698901,51.072715 0.152778,38.055107" />
37
+ <polygon fill="url(#r2)" clip-path="url(#hexClip)" points="21.698901,-1.046618 0.152778,11.948247 21.698901,51.072715 43.20532,38.055107" />
38
+ </svg>`;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * React mark — the official logo, vendored verbatim.
3
+ *
4
+ * Source: https://react.dev (the React logo; mirrored at
5
+ * https://commons.wikimedia.org/wiki/File:React-icon.svg).
6
+ * React and the React logo are trademarks of Meta Platforms, Inc. Used here
7
+ * for identification only, with no endorsement implied.
8
+ *
9
+ * Root sized to 100% so the card's wrapper controls the box.
10
+ */
11
+ export const reactSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="-11.5 -10.23174 23 20.46348">
12
+ <circle cx="0" cy="0" r="2.05" fill="#61dafb"/>
13
+ <g stroke="#61dafb" stroke-width="1" fill="none">
14
+ <ellipse rx="11" ry="4.2"/>
15
+ <ellipse rx="11" ry="4.2" transform="rotate(60)"/>
16
+ <ellipse rx="11" ry="4.2" transform="rotate(120)"/>
17
+ </g>
18
+ </svg>`;