@archinsight/cli 3.0.0-snapshot.3 → 3.0.0-snapshot.5

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 (3) hide show
  1. package/README.md +13 -2
  2. package/build/index.js +1991 -176
  3. package/package.json +1 -1
package/build/index.js CHANGED
@@ -32343,7 +32343,7 @@ var coreSources = [
32343
32343
  },
32344
32344
  {
32345
32345
  "sourceName": "core_deployment.ai",
32346
- "source": "define type DeploymentElement of Element\n\ndefine type InfrastructureComponent of DeploymentElement\n constructor infrastructureComponent\n\n required Text name\n Text description\n List of TypeSlotReference _\n\ndefine type Environment of BoundaryElement\n constructor environment\n\n required Text name\n\ndefine type DeploymentProfile of BoundaryElement\n constructor deploymentProfile\n\n List of Environment environments\n List of TypeSlotReference _\n\ndefine type DeploymentProfileReference of TypeSlotReference\n required DeploymentProfile profile\n\ndefine presentation DeploymentProfile\n graphviz\n visible = false"
32346
+ "source": "define type DeploymentElement of Element\n\ndefine type InfrastructureComponent of DeploymentElement\n constructor infrastructureComponent\n\n Text name\n Text technology\n Text description\n List of TypeSlotReference _\n\ndefine type Storage of InfrastructureComponent\n constructor storage\n\n project:\n $from -> $this\n\ndefine type Broker of InfrastructureComponent\n constructor broker\n\n Text address\n\n project:\n $from -> $this\n $to -> $this\n\ndefine type Compute of InfrastructureComponent\n constructor compute\n\n Text address\n List of InfrastructureComponent components\n\ndefine type NetworkConnection of InfrastructureComponent\n constructor networkConnection\n\n project:\n $from -> $to\n\ndefine type Environment of BoundaryElement\n constructor environment\n\n required Text name\n\ndefine type DeploymentProfile of BoundaryElement\n constructor deploymentProfile\n\n List of Environment environments\n List of TypeSlotReference _\n\ndefine type DeploymentProfileReference of TypeSlotReference\n required DeploymentProfile profile\n\ndefine presentation DeploymentProfile\n graphviz\n visible = false\n\ndefine presentation NetworkConnection\n graphviz\n visible = false\n"
32347
32347
  },
32348
32348
  {
32349
32349
  "sourceName": "core_operator.ai",
@@ -34233,7 +34233,7 @@ function linkProject(request) {
34233
34233
  const presentations = buildPresentationIndex(request.snapshot.presentations ?? [], typeSystem, diagnostics);
34234
34234
  const graph = buildIndexedGraph(documents, elements, imports, linkedEdges, typeSystem);
34235
34235
  const graphElements = elements.filter(isGraphElement);
34236
- inspectGraph(graph, graphElements, linkedEdges, diagnostics);
34236
+ inspectGraph(graph, graphElements, linkedEdges, resolvedElementAttributes, diagnostics);
34237
34237
  const tabRoots = tabRootsBySource(documents, elementsByContextAndLocalId);
34238
34238
  for (const document of documents) {
34239
34239
  resolveAttributes(
@@ -35369,6 +35369,17 @@ function addProjectedRuleEdge(linkedEdges, sourceIdentity, fromId, toId, project
35369
35369
  const targetElement = elementsById.get(target);
35370
35370
  const operator = sourceElement === void 0 || targetElement === void 0 ? void 0 : typeSystem.operatorConstructor(rule3.operator, sourceElement.type, targetElement.type);
35371
35371
  const type = operator?.ownerType ?? rule3.operator;
35372
+ const existingIndex = linkedEdges.findIndex((edge) => edge.projected === true && edge.source === source && edge.operator === rule3.operator && edge.target === target && edge.projectionScope === projectionScope);
35373
+ if (existingIndex >= 0) {
35374
+ const edge = linkedEdges[existingIndex];
35375
+ if (edge !== void 0) {
35376
+ linkedEdges[existingIndex] = {
35377
+ ...edge,
35378
+ annotations: uniqueAnnotations([...edge.annotations ?? [], ...annotations2])
35379
+ };
35380
+ }
35381
+ continue;
35382
+ }
35372
35383
  linkedEdges.push({
35373
35384
  source,
35374
35385
  target,
@@ -36202,14 +36213,14 @@ function nearestAncestor(element, elementsById, predicate) {
36202
36213
  }
36203
36214
  return void 0;
36204
36215
  }
36205
- function inspectGraph(graph, elements, edges, diagnostics) {
36216
+ function inspectGraph(graph, elements, edges, resolvedElementAttributes, diagnostics) {
36206
36217
  if (diagnostics.some((diagnostic) => diagnostic.level === void 0 || diagnostic.level === "ERROR")) {
36207
36218
  return;
36208
36219
  }
36209
- reportIsolatedElements(graph, elements, diagnostics);
36220
+ reportIsolatedElements(graph, elements, edges, resolvedElementAttributes, diagnostics);
36210
36221
  reportShadowedLowerLevelEdges(graph, edges, diagnostics);
36211
36222
  }
36212
- function reportIsolatedElements(graph, elements, diagnostics) {
36223
+ function reportIsolatedElements(graph, elements, edges, resolvedElementAttributes, diagnostics) {
36213
36224
  const referenced = /* @__PURE__ */ new Set();
36214
36225
  for (const relationId of graph.relationsOfKind("REFERENCES")) {
36215
36226
  const relation = graph.relation(relationId);
@@ -36218,6 +36229,21 @@ function reportIsolatedElements(graph, elements, diagnostics) {
36218
36229
  referenced.add(relation.target);
36219
36230
  }
36220
36231
  }
36232
+ for (const edge of edges) {
36233
+ referenced.add(edge.source);
36234
+ referenced.add(edge.target);
36235
+ }
36236
+ for (const [elementId, attributes2] of resolvedElementAttributes) {
36237
+ for (const values of Object.values(attributes2)) {
36238
+ if (values.length === 0) {
36239
+ continue;
36240
+ }
36241
+ referenced.add(elementId);
36242
+ for (const value of values) {
36243
+ referenced.add(value.id);
36244
+ }
36245
+ }
36246
+ }
36221
36247
  for (const element of elements) {
36222
36248
  if (element.anonymous || containsNestedElement(graph, element.id) || referenced.has(element.id)) {
36223
36249
  continue;
@@ -37776,7 +37802,7 @@ var QueryParser = class {
37776
37802
  };
37777
37803
 
37778
37804
  // src/version.ts
37779
- var version = "3.0.0-snapshot.3";
37805
+ var version = "3.0.0-snapshot.5";
37780
37806
 
37781
37807
  // src/index.ts
37782
37808
  var hiddenStructureTypes = /* @__PURE__ */ new Set(["List", "Nothing", "Text", "text"]);
@@ -38497,6 +38523,22 @@ function sharedSkillFiles() {
38497
38523
  path: "references/layered-architecture.md",
38498
38524
  content: genericLayeredArchitectureReference()
38499
38525
  },
38526
+ {
38527
+ path: "references/c1-context.md",
38528
+ content: genericC1ContextReference()
38529
+ },
38530
+ {
38531
+ path: "references/c2-containers.md",
38532
+ content: genericC2ContainersReference()
38533
+ },
38534
+ {
38535
+ path: "references/c3-components.md",
38536
+ content: genericC3ComponentsReference()
38537
+ },
38538
+ {
38539
+ path: "references/c4-deployment.md",
38540
+ content: genericC4DeploymentReference()
38541
+ },
38500
38542
  {
38501
38543
  path: "references/project-structure.md",
38502
38544
  content: genericProjectStructureReference()
@@ -38517,6 +38559,26 @@ function sharedSkillFiles() {
38517
38559
  path: "examples/layered-architecture.ai",
38518
38560
  content: genericLayeredArchitectureExample()
38519
38561
  },
38562
+ {
38563
+ path: "examples/c1-context.ai",
38564
+ content: genericC1ContextExample()
38565
+ },
38566
+ {
38567
+ path: "examples/c2-containers.ai",
38568
+ content: genericC2ContainersExample()
38569
+ },
38570
+ {
38571
+ path: "examples/c3-components.ai",
38572
+ content: genericC3ComponentsExample()
38573
+ },
38574
+ {
38575
+ path: "examples/c4-deployment-framework.ai",
38576
+ content: genericC4DeploymentFrameworkExample()
38577
+ },
38578
+ {
38579
+ path: "examples/c4-deployment.ai",
38580
+ content: genericC4DeploymentExample()
38581
+ },
38520
38582
  {
38521
38583
  path: "examples/c2-containers.aiq",
38522
38584
  content: genericC2QueryExample()
@@ -38593,6 +38655,15 @@ If \`archinsight\` is not available, ask the user to install or expose
38593
38655
  - Read \`references/syntax.md\` before writing unfamiliar Insight syntax.
38594
38656
  - Read \`references/layered-architecture.md\` when decomposing a system across
38595
38657
  C1/C2/C3/C4-style layers.
38658
+ - Read \`references/c1-context.md\` when adding or repairing system context
38659
+ models: actors, owned systems, external systems, and boundary choices.
38660
+ - Read \`references/c2-containers.md\` when adding or repairing
38661
+ container/service-level C2 models for a selected system.
38662
+ - Read \`references/c3-components.md\` when adding or repairing component-level
38663
+ C3 models for a selected container or service.
38664
+ - Read \`references/c4-deployment.md\` when adding or repairing deployment/C4
38665
+ models, infrastructure inventories, environment-scoped infrastructure, or
38666
+ projection rules.
38596
38667
  - Read \`references/project-structure.md\` before searching for declarations,
38597
38668
  planning imports, or making broad edits.
38598
38669
  - Read \`references/core.md\` and \`.core/*.ai\` when checking built-in types,
@@ -38626,6 +38697,15 @@ Treat this \`SKILL.md\` as the entrypoint. Load reference files only when needed
38626
38697
  - Read \`references/syntax.md\` before writing unfamiliar Insight syntax.
38627
38698
  - Read \`references/layered-architecture.md\` before decomposing a system across
38628
38699
  C1/C2/C3/C4-style layers.
38700
+ - Read \`references/c1-context.md\` before adding or repairing system context
38701
+ models: actors, owned systems, external systems, and boundary choices.
38702
+ - Read \`references/c2-containers.md\` before adding or repairing
38703
+ container/service-level C2 models for a selected system.
38704
+ - Read \`references/c3-components.md\` before adding or repairing component-level
38705
+ C3 models for a selected container or service.
38706
+ - Read \`references/c4-deployment.md\` before adding or repairing deployment/C4
38707
+ models, infrastructure inventories, environment-scoped infrastructure, or
38708
+ projection rules.
38629
38709
  - Read \`references/project-structure.md\` before searching for declarations,
38630
38710
  planning imports, or making broad edits.
38631
38711
  - Read \`references/core.md\` and \`.core/*.ai\` before assuming available
@@ -38672,6 +38752,15 @@ If \`archinsight\` is not available, ask the user to install or expose
38672
38752
  - Read \`references/syntax.md\` before writing unfamiliar Insight syntax.
38673
38753
  - Read \`references/layered-architecture.md\` when decomposing a system across
38674
38754
  C1/C2/C3/C4-style layers.
38755
+ - Read \`references/c1-context.md\` when adding or repairing system context
38756
+ models: actors, owned systems, external systems, and boundary choices.
38757
+ - Read \`references/c2-containers.md\` when adding or repairing
38758
+ container/service-level C2 models for a selected system.
38759
+ - Read \`references/c3-components.md\` when adding or repairing component-level
38760
+ C3 models for a selected container or service.
38761
+ - Read \`references/c4-deployment.md\` when adding or repairing deployment/C4
38762
+ models, infrastructure inventories, environment-scoped infrastructure, or
38763
+ projection rules.
38675
38764
  - Read \`references/project-structure.md\` before searching for declarations,
38676
38765
  planning imports, or making broad edits.
38677
38766
  - Read \`references/core.md\` and \`.core/*.ai\` when checking built-in types,
@@ -38706,6 +38795,15 @@ they are needed:
38706
38795
  - Read \`references/syntax.md\` before writing unfamiliar Insight syntax.
38707
38796
  - Read \`references/layered-architecture.md\` before decomposing a system across
38708
38797
  C1/C2/C3/C4-style layers.
38798
+ - Read \`references/c1-context.md\` before adding or repairing system context
38799
+ models: actors, owned systems, external systems, and boundary choices.
38800
+ - Read \`references/c2-containers.md\` before adding or repairing
38801
+ container/service-level C2 models for a selected system.
38802
+ - Read \`references/c3-components.md\` before adding or repairing component-level
38803
+ C3 models for a selected container or service.
38804
+ - Read \`references/c4-deployment.md\` before adding or repairing deployment/C4
38805
+ models, infrastructure inventories, environment-scoped infrastructure, or
38806
+ projection rules.
38709
38807
  - Read \`references/project-structure.md\` before searching for declarations,
38710
38808
  planning imports, or making broad edits.
38711
38809
  - Read \`references/core.md\` and \`.core/*.ai\` before assuming available
@@ -38772,6 +38870,15 @@ sections of Insight unless the existing layering is already understood.
38772
38870
  - Read \`references/syntax.md\` before writing unfamiliar Insight syntax.
38773
38871
  - Read \`references/layered-architecture.md\` when decomposing a system across
38774
38872
  C1/C2/C3/C4-style layers.
38873
+ - Read \`references/c1-context.md\` when adding or repairing system context
38874
+ models: actors, owned systems, external systems, and boundary choices.
38875
+ - Read \`references/c2-containers.md\` when adding or repairing
38876
+ container/service-level C2 models for a selected system.
38877
+ - Read \`references/c3-components.md\` when adding or repairing component-level
38878
+ C3 models for a selected container or service.
38879
+ - Read \`references/c4-deployment.md\` when adding or repairing deployment/C4
38880
+ models, infrastructure inventories, environment-scoped infrastructure, or
38881
+ projection rules.
38775
38882
  - Read \`references/project-structure.md\` before searching for declarations,
38776
38883
  planning imports, or making broad edits.
38777
38884
  - Read \`references/core.md\` and \`.core/*.ai\` when checking built-in types,
@@ -39121,8 +39228,8 @@ label feature.
39121
39228
  Projects can extend the language with typed vocabulary:
39122
39229
 
39123
39230
  \`\`\`insight
39124
- define type Broker of InfrastructureComponent
39125
- constructor broker
39231
+ define type Cache of InfrastructureComponent
39232
+ constructor cache
39126
39233
  \`\`\`
39127
39234
 
39128
39235
  When adding custom types, follow the existing framework files and validate
@@ -39138,7 +39245,8 @@ layer useful on its own.
39138
39245
 
39139
39246
  ## C1: System Context
39140
39247
 
39141
- Start with the context, people, owned systems, and external dependencies.
39248
+ Start with the context, people, owned systems, and external dependencies. Read
39249
+ \`references/c1-context.md\` before writing a real C1 model.
39142
39250
 
39143
39251
  \`\`\`insight
39144
39252
  context ecommerce
@@ -39165,7 +39273,8 @@ which external dependencies matter. Whether a peer is an owned \`system\`, an
39165
39273
 
39166
39274
  ## C2: Containers and Services
39167
39275
 
39168
- Nest deployable units under the owned system:
39276
+ Nest deployable units under the owned system. Read
39277
+ \`references/c2-containers.md\` before writing a real C2 model.
39169
39278
 
39170
39279
  \`\`\`insight
39171
39280
  system storefront
@@ -39191,8 +39300,9 @@ the selected source file.
39191
39300
 
39192
39301
  ## C3: Components
39193
39302
 
39194
- Put component details in a separate file with \`extend\` when the service becomes
39195
- interesting enough to decompose:
39303
+ Put component details in a separate file with \`extend\` when a container or
39304
+ service becomes interesting enough to decompose. Read
39305
+ \`references/c3-components.md\` before writing a real C3 model.
39196
39306
 
39197
39307
  \`\`\`insight
39198
39308
  context ecommerce
@@ -39218,7 +39328,7 @@ can intentionally choose a different scope.
39218
39328
  ## C4 and Deployment
39219
39329
 
39220
39330
  Use deployment profiles and infrastructure types when physical realization is
39221
- important:
39331
+ important. Read \`references/c4-deployment.md\` before writing a real C4 model.
39222
39332
 
39223
39333
  \`\`\`insight
39224
39334
  deploymentProfile production
@@ -39229,9 +39339,12 @@ environment eu
39229
39339
  name = Europe
39230
39340
  \`\`\`
39231
39341
 
39232
- Attach deployment details to systems, containers, services, or links only when
39233
- they clarify real runtime paths.
39234
- C4/deployment files often focus one deployment slice, but the rendered scope is
39342
+ Attach deployment details to systems, containers, services, components, or links
39343
+ only when they clarify real runtime paths. Prefer attaching deployment to C2
39344
+ containers/services when possible because C2 is usually the most representative
39345
+ logical runtime boundary.
39346
+
39347
+ C4/deployment files often focus one deployment slice. The rendered scope is
39235
39348
  defined by the query, projection selectors, and selected source file.
39236
39349
 
39237
39350
  ## Layering Rules
@@ -39246,232 +39359,1523 @@ defined by the query, projection selectors, and selected source file.
39246
39359
  - Validate after each layer before adding the next.
39247
39360
  `;
39248
39361
  }
39249
- function genericProjectStructureReference() {
39250
- return `# Project Structure Workflow
39362
+ function genericC1ContextReference() {
39363
+ return `# C1 System Context
39251
39364
 
39252
- Use \`archinsight structure\` before broad edits, imports, or declaration lookup.
39253
- Do not start with raw grep when you need to know what the linked project
39254
- contains.
39365
+ Use this reference only for C1 work: modeling a bounded context, its users,
39366
+ owned systems, external systems, and high-level relationships.
39255
39367
 
39256
- ## Commands
39368
+ ## What C1 Answers
39257
39369
 
39258
- Human-readable overview:
39370
+ A C1 view answers: "What system are we discussing, who uses it, and which
39371
+ outside systems does it depend on?"
39259
39372
 
39260
- \`\`\`shell
39261
- archinsight structure . --format text
39262
- \`\`\`
39373
+ Do not include containers, services, components, databases, queues, or runtime
39374
+ nodes unless the project deliberately treats them as context-level systems. C1
39375
+ is about boundaries and responsibilities, not implementation structure.
39263
39376
 
39264
- Machine-readable tree:
39377
+ ## C1 Workflow
39265
39378
 
39266
- \`\`\`shell
39267
- archinsight structure . --format json
39268
- \`\`\`
39379
+ 1. Name the bounded \`context <id>\`.
39380
+ 2. Add external actors that initiate or consume behavior.
39381
+ 3. Add owned \`system\` declarations inside the modeled boundary.
39382
+ 4. Add \`external system\` declarations for dependencies outside the boundary.
39383
+ 5. Add high-level links that explain business or capability flow.
39384
+ 6. Validate with \`archinsight link . --format text\`.
39385
+ 7. Render with \`archinsight render . -c <context-id> -v c1 -f svg -o c1.svg\`.
39269
39386
 
39270
- The structure output includes:
39387
+ ## Boundary Choices
39271
39388
 
39272
- - the type hierarchy, including project-defined custom types;
39273
- - context ids;
39274
- - declaration ids and resolved types;
39275
- - source file, line, and column for each declaration;
39276
- - nesting under contexts and parent elements.
39389
+ Choose the modeled boundary before choosing constructors.
39277
39390
 
39278
- ## Declaration Lookup
39391
+ - Use \`system\` for systems owned inside the current context.
39392
+ - Use \`external system\` for systems outside the current context boundary.
39393
+ - Use \`external actor\` for people, roles, teams, or external automation that
39394
+ interacts with the system from outside.
39395
+ - Use \`import <id> from context <context-id>\` when a reusable outside system is
39396
+ declared in another context.
39279
39397
 
39280
- When you need an element for a link or import:
39398
+ Externality is relative. A system can be external to the current system but
39399
+ still owned in the same context. A vendor platform or regulator is usually
39400
+ external to the context.
39281
39401
 
39282
- 1. Run \`archinsight structure . --format text\`.
39283
- 2. Find the relevant context and declaration id in the declarations tree.
39284
- 3. Check the source location shown in parentheses.
39285
- 4. Open that source file for surrounding attributes and relationships.
39286
- 5. Validate after editing with \`archinsight link . --format text\`.
39402
+ ## Basic C1 Pattern
39287
39403
 
39288
- Use \`--format json\` when you need exact source locations for many ids or when
39289
- the text tree is too large.
39404
+ \`\`\`insight
39405
+ context commerce
39406
+ name = Commerce Platform
39290
39407
 
39291
- ## Imports
39408
+ external actor shopper
39409
+ name = Shopper
39410
+ technology = Browser
39411
+ description = Browses products and places orders
39412
+ links:
39413
+ -> storefront
39414
+ description = Shops and checks out
39292
39415
 
39293
- Before adding an import, find the declaration's context in structure output. A
39294
- cross-context link uses the target id and context id:
39416
+ external actor support_agent
39417
+ name = Support agent
39418
+ technology = Back-office browser
39419
+ description = Helps customers investigate orders
39420
+ links:
39421
+ -> order_admin
39422
+ description = Looks up order state and customer communication
39295
39423
 
39296
- \`\`\`insight
39297
- import payments from context external_systems
39424
+ external system payment_provider
39425
+ name = Payment Provider
39426
+ technology = HTTPS API
39427
+ description = Authorizes card payments
39298
39428
 
39299
- links:
39300
- -> payments from external_systems
39429
+ system storefront
39430
+ name = Storefront
39431
+ technology = Web application
39432
+ description = Lets shoppers browse products and place orders
39433
+ links:
39434
+ -> payment_provider
39435
+ technology = HTTPS
39436
+ description = Requests payment authorization
39437
+
39438
+ system order_admin
39439
+ name = Order Admin
39440
+ technology = Internal web application
39441
+ description = Lets support staff inspect and manage orders
39442
+ links:
39443
+ -> storefront
39444
+ description = Reads customer order data
39301
39445
  \`\`\`
39302
39446
 
39303
- Do not guess context ids from filenames. Filenames, context ids, and element ids
39304
- can differ.
39447
+ ## Owned Peer Pattern
39305
39448
 
39306
- ## Type and Constructor Lookup
39449
+ Do not make every peer \`external system\`. If two systems are owned inside the
39450
+ same architecture boundary, keep both as \`system\` and link them:
39307
39451
 
39308
- The type tree tells you where custom elements can be nested. If a constructor or
39309
- attribute is unfamiliar:
39452
+ \`\`\`insight
39453
+ context company_platform
39454
+ name = Company Platform
39310
39455
 
39311
- 1. Inspect \`archinsight structure . --format text\` for project custom types.
39312
- 2. Inspect \`.core/*.ai\` for built-in types.
39313
- 3. Validate a small edit before applying the pattern widely.
39456
+ system fintech
39457
+ name = Fintech
39458
+ description = Payment and account capabilities
39314
39459
 
39315
- Use grep only after structure has identified the likely source file or type. Raw
39316
- grep is a fallback for surrounding comments and prose, not the source of truth
39317
- for project declarations.
39318
- `;
39319
- }
39320
- function genericCoreReference() {
39321
- return `# Core Language Sources
39460
+ system compliance
39461
+ name = Compliance
39462
+ description = Compliance rules, audit, and reporting
39463
+ links:
39464
+ -> fintech
39465
+ description = Reads transactions for screening and reporting
39466
+ \`\`\`
39322
39467
 
39323
- The \`.core/*.ai\` files bundled with this skill are the built-in Archinsight type
39324
- model. Read them when you need to know available constructors, attributes,
39325
- children, presentations, projections, or relationship operators.
39468
+ Here \`fintech\` can be outside the compliance team boundary, but it is not
39469
+ outside the company platform context. Use the context boundary, not team
39470
+ ownership alone, to decide \`system\` vs \`external system\`.
39326
39471
 
39327
- Some agent file tools may classify \`.ai\` as Adobe Illustrator binary files and
39328
- refuse to open them. If that happens, read the bundled sources through the shell:
39472
+ ## Reusable External Context Pattern
39329
39473
 
39330
- \`\`\`shell
39331
- cat .core/core_operator.ai
39332
- sed -n '1,160p' .core/core_system.ai
39333
- \`\`\`
39474
+ When the same outside dependency appears in many contexts, declare it once and
39475
+ import it:
39334
39476
 
39335
- ## Reading Types
39477
+ \`\`\`insight
39478
+ context external_platforms
39479
+
39480
+ external system stripe
39481
+ name = Stripe
39482
+ technology = HTTPS API
39483
+ description = External payment platform
39484
+ \`\`\`
39336
39485
 
39337
39486
  \`\`\`insight
39338
- define type System of SystemElement
39339
- constructor system
39487
+ context commerce
39340
39488
 
39341
- required Text name
39342
- Text technology
39343
- List of Wire links
39344
- List of Container _
39489
+ import stripe from context external_platforms
39490
+
39491
+ system storefront
39492
+ name = Storefront
39493
+ links:
39494
+ -> stripe from external_platforms
39495
+ technology = HTTPS
39496
+ description = Requests payment authorization
39345
39497
  \`\`\`
39346
39498
 
39347
- Interpretation:
39499
+ Use imports for shared declarations; do not duplicate the same vendor system in
39500
+ every context unless the project intentionally wants separate local identities.
39348
39501
 
39349
- - \`define type System of SystemElement\` means \`System\` inherits from
39350
- \`SystemElement\`.
39351
- - \`constructor system\` means \`system <id>\` is valid syntax for that type.
39352
- - \`required Text name\` means \`name = ...\` is required.
39353
- - \`Text technology\` means \`technology = ...\` is optional.
39354
- - \`List of Wire links\` enables a \`links:\` block whose children are wires.
39355
- - \`List of Container _\` means unnamed child containers can be nested here.
39502
+ ## C1 Links
39356
39503
 
39357
- Users can define more types in project files. Always inspect project structure
39358
- and project framework files before assuming only core constructors exist.
39504
+ Links should be high-level and readable:
39359
39505
 
39360
- ## Reading Type Extensions
39506
+ \`\`\`insight
39507
+ links:
39508
+ -> storefront
39509
+ description = Places orders
39510
+ \`\`\`
39361
39511
 
39362
- Project files can extend built-in or custom types:
39512
+ Add \`technology\`, \`call\`, or \`via\` only when the detail is stable and useful
39513
+ at context level. Prefer capability language over endpoint trivia.
39514
+
39515
+ Use \`~>\` for meaningful asynchronous context flows:
39363
39516
 
39364
39517
  \`\`\`insight
39365
- extend type Environment
39366
- Compute compute
39367
- Storage storage
39518
+ links:
39519
+ ~> analytics_platform
39520
+ technology = Kafka
39521
+ via = order.completed
39522
+ description = Publishes completed order events
39368
39523
  \`\`\`
39369
39524
 
39370
- Interpretation:
39525
+ ## What Not To Put In C1
39371
39526
 
39372
- - this changes the \`Environment\` schema, not one concrete environment object;
39373
- - every \`environment <id>\` can now contain or reference the added slots;
39374
- - existing inherited attributes and child slots remain available;
39375
- - later declarations with the same attribute name override that attribute
39376
- definition;
39377
- - multiple \`extend type Environment\` blocks are allowed but produce a warning;
39378
- - \`archinsight structure . --format text\` is the quickest way to inspect the
39379
- effective type tree after extensions are applied.
39527
+ - Internal containers such as \`web_app\`, \`api\`, or \`worker\`.
39528
+ - Components, classes, packages, screens, handlers, or repositories.
39529
+ - Databases, queues, pods, nodes, gateways, or regions unless modeled as
39530
+ context-level systems.
39531
+ - Low-level calls between internals.
39532
+ - Placeholder systems invented only to make the diagram symmetric.
39380
39533
 
39381
- Use \`extend service checkout_api\` or another constructor form only when you
39382
- intend to extend one graph object instance in a \`context\`. Use \`extend type\`
39383
- when you intend to change the available vocabulary/schema for all instances of
39384
- that type.
39534
+ ## Common C1 Mistakes
39385
39535
 
39386
- Keep repeated type extensions in one framework/definitions file when possible.
39387
- If validation reports \`TYPE_EXTENDED_MULTIPLE_TIMES\`, consolidate the
39388
- extensions or confirm with the user that the split is intentional.
39536
+ - Treating a peer owned in the same context as \`external system\`.
39537
+ - Duplicating imported external systems instead of importing the shared
39538
+ declaration.
39539
+ - Adding implementation details that belong to C2/C3/C4.
39540
+ - Drawing a relationship without naming what capability or dependency it means.
39541
+ - Choosing constructors before deciding the context boundary.
39389
39542
 
39390
- ## Reading Relationship Operators
39543
+ ## Validation Commands
39391
39544
 
39392
- Core synchronous and asynchronous links are operators:
39545
+ \`\`\`shell
39546
+ archinsight structure . --format text
39547
+ archinsight link . --format text
39548
+ archinsight render . -c commerce -v c1 -f svg -o commerce-c1.svg
39549
+ \`\`\`
39393
39550
 
39394
- \`\`\`insight
39395
- define operator Wire of Edge
39396
- Text technology
39397
- Text description
39398
- required Text model
39399
- DeploymentProfile deployment
39551
+ Use \`examples/c1-context.ai\` as a compact valid C1 model when syntax is
39552
+ unclear.
39553
+ `;
39554
+ }
39555
+ function genericC2ContainersReference() {
39556
+ return `# C2 Containers and Services
39400
39557
 
39401
- define operator SyncWire of Wire
39402
- constructor -> Element
39403
- on Element
39404
- model = sync
39558
+ Use this reference only for C2 work: decomposing one selected owned system into
39559
+ deployable containers, backend services, and their runtime collaborations.
39405
39560
 
39406
- Text call
39561
+ ## What C2 Answers
39407
39562
 
39408
- define operator AsyncWire of Wire
39409
- constructor ~> Element
39410
- on Element
39411
- model = async
39563
+ A C2 view answers: "Inside this system, which deployable or executable units
39564
+ exist, what technologies do they use, and how do they collaborate?"
39412
39565
 
39413
- Text via
39414
- \`\`\`
39566
+ Prefer one focal system per C2 source file. The built-in C2 view is scoped by
39567
+ the selected source file, so a C2 file should usually contain the selected
39568
+ \`system <id>\` declaration or an \`extend system <id>\` block with its
39569
+ containers/services.
39415
39570
 
39416
- Interpretation:
39571
+ ## C2 Workflow
39417
39572
 
39418
- - \`->\` creates a synchronous \`SyncWire\`.
39419
- - \`~>\` creates an asynchronous \`AsyncWire\`.
39420
- - \`technology\`, \`description\`, and \`deployment\` are common wire attributes.
39421
- - \`call\` is singular and belongs to \`->\`.
39422
- - \`via\` belongs to \`~>\`.
39423
- - \`model\` is set by the operator constructor; do not author it manually unless
39424
- the project explicitly uses that convention.
39573
+ 1. Run \`archinsight structure . --format text\` to find the exact system id,
39574
+ existing containers/services, and external declarations.
39575
+ 2. Create or edit a C2 file in the same \`context <id>\`.
39576
+ 3. Import external systems from other contexts when needed.
39577
+ 4. Add \`container\` declarations for deployable applications or executables.
39578
+ 5. Add \`service\` declarations for backend services or service-like runtime
39579
+ units.
39580
+ 6. Add runtime links between containers/services and real external systems.
39581
+ 7. Validate with \`archinsight link . --format text\`.
39582
+ 8. Render with \`archinsight render . -c <context-id> -s <c2-file.ai> -v c2 -f svg -o c2.svg\`.
39425
39583
 
39426
- ## Reading Presentations
39584
+ ## File Split Pattern
39585
+
39586
+ Keep C1 focused on the system boundary:
39427
39587
 
39428
39588
  \`\`\`insight
39429
- define presentation Element
39430
- header = name
39431
- subtitle = technology
39432
- body = description
39589
+ context commerce
39590
+ name = Commerce Platform
39433
39591
 
39434
- light
39435
- fill = "#438dd5"
39592
+ external system payment_provider
39593
+ name = Payment Provider
39594
+ technology = HTTPS API
39436
39595
 
39437
- graphviz
39438
- shape = box
39596
+ system storefront
39597
+ name = Storefront
39598
+ technology = Commerce system
39599
+ description = Lets shoppers browse products and place orders
39439
39600
  \`\`\`
39440
39601
 
39441
- Presentations define durable visual defaults for rendered diagrams:
39602
+ Put C2 details in a system file:
39442
39603
 
39443
- - \`header\`, \`subtitle\`, and \`body\` map model attributes into labels.
39444
- - \`light\` and \`dark\` define theme-specific colors.
39445
- - \`graphviz\` carries renderer-specific layout/style hints.
39604
+ \`\`\`insight
39605
+ context commerce
39446
39606
 
39447
- Use \`define presentation X\` once when creating a presentation for a new type.
39448
- Use \`extend presentation X\` when changing a built-in or project presentation:
39607
+ extend system storefront
39608
+ container web_app
39609
+ name = Web app
39610
+ technology = SvelteKit, TypeScript
39611
+ description = Renders product pages and checkout screens
39612
+ links:
39613
+ -> checkout_api
39614
+ technology = HTTPS, JSON
39615
+ call = POST /checkout
39616
+ description = Starts checkout and shows order status
39449
39617
 
39450
- \`\`\`insight
39451
- extend presentation AsyncWire
39452
- header = technology
39453
- subtitle = via
39454
- body = description
39618
+ service checkout_api
39619
+ name = Checkout API
39620
+ technology = Kotlin, PostgreSQL
39621
+ description = Prices carts, creates orders, and coordinates payment
39622
+ links:
39623
+ -> payment_provider
39624
+ technology = HTTPS
39625
+ call = POST /payments/authorizations
39626
+ description = Requests payment authorization
39455
39627
  \`\`\`
39456
39628
 
39457
- Presentation extension is a merge, not a full replacement:
39629
+ ## Frontend and Backend Pattern
39458
39630
 
39459
- - omitted slots and section properties are inherited from the base type or
39460
- existing presentation;
39461
- - assigning the same slot or section property overrides that one value;
39462
- - inherited \`graphviz\` settings such as \`style = dashed\` survive unless the
39463
- extension overrides that property;
39464
- - repeated \`define presentation X\` is an error in current Archinsight.
39631
+ Use \`container\` for applications and executables that have an addressable
39632
+ runtime boundary:
39465
39633
 
39466
- Each label slot accepts exactly one attribute name. Do not use expressions,
39467
- lists, text templates, or concatenation in \`header\`, \`subtitle\`, or \`body\`.
39468
- \`body = description via\`, \`body = description, via\`, and
39469
- \`body = description (via)\` mean "look for an attribute with that exact text"
39470
- and will fail validation.
39634
+ \`\`\`insight
39635
+ container web_app
39636
+ name = Web app
39637
+ technology = SvelteKit, TypeScript
39638
+ description = Browser-facing application for customers
39639
+ \`\`\`
39471
39640
 
39472
- The renderer has three label slots: \`header\`, \`subtitle\`, and \`body\`.
39473
- If all three are already used, there is no built-in fourth line for additional
39474
- metadata. Choose the most important attribute for each slot or ask the user
39641
+ Use \`service\` for backend services and service-like runtime units:
39642
+
39643
+ \`\`\`insight
39644
+ service checkout_api
39645
+ name = Checkout API
39646
+ technology = Kotlin, PostgreSQL
39647
+ description = Coordinates checkout and payment authorization
39648
+ \`\`\`
39649
+
39650
+ Do not turn every library, package, or class into a C2 node. Those belong to C3
39651
+ only when they become stable architectural responsibilities.
39652
+
39653
+ ## External System Pattern
39654
+
39655
+ For an external dependency declared in the same context:
39656
+
39657
+ \`\`\`insight
39658
+ external system payment_provider
39659
+ name = Payment Provider
39660
+ technology = HTTPS API
39661
+
39662
+ system storefront
39663
+ name = Storefront
39664
+
39665
+ service checkout_api
39666
+ name = Checkout API
39667
+ links:
39668
+ -> payment_provider
39669
+ technology = HTTPS
39670
+ call = POST /payments/authorizations
39671
+ \`\`\`
39672
+
39673
+ For a dependency declared in another context, import it:
39674
+
39675
+ \`\`\`insight
39676
+ context commerce
39677
+
39678
+ import stripe from context external_platforms
39679
+
39680
+ extend system storefront
39681
+ service checkout_api
39682
+ name = Checkout API
39683
+ links:
39684
+ -> stripe from external_platforms
39685
+ technology = HTTPS
39686
+ call = POST /payments/authorizations
39687
+ \`\`\`
39688
+
39689
+ Do not copy an outside system into the current context just to satisfy a link.
39690
+ Import the real declaration when it is shared.
39691
+
39692
+ ## Async and Eventing Pattern
39693
+
39694
+ Use \`~>\` for meaningful asynchronous relationships:
39695
+
39696
+ \`\`\`insight
39697
+ service checkout_api
39698
+ name = Checkout API
39699
+ links:
39700
+ ~> analytics_platform
39701
+ technology = Kafka
39702
+ via = checkout.completed
39703
+ description = Publishes completed checkout events
39704
+ \`\`\`
39705
+
39706
+ Do not add a broker node just to make an event diagram look familiar. A broker
39707
+ is usually deployment/C4 infrastructure unless the project defines it as a
39708
+ runtime system or service in the selected view.
39709
+
39710
+ ## C2 Link Details
39711
+
39712
+ Use link attributes to make runtime collaboration understandable:
39713
+
39714
+ \`\`\`insight
39715
+ links:
39716
+ -> checkout_api
39717
+ technology = HTTPS, JSON
39718
+ call = POST /checkout
39719
+ description = Starts checkout and returns order status
39720
+ \`\`\`
39721
+
39722
+ \`call\` is singular. Use \`via\` for async topics or channels. Keep endpoint
39723
+ details at C2 only when they clarify the architecture; otherwise use a plain
39724
+ \`description\`.
39725
+
39726
+ ## What Not To Put In C2
39727
+
39728
+ - Components, classes, handlers, repositories, or UI widgets.
39729
+ - Deployment nodes, pods, regions, network gateways, or secret stores unless the
39730
+ project models them as C2 runtime systems.
39731
+ - Database tables and internal schemas.
39732
+ - One-off scripts or build-time tools unless they are real runtime units.
39733
+ - Duplicate links already represented at a lower C3 level unless the C2 view is
39734
+ intentionally showing the rollup.
39735
+
39736
+ ## Common C2 Mistakes
39737
+
39738
+ - Adding C2 nodes directly under \`context\` instead of under a \`system\`.
39739
+ - Modeling infrastructure that belongs to C4/deployment.
39740
+ - Mixing C2 container/service links with C3 component links in the same source
39741
+ file without a clear view goal.
39742
+ - Forgetting \`--source <c2-file.ai>\` when rendering C2.
39743
+ - Making every peer an \`external system\` instead of deciding whether it is
39744
+ owned in the current context.
39745
+
39746
+ ## Validation Commands
39747
+
39748
+ \`\`\`shell
39749
+ archinsight structure . --format text
39750
+ archinsight link . --format text
39751
+ archinsight render . -c commerce -s storefront-containers.ai -v c2 -f svg -o storefront-c2.svg
39752
+ \`\`\`
39753
+
39754
+ Use \`examples/c2-containers.ai\` as a compact valid C2 model when syntax is
39755
+ unclear.
39756
+ `;
39757
+ }
39758
+ function genericC3ComponentsReference() {
39759
+ return `# C3 Components
39760
+
39761
+ Use this reference only for C3 work: decomposing one selected container or
39762
+ service into internal components and their collaborations.
39763
+
39764
+ ## What C3 Answers
39765
+
39766
+ A C3 view answers: "Inside this container/service, what named responsibilities
39767
+ collaborate to deliver its behavior?"
39768
+
39769
+ Prefer one focal container or service per C3 source file. The built-in C3 view
39770
+ is scoped by the selected source file, so the C3 file should usually contain an
39771
+ \`extend container <id>\` or \`extend service <id>\` block for the focal element.
39772
+
39773
+ Do not model every class, function, method, or package. A component should be a
39774
+ stable architectural responsibility that is useful in a diagram and review.
39775
+
39776
+ ## C3 Workflow
39777
+
39778
+ 1. Run \`archinsight structure . --format text\` to find the exact container or
39779
+ service id, available constructors, and existing imports.
39780
+ 2. Create or edit a C3 file in the same \`context <id>\`.
39781
+ 3. Import elements from other contexts only when the component links to them.
39782
+ 4. Use \`extend container <id>\` or \`extend service <id>\`.
39783
+ 5. Add \`component\` declarations with \`name\`, \`technology\`, and
39784
+ \`responsibility\`.
39785
+ 6. Add links between components and to real external endpoints.
39786
+ 7. Validate with \`archinsight link . --format text\`.
39787
+ 8. Render with \`archinsight render . -c <context-id> -s <c3-file.ai> -v c3 -f svg -o c3.svg\`.
39788
+
39789
+ ## File Split Pattern
39790
+
39791
+ Keep the C2 declaration small:
39792
+
39793
+ \`\`\`insight
39794
+ context commerce
39795
+ name = Commerce Platform
39796
+
39797
+ external system payment_provider
39798
+ name = Payment Provider
39799
+ technology = HTTPS API
39800
+
39801
+ system storefront
39802
+ name = Storefront
39803
+
39804
+ service checkout_api
39805
+ name = Checkout API
39806
+ technology = Kotlin, PostgreSQL
39807
+ description = Handles cart pricing, order placement, and payment orchestration
39808
+ \`\`\`
39809
+
39810
+ Put component details in a C3 file:
39811
+
39812
+ \`\`\`insight
39813
+ context commerce
39814
+
39815
+ extend service checkout_api
39816
+ component checkout_controller
39817
+ name = Checkout controller
39818
+ technology = REST controller
39819
+ responsibility = Accepts checkout requests and returns order status
39820
+ links:
39821
+ -> checkout_service
39822
+
39823
+ component checkout_service
39824
+ name = Checkout service
39825
+ technology = Kotlin
39826
+ responsibility = Coordinates pricing, payment authorization, and order creation
39827
+ links:
39828
+ -> payment_gateway
39829
+ -> order_repository
39830
+
39831
+ component payment_gateway
39832
+ name = Payment gateway
39833
+ technology = HTTP client
39834
+ responsibility = Translates internal payment commands to provider API calls
39835
+ links:
39836
+ -> payment_provider
39837
+ technology = HTTPS
39838
+ call = POST /payments/authorizations
39839
+ description = Authorizes customer payment
39840
+
39841
+ component order_repository
39842
+ name = Order repository
39843
+ technology = SQL
39844
+ responsibility = Persists order state and checkout audit records
39845
+ \`\`\`
39846
+
39847
+ ## Frontend Container Pattern
39848
+
39849
+ Use C3 for UI responsibilities when the frontend container has distinct
39850
+ architectural parts:
39851
+
39852
+ \`\`\`insight
39853
+ context commerce
39854
+
39855
+ extend container web_app
39856
+ component route_shell
39857
+ name = Route shell
39858
+ technology = SvelteKit routing
39859
+ responsibility = Owns route loading, authenticated layout, and page composition
39860
+ links:
39861
+ -> checkout_page
39862
+ -> session_store
39863
+
39864
+ component checkout_page
39865
+ name = Checkout page
39866
+ technology = Svelte
39867
+ responsibility = Collects checkout input and presents order progress
39868
+ links:
39869
+ -> api_client
39870
+
39871
+ component session_store
39872
+ name = Session store
39873
+ technology = Browser storage
39874
+ responsibility = Keeps current user and session state for client-side decisions
39875
+
39876
+ component api_client
39877
+ name = API client
39878
+ technology = Fetch, JSON
39879
+ responsibility = Wraps backend API calls and maps transport errors to UI state
39880
+ links:
39881
+ -> checkout_api
39882
+ technology = HTTPS, JSON
39883
+ call = POST /checkout
39884
+ \`\`\`
39885
+
39886
+ This is useful when frontend structure affects architecture. If the frontend is
39887
+ only a thin page with no meaningful internal decisions, leave it at C2.
39888
+
39889
+ ## Backend Service Pattern
39890
+
39891
+ Use C3 to separate adapters, orchestration, domain logic, persistence, and
39892
+ integration boundaries:
39893
+
39894
+ \`\`\`insight
39895
+ context commerce
39896
+
39897
+ extend service inventory_api
39898
+ component inventory_resource
39899
+ name = Inventory resource
39900
+ technology = REST
39901
+ responsibility = Exposes stock reservations and availability endpoints
39902
+ links:
39903
+ -> reservation_service
39904
+
39905
+ component reservation_service
39906
+ name = Reservation service
39907
+ technology = Java
39908
+ responsibility = Applies reservation rules and coordinates stock updates
39909
+ links:
39910
+ -> inventory_policy
39911
+ -> reservation_repository
39912
+ ~> inventory_events
39913
+ technology = Kafka
39914
+ via = inventory.reserved
39915
+ description = Publishes successful reservation events
39916
+
39917
+ component inventory_policy
39918
+ name = Inventory policy
39919
+ technology = Java
39920
+ responsibility = Decides whether stock can be promised to an order
39921
+
39922
+ component reservation_repository
39923
+ name = Reservation repository
39924
+ technology = SQL
39925
+ responsibility = Stores reservation state and idempotency keys
39926
+
39927
+ component inventory_events
39928
+ name = Inventory events
39929
+ technology = Kafka producer
39930
+ responsibility = Publishes inventory domain events for downstream systems
39931
+ \`\`\`
39932
+
39933
+ Use \`->\` for synchronous calls and \`~>\` for asynchronous flows. Use singular
39934
+ \`call\` for the synchronous operation and \`via\` for the asynchronous topic,
39935
+ queue, or channel.
39936
+
39937
+ ## Imported Boundary Pattern
39938
+
39939
+ When a component links to an element from another context, import it and use
39940
+ \`from <context-id>\` on the link target:
39941
+
39942
+ \`\`\`insight
39943
+ context commerce
39944
+
39945
+ import fraud_api from context risk_platform
39946
+
39947
+ extend service checkout_api
39948
+ component risk_adapter
39949
+ name = Risk adapter
39950
+ technology = HTTP client
39951
+ responsibility = Requests fraud decisions before payment authorization
39952
+ links:
39953
+ -> fraud_api from risk_platform
39954
+ technology = HTTPS
39955
+ call = POST /risk/decisions
39956
+ description = Requests checkout risk decision
39957
+ \`\`\`
39958
+
39959
+ Do not copy an imported system into the current context just to make the C3
39960
+ diagram render. Import the real declaration and validate the link.
39961
+
39962
+ ## Component Naming
39963
+
39964
+ Prefer names that reveal responsibility:
39965
+
39966
+ - \`checkout_controller\`, \`checkout_service\`, \`payment_gateway\`
39967
+ - \`reservation_policy\`, \`reservation_repository\`, \`inventory_events\`
39968
+ - \`route_shell\`, \`checkout_page\`, \`api_client\`
39969
+
39970
+ Avoid names that are only implementation trivia:
39971
+
39972
+ - \`utils\`, \`helpers\`, \`module1\`, \`manager\`
39973
+ - individual classes unless the class is the architectural boundary
39974
+ - framework-generated files or folders
39975
+
39976
+ ## Responsibility Boundaries
39977
+
39978
+ A good C3 component has at least one of these:
39979
+
39980
+ - a distinct external adapter;
39981
+ - a domain or orchestration responsibility;
39982
+ - a persistence boundary;
39983
+ - an asynchronous producer or consumer role;
39984
+ - a security, policy, parsing, rendering, or transformation responsibility;
39985
+ - a UI composition, state, or backend API boundary that affects architecture.
39986
+
39987
+ If a component cannot be described without mentioning code organization only,
39988
+ leave it out or ask for a more architectural boundary.
39989
+
39990
+ ## Links in C3
39991
+
39992
+ Links should explain runtime collaboration inside the focal container/service.
39993
+
39994
+ Use internal component links:
39995
+
39996
+ \`\`\`insight
39997
+ links:
39998
+ -> checkout_service
39999
+ \`\`\`
40000
+
40001
+ Add call details when they matter:
40002
+
40003
+ \`\`\`insight
40004
+ links:
40005
+ -> payment_gateway
40006
+ call = authorize(paymentCommand)
40007
+ description = Requests payment authorization
40008
+ \`\`\`
40009
+
40010
+ Use async details for events:
40011
+
40012
+ \`\`\`insight
40013
+ links:
40014
+ ~> inventory_events
40015
+ via = inventory.reserved
40016
+ description = Publishes reservation completion
40017
+ \`\`\`
40018
+
40019
+ Do not add a broker as a component unless the broker is actually part of the
40020
+ focal container/service. Shared brokers, queues, gateways, and runtime placement
40021
+ usually belong to deployment/C4 or infrastructure modeling.
40022
+
40023
+ ## Common C3 Mistakes
40024
+
40025
+ - Writing C3 components under a \`system\` instead of under a container/service
40026
+ unless the project type model explicitly allows that.
40027
+ - Creating one C3 file for every class or package.
40028
+ - Linking to an external element without importing it when it lives in another
40029
+ context.
40030
+ - Forgetting \`--source <c3-file.ai>\` when rendering C3.
40031
+ - Mixing C2 container links and C3 component links in one view question.
40032
+ - Keeping a broad container/service link and an equivalent lower-level component
40033
+ link without deciding which level should own the relationship.
40034
+ - Inventing components to satisfy a diagram shape instead of describing real
40035
+ responsibilities.
40036
+
40037
+ ## Validation Commands
40038
+
40039
+ \`\`\`shell
40040
+ archinsight structure . --format text
40041
+ archinsight link . --format text
40042
+ archinsight render . -c commerce -s checkout_components.ai -v c3 -f svg -o checkout-c3.svg
40043
+ \`\`\`
40044
+
40045
+ Use \`examples/c3-components.ai\` as a compact valid C3 model when syntax is
40046
+ unclear.
40047
+ `;
40048
+ }
40049
+ function genericC4DeploymentReference() {
40050
+ return `# C4 Deployment and Infrastructure
40051
+
40052
+ Use this reference only for C4 work: deployment profiles, environments,
40053
+ environment-scoped infrastructure inventory, \`uses\` / \`runsOn\`, and
40054
+ projection rules.
40055
+
40056
+ ## Contents
40057
+
40058
+ - What C4 Answers
40059
+ - Mental Model
40060
+ - C4 Workflow
40061
+ - Environment Inventory
40062
+ - Why Infrastructure Is Per Environment
40063
+ - Attaching Deployment To C1-C3 Elements
40064
+ - usesProfile, environmentsFrom, runsOn, and uses
40065
+ - Deployment Archetypes
40066
+ - Projection Rules
40067
+ - Traffic Path Example
40068
+ - Compute and Grouping
40069
+ - Many-To-Many Deployment
40070
+ - What Not To Put In C4
40071
+ - Common C4 Mistakes
40072
+ - Validation Commands
40073
+
40074
+ ## What C4 Answers
40075
+
40076
+ A C4/deployment view answers: "Where do logical architecture elements run, what
40077
+ environment-specific infrastructure do they use, and what physical path does a
40078
+ logical relationship expand into?"
40079
+
40080
+ C4 is not just another decomposition level. C1-C3 mostly describe logical
40081
+ architecture. C4 maps logical elements and links onto environment-local
40082
+ infrastructure inventory.
40083
+
40084
+ ## Mental Model
40085
+
40086
+ There are three layers:
40087
+
40088
+ 1. Schema: extend \`Environment\` with infrastructure slots such as
40089
+ \`Compute compute\`, \`Storage storage\`, \`Broker broker\`,
40090
+ \`NetworkConnection network\`, or \`PublicGateway publicGateway\`.
40091
+ \`Compute\`, \`Storage\`, \`Broker\`, and \`NetworkConnection\` are core
40092
+ deployment types.
40093
+ 2. Inventory: each \`environment <id>\` fills those slots with concrete
40094
+ infrastructure instances for that environment.
40095
+ 3. Deployment references: logical systems, containers, services, components, or
40096
+ links use \`deployment:\` with \`runsOn\`, \`uses\`, \`usesProfile\`, or
40097
+ \`environmentsFrom\` to reference the inventory.
40098
+
40099
+ An \`InfrastructureComponent\` is not an orphan. It is usually inventory inside
40100
+ an \`environment\` slot. The hook is the type extension:
40101
+
40102
+ \`\`\`insight
40103
+ extend type Environment
40104
+ Compute compute
40105
+ Storage storage
40106
+ Broker broker
40107
+ NetworkConnection network
40108
+ PublicGateway publicGateway
40109
+ \`\`\`
40110
+
40111
+ After that, every \`environment <id>\` can provide those slots:
40112
+
40113
+ \`\`\`insight
40114
+ environment prod
40115
+ name = Production
40116
+
40117
+ compute:
40118
+ compute kube
40119
+ name = Kubernetes
40120
+
40121
+ storage:
40122
+ storage db
40123
+ name = PostgreSQL
40124
+
40125
+ broker:
40126
+ broker events
40127
+ name = Event broker
40128
+ address = kafka.prod.internal:9092
40129
+
40130
+ network:
40131
+ networkConnection private_path
40132
+ name = Private service path
40133
+ \`\`\`
40134
+
40135
+ ## C4 Workflow
40136
+
40137
+ 1. Inspect existing deployment types with \`archinsight structure . --format text\`.
40138
+ 2. Read \`references/core.md\` and project framework files for existing
40139
+ \`extend type Environment\`, infrastructure types, and projection rules.
40140
+ 3. Add or reuse infrastructure types in a definition file. Prefer core
40141
+ \`Compute\`, \`Storage\`, \`Broker\`, and \`NetworkConnection\` for common
40142
+ deployment inventory.
40143
+ 4. Extend \`Environment\` with slots for the infrastructure inventory.
40144
+ 5. Create one or more \`environment <id>\` declarations and fill the slots.
40145
+ 6. Add \`deploymentProfile\` declarations that select environments and common
40146
+ \`runsOn\` / \`uses\` defaults.
40147
+ 7. Attach \`deployment:\` blocks to logical elements or links.
40148
+ 8. Validate with \`archinsight link . --format text\`.
40149
+ 9. Render with \`archinsight render . -c <context-id> -s <c4-file.ai> -v c4 -f svg -o c4.svg\`.
40150
+
40151
+ ## Environment Inventory
40152
+
40153
+ Define infrastructure vocabulary in a definition file:
40154
+
40155
+ \`\`\`insight
40156
+ extend type Environment
40157
+ ServiceProvider cloud
40158
+ Compute compute
40159
+ Storage storage
40160
+ Broker broker
40161
+ NetworkConnection network
40162
+ PublicGateway publicGateway
40163
+
40164
+ define type ServiceProvider of InfrastructureComponent
40165
+ constructor serviceProvider
40166
+
40167
+ define type PublicGateway of InfrastructureComponent
40168
+ constructor publicGateway
40169
+ required InfrastructureComponent cdn
40170
+ required InfrastructureComponent loadBalancer
40171
+ \`\`\`
40172
+
40173
+ Then fill concrete environments:
40174
+
40175
+ \`\`\`insight
40176
+ environment prod
40177
+ name = Production
40178
+
40179
+ cloud:
40180
+ serviceProvider aws
40181
+ name = AWS
40182
+
40183
+ compute:
40184
+ compute eks
40185
+ name = EKS
40186
+ runsOn cloud
40187
+
40188
+ storage:
40189
+ storage orders_db
40190
+ name = Orders PostgreSQL
40191
+ runsOn cloud
40192
+
40193
+ broker:
40194
+ broker events
40195
+ name = Event broker
40196
+ technology = Kafka
40197
+ address = kafka.prod.internal:9092
40198
+ runsOn compute
40199
+
40200
+ network:
40201
+ networkConnection private_path
40202
+ name = Private service path
40203
+ runsOn compute
40204
+
40205
+ publicGateway:
40206
+ publicGateway public_edge
40207
+ name = Public edge
40208
+ cdn:
40209
+ infrastructureComponent cloudfront
40210
+ name = CloudFront
40211
+ runsOn cloud
40212
+ loadBalancer:
40213
+ infrastructureComponent alb
40214
+ name = Application Load Balancer
40215
+ runsOn cloud
40216
+ runsOn compute
40217
+ \`\`\`
40218
+
40219
+ \`cloud\`, \`compute\`, \`storage\`, and \`publicGateway\` are slots on this
40220
+ specific \`prod\` environment. Another environment can fill the same slots with
40221
+ different concrete infrastructure.
40222
+
40223
+ ## Why Infrastructure Is Per Environment
40224
+
40225
+ Infrastructure must be per environment because deployment is many-to-many:
40226
+
40227
+ - one logical service can run in several environments;
40228
+ - each environment can use different compute, storage, gateways, regions, or
40229
+ providers;
40230
+ - the same \`uses storage\` reference must resolve to the current environment's
40231
+ storage instance, not to one global database node;
40232
+ - projection rules need environment-local inventory to expand logical edges into
40233
+ physical paths.
40234
+
40235
+ If infrastructure were modeled as global nodes, the model could not say:
40236
+ "Checkout API runs on EKS in production, Cloud Run in staging, and uses a
40237
+ different database in each environment" without duplicating logical services.
40238
+
40239
+ ## Attaching Deployment To C1-C3 Elements
40240
+
40241
+ \`deployment\` is available on systems, containers/services, components, and
40242
+ wires. Attach it where it best represents the runtime boundary.
40243
+
40244
+ Prefer C2 containers/services for most deployment mapping:
40245
+
40246
+ - C1 systems are often too broad and hide real runtime placement.
40247
+ - C3 components are often too fine and can overfit code structure.
40248
+ - C2 containers/services usually represent deployable runtime units.
40249
+
40250
+ Use C1 deployment only when the whole system is deployed as one unit. Use C3
40251
+ deployment when a component is independently deployed or has a distinct physical
40252
+ path. Use wire deployment when a specific logical relationship travels through
40253
+ infrastructure such as a public gateway, private gateway, broker, or egress path.
40254
+
40255
+ ## usesProfile, environmentsFrom, runsOn, and uses
40256
+
40257
+ \`deploymentProfile\` names a reusable deployment scope:
40258
+
40259
+ \`\`\`insight
40260
+ deploymentProfile global
40261
+ environments:
40262
+ prod
40263
+ staging
40264
+
40265
+ runsOn compute
40266
+ \`\`\`
40267
+
40268
+ \`usesProfile\` copies the profile's environments and deployment operators to a
40269
+ logical element:
40270
+
40271
+ \`\`\`insight
40272
+ service checkout_api
40273
+ name = Checkout API
40274
+ deployment:
40275
+ usesProfile global
40276
+ uses storage
40277
+ \`\`\`
40278
+
40279
+ \`runsOn compute\` resolves the \`compute\` slot inside each selected
40280
+ environment and stores it as the logical element's placement. \`uses storage\`
40281
+ resolves the environment-local \`storage\` slot and projects edges to it.
40282
+
40283
+ \`environmentsFrom global\` copies only the environments from a profile. It is
40284
+ useful on a link when the path should share the same environment set but use its
40285
+ own infrastructure. It deliberately does not copy \`runsOn\` or \`uses\` from
40286
+ the profile:
40287
+
40288
+ \`\`\`insight
40289
+ links:
40290
+ -> checkout_api
40291
+ deployment:
40292
+ environmentsFrom global
40293
+ uses publicGateway
40294
+ \`\`\`
40295
+
40296
+ \`usesProfile global\` copies environments and profile operators. Use it on an
40297
+ element when the profile's defaults apply. Use \`environmentsFrom global\` on a
40298
+ link when only the environment scope should be reused.
40299
+
40300
+ You can also use \`environmentsFrom\` on an element when it should share the
40301
+ profile's environment list but choose its own placement or dependencies:
40302
+
40303
+ \`\`\`insight
40304
+ service batch_worker
40305
+ name = Batch Worker
40306
+ deployment:
40307
+ environmentsFrom regional_service
40308
+ runsOn compute
40309
+ uses storage
40310
+ \`\`\`
40311
+
40312
+ Here \`batch_worker\` deploys to the same environments as
40313
+ \`regional_service\`, but it does not inherit \`regional_service\` defaults such
40314
+ as \`uses observability\`. Add every desired \`runsOn\` and \`uses\` explicitly.
40315
+
40316
+ ## Deployment Archetypes
40317
+
40318
+ Use \`deploymentProfile\` to create named deployment archetypes such as
40319
+ \`global_service\`, \`regional_service\`, or \`public_regional_service\`. A
40320
+ profile should select concrete \`environment\` instances and attach the common
40321
+ deployment operators that most services of that archetype need.
40322
+
40323
+ Example environment inventory:
40324
+
40325
+ \`\`\`insight
40326
+ environment global_edge
40327
+ name = Global edge
40328
+
40329
+ compute:
40330
+ compute edge_runtime
40331
+ name = Edge runtime
40332
+
40333
+ publicGateway:
40334
+ publicGateway edge_gateway
40335
+ name = Global public gateway
40336
+ cdn:
40337
+ infrastructureComponent cloudfront
40338
+ name = CloudFront
40339
+ loadBalancer:
40340
+ infrastructureComponent global_lb
40341
+ name = Global Load Balancer
40342
+
40343
+ environment eu
40344
+ name = Europe
40345
+
40346
+ compute:
40347
+ compute kube_eu
40348
+ name = Kubernetes EU
40349
+
40350
+ storage:
40351
+ storage db_eu
40352
+ name = PostgreSQL EU
40353
+
40354
+ observability:
40355
+ monitoring otel_eu
40356
+ name = OpenTelemetry Collector EU
40357
+ display:
40358
+ infrastructureComponent grafana
40359
+ name = Grafana Cloud
40360
+ \`\`\`
40361
+
40362
+ Example profiles:
40363
+
40364
+ \`\`\`insight
40365
+ deploymentProfile global_service
40366
+ environments:
40367
+ global_edge
40368
+
40369
+ runsOn compute
40370
+ uses publicGateway
40371
+
40372
+ deploymentProfile regional_service
40373
+ environments:
40374
+ eu
40375
+
40376
+ runsOn compute
40377
+ uses observability
40378
+ \`\`\`
40379
+
40380
+ Then attach the archetype with one \`usesProfile\`:
40381
+
40382
+ \`\`\`insight
40383
+ container web_app
40384
+ name = Web app
40385
+ deployment:
40386
+ usesProfile global_service
40387
+
40388
+ service checkout_api
40389
+ name = Checkout API
40390
+ deployment:
40391
+ usesProfile regional_service
40392
+ uses storage
40393
+ \`\`\`
40394
+
40395
+ The profile supplies the common environment scope, placement, and standard
40396
+ infrastructure. Additional local \`uses\` entries extend the profile for that
40397
+ specific element. In the example, \`checkout_api\` inherits regional compute and
40398
+ observability from \`regional_service\`, then adds its own \`uses storage\`
40399
+ because this service owns persistent state.
40400
+
40401
+ Use separate profiles when the default infrastructure differs. For example,
40402
+ \`public_regional_service\` can include both \`uses observability\` and
40403
+ \`uses publicGateway\`, while \`regional_worker\` may use the same environments,
40404
+ compute, and observability but omit public ingress. Put path-only infrastructure
40405
+ such as \`network\` on the wire deployment when it represents a specific
40406
+ service-to-service path.
40407
+
40408
+ When an element should reuse only the environments from an archetype, use
40409
+ \`environmentsFrom <profile>\` instead of \`usesProfile <profile>\` and then add
40410
+ the local \`runsOn\` / \`uses\` entries explicitly.
40411
+
40412
+ Do not try to make infrastructure global to avoid repeating profiles. The
40413
+ profile should select environment instances; the selected environments provide
40414
+ their own concrete infrastructure through slots.
40415
+
40416
+ ## Projection Rules
40417
+
40418
+ Projection rules live on infrastructure types. They explain how a logical
40419
+ \`uses <slot>\` reference expands into projected graph edges.
40420
+
40421
+ Core defaults:
40422
+
40423
+ - \`Storage\`: \`$from -> $this\`.
40424
+ - \`Broker\`: \`$from -> $this\` and \`$to -> $this\`, because both sides
40425
+ physically connect to the broker.
40426
+ - \`NetworkConnection\`: \`$from -> $to\`, for an ordinary direct network call
40427
+ that should still appear on the deployment layer.
40428
+
40429
+ Custom infrastructure types can define their own projection rules.
40430
+
40431
+ \`\`\`insight
40432
+ define type PublicGateway of InfrastructureComponent
40433
+ constructor publicGateway
40434
+ required InfrastructureComponent cdn
40435
+ required InfrastructureComponent loadBalancer
40436
+
40437
+ project:
40438
+ $from -> cdn
40439
+ cdn -> loadBalancer
40440
+ loadBalancer -> $this
40441
+ $this -> $to
40442
+ \`\`\`
40443
+
40444
+ When a service says \`uses storage\`, the selected environment's storage instance
40445
+ receives a projected edge from the logical service:
40446
+
40447
+ \`\`\`text
40448
+ checkout_api -> prod.orders_db
40449
+ checkout_api -> staging.orders_db
40450
+ \`\`\`
40451
+
40452
+ When a wire says \`uses network\`, the selected environment's network connection
40453
+ keeps the logical source-to-target relationship visible in the deployment view:
40454
+
40455
+ \`\`\`insight
40456
+ links:
40457
+ -> checkout_api
40458
+ deployment:
40459
+ environmentsFrom regional_service
40460
+ uses network
40461
+ \`\`\`
40462
+
40463
+ If a logical relationship is missing from a C4/deployment diagram, check whether
40464
+ the wire has deployment information and uses a path-producing slot such as
40465
+ \`network\`, \`publicGateway\`, or another type with a \`project:\` rule. C4
40466
+ queries commonly select projected deployment edges; a plain logical wire without
40467
+ deployment projection may be correct in C2/C3 but absent from the deployment
40468
+ layer.
40469
+
40470
+ Projection terms:
40471
+
40472
+ - \`$from\` is the logical source of the deployment use.
40473
+ - \`$to\` is the logical target when the deployment is attached to a wire.
40474
+ - \`$this\` is the infrastructure component instance selected by \`uses\`.
40475
+ - plain names such as \`cdn\` or \`loadBalancer\` are attributes/slots on
40476
+ \`$this\`.
40477
+
40478
+ ## Traffic Path Example
40479
+
40480
+ A public gateway can expand one logical edge into a physical path:
40481
+
40482
+ \`\`\`insight
40483
+ define type PublicGateway of InfrastructureComponent
40484
+ constructor publicGateway
40485
+ required InfrastructureComponent cdn
40486
+ required InfrastructureComponent loadBalancer
40487
+
40488
+ project:
40489
+ $from -> cdn
40490
+ cdn -> loadBalancer
40491
+ loadBalancer -> $this
40492
+ $this -> $to
40493
+ \`\`\`
40494
+
40495
+ Given this logical relationship:
40496
+
40497
+ \`\`\`insight
40498
+ external actor customer
40499
+ name = Customer
40500
+ links:
40501
+ -> web_app
40502
+ deployment:
40503
+ environmentsFrom public_regional_service
40504
+ uses publicGateway
40505
+ \`\`\`
40506
+
40507
+ And this environment inventory:
40508
+
40509
+ \`\`\`insight
40510
+ environment prod
40511
+ name = Production
40512
+
40513
+ publicGateway:
40514
+ publicGateway public_edge
40515
+ name = Public edge
40516
+ cdn:
40517
+ infrastructureComponent cloudfront
40518
+ name = CloudFront
40519
+ loadBalancer:
40520
+ infrastructureComponent alb
40521
+ name = Application Load Balancer
40522
+ \`\`\`
40523
+
40524
+ The projection creates the physical path:
40525
+
40526
+ \`\`\`text
40527
+ customer -> cloudfront -> alb -> public_edge -> web_app
40528
+ \`\`\`
40529
+
40530
+ The logical edge remains the authoring intent. The projected edges are derived
40531
+ from deployment inventory and the \`project:\` rule.
40532
+
40533
+ ## Compute and Grouping
40534
+
40535
+ \`runsOn compute\` is placement, not a traffic path by itself. It resolves the
40536
+ selected environment's compute slot and marks where a logical element runs:
40537
+
40538
+ \`\`\`insight
40539
+ deploymentProfile regional_service
40540
+ environments:
40541
+ prod
40542
+ staging
40543
+
40544
+ runsOn compute
40545
+ uses observability
40546
+
40547
+ deploymentProfile public_regional_service
40548
+ environments:
40549
+ prod
40550
+ staging
40551
+
40552
+ runsOn compute
40553
+ uses observability
40554
+ uses publicGateway
40555
+
40556
+ service checkout_api
40557
+ name = Checkout API
40558
+ deployment:
40559
+ usesProfile global
40560
+ \`\`\`
40561
+
40562
+ If \`prod.compute\` is EKS and \`staging.compute\` is Cloud Run, the same
40563
+ \`checkout_api\` can render in both compute groups. The built-in C4 query groups
40564
+ by \`node.runsOn\`, so compute is usually the visual grouping anchor.
40565
+
40566
+ Use \`runsOn\` on infrastructure too:
40567
+
40568
+ \`\`\`insight
40569
+ storage orders_db
40570
+ name = Orders PostgreSQL
40571
+ runsOn cloud
40572
+ \`\`\`
40573
+
40574
+ This places the database under its provider or parent infrastructure in the
40575
+ rendered deployment graph.
40576
+
40577
+ ## Many-To-Many Deployment
40578
+
40579
+ This is the core reason for the model:
40580
+
40581
+ \`\`\`insight
40582
+ deploymentProfile global
40583
+ environments:
40584
+ prod
40585
+ staging
40586
+
40587
+ runsOn compute
40588
+
40589
+ service checkout_api
40590
+ name = Checkout API
40591
+ deployment:
40592
+ usesProfile global
40593
+ uses storage
40594
+ \`\`\`
40595
+
40596
+ If \`prod.compute = EKS\`, \`prod.storage = Aurora\`,
40597
+ \`staging.compute = Cloud Run\`, and \`staging.storage = Cloud SQL\`, the single
40598
+ logical service projects into both environments without duplicating
40599
+ \`checkout_api\`.
40600
+
40601
+ ## What Not To Put In C4
40602
+
40603
+ - Global infrastructure nodes when the infrastructure differs by environment.
40604
+ - Logical components invented only to represent physical routing.
40605
+ - C3 internals unless they are independently deployed.
40606
+ - Cloud resources with no relationship to a deployment question.
40607
+ - A broker/gateway/load balancer in C2 just because it appears in deployment.
40608
+
40609
+ ## Common C4 Mistakes
40610
+
40611
+ - Defining infrastructure types but forgetting to extend \`Environment\` with
40612
+ slots for them.
40613
+ - Creating \`infrastructureComponent\` nodes at context level when they should
40614
+ live in an \`environment\` inventory slot.
40615
+ - Using \`usesProfile\` on a wire when only \`environmentsFrom\` is intended.
40616
+ - Forgetting \`--source <c4-file.ai>\` when rendering C4.
40617
+ - Expecting \`runsOn\` to draw traffic; use \`project:\` rules and \`uses\` for
40618
+ traffic/path projections.
40619
+ - Treating projected edges as source declarations; they are derived.
40620
+
40621
+ ## Validation Commands
40622
+
40623
+ \`\`\`shell
40624
+ archinsight structure . --format text
40625
+ archinsight link . --format text
40626
+ archinsight render . -c deployment_shop -s c4-deployment.ai -v c4 -f svg -o deployment-c4.svg
40627
+ \`\`\`
40628
+
40629
+ Use \`examples/c4-deployment-framework.ai\` and \`examples/c4-deployment.ai\` as
40630
+ a compact valid C4 model when syntax is unclear.
40631
+ `;
40632
+ }
40633
+ function genericProjectStructureReference() {
40634
+ return `# Project Structure Workflow
40635
+
40636
+ Use \`archinsight structure\` before broad edits, imports, or declaration lookup.
40637
+ Do not start with raw grep when you need to know what the linked project
40638
+ contains.
40639
+
40640
+ ## Commands
40641
+
40642
+ Human-readable overview:
40643
+
40644
+ \`\`\`shell
40645
+ archinsight structure . --format text
40646
+ \`\`\`
40647
+
40648
+ Machine-readable tree:
40649
+
40650
+ \`\`\`shell
40651
+ archinsight structure . --format json
40652
+ \`\`\`
40653
+
40654
+ The structure output includes:
40655
+
40656
+ - the type hierarchy, including project-defined custom types;
40657
+ - context ids;
40658
+ - declaration ids and resolved types;
40659
+ - source file, line, and column for each declaration;
40660
+ - nesting under contexts and parent elements.
40661
+
40662
+ ## Declaration Lookup
40663
+
40664
+ When you need an element for a link or import:
40665
+
40666
+ 1. Run \`archinsight structure . --format text\`.
40667
+ 2. Find the relevant context and declaration id in the declarations tree.
40668
+ 3. Check the source location shown in parentheses.
40669
+ 4. Open that source file for surrounding attributes and relationships.
40670
+ 5. Validate after editing with \`archinsight link . --format text\`.
40671
+
40672
+ Use \`--format json\` when you need exact source locations for many ids or when
40673
+ the text tree is too large.
40674
+
40675
+ ## Imports
40676
+
40677
+ Before adding an import, find the declaration's context in structure output. A
40678
+ cross-context link uses the target id and context id:
40679
+
40680
+ \`\`\`insight
40681
+ import payments from context external_systems
40682
+
40683
+ links:
40684
+ -> payments from external_systems
40685
+ \`\`\`
40686
+
40687
+ Do not guess context ids from filenames. Filenames, context ids, and element ids
40688
+ can differ.
40689
+
40690
+ ## Type and Constructor Lookup
40691
+
40692
+ The type tree tells you where custom elements can be nested. If a constructor or
40693
+ attribute is unfamiliar:
40694
+
40695
+ 1. Inspect \`archinsight structure . --format text\` for project custom types.
40696
+ 2. Inspect \`.core/*.ai\` for built-in types.
40697
+ 3. Validate a small edit before applying the pattern widely.
40698
+
40699
+ Use grep only after structure has identified the likely source file or type. Raw
40700
+ grep is a fallback for surrounding comments and prose, not the source of truth
40701
+ for project declarations.
40702
+ `;
40703
+ }
40704
+ function genericCoreReference() {
40705
+ return `# Core Language Sources
40706
+
40707
+ The \`.core/*.ai\` files bundled with this skill are the built-in Archinsight type
40708
+ model. Read them when you need to know available constructors, attributes,
40709
+ children, presentations, projections, or relationship operators.
40710
+
40711
+ Some agent file tools may classify \`.ai\` as Adobe Illustrator binary files and
40712
+ refuse to open them. If that happens, read the bundled sources through the shell:
40713
+
40714
+ \`\`\`shell
40715
+ cat .core/core_operator.ai
40716
+ sed -n '1,160p' .core/core_system.ai
40717
+ \`\`\`
40718
+
40719
+ ## Reading Types
40720
+
40721
+ \`\`\`insight
40722
+ define type System of SystemElement
40723
+ constructor system
40724
+
40725
+ required Text name
40726
+ Text technology
40727
+ List of Wire links
40728
+ List of Container _
40729
+ \`\`\`
40730
+
40731
+ Interpretation:
40732
+
40733
+ - \`define type System of SystemElement\` means \`System\` inherits from
40734
+ \`SystemElement\`.
40735
+ - \`constructor system\` means \`system <id>\` is valid syntax for that type.
40736
+ - \`required Text name\` means \`name = ...\` is required.
40737
+ - \`Text technology\` means \`technology = ...\` is optional.
40738
+ - \`List of Wire links\` enables a \`links:\` block whose children are wires.
40739
+ - \`List of Container _\` means unnamed child containers can be nested here.
40740
+
40741
+ Users can define more types in project files. Always inspect project structure
40742
+ and project framework files before assuming only core constructors exist.
40743
+
40744
+ ## Built-in Deployment Infrastructure
40745
+
40746
+ \`core_deployment.ai\` provides common infrastructure inventory types:
40747
+
40748
+ - \`InfrastructureComponent\`: optional \`name\`, \`technology\`,
40749
+ \`description\`, plus deployment references.
40750
+ - \`Storage\` / constructor \`storage\`: for databases, buckets, volumes, and
40751
+ other stateful stores.
40752
+ - \`Broker\` / constructor \`broker\`: for message brokers and event buses;
40753
+ adds optional \`address\`.
40754
+ - \`Compute\` / constructor \`compute\`: for runtimes, clusters, nodes, and
40755
+ platforms; adds optional \`address\` and can contain nested infrastructure
40756
+ components in a \`components:\` block.
40757
+ - \`NetworkConnection\` / constructor \`networkConnection\`: for a direct
40758
+ network hop that projects \`$from -> $to\` on deployment views.
40759
+
40760
+ Extend \`Environment\` with slots for these types, then fill each concrete
40761
+ \`environment <id>\` with env-local instances.
40762
+
40763
+ ## Reading Type Extensions
40764
+
40765
+ Project files can extend built-in or custom types:
40766
+
40767
+ \`\`\`insight
40768
+ extend type Environment
40769
+ Compute compute
40770
+ Storage storage
40771
+ Broker broker
40772
+ \`\`\`
40773
+
40774
+ Interpretation:
40775
+
40776
+ - this changes the \`Environment\` schema, not one concrete environment object;
40777
+ - every \`environment <id>\` can now contain or reference the added slots;
40778
+ - existing inherited attributes and child slots remain available;
40779
+ - later declarations with the same attribute name override that attribute
40780
+ definition;
40781
+ - multiple \`extend type Environment\` blocks are allowed but produce a warning;
40782
+ - \`archinsight structure . --format text\` is the quickest way to inspect the
40783
+ effective type tree after extensions are applied.
40784
+
40785
+ Use \`extend service checkout_api\` or another constructor form only when you
40786
+ intend to extend one graph object instance in a \`context\`. Use \`extend type\`
40787
+ when you intend to change the available vocabulary/schema for all instances of
40788
+ that type.
40789
+
40790
+ Keep repeated type extensions in one framework/definitions file when possible.
40791
+ If validation reports \`TYPE_EXTENDED_MULTIPLE_TIMES\`, consolidate the
40792
+ extensions or confirm with the user that the split is intentional.
40793
+
40794
+ ## Reading Relationship Operators
40795
+
40796
+ Core synchronous and asynchronous links are operators:
40797
+
40798
+ \`\`\`insight
40799
+ define operator Wire of Edge
40800
+ Text technology
40801
+ Text description
40802
+ required Text model
40803
+ DeploymentProfile deployment
40804
+
40805
+ define operator SyncWire of Wire
40806
+ constructor -> Element
40807
+ on Element
40808
+ model = sync
40809
+
40810
+ Text call
40811
+
40812
+ define operator AsyncWire of Wire
40813
+ constructor ~> Element
40814
+ on Element
40815
+ model = async
40816
+
40817
+ Text via
40818
+ \`\`\`
40819
+
40820
+ Interpretation:
40821
+
40822
+ - \`->\` creates a synchronous \`SyncWire\`.
40823
+ - \`~>\` creates an asynchronous \`AsyncWire\`.
40824
+ - \`technology\`, \`description\`, and \`deployment\` are common wire attributes.
40825
+ - \`call\` is singular and belongs to \`->\`.
40826
+ - \`via\` belongs to \`~>\`.
40827
+ - \`model\` is set by the operator constructor; do not author it manually unless
40828
+ the project explicitly uses that convention.
40829
+
40830
+ ## Reading Presentations
40831
+
40832
+ \`\`\`insight
40833
+ define presentation Element
40834
+ header = name
40835
+ subtitle = technology
40836
+ body = description
40837
+
40838
+ light
40839
+ fill = "#438dd5"
40840
+
40841
+ graphviz
40842
+ shape = box
40843
+ \`\`\`
40844
+
40845
+ Presentations define durable visual defaults for rendered diagrams:
40846
+
40847
+ - \`header\`, \`subtitle\`, and \`body\` map model attributes into labels.
40848
+ - \`light\` and \`dark\` define theme-specific colors.
40849
+ - \`graphviz\` carries renderer-specific layout/style hints.
40850
+
40851
+ Use \`define presentation X\` once when creating a presentation for a new type.
40852
+ Use \`extend presentation X\` when changing a built-in or project presentation:
40853
+
40854
+ \`\`\`insight
40855
+ extend presentation AsyncWire
40856
+ header = technology
40857
+ subtitle = via
40858
+ body = description
40859
+ \`\`\`
40860
+
40861
+ Presentation extension is a merge, not a full replacement:
40862
+
40863
+ - omitted slots and section properties are inherited from the base type or
40864
+ existing presentation;
40865
+ - assigning the same slot or section property overrides that one value;
40866
+ - inherited \`graphviz\` settings such as \`style = dashed\` survive unless the
40867
+ extension overrides that property;
40868
+ - repeated \`define presentation X\` is an error in current Archinsight.
40869
+
40870
+ Each label slot accepts exactly one attribute name. Do not use expressions,
40871
+ lists, text templates, or concatenation in \`header\`, \`subtitle\`, or \`body\`.
40872
+ \`body = description via\`, \`body = description, via\`, and
40873
+ \`body = description (via)\` mean "look for an attribute with that exact text"
40874
+ and will fail validation.
40875
+
40876
+ The renderer has three label slots: \`header\`, \`subtitle\`, and \`body\`.
40877
+ If all three are already used, there is no built-in fourth line for additional
40878
+ metadata. Choose the most important attribute for each slot or ask the user
39475
40879
  whether they want a language/rendering change.
39476
40880
 
39477
40881
  Default wire presentations are:
@@ -39811,6 +41215,417 @@ system storefront
39811
41215
  responsibility = Calls the payment provider and normalizes errors
39812
41216
  `;
39813
41217
  }
41218
+ function genericC1ContextExample() {
41219
+ return `context customer_portal
41220
+ name = Customer Portal
41221
+
41222
+ external actor customer
41223
+ name = Customer
41224
+ technology = Browser, mobile app
41225
+ description = Manages account details and service requests
41226
+ links:
41227
+ -> portal
41228
+ description = Views account state and submits requests
41229
+
41230
+ external actor support_agent
41231
+ name = Support agent
41232
+ technology = Back-office browser
41233
+ description = Helps customers resolve account and service issues
41234
+ links:
41235
+ -> service_console
41236
+ description = Reviews account state and updates service requests
41237
+
41238
+ external system identity_provider
41239
+ name = Identity Provider
41240
+ technology = OIDC
41241
+ description = Authenticates customers and support staff
41242
+
41243
+ external system notification_platform
41244
+ name = Notification Platform
41245
+ technology = Email, SMS
41246
+ description = Sends customer notifications
41247
+
41248
+ system portal
41249
+ name = Portal
41250
+ technology = Web application
41251
+ description = Customer-facing self-service experience
41252
+ links:
41253
+ -> identity_provider
41254
+ technology = OIDC
41255
+ description = Authenticates customers
41256
+ -> notification_platform
41257
+ technology = HTTPS
41258
+ description = Sends request status notifications
41259
+
41260
+ system service_console
41261
+ name = Service Console
41262
+ technology = Internal web application
41263
+ description = Support-facing account and request management
41264
+ links:
41265
+ -> portal
41266
+ description = Reads customer account and request state
41267
+ -> identity_provider
41268
+ technology = OIDC
41269
+ description = Authenticates support staff
41270
+ `;
41271
+ }
41272
+ function genericC2ContainersExample() {
41273
+ return `context fulfillment
41274
+ name = Fulfillment Platform
41275
+
41276
+ external actor warehouse_operator
41277
+ name = Warehouse operator
41278
+ technology = Browser
41279
+ description = Picks, packs, and ships orders
41280
+ links:
41281
+ -> warehouse_ui
41282
+ description = Processes pick, pack, and ship work
41283
+
41284
+ external system carrier_api
41285
+ name = Carrier API
41286
+ technology = HTTPS API
41287
+ description = Books shipments and returns tracking updates
41288
+
41289
+ external system notification_platform
41290
+ name = Notification Platform
41291
+ technology = HTTPS API
41292
+ description = Sends shipment notifications to customers
41293
+
41294
+ system fulfillment
41295
+ name = Fulfillment
41296
+ technology = Fulfillment system
41297
+ description = Coordinates packing, shipping, and customer shipment updates
41298
+
41299
+ container warehouse_ui
41300
+ name = Warehouse UI
41301
+ technology = React, TypeScript
41302
+ description = Guides warehouse operators through pick, pack, and ship flows
41303
+ links:
41304
+ -> fulfillment_api
41305
+ technology = HTTPS, JSON
41306
+ call = POST /shipments
41307
+ description = Creates and updates shipment work
41308
+
41309
+ service fulfillment_api
41310
+ name = Fulfillment API
41311
+ technology = Kotlin, PostgreSQL
41312
+ description = Owns fulfillment workflow state and carrier integration
41313
+ links:
41314
+ -> carrier_api
41315
+ technology = HTTPS
41316
+ call = POST /labels
41317
+ description = Buys shipment labels
41318
+ -> notification_worker
41319
+ description = Enqueues shipment notification work
41320
+
41321
+ service notification_worker
41322
+ name = Notification Worker
41323
+ technology = Node.js worker
41324
+ description = Sends asynchronous shipment notifications
41325
+ links:
41326
+ -> notification_platform
41327
+ technology = HTTPS
41328
+ call = POST /messages
41329
+ description = Sends shipment status notifications
41330
+ `;
41331
+ }
41332
+ function genericC3ComponentsExample() {
41333
+ return `context commerce
41334
+ name = Commerce Platform
41335
+
41336
+ external actor shopper
41337
+ name = Shopper
41338
+ technology = Browser
41339
+ links:
41340
+ -> web_app
41341
+
41342
+ external system payment_provider
41343
+ name = Payment Provider
41344
+ technology = HTTPS API
41345
+
41346
+ external system analytics_platform
41347
+ name = Analytics Platform
41348
+ technology = Kafka consumer
41349
+
41350
+ system storefront
41351
+ name = Storefront
41352
+ technology = Commerce system
41353
+
41354
+ container web_app
41355
+ name = Web app
41356
+ technology = SvelteKit, TypeScript
41357
+ description = Presents checkout screens and calls the backend API
41358
+
41359
+ component checkout_page
41360
+ name = Checkout page
41361
+ technology = Svelte
41362
+ responsibility = Collects checkout details and shows order progress
41363
+ links:
41364
+ -> api_client
41365
+
41366
+ component api_client
41367
+ name = API client
41368
+ technology = Fetch, JSON
41369
+ responsibility = Wraps backend calls and maps transport errors to UI state
41370
+ links:
41371
+ -> checkout_api
41372
+ technology = HTTPS, JSON
41373
+ call = POST /checkout
41374
+
41375
+ service checkout_api
41376
+ name = Checkout API
41377
+ technology = Kotlin, PostgreSQL
41378
+ description = Prices carts, creates orders, and coordinates payment
41379
+ links:
41380
+ ~> analytics_platform
41381
+ technology = Kafka
41382
+ via = checkout.completed
41383
+ description = Publishes completed checkout events
41384
+
41385
+ component checkout_controller
41386
+ name = Checkout controller
41387
+ technology = REST controller
41388
+ responsibility = Accepts checkout requests and returns order status
41389
+ links:
41390
+ -> checkout_service
41391
+
41392
+ component checkout_service
41393
+ name = Checkout service
41394
+ technology = Kotlin
41395
+ responsibility = Coordinates pricing, payment authorization, and order creation
41396
+ links:
41397
+ -> payment_gateway
41398
+ call = authorize(paymentCommand)
41399
+ description = Requests payment authorization
41400
+ -> order_repository
41401
+ ~> checkout_events
41402
+ technology = Kafka
41403
+ via = checkout.completed
41404
+ description = Publishes completed checkout events
41405
+
41406
+ component payment_gateway
41407
+ name = Payment gateway
41408
+ technology = HTTP client
41409
+ responsibility = Translates internal payment commands to provider API calls
41410
+ links:
41411
+ -> payment_provider
41412
+ technology = HTTPS
41413
+ call = POST /payments/authorizations
41414
+ description = Authorizes customer payment
41415
+
41416
+ component order_repository
41417
+ name = Order repository
41418
+ technology = SQL
41419
+ responsibility = Stores order state and checkout audit records
41420
+
41421
+ component checkout_events
41422
+ name = Checkout events
41423
+ technology = Kafka producer
41424
+ responsibility = Publishes checkout lifecycle events for downstream consumers
41425
+ `;
41426
+ }
41427
+ function genericC4DeploymentFrameworkExample() {
41428
+ return `extend type Environment
41429
+ ServiceProvider cloud
41430
+ Compute compute
41431
+ Storage storage
41432
+ Broker broker
41433
+ PublicGateway publicGateway
41434
+ Monitoring observability
41435
+ NetworkConnection network
41436
+
41437
+ define type ServiceProvider of InfrastructureComponent
41438
+ constructor serviceProvider
41439
+
41440
+ define type PublicGateway of InfrastructureComponent
41441
+ constructor publicGateway
41442
+ required InfrastructureComponent cdn
41443
+ required InfrastructureComponent loadBalancer
41444
+
41445
+ project:
41446
+ $from -> cdn
41447
+ cdn -> loadBalancer
41448
+ loadBalancer -> $this
41449
+ $this -> $to
41450
+
41451
+ define type Monitoring of InfrastructureComponent
41452
+ constructor monitoring
41453
+ required InfrastructureComponent display
41454
+
41455
+ project:
41456
+ $this -> $from
41457
+ $this -> display
41458
+
41459
+ `;
41460
+ }
41461
+ function genericC4DeploymentExample() {
41462
+ return `context deployment_shop
41463
+ name = Deployment Shop
41464
+
41465
+ external actor shopper
41466
+ name = Shopper
41467
+ technology = Browser
41468
+ links:
41469
+ -> web_app
41470
+ deployment:
41471
+ environmentsFrom public_regional_service
41472
+ uses publicGateway
41473
+
41474
+ external system payment_provider
41475
+ name = Payment Provider
41476
+ technology = HTTPS API
41477
+
41478
+ deploymentProfile regional_service
41479
+ environments:
41480
+ prod
41481
+ staging
41482
+
41483
+ runsOn compute
41484
+ uses observability
41485
+
41486
+ deploymentProfile public_regional_service
41487
+ environments:
41488
+ prod
41489
+ staging
41490
+
41491
+ runsOn compute
41492
+ uses observability
41493
+ uses publicGateway
41494
+
41495
+ environment prod
41496
+ name = Production
41497
+
41498
+ cloud:
41499
+ serviceProvider _
41500
+ name = AWS
41501
+
41502
+ compute:
41503
+ compute _
41504
+ name = EKS
41505
+ runsOn cloud
41506
+
41507
+ storage:
41508
+ storage _
41509
+ name = Aurora PostgreSQL
41510
+ technology = PostgreSQL
41511
+ runsOn cloud
41512
+
41513
+ broker:
41514
+ broker _
41515
+ name = Event broker
41516
+ technology = MSK Kafka
41517
+ address = kafka.prod.internal:9092
41518
+ runsOn compute
41519
+
41520
+ publicGateway:
41521
+ publicGateway _
41522
+ name = Public edge
41523
+ cdn:
41524
+ infrastructureComponent cloudfront
41525
+ name = CloudFront
41526
+ runsOn cloud
41527
+ loadBalancer:
41528
+ infrastructureComponent alb
41529
+ name = Application Load Balancer
41530
+ runsOn cloud
41531
+ runsOn compute
41532
+
41533
+ observability:
41534
+ monitoring _
41535
+ name = OpenTelemetry Collector
41536
+ display:
41537
+ infrastructureComponent _
41538
+ name = Grafana Cloud
41539
+ runsOn compute
41540
+
41541
+ network:
41542
+ networkConnection _
41543
+ name = Service mesh
41544
+ runsOn compute
41545
+
41546
+ environment staging
41547
+ name = Staging
41548
+
41549
+ cloud:
41550
+ serviceProvider _
41551
+ name = Google Cloud
41552
+
41553
+ compute:
41554
+ compute _
41555
+ name = Cloud Run
41556
+ runsOn cloud
41557
+
41558
+ storage:
41559
+ storage _
41560
+ name = Cloud SQL
41561
+ technology = PostgreSQL
41562
+ runsOn cloud
41563
+
41564
+ broker:
41565
+ broker _
41566
+ name = Event broker
41567
+ technology = Pub/Sub
41568
+ address = pubsub.googleapis.com
41569
+ runsOn compute
41570
+
41571
+ publicGateway:
41572
+ publicGateway _
41573
+ name = Public edge
41574
+ cdn:
41575
+ infrastructureComponent cloud_cdn
41576
+ name = Cloud CDN
41577
+ runsOn cloud
41578
+ loadBalancer:
41579
+ infrastructureComponent https_lb
41580
+ name = HTTPS Load Balancer
41581
+ runsOn cloud
41582
+ runsOn compute
41583
+
41584
+ observability:
41585
+ monitoring _
41586
+ name = Cloud Monitoring Agent
41587
+ display:
41588
+ infrastructureComponent _
41589
+ name = Cloud Monitoring
41590
+ runsOn compute
41591
+
41592
+ network:
41593
+ networkConnection _
41594
+ name = Internal routes
41595
+ runsOn compute
41596
+
41597
+ system storefront
41598
+ name = Storefront
41599
+ technology = Commerce system
41600
+
41601
+ container web_app
41602
+ name = Web app
41603
+ technology = SvelteKit, TypeScript
41604
+ description = Customer-facing checkout application
41605
+ deployment:
41606
+ usesProfile public_regional_service
41607
+ links:
41608
+ -> checkout_api
41609
+ technology = HTTPS, JSON
41610
+ call = POST /checkout
41611
+ deployment:
41612
+ environmentsFrom regional_service
41613
+ uses network
41614
+
41615
+ service checkout_api
41616
+ name = Checkout API
41617
+ technology = Kotlin, PostgreSQL
41618
+ description = Creates orders and coordinates payment
41619
+ deployment:
41620
+ usesProfile regional_service
41621
+ uses storage
41622
+ uses broker
41623
+ links:
41624
+ -> payment_provider
41625
+ technology = HTTPS
41626
+ call = POST /payments/authorizations
41627
+ `;
41628
+ }
39814
41629
  function genericC2QueryExample() {
39815
41630
  return `MATCH (container:ContainerElement)
39816
41631
  WHERE container.sourceIdentity = $tab