dsh-archify-projects 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +204 -2
  2. package/cordis.patch.yml +99 -0
  3. package/dist/client.js +2261 -0
  4. package/dist/client.js.map +1 -0
  5. package/docs/CONTAINER.md +197 -0
  6. package/docs/DESIGN.md +905 -0
  7. package/docs/HANDOVER.md +391 -0
  8. package/docs/PUBLISH.md +107 -0
  9. package/icon.svg +12 -0
  10. package/lib/host/archify-skill.js +116 -0
  11. package/lib/host/archify-skill.js.map +1 -0
  12. package/lib/host/config.js +95 -0
  13. package/lib/host/config.js.map +1 -0
  14. package/lib/host/context.js +28 -0
  15. package/lib/host/context.js.map +1 -0
  16. package/lib/host/git.js +185 -0
  17. package/lib/host/git.js.map +1 -0
  18. package/lib/host/http.js +184 -0
  19. package/lib/host/http.js.map +1 -0
  20. package/lib/host/index.js +90 -0
  21. package/lib/host/index.js.map +1 -0
  22. package/lib/host/policy.js +124 -0
  23. package/lib/host/policy.js.map +1 -0
  24. package/lib/host/routes.js +667 -0
  25. package/lib/host/routes.js.map +1 -0
  26. package/lib/host/runner.js +913 -0
  27. package/lib/host/runner.js.map +1 -0
  28. package/lib/host/store.js +370 -0
  29. package/lib/host/store.js.map +1 -0
  30. package/lib/host/workspace.js +65 -0
  31. package/lib/host/workspace.js.map +1 -0
  32. package/lib/shared/format.js +138 -0
  33. package/lib/shared/format.js.map +1 -0
  34. package/lib/shared/prompt.js +257 -0
  35. package/lib/shared/prompt.js.map +1 -0
  36. package/lib/shared/protocol.js +31 -0
  37. package/lib/shared/protocol.js.map +1 -0
  38. package/lib/shared/types.js +173 -0
  39. package/lib/shared/types.js.map +1 -0
  40. package/locale/en.json +6 -0
  41. package/locale/zh.json +6 -0
  42. package/package.json +98 -4
  43. package/skills/archify/LICENSE +22 -0
  44. package/skills/archify/SKILL.md +109 -0
  45. package/skills/archify/THIRD_PARTY_NOTICES.md +69 -0
  46. package/skills/archify/assets/JetBrainsMono-OFL.txt +93 -0
  47. package/skills/archify/assets/template.html +13709 -0
  48. package/skills/archify/bin/archify.mjs +6936 -0
  49. package/skills/archify/bin/delivery-update.mjs +91 -0
  50. package/skills/archify/bin/finalize.mjs +895 -0
  51. package/skills/archify/bin/open-artifact.mjs +146 -0
  52. package/skills/archify/bin/preview.mjs +969 -0
  53. package/skills/archify/bin/recover-output.mjs +41 -0
  54. package/skills/archify/bin/visual-check.mjs +2667 -0
  55. package/skills/archify/brand-marks/README.md +31 -0
  56. package/skills/archify/brand-marks/catalog.json +131 -0
  57. package/skills/archify/delta/architecture-delta.mjs +1313 -0
  58. package/skills/archify/examples/agent-run.lifecycle.json +55 -0
  59. package/skills/archify/examples/agent-tool-call.workflow.json +74 -0
  60. package/skills/archify/examples/async-job-roundtrip.sequence.json +56 -0
  61. package/skills/archify/examples/brand-aware-delivery.architecture.json +34 -0
  62. package/skills/archify/examples/cache-miss-request.sequence.json +77 -0
  63. package/skills/archify/examples/checkout-platform.base.architecture.json +32 -0
  64. package/skills/archify/examples/checkout-platform.head.architecture.json +32 -0
  65. package/skills/archify/examples/dataflow-product-analytics.html +13820 -0
  66. package/skills/archify/examples/deployment-release.lifecycle.json +48 -0
  67. package/skills/archify/examples/event-stream.dataflow.json +52 -0
  68. package/skills/archify/examples/holiday-planning.workflow.json +143 -0
  69. package/skills/archify/examples/incident-response.workflow.json +59 -0
  70. package/skills/archify/examples/lifecycle-agent-run.html +13765 -0
  71. package/skills/archify/examples/locales/de.json +425 -0
  72. package/skills/archify/examples/locales/es.json +440 -0
  73. package/skills/archify/examples/locales/fr.json +425 -0
  74. package/skills/archify/examples/locales/fr.partial.json +22 -0
  75. package/skills/archify/examples/locales/it.json +425 -0
  76. package/skills/archify/examples/locales/ja.json +425 -0
  77. package/skills/archify/examples/locales/ko.json +440 -0
  78. package/skills/archify/examples/locales/pt.json +425 -0
  79. package/skills/archify/examples/locales/ru.json +425 -0
  80. package/skills/archify/examples/product-analytics.dataflow.json +71 -0
  81. package/skills/archify/examples/production-deployment.architecture.json +51 -0
  82. package/skills/archify/examples/release-delivery.workflow.json +57 -0
  83. package/skills/archify/examples/sequence-cache-miss-request.html +13835 -0
  84. package/skills/archify/examples/web-app-rendered.html +13808 -0
  85. package/skills/archify/examples/web-app.architecture.json +41 -0
  86. package/skills/archify/examples/workflow-agent-tool-call-rendered.html +13826 -0
  87. package/skills/archify/migrations/workflow-v2.mjs +280 -0
  88. package/skills/archify/package.json +17 -0
  89. package/skills/archify/recipes/scenarios.mjs +430 -0
  90. package/skills/archify/references/architecture-layout-repair.md +18 -0
  91. package/skills/archify/references/authoring-contract.md +419 -0
  92. package/skills/archify/references/authoring-defaults.md +41 -0
  93. package/skills/archify/references/brand-marks.md +82 -0
  94. package/skills/archify/references/delivery-contract.md +588 -0
  95. package/skills/archify/references/repository-authoring.md +105 -0
  96. package/skills/archify/references/update-awareness.md +12 -0
  97. package/skills/archify/references/viewer-runtime.md +35 -0
  98. package/skills/archify/renderers/architecture/grid.mjs +62 -0
  99. package/skills/archify/renderers/architecture/labels.mjs +215 -0
  100. package/skills/archify/renderers/architecture/render-architecture.mjs +1001 -0
  101. package/skills/archify/renderers/architecture/routing.mjs +1157 -0
  102. package/skills/archify/renderers/dataflow/README.md +105 -0
  103. package/skills/archify/renderers/dataflow/render-dataflow.mjs +544 -0
  104. package/skills/archify/renderers/lifecycle/README.md +171 -0
  105. package/skills/archify/renderers/lifecycle/grid-routing.mjs +429 -0
  106. package/skills/archify/renderers/lifecycle/render-lifecycle.mjs +938 -0
  107. package/skills/archify/renderers/sequence/README.md +129 -0
  108. package/skills/archify/renderers/sequence/render-sequence.mjs +526 -0
  109. package/skills/archify/renderers/shared/atomic-output.mjs +1982 -0
  110. package/skills/archify/renderers/shared/brand-marks.mjs +670 -0
  111. package/skills/archify/renderers/shared/cli.mjs +451 -0
  112. package/skills/archify/renderers/shared/desktop-readability.mjs +132 -0
  113. package/skills/archify/renderers/shared/diagnostics.mjs +173 -0
  114. package/skills/archify/renderers/shared/engineering-profiles.mjs +157 -0
  115. package/skills/archify/renderers/shared/generated-brand-marks.mjs +2003 -0
  116. package/skills/archify/renderers/shared/generated-validators.mjs +134 -0
  117. package/skills/archify/renderers/shared/geometry.mjs +1941 -0
  118. package/skills/archify/renderers/shared/i18n.mjs +603 -0
  119. package/skills/archify/renderers/shared/layout-report.mjs +42 -0
  120. package/skills/archify/renderers/shared/legend.mjs +217 -0
  121. package/skills/archify/renderers/shared/output-path.mjs +440 -0
  122. package/skills/archify/renderers/shared/path-semantics.mjs +1017 -0
  123. package/skills/archify/renderers/shared/portable-path.mjs +408 -0
  124. package/skills/archify/renderers/shared/repository-evidence.mjs +352 -0
  125. package/skills/archify/renderers/shared/repository-location.mjs +59 -0
  126. package/skills/archify/renderers/shared/route-quality.mjs +614 -0
  127. package/skills/archify/renderers/shared/sidecar-path.mjs +38 -0
  128. package/skills/archify/renderers/shared/spatial-grid.mjs +66 -0
  129. package/skills/archify/renderers/shared/text-fit.mjs +105 -0
  130. package/skills/archify/renderers/shared/utils.mjs +254 -0
  131. package/skills/archify/renderers/shared/validator.mjs +86 -0
  132. package/skills/archify/renderers/workflow/README.md +301 -0
  133. package/skills/archify/renderers/workflow/render-workflow.mjs +37 -0
  134. package/skills/archify/renderers/workflow/workflow-compiler.mjs +4913 -0
  135. package/skills/archify/renderers/workflow/workflow-migration-geometry.mjs +144 -0
  136. package/skills/archify/schemas/README.md +256 -0
  137. package/skills/archify/schemas/architecture.schema.json +152 -0
  138. package/skills/archify/schemas/common.schema.json +181 -0
  139. package/skills/archify/schemas/dataflow.schema.json +254 -0
  140. package/skills/archify/schemas/lifecycle.schema.json +280 -0
  141. package/skills/archify/schemas/sequence.schema.json +234 -0
  142. package/skills/archify/schemas/workflow.schema.json +439 -0
  143. package/skills/archify/scripts/check-render-output.mjs +1388 -0
  144. package/skills/archify/scripts/check-update.mjs +1710 -0
  145. package/skills/archify/scripts/delivery-update-child.mjs +23 -0
  146. package/skills/archify/scripts/render-examples.mjs +26 -0
  147. package/skills/archify/scripts/update-contract.mjs +182 -0
  148. package/skills/archify/skill-release.json +10 -0
@@ -0,0 +1,144 @@
1
+ const TARGET_SCHEMA_VERSION = 2;
2
+
3
+ function clone(value) {
4
+ return JSON.parse(JSON.stringify(value));
5
+ }
6
+
7
+ /**
8
+ * Return the authored workflow as a schema-v2 document without its capacity
9
+ * override. The compiler can use this projection to discover the intrinsic v2
10
+ * rank plan before deciding whether an explicit viewBox needs to grow.
11
+ */
12
+ export function intrinsicWorkflow(workflow) {
13
+ const intrinsic = clone(workflow);
14
+ intrinsic.schema_version = TARGET_SCHEMA_VERSION;
15
+ intrinsic.meta = { ...intrinsic.meta };
16
+ delete intrinsic.meta.viewBox;
17
+ return intrinsic;
18
+ }
19
+
20
+ /**
21
+ * Return a schema-v2 planning projection that removes authored route geometry
22
+ * which may only become valid after its legacy X coordinates are remapped.
23
+ * Rank-affecting automatic and straight relationships remain in the projection.
24
+ */
25
+ export function planningWorkflow(workflow) {
26
+ const planned = intrinsicWorkflow(workflow);
27
+ planned.edges = planned.edges.flatMap((edge) => {
28
+ const hasRoutedGeometry = Array.isArray(edge.via)
29
+ || (edge.route && !['auto', 'straight'].includes(edge.route))
30
+ || edge.channelX !== undefined
31
+ || edge.channelY !== undefined;
32
+ if (hasRoutedGeometry) return [];
33
+
34
+ const automatic = {};
35
+ for (const property of ['id', 'from', 'to', 'variant', 'role', 'width']) {
36
+ if (edge[property] !== undefined) automatic[property] = edge[property];
37
+ }
38
+ if (edge.route === 'straight') automatic.route = 'straight';
39
+ if (edge.labelAt === undefined && edge.label !== undefined) automatic.label = edge.label;
40
+ return [automatic];
41
+ });
42
+
43
+ if (Array.isArray(planned.mainPath)) {
44
+ const projectedPairs = new Set(planned.edges.map((edge) => `${edge.from}\u0000${edge.to}`));
45
+ const projectionBreaksMainPath = planned.mainPath.some((from, index) => (
46
+ index < planned.mainPath.length - 1
47
+ && !projectedPairs.has(`${from}\u0000${planned.mainPath[index + 1]}`)
48
+ ));
49
+ if (projectionBreaksMainPath) delete planned.mainPath;
50
+ }
51
+
52
+ return planned;
53
+ }
54
+
55
+ function mappedNumber(value) {
56
+ return Number(value.toFixed(6));
57
+ }
58
+
59
+ /**
60
+ * Build a deterministic piecewise-linear mapping between corresponding legacy
61
+ * and readable rank centers. Coordinates outside the rank span are extrapolated
62
+ * using the nearest segment so explicitly authored outside corridors retain
63
+ * their relative offset.
64
+ */
65
+ export function createHorizontalRankMapper(oldColumns, newColumns) {
66
+ if (
67
+ !Array.isArray(oldColumns)
68
+ || !Array.isArray(newColumns)
69
+ || oldColumns.length !== newColumns.length
70
+ || oldColumns.length < 2
71
+ || !oldColumns.every(Number.isFinite)
72
+ || !newColumns.every(Number.isFinite)
73
+ ) {
74
+ throw new TypeError('Horizontal rank mapping requires matching finite column arrays.');
75
+ }
76
+ for (let index = 1; index < oldColumns.length; index += 1) {
77
+ if (oldColumns[index] <= oldColumns[index - 1] || newColumns[index] <= newColumns[index - 1]) {
78
+ throw new TypeError('Horizontal rank mapping requires strictly increasing columns.');
79
+ }
80
+ }
81
+
82
+ return (x) => {
83
+ if (!Number.isFinite(x)) throw new TypeError('Horizontal rank mapping requires a finite x coordinate.');
84
+ let segment = oldColumns.length - 2;
85
+ if (x <= oldColumns[0]) {
86
+ segment = 0;
87
+ } else {
88
+ for (let index = 0; index < oldColumns.length - 1; index += 1) {
89
+ if (x <= oldColumns[index + 1]) {
90
+ segment = index;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+ const oldSpan = oldColumns[segment + 1] - oldColumns[segment];
96
+ const newSpan = newColumns[segment + 1] - newColumns[segment];
97
+ const ratio = (x - oldColumns[segment]) / oldSpan;
98
+ return mappedNumber(newColumns[segment] + ratio * newSpan);
99
+ };
100
+ }
101
+
102
+ /**
103
+ * Apply one horizontal coordinate mapping to every schema-v1 absolute X pin.
104
+ * The caller owns the supplied workflow; this function reports an audit trail
105
+ * for each changed coordinate in stable document order.
106
+ */
107
+ export function mapExplicitCoordinates(workflow, mapX) {
108
+ const changedCoordinates = [];
109
+ const record = (path, owner, property) => {
110
+ const from = owner[property];
111
+ const to = mapX(from);
112
+ owner[property] = to;
113
+ if (to !== from) changedCoordinates.push({ path, from, to });
114
+ };
115
+
116
+ for (const [edgeIndex, edge] of workflow.edges.entries()) {
117
+ if (Array.isArray(edge.via)) {
118
+ for (const [pointIndex, point] of edge.via.entries()) {
119
+ if (Array.isArray(point) && Number.isFinite(point[0])) {
120
+ record(`/edges/${edgeIndex}/via/${pointIndex}/0`, point, 0);
121
+ }
122
+ }
123
+ }
124
+ if (Array.isArray(edge.labelAt) && Number.isFinite(edge.labelAt[0])) {
125
+ record(`/edges/${edgeIndex}/labelAt/0`, edge.labelAt, 0);
126
+ }
127
+ if (Number.isFinite(edge.channelX)) {
128
+ record(`/edges/${edgeIndex}/channelX`, edge, 'channelX');
129
+ }
130
+ }
131
+ return changedCoordinates;
132
+ }
133
+
134
+ /**
135
+ * Construct an independently owned schema-v2 candidate with all authored
136
+ * absolute X pins mapped to the readable rank plan.
137
+ */
138
+ export function createMappedWorkflowCandidate(workflow, oldColumns, newColumns) {
139
+ const document = clone(workflow);
140
+ document.schema_version = TARGET_SCHEMA_VERSION;
141
+ const mapX = createHorizontalRankMapper(oldColumns, newColumns);
142
+ const changedCoordinates = mapExplicitCoordinates(document, mapX);
143
+ return { document, changedCoordinates };
144
+ }
@@ -0,0 +1,256 @@
1
+ # Archify JSON IR Schemas
2
+
3
+ Each typed renderer consumes a JSON intermediate representation (IR) validated
4
+ against one of the schemas in this folder before any layout work happens.
5
+
6
+ ## Files
7
+
8
+ | Schema | Governs | Structural arrays |
9
+ |--------|---------|-------------------|
10
+ | `workflow.schema.json` | `diagram_type: "workflow"` | `lanes`, `phases`, `groups`, `mainPath`, `nodes`, `edges` |
11
+ | `sequence.schema.json` | `diagram_type: "sequence"` | `participants`, `segments`, `messages`, `activations` |
12
+ | `dataflow.schema.json` | `diagram_type: "dataflow"` | `stages`, `nodes`, `flows` |
13
+ | `lifecycle.schema.json` | `diagram_type: "lifecycle"` | `lanes`, `states`, `transitions` |
14
+ | `architecture.schema.json` | `diagram_type: "architecture"` | `components`, `boundaries`, `connections` |
15
+ | `common.schema.json` | shared `$defs` only (no top-level document) | — |
16
+
17
+ Every diagram schema requires `schema_version`, `diagram_type`, `meta` (with
18
+ `title` and a durable portable `output`), and its structural arrays — except `segments`, `activations`, and
19
+ `cards`, which are optional — and sets `additionalProperties: false` at every
20
+ level, so unknown fields are rejected rather than silently ignored.
21
+
22
+ Every `meta` object also accepts `animation: "trace"` for opt-in SVG/CSS motion
23
+ in generated HTML. Omit it, or set `"none"`, for the default static output.
24
+ It also accepts `locale`, any well-formed language tag (schema pattern
25
+ `^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$`). The field selects the fixed Viewer UI,
26
+ renderer-owned default legend and accessibility copy, document-title suffix,
27
+ and `<html lang>` value; it does not translate authored strings. `en` and
28
+ `zh-CN` are built-in catalogs; any other tag needs a matching `translations`
29
+ object (see below) or the renderer falls back to English and discloses it.
30
+ Omitting `locale` preserves legacy behavior and resolves to English.
31
+ Malformed locale tags fail schema validation instead of being guessed or
32
+ silently rewritten.
33
+
34
+ `meta.translations` supplies the Viewer message catalog for a `locale` with no
35
+ built-in catalog, as data: an object mapping canonical message keys (see
36
+ `catalogKeys()` in `renderers/shared/i18n.mjs`) to translated strings whose
37
+ `{placeholder}` tokens match the English source. A key that is missing,
38
+ unrecognized, or has mismatched placeholders falls back to English rather than
39
+ failing the render; `validate`/`render`/`deliver` report the resulting
40
+ coverage to stderr. Spanish uses the reusable `examples/locales/es.json`
41
+ catalog; dev inputs that previously used only `locale: "es"` now need this
42
+ object in `meta.translations` to retain Spanish UI.
43
+ `visual_preset` accepts `classic` (the stable default), `signal-flow` (luminous
44
+ motion-forward presentation), `blueprint` (high-contrast engineering review),
45
+ or `editorial` (warm publication-style design review and documentation).
46
+ Presets change only viewer styling; they do not alter semantic IDs or geometry.
47
+ Sequence `meta` additionally accepts `column_fit`. The default `fixed` keeps
48
+ the historical 108px column gap and 86px participant boxes, so an authored
49
+ diagram renders at the same coordinates no matter how wide its viewBox is.
50
+ `spread` derives the gap and box width from the viewBox instead, which turns a
51
+ wide canvas into column distance and label room rather than empty space on the
52
+ right. Lane order, IDs, and message semantics are unchanged either way.
53
+
54
+ `meta.views` is retired. The schemas still accept the old guided-view shape so
55
+ existing files keep validating, but renderers ignore it; do not author it.
56
+
57
+ ### Legend presentation contract
58
+
59
+ Every `meta` object accepts the same optional legend shape without changing
60
+ the schema version already selected for that renderer:
61
+
62
+ ```json
63
+ "legend": {
64
+ "mode": "auto",
65
+ "entries": {
66
+ "security": { "label": "restricted data", "visible": true }
67
+ }
68
+ }
69
+ ```
70
+
71
+ `mode` is `auto` (the default), `all`, or `hidden`. `auto` includes only kinds
72
+ present in typed IR; `all` includes the renderer's full stable catalog;
73
+ `hidden` removes the complete legend and takes precedence over entry overrides.
74
+ Architecture documents that omit an explicit `viewBox` size that automatic
75
+ viewBox from the same measured resolved legend footprint used for final SVG
76
+ layout. Across all renderers, legacy documents that omit `meta.legend` use a
77
+ compatibility-safe implicit `auto`: if the resolved legend cannot fit an
78
+ explicit authored viewBox without overlap, Archify omits the complete legend
79
+ instead of turning a previously valid schema-v1 document into a hard failure.
80
+ Once an author adds `meta.legend` (including explicit `mode: "auto"`), the
81
+ layout is intentional and unfit labels or bands fail with a path-prefixed
82
+ diagnostic. An entry may set a non-empty, bounded `label`, boolean `visible`,
83
+ or both.
84
+ `visible: false` removes a resolved entry and `visible: true` forces a supported
85
+ but unused kind into the visual legend. Unknown kinds and properties fail
86
+ strict validation.
87
+
88
+ Supported keys are renderer-owned:
89
+
90
+ | Renderer | `meta.legend.entries` keys |
91
+ |---|---|
92
+ | Architecture | `frontend`, `backend`, `database`, `cloud`, `security`, `messagebus`, `external` |
93
+ | Workflow | `frontend`, `backend`, `security`, `messagebus`, `database`, `cloud`, `external` |
94
+ | Sequence | `emphasis`, `return`, `security`, `dashed`, `default` |
95
+ | Dataflow | `emphasis`, `security`, `dashed`, `database`, `default` |
96
+ | Lifecycle | `start`, `active`, `waiting`, `decision`, `success`, `failure`, `neutral`, `external` |
97
+
98
+ Labels are presentation only: they do not rename the stable kind, change
99
+ nodes/relationships, or create Semantic Lens edge facts. Sequence message and
100
+ Dataflow flow-variant entries are visual keys. Component/state entries backed
101
+ by exact compiled node facts receive the interactive Semantic Legend bridge;
102
+ this includes Dataflow `database` when a real `nodes[].type: "database"` fact
103
+ exists.
104
+
105
+ Every relationship collection (`connections`, `edges`, `messages`, `flows`, and
106
+ `transitions`) accepts an optional author-controlled `id` using the shared ID
107
+ pattern. The renderer keeps its source-order runtime key separately, while the
108
+ authored ID enables a stable `#relation=<id>` viewer link that survives array
109
+ reordering. ID-less documents remain valid and their relationship pins stay
110
+ local to the current page.
111
+
112
+ Every semantic node collection (`components`, `nodes`, `participants`, and
113
+ `states`) also accepts one optional `brand`: either a canonical string returned
114
+ by `archify brands --json`, or a digest-pinned `{ "url", "sha256" }` object
115
+ returned by `archify brands capture <url> --json`. Known IDs and known-brand
116
+ domains use the bundled vector catalogue. Unknown URLs must be captured in that
117
+ explicit command before authoring; render and validate never perform an
118
+ unpinned network capture. Unsafe, unavailable, changed, or unsupported content
119
+ fails closed with a brand diagnostic. Omitted `brand` preserves the prior
120
+ output.
121
+
122
+ ## schema_version policy
123
+
124
+ Workflow supports schema versions 1 and 2. Version 1 remains the fixed-layout
125
+ compatibility contract; version 2 opts into the readable workflow compiler and
126
+ can be produced explicitly with `archify migrate workflow ... --to-schema 2`.
127
+ Lifecycle also supports versions 1 and 2 with the same fields. Version 1 keeps
128
+ the fixed three-band layout; version 2 renders one row per lane on a shared
129
+ column grid (see the [lifecycle renderer](../renderers/lifecycle/README.md)).
130
+ Lifecycle has no migration command: to adopt v2, set `schema_version: 2`,
131
+ re-place lower-lane `col` values on the shared grid (v1 column `N` sat under
132
+ main column `N + 2`), and drop coordinates authored for the v1 canvas
133
+ (`viewBox`, `via`, `channelX`, `channelY`, `labelAt`).
134
+ The other three diagram schemas keep `schema_version` pinned to `1`; they have
135
+ no schema-version migration command. For any of the five diagram types, repair
136
+ a legacy missing or nonportable `meta.output` in the source and run `validate`.
137
+ For a workflow v1-to-v2 migration specifically, `migrate workflow` also accepts
138
+ `--output reports/diagram.html` to put that portable value in the separate v2
139
+ destination without changing the legacy source.
140
+
141
+ Workflow also accepts optional `semanticChecks`. `allowedRoots` and
142
+ `allowedTerminals` close the set of intentional graph sources and sinks;
143
+ `requiredEdges` requires exact authored relationships; and `requiredPaths`
144
+ requires directed reachability while allowing intermediate nodes. The compiler
145
+ evaluates these facts before layout and returns typed `workflow/*` diagnostics.
146
+ The field is additive and geometry-neutral: omitting it preserves existing
147
+ workflow behavior and including a satisfied contract does not change SVG or
148
+ layout-receipt bytes.
149
+
150
+ A file that validates today must keep validating and rendering within its
151
+ declared version throughout the 2.x release line. The explicitly reviewed
152
+ portable-output hardening is the one exception: older v1 documents that omit
153
+ `meta.output` must add a portable POSIX-relative `.html` path (for example,
154
+ `reports/diagram.html`); ordinary explicit CLI output arguments do not replace
155
+ this durable authored value. The workflow-only v1-to-v2 migration command may
156
+ instead receive that value explicitly as `--output reports/diagram.html`; it
157
+ writes the value only to its separate validated destination. Additive viewer,
158
+ accessibility, and presentation improvements may enhance generated HTML, but
159
+ they must not reinterpret authored IR or turn a previously valid profile-less
160
+ v1 file into a new hard layout failure. Breaking IR changes require a new
161
+ version; additive, backwards-compatible fields do not.
162
+
163
+ ## Shared definitions (common.schema.json)
164
+
165
+ The five diagram schemas reference `common.schema.json#/$defs/...`:
166
+
167
+ - `id` — element identifiers, pattern `^[a-zA-Z][a-zA-Z0-9_-]*$`
168
+ - `point` — an `[x, y]` pair of numbers (used by `via` and `labelAt`)
169
+ - `componentType` — `frontend`, `backend`, `database`, `cloud`, `security`,
170
+ `messagebus`, `external`
171
+ - `locale` — a well-formed renderer locale tag (`en` and `zh-CN` are built in;
172
+ any other tag needs a matching `translations` object)
173
+ - `translations` — canonical message key → translated string, for a `locale`
174
+ with no built-in catalog
175
+ - `portableOutputPath` — the portable POSIX-relative `.html` path used by
176
+ `meta.output`; see the two output-path boundaries in the
177
+ [delivery contract](../references/delivery-contract.md#output-path-contracts)
178
+ - `brandMark` — one optional built-in brand ID or explicit HTTP(S) site URL
179
+ - `variant` — `default`, `emphasis`, `security`, `dashed` (sequence messages
180
+ extend this list locally with `return`)
181
+ - `legendMode` and `legendEntry` — the shared strict mode and label/visibility
182
+ override shapes used by each renderer-owned key map
183
+ - `guidedViews` — the retired `meta.views` shape, still accepted and ignored
184
+ - `cards` — the summary-card blocks rendered below the SVG
185
+
186
+ Lifecycle state `type` is mode-specific (`start`/`active`/`waiting`/...) and
187
+ stays in `lifecycle.schema.json`.
188
+
189
+ The JSON Schema definition is the portable contract's structurally expressible
190
+ preflight. The shipped generated validator wrapper and CLI additionally enforce
191
+ byte-based component limits and the complete runtime path contract; consumers
192
+ that need the same cross-platform acceptance boundary should use that wrapper.
193
+
194
+ ## Runtime validation
195
+
196
+ At development time, `scripts/generate-validators.mjs` compiles all five
197
+ schemas with ajv's draft 2020-12 standalone generator using `strict: true` and
198
+ `allErrors: true`. The generated `renderers/shared/generated-validators.mjs`
199
+ is committed and shipped with the skill, so runtime validation has no npm or
200
+ network dependency. `renderers/shared/validator.mjs` applies the matching
201
+ standalone validator before the renderer's own layout checks.
202
+ The shared loader then checks cross-collection facts that JSON Schema cannot
203
+ express cleanly here: duplicate view IDs, duplicate focus IDs, focus IDs that do
204
+ not exist in the diagram's semantic collection, and duplicate authored
205
+ relationship IDs within the mode's relationship collection.
206
+
207
+ All five modes support opt-in, revision-pinned repository evidence.
208
+ `meta.repository` names the repository URL and full commit SHA, with optional
209
+ `provider` (`github` or `gitee`) and `link_mode` (`web` or `local-only`; see the
210
+ authoring contract); a node may carry one to three `sources` with repo-relative POSIX paths, optional line
211
+ ranges, and optional labels. Sources are authored on the mode's own node
212
+ collection — Architecture `components`, Workflow and Data Flow `nodes`,
213
+ Sequence `participants`, Lifecycle `states` — and the verified payload is keyed
214
+ by node id. Shape is schema-checked, then the renderer requires
215
+ `--repo-root`: the local Git origin must match, and Git must prove the commit,
216
+ blobs, and requested lines. Verified evidence is embedded outside the canonical
217
+ SVG for the Semantic Passport and Node Finder; ordinary documents and visual
218
+ exports carry no repository evidence.
219
+
220
+ ## Visual quality and engineering truth
221
+
222
+ `meta.quality_profile` and `meta.engineering_profile` answer different
223
+ questions. `quality_profile` is available in all five modes and controls how
224
+ strictly Archify judges composition. `engineering_profile` is an optional
225
+ Architecture-only semantic contract; omitting it preserves the ordinary v1
226
+ behavior.
227
+
228
+ The first engineering profile is `deployment-ownership`. Enable it only when
229
+ the user wants a fail-closed deployment review and the source facts are known.
230
+ It requires every non-external component to name an owner in `tag` and belong
231
+ to exactly one `region`; the document must contain both `region` and
232
+ `security-group` boundaries; every `database` must be inside a
233
+ `security-group`; each security group must contain members from one shared
234
+ region; and every connection whose region or security-group membership changes
235
+ must name the real crossing mechanism in `label`.
236
+
237
+ The profile validates only authored IR. It does not discover infrastructure,
238
+ infer owners, or prove that a diagram matches a live environment. If a fact is
239
+ unknown, leave the profile unset or obtain the fact instead of inventing it.
240
+
241
+ `npm test` runs the generator in check mode and fails when the committed
242
+ validators drift from their schemas.
243
+
244
+ ## Error format
245
+
246
+ Schema violations exit non-zero. Each ajv error is reported on its own line as
247
+ the instance path — annotated with the nearest enclosing element's `id` or
248
+ `label` — followed by the message and parameters:
249
+
250
+ ```text
251
+ workflow schema validation failed:
252
+ /nodes/3 (id/label: "router") must NOT have additional properties {"additionalProperty":"colour"}
253
+ ```
254
+
255
+ Schemas catch shape errors (types, enums, ranges, unknown fields); geometry
256
+ problems such as overlaps and label collisions are the renderers' job.
@@ -0,0 +1,152 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/tt-a1i/archify/schemas/architecture.schema.json",
4
+ "title": "Archify Architecture Diagram",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema_version", "diagram_type", "meta", "components"],
8
+ "properties": {
9
+ "schema_version": { "const": 1 },
10
+ "diagram_type": { "const": "architecture" },
11
+ "meta": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": ["title", "output"],
15
+ "properties": {
16
+ "title": { "type": "string", "minLength": 1 },
17
+ "locale": { "$ref": "common.schema.json#/$defs/locale" },
18
+ "translations": { "$ref": "common.schema.json#/$defs/translations" },
19
+ "subtitle": { "type": "string" },
20
+ "output": { "$ref": "common.schema.json#/$defs/portableOutputPath" },
21
+ "animation": { "$ref": "common.schema.json#/$defs/animation" },
22
+ "visual_preset": { "$ref": "common.schema.json#/$defs/visualPreset" },
23
+ "quality_profile": { "$ref": "common.schema.json#/$defs/qualityProfile" },
24
+ "engineering_profile": { "enum": ["deployment-ownership"] },
25
+ "repository": { "$ref": "common.schema.json#/$defs/repository" },
26
+ "views": { "$ref": "common.schema.json#/$defs/guidedViews" },
27
+ "legend": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "properties": {
31
+ "mode": { "$ref": "common.schema.json#/$defs/legendMode" },
32
+ "entries": {
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "properties": {
36
+ "frontend": { "$ref": "common.schema.json#/$defs/legendEntry" },
37
+ "backend": { "$ref": "common.schema.json#/$defs/legendEntry" },
38
+ "database": { "$ref": "common.schema.json#/$defs/legendEntry" },
39
+ "cloud": { "$ref": "common.schema.json#/$defs/legendEntry" },
40
+ "security": { "$ref": "common.schema.json#/$defs/legendEntry" },
41
+ "messagebus": { "$ref": "common.schema.json#/$defs/legendEntry" },
42
+ "external": { "$ref": "common.schema.json#/$defs/legendEntry" }
43
+ }
44
+ }
45
+ }
46
+ },
47
+ "viewBox": {
48
+ "type": "array",
49
+ "prefixItems": [
50
+ { "type": "number", "minimum": 320 },
51
+ { "type": "number", "minimum": 240 }
52
+ ],
53
+ "items": false,
54
+ "minItems": 2,
55
+ "maxItems": 2
56
+ }
57
+ }
58
+ },
59
+ "layout": {
60
+ "type": "object",
61
+ "additionalProperties": false,
62
+ "required": ["mode"],
63
+ "properties": {
64
+ "mode": { "enum": ["grid"] },
65
+ "origin": { "$ref": "common.schema.json#/$defs/point" },
66
+ "cols": { "type": "integer", "minimum": 1, "maximum": 12 },
67
+ "gapX": { "type": "number", "minimum": 0 },
68
+ "gapY": { "type": "number", "minimum": 0 },
69
+ "cellW": { "type": "number", "minimum": 40 },
70
+ "cellH": { "type": "number", "minimum": 24 }
71
+ }
72
+ },
73
+ "components": {
74
+ "type": "array",
75
+ "minItems": 1,
76
+ "items": {
77
+ "type": "object",
78
+ "additionalProperties": false,
79
+ "required": ["id", "type", "label"],
80
+ "properties": {
81
+ "id": { "$ref": "common.schema.json#/$defs/id" },
82
+ "type": { "$ref": "common.schema.json#/$defs/componentType" },
83
+ "label": { "type": "string", "minLength": 1 },
84
+ "sublabel": { "type": "string" },
85
+ "tag": { "type": "string" },
86
+ "icon": { "$ref": "common.schema.json#/$defs/nodeIcon" },
87
+ "brand": { "$ref": "common.schema.json#/$defs/brandMark" },
88
+ "sources": { "$ref": "common.schema.json#/$defs/sourceReferences" },
89
+ "row": { "type": "integer", "minimum": 0 },
90
+ "col": { "type": "integer", "minimum": 0 },
91
+ "pos": { "$ref": "common.schema.json#/$defs/point" },
92
+ "size": {
93
+ "type": "array",
94
+ "prefixItems": [
95
+ { "type": "number", "exclusiveMinimum": 0 },
96
+ { "type": "number", "exclusiveMinimum": 0 }
97
+ ],
98
+ "items": false,
99
+ "minItems": 2,
100
+ "maxItems": 2
101
+ }
102
+ }
103
+ }
104
+ },
105
+ "boundaries": {
106
+ "type": "array",
107
+ "items": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "required": ["kind", "label", "wraps"],
111
+ "properties": {
112
+ "kind": { "enum": ["region", "security-group"] },
113
+ "label": { "type": "string", "minLength": 1 },
114
+ "wraps": {
115
+ "type": "array",
116
+ "minItems": 1,
117
+ "items": { "$ref": "common.schema.json#/$defs/id" }
118
+ },
119
+ "pad": { "type": "number", "minimum": 0 }
120
+ }
121
+ }
122
+ },
123
+ "connections": {
124
+ "type": "array",
125
+ "items": {
126
+ "type": "object",
127
+ "additionalProperties": false,
128
+ "required": ["from", "to"],
129
+ "properties": {
130
+ "id": { "$ref": "common.schema.json#/$defs/id" },
131
+ "from": { "$ref": "common.schema.json#/$defs/id" },
132
+ "to": { "$ref": "common.schema.json#/$defs/id" },
133
+ "label": { "type": "string" },
134
+ "variant": { "$ref": "common.schema.json#/$defs/variant" },
135
+ "fromSide": { "$ref": "common.schema.json#/$defs/side" },
136
+ "toSide": { "$ref": "common.schema.json#/$defs/side" },
137
+ "route": { "enum": ["auto", "straight", "orthogonal-h", "orthogonal-v"] },
138
+ "via": {
139
+ "type": "array",
140
+ "items": { "$ref": "common.schema.json#/$defs/point" }
141
+ },
142
+ "labelAt": { "$ref": "common.schema.json#/$defs/point" },
143
+ "labelDx": { "type": "number" },
144
+ "labelDy": { "type": "number" },
145
+ "labelSegment": { "type": "integer", "minimum": 0 },
146
+ "width": { "$ref": "common.schema.json#/$defs/relationshipWidth" }
147
+ }
148
+ }
149
+ },
150
+ "cards": { "$ref": "common.schema.json#/$defs/cards" }
151
+ }
152
+ }