@transitrix/diagrams 1.10.0 → 1.12.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 (71) hide show
  1. package/dist/activities/resolver.d.ts +3 -0
  2. package/dist/activities/resolver.js +39 -18
  3. package/dist/activities/validate.js +67 -4
  4. package/dist/canon-resolver-utils.d.ts +3 -0
  5. package/dist/canon-resolver-utils.js +16 -0
  6. package/dist/compliance/classify.js +1 -0
  7. package/dist/compliance/impact.d.ts +3 -1
  8. package/dist/compliance/impact.js +41 -13
  9. package/dist/compliance/types.d.ts +6 -0
  10. package/dist/compliance-verification-matrix/build.d.ts +17 -0
  11. package/dist/compliance-verification-matrix/build.js +65 -0
  12. package/dist/compliance-verification-matrix/csv.d.ts +6 -0
  13. package/dist/compliance-verification-matrix/csv.js +41 -0
  14. package/dist/compliance-verification-matrix/index.d.ts +3 -0
  15. package/dist/compliance-verification-matrix/index.js +2 -0
  16. package/dist/compliance-verification-matrix/types.d.ts +75 -0
  17. package/dist/compliance-verification-matrix/types.js +4 -0
  18. package/dist/fgca/action-change-ids.d.ts +7 -0
  19. package/dist/fgca/action-change-ids.js +11 -0
  20. package/dist/fgca/parse-canonical.d.ts +17 -3
  21. package/dist/fgca/parse-canonical.js +44 -16
  22. package/dist/fgca/resolver.d.ts +6 -2
  23. package/dist/fgca/resolver.js +28 -6
  24. package/dist/fgca/validate.d.ts +2 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/process-blueprint/index.d.ts +3 -1
  28. package/dist/process-blueprint/index.js +1 -0
  29. package/dist/process-blueprint/layout.js +33 -29
  30. package/dist/process-blueprint/resolve-columns.d.ts +52 -0
  31. package/dist/process-blueprint/resolve-columns.js +138 -0
  32. package/dist/process-blueprint/types.d.ts +23 -5
  33. package/dist/process-blueprint/validate.d.ts +19 -1
  34. package/dist/process-blueprint/validate.js +73 -21
  35. package/dist/repo-validate/check-process-parent.d.ts +8 -0
  36. package/dist/repo-validate/check-process-parent.js +172 -0
  37. package/dist/repo-validate/index.d.ts +1 -0
  38. package/dist/repo-validate/index.js +1 -0
  39. package/dist/repo-validate/validate-repo.js +3 -0
  40. package/dist/webview/entry.js +26 -4
  41. package/dist/webview/render-fgca.d.ts +2 -0
  42. package/dist/webview/render-fgca.js +9 -3
  43. package/dist/webview/render-process.d.ts +19 -1
  44. package/dist/webview/render-process.js +75 -42
  45. package/package.json +3 -3
  46. package/src/activities/resolver.ts +40 -20
  47. package/src/activities/validate.ts +66 -4
  48. package/src/canon-resolver-utils.ts +19 -0
  49. package/src/compliance/classify.ts +1 -0
  50. package/src/compliance/impact.ts +41 -12
  51. package/src/compliance/types.ts +6 -0
  52. package/src/compliance-verification-matrix/build.ts +84 -0
  53. package/src/compliance-verification-matrix/csv.ts +47 -0
  54. package/src/compliance-verification-matrix/index.ts +7 -0
  55. package/src/compliance-verification-matrix/types.ts +85 -0
  56. package/src/fgca/action-change-ids.ts +13 -0
  57. package/src/fgca/parse-canonical.ts +56 -15
  58. package/src/fgca/resolver.ts +39 -6
  59. package/src/fgca/validate.ts +2 -0
  60. package/src/index.ts +1 -0
  61. package/src/process-blueprint/index.ts +11 -0
  62. package/src/process-blueprint/layout.ts +48 -29
  63. package/src/process-blueprint/resolve-columns.ts +147 -0
  64. package/src/process-blueprint/types.ts +19 -5
  65. package/src/process-blueprint/validate.ts +107 -21
  66. package/src/repo-validate/check-process-parent.ts +184 -0
  67. package/src/repo-validate/index.ts +5 -0
  68. package/src/repo-validate/validate-repo.ts +3 -0
  69. package/src/webview/entry.ts +26 -4
  70. package/src/webview/render-fgca.ts +13 -2
  71. package/src/webview/render-process.ts +94 -49
@@ -27,8 +27,9 @@ export interface ComplianceLaneAssertion {
27
27
  /** Compliance realisation status. */
28
28
  status: 'compliant' | 'partial' | 'non_compliant' | 'under_review' | 'pending_owner' | 'n_a';
29
29
  /**
30
- * Typed IDs of stages / process steps where the requirement is realised.
31
- * When empty/absent, the assertion covers the entire subject, not a specific stage.
30
+ * Typed IDs of processes or steps where the requirement is realised.
31
+ * Sketch `STAGE-…` ids are not a join key. When empty/absent, the assertion
32
+ * covers the entire subject, not a specific column.
32
33
  */
33
34
  realised_via?: string[];
34
35
  }
@@ -89,9 +90,12 @@ export interface ComplianceRow {
89
90
  }
90
91
  export interface Stage {
91
92
  id: string;
92
- name: string;
93
- goal: string;
94
- result: string;
93
+ /** Required on `STAGE-…` sketch columns (`BP-005`); omitted on `PROCESS-…`. */
94
+ name?: string;
95
+ /** Required on `STAGE-…` sketch columns (`BP-005`); omitted on `PROCESS-…`. */
96
+ goal?: string;
97
+ /** Required on `STAGE-…` sketch columns (`BP-005`); omitted on `PROCESS-…`. */
98
+ result?: string;
95
99
  description?: string;
96
100
  }
97
101
  export interface AspectEntry {
@@ -188,6 +192,20 @@ export interface ProcessBlueprintLayoutOptions {
188
192
  * When absent, all stages are shown.
189
193
  */
190
194
  visibleStages?: string[];
195
+ /**
196
+ * Catalogue of `PROCESS-…` column records (id → name / optional goal / result).
197
+ * Required to header catalogued columns; ignored for `STAGE-…` sketches.
198
+ */
199
+ processCatalog?: ReadonlyMap<string, {
200
+ name: string;
201
+ goal?: string;
202
+ result?: string;
203
+ }>;
204
+ /**
205
+ * STEP id → home PROCESS id (contained in `PROCESS.flow` or promoted).
206
+ * Used by the compliance-lane join; omit to skip STEP-level pins.
207
+ */
208
+ stepHomeProcess?: ReadonlyMap<string, string>;
191
209
  }
192
210
  import type { LayoutBounds } from '../geometry.js';
193
211
  export type { LayoutBounds };
@@ -1,3 +1,21 @@
1
1
  import type { ValidationError, ValidationWarning, ValidationResult } from '../validation-types.js';
2
+ import type { CanonCatalog } from '../typed-id.js';
2
3
  export type { ValidationError, ValidationWarning, ValidationResult };
3
- export declare function validateProcessBlueprint(input: unknown): ValidationResult;
4
+ export interface ProcessParentEdge {
5
+ /** Child process id (`from`). */
6
+ from: string;
7
+ /** Parent process id (`to`). */
8
+ to: string;
9
+ }
10
+ export interface ProcessBlueprintValidateOptions {
11
+ /** When provided, BP-012 resolves `PROCESS-…` column ids against admitted canon. */
12
+ catalog?: CanonCatalog;
13
+ /**
14
+ * In-effect `process_parent` edges (child → parent). When provided, BP-014
15
+ * warns if `process_blueprint.process` is set and a `PROCESS-…` column has
16
+ * no such edge to that parent. Omit to skip BP-014 (file-scope without the
17
+ * relation catalogue).
18
+ */
19
+ processParentEdges?: readonly ProcessParentEdge[];
20
+ }
21
+ export declare function validateProcessBlueprint(input: unknown, options?: ProcessBlueprintValidateOptions): ValidationResult;
@@ -1,13 +1,27 @@
1
1
  const ID_GRAMMAR_RE = /^[A-Z][A-Z_]*(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
2
2
  const PROCESS_BLUEPRINT_ID_RE = /^PROCESS_BLUEPRINT(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
3
3
  const STAGE_ID_RE = /^STAGE(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
4
+ const PROCESS_ID_RE = /^PROCESS(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
4
5
  const APPLICATION_ID_RE = /^APPLICATION(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
5
6
  const ROLE_ID_RE = /^ROLE(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
6
7
  const ASPECT_CATEGORIES = ['systems', 'actors', 'equipment', 'information_entities'];
8
+ const RESTATED_COLUMN_FIELDS = ['name', 'goal', 'result'];
7
9
  function isNonEmptyString(v) {
8
10
  return typeof v === 'string' && v.trim().length > 0;
9
11
  }
10
- export function validateProcessBlueprint(input) {
12
+ function isProcessColumnId(id) {
13
+ return PROCESS_ID_RE.test(id);
14
+ }
15
+ function isStageColumnId(id) {
16
+ return STAGE_ID_RE.test(id);
17
+ }
18
+ function isColumnId(id) {
19
+ return isStageColumnId(id) || isProcessColumnId(id);
20
+ }
21
+ function fieldIsPresent(record, key) {
22
+ return Object.prototype.hasOwnProperty.call(record, key);
23
+ }
24
+ export function validateProcessBlueprint(input, options = {}) {
11
25
  const errors = [];
12
26
  const warnings = [];
13
27
  if (!input || typeof input !== 'object') {
@@ -47,6 +61,7 @@ export function validateProcessBlueprint(input) {
47
61
  return { valid: false, errors, warnings };
48
62
  }
49
63
  const stageIds = new Set();
64
+ const processColumnIds = [];
50
65
  for (let i = 0; i < stagesRaw.length; i++) {
51
66
  const s = stagesRaw[i];
52
67
  const path = `stages[${i}]`;
@@ -55,31 +70,68 @@ export function validateProcessBlueprint(input) {
55
70
  continue;
56
71
  }
57
72
  if (!isNonEmptyString(s['id'])) {
58
- errors.push({ code: 'BP-005', message: `${path}.id is required` });
73
+ errors.push({ code: 'BP-006', message: `${path}.id is required` });
74
+ continue;
75
+ }
76
+ const sid = s['id'].trim();
77
+ if (stageIds.has(sid)) {
78
+ errors.push({ code: 'BP-006', message: `Duplicate stage id: "${sid}"` });
59
79
  }
60
80
  else {
61
- const sid = s['id'].trim();
62
- if (stageIds.has(sid)) {
63
- errors.push({ code: 'BP-006', message: `Duplicate stage id: "${sid}"` });
64
- }
65
- else {
66
- stageIds.add(sid);
81
+ stageIds.add(sid);
82
+ }
83
+ if (!isColumnId(sid)) {
84
+ errors.push({
85
+ code: 'BP-006',
86
+ message: `${path}.id "${sid}" must match STAGE-[<middle>-]<INTEGER> or PROCESS-[<middle>-]<INTEGER>`,
87
+ });
88
+ continue;
89
+ }
90
+ if (isProcessColumnId(sid)) {
91
+ processColumnIds.push(sid);
92
+ for (const field of RESTATED_COLUMN_FIELDS) {
93
+ if (fieldIsPresent(s, field)) {
94
+ errors.push({
95
+ code: 'BP-013',
96
+ message: `${path}.${field} must not be restated on a PROCESS-… column — derive it from the process element`,
97
+ });
98
+ }
67
99
  }
68
- if (!STAGE_ID_RE.test(sid)) {
69
- errors.push({
70
- code: 'BP-006',
71
- message: `${path}.id "${sid}" must match STAGE-[<middle>-]<INTEGER>`,
72
- });
100
+ if (options.catalog) {
101
+ const resolved = options.catalog.typeOf(sid);
102
+ if (resolved !== 'PROCESS') {
103
+ errors.push({
104
+ code: 'BP-012',
105
+ message: `${path}.id "${sid}" must resolve to an admitted PROCESS element`,
106
+ });
107
+ }
73
108
  }
74
109
  }
75
- if (!isNonEmptyString(s['name'])) {
76
- errors.push({ code: 'BP-005', message: `${path}.name is required` });
77
- }
78
- if (!isNonEmptyString(s['goal'])) {
79
- errors.push({ code: 'BP-005', message: `${path}.goal is required` });
110
+ else {
111
+ if (!isNonEmptyString(s['name'])) {
112
+ errors.push({ code: 'BP-005', message: `${path}.name is required` });
113
+ }
114
+ if (!isNonEmptyString(s['goal'])) {
115
+ errors.push({ code: 'BP-005', message: `${path}.goal is required` });
116
+ }
117
+ if (!isNonEmptyString(s['result'])) {
118
+ errors.push({ code: 'BP-005', message: `${path}.result is required` });
119
+ }
80
120
  }
81
- if (!isNonEmptyString(s['result'])) {
82
- errors.push({ code: 'BP-005', message: `${path}.result is required` });
121
+ }
122
+ const parentProcess = isNonEmptyString(pb['process']) ? pb['process'].trim() : undefined;
123
+ if (parentProcess && options.processParentEdges && processColumnIds.length > 0) {
124
+ const linked = new Set(options.processParentEdges
125
+ .filter((e) => e.to === parentProcess)
126
+ .map((e) => e.from));
127
+ for (const child of processColumnIds) {
128
+ if (!linked.has(child)) {
129
+ warnings.push({
130
+ code: 'BP-014',
131
+ message: `Column "${child}" is a PROCESS-… id and process_blueprint.process is "${parentProcess}", ` +
132
+ `but no in-effect process_parent REL links that column to that parent`,
133
+ });
134
+ }
83
135
  }
84
136
  }
85
137
  const usedStageIds = new Set();
@@ -105,7 +157,7 @@ export function validateProcessBlueprint(input) {
105
157
  if (!Array.isArray(entryStages) || entryStages.length === 0) {
106
158
  errors.push({
107
159
  code: 'BP-007',
108
- message: `${path}.stages must be a non-empty array of STAGE-… ids`,
160
+ message: `${path}.stages must be a non-empty array of declared column ids`,
109
161
  });
110
162
  }
111
163
  else {
@@ -0,0 +1,8 @@
1
+ import type { ProcessParentEdge } from '../process-blueprint/validate.js';
2
+ import type { RepoFinding, RepoModelInput } from './types.js';
3
+ /** Inclusive window: in effect at `asOf` iff valid_from ≤ asOf and (valid_to is null or asOf ≤ valid_to). */
4
+ export declare function relationInEffectAt(data: Record<string, unknown>, asOf: string): boolean;
5
+ export declare function todayIsoDate(now?: Date): string;
6
+ /** In-effect `process_parent` edges (child → parent) among loaded REL files. */
7
+ export declare function collectInEffectProcessParentEdges(input: RepoModelInput, asOf?: string): ProcessParentEdge[];
8
+ export declare function checkProcessParentSemantics(input: RepoModelInput, findings: RepoFinding[]): void;
@@ -0,0 +1,172 @@
1
+ // process_parent relation checks — 17-relations.md §3 / §5 (REL-007, REL-008)
2
+ // and endpoint TYPE (PROCESS → PROCESS), plus the in-effect edge collector
3
+ // that process-blueprint BP-014 consumes.
4
+ //
5
+ // REL-007 is single-file (from === to). REL-008 is cross-cutting over the
6
+ // admitted process_parent graph and is a warning, parallel to REL-006.
7
+ import { docId, endpointId } from './validate-repo.js';
8
+ const PScope = 'repo';
9
+ function isProcessNotation(n) {
10
+ return n === 'process';
11
+ }
12
+ function isoDate(value) {
13
+ return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}/.test(value) ? value.slice(0, 10) : undefined;
14
+ }
15
+ /** Inclusive window: in effect at `asOf` iff valid_from ≤ asOf and (valid_to is null or asOf ≤ valid_to). */
16
+ export function relationInEffectAt(data, asOf) {
17
+ const from = isoDate(data['valid_from']);
18
+ if (from && from > asOf)
19
+ return false;
20
+ const to = data['valid_to'];
21
+ if (to === null || to === undefined)
22
+ return true;
23
+ const toDate = isoDate(to);
24
+ if (!toDate)
25
+ return true;
26
+ return asOf <= toDate;
27
+ }
28
+ export function todayIsoDate(now = new Date()) {
29
+ return now.toISOString().slice(0, 10);
30
+ }
31
+ /** In-effect `process_parent` edges (child → parent) among loaded REL files. */
32
+ export function collectInEffectProcessParentEdges(input, asOf = todayIsoDate()) {
33
+ const edges = [];
34
+ for (const doc of input.relations) {
35
+ if (!doc.data)
36
+ continue;
37
+ if (doc.data['type'] !== 'process_parent')
38
+ continue;
39
+ if (!relationInEffectAt(doc.data, asOf))
40
+ continue;
41
+ const fromId = endpointId(doc.data['from']) ?? endpointId(doc.data['source']);
42
+ const toId = endpointId(doc.data['to']) ?? endpointId(doc.data['target']);
43
+ if (!fromId || !toId)
44
+ continue;
45
+ edges.push({ from: fromId, to: toId });
46
+ }
47
+ return edges;
48
+ }
49
+ function processParentRels(input) {
50
+ const out = [];
51
+ for (const doc of input.relations) {
52
+ if (!doc.data)
53
+ continue;
54
+ if (doc.data['type'] !== 'process_parent')
55
+ continue;
56
+ const fromId = endpointId(doc.data['from']) ?? endpointId(doc.data['source']);
57
+ const toId = endpointId(doc.data['to']) ?? endpointId(doc.data['target']);
58
+ if (!fromId || !toId)
59
+ continue;
60
+ out.push({ relId: docId(doc) ?? '', fromId, toId });
61
+ }
62
+ return out;
63
+ }
64
+ /** REL-007 — process_parent self-reference. */
65
+ function checkSelfReference(rels, findings) {
66
+ for (const rel of rels) {
67
+ if (rel.fromId === rel.toId) {
68
+ findings.push({
69
+ scope: PScope,
70
+ id: rel.relId,
71
+ ruleId: 'REL-007',
72
+ message: `REL-007: process_parent relation '${rel.relId}' has from equal to to ('${rel.fromId}').`,
73
+ });
74
+ }
75
+ }
76
+ }
77
+ /** REL-008 — cycle in the process_parent graph (warning). */
78
+ function checkCycle(rels, findings) {
79
+ const childrenOf = new Map();
80
+ const relByChildParent = new Map();
81
+ const nodes = new Set();
82
+ for (const rel of rels) {
83
+ if (rel.fromId === rel.toId)
84
+ continue;
85
+ nodes.add(rel.fromId);
86
+ nodes.add(rel.toId);
87
+ const list = childrenOf.get(rel.fromId);
88
+ if (list)
89
+ list.push(rel.toId);
90
+ else
91
+ childrenOf.set(rel.fromId, [rel.toId]);
92
+ relByChildParent.set(`${rel.fromId}\0${rel.toId}`, rel.relId);
93
+ }
94
+ const UNVISITED = 0;
95
+ const VISITING = 1;
96
+ const DONE = 2;
97
+ const state = new Map();
98
+ let hit;
99
+ function walk(id) {
100
+ const s = state.get(id) ?? UNVISITED;
101
+ if (s === DONE)
102
+ return false;
103
+ if (s === VISITING) {
104
+ hit = id;
105
+ return true;
106
+ }
107
+ state.set(id, VISITING);
108
+ for (const parent of childrenOf.get(id) ?? []) {
109
+ if (nodes.has(parent) && walk(parent))
110
+ return true;
111
+ }
112
+ state.set(id, DONE);
113
+ return false;
114
+ }
115
+ for (const id of nodes) {
116
+ if (walk(id))
117
+ break;
118
+ }
119
+ if (!hit)
120
+ return;
121
+ const relId = [...relByChildParent.entries()].find(([key]) => key.startsWith(`${hit}\0`))?.[1] ?? hit;
122
+ findings.push({
123
+ scope: PScope,
124
+ id: relId,
125
+ ruleId: 'REL-008',
126
+ severity: 'warning',
127
+ message: `REL-008: process_parent graph contains a cycle involving '${hit}'.`,
128
+ });
129
+ }
130
+ /**
131
+ * Endpoint TYPE for process_parent: both ends must be PROCESS when they
132
+ * resolve. Unknown endpoints stay with referential integrity; this pass only
133
+ * fires when the element exists and is the wrong notation.
134
+ */
135
+ function checkEndpointTypes(input, rels, findings) {
136
+ const elementById = new Map();
137
+ for (const doc of input.elements) {
138
+ const id = docId(doc);
139
+ if (id && doc.data)
140
+ elementById.set(id, doc.data);
141
+ }
142
+ for (const rel of rels) {
143
+ const from = elementById.get(rel.fromId);
144
+ if (from && !isProcessNotation(from['notation'])) {
145
+ findings.push({
146
+ scope: PScope,
147
+ id: rel.relId,
148
+ ruleId: 'REL-002',
149
+ message: `Layer-semantics: '${rel.relId}' type 'process_parent' requires from to be ` +
150
+ `PROCESS; got notation='${from['notation']}'.`,
151
+ });
152
+ }
153
+ const to = elementById.get(rel.toId);
154
+ if (to && !isProcessNotation(to['notation'])) {
155
+ findings.push({
156
+ scope: PScope,
157
+ id: rel.relId,
158
+ ruleId: 'REL-002',
159
+ message: `Layer-semantics: '${rel.relId}' type 'process_parent' requires to to be ` +
160
+ `PROCESS; got notation='${to['notation']}'.`,
161
+ });
162
+ }
163
+ }
164
+ }
165
+ export function checkProcessParentSemantics(input, findings) {
166
+ const rels = processParentRels(input);
167
+ if (rels.length === 0)
168
+ return;
169
+ checkSelfReference(rels, findings);
170
+ checkCycle(rels, findings);
171
+ checkEndpointTypes(input, rels, findings);
172
+ }
@@ -1,3 +1,4 @@
1
1
  export { validateRepoModel } from './validate-repo.js';
2
2
  export { resolveRepoModel } from './resolve-model.js';
3
+ export { checkProcessParentSemantics, collectInEffectProcessParentEdges, todayIsoDate, } from './check-process-parent.js';
3
4
  export type { RepoDoc, RepoFinding, RepoModelInput, ResolvedElementRecord, ResolvedRelationRecord, ResolvedRepoModel } from './types.js';
@@ -1,2 +1,3 @@
1
1
  export { validateRepoModel } from './validate-repo.js';
2
2
  export { resolveRepoModel } from './resolve-model.js';
3
+ export { checkProcessParentSemantics, collectInEffectProcessParentEdges, todayIsoDate, } from './check-process-parent.js';
@@ -30,6 +30,7 @@ import { checkStrategyChainSemantics } from './check-strategy-chain.js';
30
30
  import { checkElementHygiene } from './check-element-hygiene.js';
31
31
  import { checkVersionedAttributes } from './check-versioned-attributes.js';
32
32
  import { checkCandidateFields } from './check-candidate-fields.js';
33
+ import { checkProcessParentSemantics } from './check-process-parent.js';
33
34
  const PScope = 'repo';
34
35
  /** Statuses that, per lint.py's policy check, require an owner. */
35
36
  const OWNER_REQUIRED_STATUSES = new Set(['Active', 'Production']);
@@ -154,6 +155,7 @@ function checkReferentialIntegrity(input, findings) {
154
155
  * realizes — BUSINESS_SERVICE → CAPABILITY (25-business-services.md)
155
156
  * hosts — NODE → TECHNOLOGY_SERVICE (25-nodes.md / 26-technology-services.md)
156
157
  * uses — APPLICATION → TECHNOLOGY_SERVICE (26-technology-services.md)
158
+ * process_parent — PROCESS → PROCESS (17-relations.md §3; REL-007/008)
157
159
  *
158
160
  * Implemented element checks:
159
161
  * TSVC-003 — TECHNOLOGY_SERVICE.node must resolve to NODE notation
@@ -407,6 +409,7 @@ export function validateRepoModel(input) {
407
409
  checkAtomicity(input, findings);
408
410
  checkReferentialIntegrity(input, findings);
409
411
  checkLayerSemantics(input, findings);
412
+ checkProcessParentSemantics(input, findings);
410
413
  checkPolicy(input, findings);
411
414
  // Phase 7 — strategy-chain semantic rules ported from DSM's Go Validate*
412
415
  // functions (GOALS-010, ACT-006..009, FGCA-008..011).
@@ -113,22 +113,44 @@ function dispatchValidate(kind, doc) {
113
113
  return r;
114
114
  }
115
115
  case 'dgca': {
116
- const v = parseCanonicalFGCA(doc);
116
+ const meta = (doc ?? {});
117
+ const outOfScopeGoalIds = meta['__outOfScopeGoalIds'] instanceof Set
118
+ ? meta['__outOfScopeGoalIds']
119
+ : Array.isArray(meta['__outOfScopeGoalIds'])
120
+ ? new Set(meta['__outOfScopeGoalIds'])
121
+ : undefined;
122
+ const outOfScopeFactorIds = meta['__outOfScopeFactorIds'] instanceof Set
123
+ ? meta['__outOfScopeFactorIds']
124
+ : Array.isArray(meta['__outOfScopeFactorIds'])
125
+ ? new Set(meta['__outOfScopeFactorIds'])
126
+ : undefined;
127
+ const v = parseCanonicalFGCA(doc, outOfScopeGoalIds, outOfScopeFactorIds);
117
128
  const r = emptyResult(kind, v.valid ? 'ok' : 'error');
118
129
  r.errors.push(...v.errors);
119
130
  r.warnings.push(...v.warnings);
120
131
  if (v.valid && v.parsed) {
121
- r.svg = renderFgcaSvg(v.parsed, { variant: 'dgca' });
132
+ r.svg = renderFgcaSvg(v.parsed, { variant: 'dgca', scopeCaption: v.scopeCaption });
122
133
  }
123
134
  return r;
124
135
  }
125
136
  case 'dga': {
126
- const v = parseCanonicalFGA(doc);
137
+ const meta = (doc ?? {});
138
+ const outOfScopeGoalIds = meta['__outOfScopeGoalIds'] instanceof Set
139
+ ? meta['__outOfScopeGoalIds']
140
+ : Array.isArray(meta['__outOfScopeGoalIds'])
141
+ ? new Set(meta['__outOfScopeGoalIds'])
142
+ : undefined;
143
+ const outOfScopeFactorIds = meta['__outOfScopeFactorIds'] instanceof Set
144
+ ? meta['__outOfScopeFactorIds']
145
+ : Array.isArray(meta['__outOfScopeFactorIds'])
146
+ ? new Set(meta['__outOfScopeFactorIds'])
147
+ : undefined;
148
+ const v = parseCanonicalFGA(doc, outOfScopeGoalIds, outOfScopeFactorIds);
127
149
  const r = emptyResult(kind, v.valid ? 'ok' : 'error');
128
150
  r.errors.push(...v.errors);
129
151
  r.warnings.push(...v.warnings);
130
152
  if (v.valid && v.parsed) {
131
- r.svg = renderFgcaSvg(v.parsed, { variant: 'dga' });
153
+ r.svg = renderFgcaSvg(v.parsed, { variant: 'dga', scopeCaption: v.scopeCaption });
132
154
  }
133
155
  return r;
134
156
  }
@@ -41,6 +41,8 @@ export interface RenderFgcaOptions {
41
41
  entryCurvature?: number;
42
42
  nodeSizePreset?: NodeSizePreset;
43
43
  layoutOptions?: Parameters<typeof layoutFGCAPreview>[1];
44
+ /** Show scope caption when goal-scoped projection omits goals that reference out-of-scope goals. */
45
+ scopeCaption?: boolean;
44
46
  }
45
47
  export declare function renderFgcaSvg(doc: FGCADoc, options?: RenderFgcaOptions): string;
46
48
  export {};
@@ -66,8 +66,8 @@ export function renderFgcaBody(columns, nodes, edges, curvature, entryCurvature,
66
66
  return `${headerSvg}\n${nodeSvg}\n${edgeSvg}`;
67
67
  }
68
68
  export function renderFgcaSvg(doc, options = {}) {
69
- const { variant = 'dgca', title = '', curvature = DEFAULT_EDGE_CURVATURE, entryCurvature, nodeSizePreset = 'normal', layoutOptions, } = options;
70
- const hideChanges = variant === 'dga';
69
+ const { variant = 'dgca', title = '', curvature = DEFAULT_EDGE_CURVATURE, entryCurvature, nodeSizePreset = 'normal', layoutOptions, scopeCaption = false, } = options;
70
+ const hideChanges = variant === 'dga' || doc.hideChanges === true;
71
71
  const nodeSize = resolveDgcaNodeSize(parseNodeSizePreset(nodeSizePreset));
72
72
  const { nodes, edges, columns, width, height } = layoutFGCAPreview(doc, {
73
73
  hideChanges,
@@ -85,8 +85,13 @@ export function renderFgcaSvg(doc, options = {}) {
85
85
  const titleSvg = title
86
86
  ? `<text class="text-header" x="${PAD}" y="${PAD - 6}">${escXml(title)}</text>`
87
87
  : '';
88
+ const captionSvg = scopeCaption
89
+ ? `<text class="text-caption" x="${PAD}" y="${height + 16}">${escXml('This diagram is shown for the selected goal scope. Actions on it may also serve goals outside that scope.')}</text>`
90
+ : '';
88
91
  const embedCss = generateSvgEmbedCss('transitrix');
89
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
92
+ // Calculate final height including caption if present
93
+ const finalHeight = scopeCaption ? height + 24 : height;
94
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${finalHeight}" viewBox="0 0 ${width} ${finalHeight}">
90
95
  <style>${embedCss}</style>
91
96
  <defs>
92
97
  <marker id="arrow" markerWidth="8" markerHeight="8" refX="8" refY="3" orient="auto">
@@ -95,5 +100,6 @@ export function renderFgcaSvg(doc, options = {}) {
95
100
  </defs>
96
101
  ${titleSvg}
97
102
  ${body}
103
+ ${captionSvg}
98
104
  </svg>`;
99
105
  }
@@ -64,13 +64,31 @@ export interface ProcessDiagramLayout {
64
64
  flows: ProcessFlow[];
65
65
  associations: ProcessAssociation[];
66
66
  }
67
+ export interface BpmnTypography {
68
+ taskFontPx: number;
69
+ headerFontPx: number;
70
+ labelFontPx: number;
71
+ taskChars: number;
72
+ taskLineH: number;
73
+ labelChars: number;
74
+ labelLineH: number;
75
+ headerCharW: number;
76
+ }
77
+ /** Interactive-preview / default-export type sizes. */
78
+ export declare const DEFAULT_BPMN_TYPOGRAPHY: BpmnTypography;
79
+ /** Presentation-export type sizes (20 px floor, wrap tuned to default node boxes). */
80
+ export declare const PRESENTATION_BPMN_TYPOGRAPHY: BpmnTypography;
67
81
  export interface RenderProcessOptions {
68
82
  /** Raw SVG injected after `<style>` — a title line or full title block. */
69
83
  title?: string;
70
84
  /** Extra vertical space (px) reserved above the pool for a title block. */
71
85
  topInset?: number;
86
+ /** Label metrics. Omit for the interactive-preview defaults. */
87
+ typography?: BpmnTypography;
72
88
  }
73
- export declare const BPMN_PROCESS_CSS = "\n.bpmn-pool { fill: var(--ts-bg-surface,#f8fafc); stroke: var(--ts-node-stroke,#004d67); stroke-width: 1.5; }\n.bpmn-pool-name { fill: var(--ts-bg-elevated,#f1f5f9); stroke: var(--ts-node-stroke,#004d67); stroke-width: 0.75; }\n.bpmn-lane { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#004d67); stroke-width: 0.75; }\n.bpmn-lane-header { fill: var(--ts-bg-elevated,#f1f5f9); stroke: var(--ts-node-stroke,#004d67); stroke-width: 0.75; }\n.bpmn-pool-label { fill: var(--ts-text-primary,#0d2b35); font-family: var(--vscode-font-family, system-ui, -apple-system, sans-serif); font-size: 11px; font-weight: 700; }\n.bpmn-lane-label { fill: var(--ts-text-primary,#0d2b35); font-family: var(--vscode-font-family, system-ui, -apple-system, sans-serif); font-size: 11px; font-weight: 600; }\n.bpmn-task { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#004d67); stroke-width: 1.5; }\n.bpmn-task-name { fill: var(--ts-text-primary,#0d2b35); font-family: var(--vscode-font-family, system-ui, -apple-system, sans-serif); font-size: 11px; text-anchor: middle; }\n.bpmn-event { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#004d67); }\n.bpmn-event-start { stroke-width: 1.5; }\n.bpmn-event-end { stroke-width: 4; }\n.bpmn-event-label { fill: var(--ts-text-secondary,#516970); font-family: var(--vscode-font-family, system-ui, -apple-system, sans-serif); font-size: 10px; text-anchor: middle; }\n.bpmn-gateway { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#004d67); stroke-width: 1.5; }\n.bpmn-gateway-marker { stroke: var(--ts-node-stroke,#004d67); stroke-width: 2.5; stroke-linecap: round; fill: none; }\n.bpmn-gateway-label { fill: var(--ts-text-secondary,#516970); font-family: var(--vscode-font-family, system-ui, -apple-system, sans-serif); font-size: 10px; text-anchor: middle; }\n.bpmn-seq-flow { fill: none; stroke: var(--ts-edge-stroke,#004d67); stroke-width: 1.5; }\n.bpmn-default-mark { stroke: var(--ts-edge-stroke,#004d67); stroke-width: 1.5; stroke-linecap: round; }\n.bpmn-assoc { fill: none; stroke: var(--ts-edge-stroke,#004d67); stroke-width: 1; stroke-dasharray: 4 2; }\n.bpmn-data-obj { fill: var(--ts-bg,#ffffff); stroke: var(--ts-node-stroke,#004d67); stroke-width: 1; }\n.bpmn-data-obj-label { fill: var(--ts-text-secondary,#516970); font-size: 10px; text-anchor: middle; }\n.bpmn-event-intermediate { fill: none; stroke: var(--ts-node-stroke,#004d67); stroke-width: 1; }\n.bpmn-event-icon { fill: none; stroke: var(--ts-node-stroke,#004d67); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }\n";
89
+ export declare function bpmnProcessCss(t?: BpmnTypography): string;
90
+ /** Default-preview CSS (11 px / 10 px). Presentation export builds its own via `bpmnProcessCss`. */
91
+ export declare const BPMN_PROCESS_CSS: string;
74
92
  /**
75
93
  * Canonical body emitter, shared by every host (VS Code, JCEF, static export).
76
94
  *