@transitrix/diagrams 1.8.21 → 1.10.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 (190) hide show
  1. package/dist/activity-card/types.js +1 -1
  2. package/dist/agreement.d.ts +15 -0
  3. package/dist/agreement.js +61 -0
  4. package/dist/applications/index.d.ts +2 -0
  5. package/dist/applications/index.js +1 -0
  6. package/dist/applications/resolve-maturity.d.ts +16 -0
  7. package/dist/applications/resolve-maturity.js +57 -0
  8. package/dist/applications/validate.js +20 -0
  9. package/dist/capability-map/CapabilityCardNode.d.ts +1 -1
  10. package/dist/capability-map/CapabilityRootNode.d.ts +1 -1
  11. package/dist/capability-map/index.d.ts +2 -0
  12. package/dist/capability-map/index.js +1 -0
  13. package/dist/capability-map/resolve-maturity.d.ts +20 -0
  14. package/dist/capability-map/resolve-maturity.js +72 -0
  15. package/dist/capability-map/validate.js +1 -2
  16. package/dist/codex/index.d.ts +1 -1
  17. package/dist/codex/index.js +1 -1
  18. package/dist/codex/types.d.ts +9 -2
  19. package/dist/codex/types.js +10 -3
  20. package/dist/codex/validate.js +29 -3
  21. package/dist/compliance/classify.d.ts +21 -2
  22. package/dist/compliance/classify.js +68 -13
  23. package/dist/compliance/confidence.js +1 -1
  24. package/dist/compliance/gap-report.d.ts +31 -1
  25. package/dist/compliance/gap-report.js +55 -3
  26. package/dist/compliance/html.js +14 -6
  27. package/dist/compliance/impact.js +1 -1
  28. package/dist/compliance/index.d.ts +3 -1
  29. package/dist/compliance/index.js +2 -0
  30. package/dist/compliance/markdown.js +26 -4
  31. package/dist/compliance/reverse-index.d.ts +6 -1
  32. package/dist/compliance/reverse-index.js +27 -3
  33. package/dist/compliance/trace.js +5 -1
  34. package/dist/compliance/types.d.ts +70 -0
  35. package/dist/compliance/types.js +1 -2
  36. package/dist/compliance/views.js +1 -1
  37. package/dist/compliance-matrix/build.js +0 -0
  38. package/dist/compliance-matrix/types.d.ts +1 -1
  39. package/dist/compliance-matrix/types.js +1 -1
  40. package/dist/confidence/score.js +1 -1
  41. package/dist/constraint/validate.js +3 -0
  42. package/dist/edge-path.js +1 -1
  43. package/dist/factor/validate.js +2 -2
  44. package/dist/fgca/chain-table.js +1 -1
  45. package/dist/fgca/nodeTypes.d.ts +4 -4
  46. package/dist/fgca/nodes/FGCAActivityNode.d.ts +1 -1
  47. package/dist/fgca/nodes/FGCAChangeNode.d.ts +1 -1
  48. package/dist/fgca/nodes/FGCAFactorNode.d.ts +1 -1
  49. package/dist/fgca/nodes/FGCAGoalNode.d.ts +1 -1
  50. package/dist/fgca/parse-canonical.d.ts +2 -2
  51. package/dist/fgca/parse-canonical.js +2 -2
  52. package/dist/fgca/preview-layout.d.ts +1 -1
  53. package/dist/goals/GoalNode.d.ts +1 -1
  54. package/dist/goals/layout.d.ts +1 -1
  55. package/dist/goals/layout.js +1 -1
  56. package/dist/goals/parse-canonical.d.ts +1 -1
  57. package/dist/goals/parse-canonical.js +1 -1
  58. package/dist/goals/types.d.ts +1 -1
  59. package/dist/goals/validate.js +2 -2
  60. package/dist/link-suspicion.d.ts +43 -0
  61. package/dist/link-suspicion.js +156 -0
  62. package/dist/metric/index.d.ts +4 -0
  63. package/dist/metric/index.js +2 -0
  64. package/dist/metric/types.d.ts +24 -0
  65. package/dist/metric/types.js +7 -0
  66. package/dist/metric/validate.d.ts +7 -0
  67. package/dist/metric/validate.js +90 -0
  68. package/dist/need/index.d.ts +3 -0
  69. package/dist/need/index.js +1 -0
  70. package/dist/need/types.d.ts +21 -0
  71. package/dist/need/types.js +3 -0
  72. package/dist/need/validate.d.ts +7 -0
  73. package/dist/need/validate.js +60 -0
  74. package/dist/repo-validate/check-candidate-fields.d.ts +6 -0
  75. package/dist/repo-validate/check-candidate-fields.js +87 -0
  76. package/dist/repo-validate/check-versioned-attributes.d.ts +4 -0
  77. package/dist/repo-validate/check-versioned-attributes.js +105 -0
  78. package/dist/repo-validate/validate-repo.js +7 -0
  79. package/dist/requirement/index.d.ts +2 -2
  80. package/dist/requirement/index.js +1 -1
  81. package/dist/requirement/types.d.ts +19 -1
  82. package/dist/requirement/types.js +3 -1
  83. package/dist/requirement/validate.js +22 -1
  84. package/dist/risk/index.d.ts +4 -0
  85. package/dist/risk/index.js +2 -0
  86. package/dist/risk/types.d.ts +25 -0
  87. package/dist/risk/types.js +3 -0
  88. package/dist/risk/validate.d.ts +7 -0
  89. package/dist/risk/validate.js +108 -0
  90. package/dist/schema-version.d.ts +9 -6
  91. package/dist/schema-version.js +9 -6
  92. package/dist/theme/themes.js +3 -2
  93. package/dist/validation/index.d.ts +4 -0
  94. package/dist/validation/index.js +2 -0
  95. package/dist/validation/types.d.ts +31 -0
  96. package/dist/validation/types.js +21 -0
  97. package/dist/validation/validate.d.ts +7 -0
  98. package/dist/validation/validate.js +106 -0
  99. package/dist/verification/index.d.ts +4 -0
  100. package/dist/verification/index.js +2 -0
  101. package/dist/verification/types.d.ts +31 -0
  102. package/dist/verification/types.js +12 -0
  103. package/dist/verification/validate.d.ts +7 -0
  104. package/dist/verification/validate.js +104 -0
  105. package/dist/versioned-attribute/index.d.ts +4 -0
  106. package/dist/versioned-attribute/index.js +2 -0
  107. package/dist/versioned-attribute/resolve.d.ts +15 -0
  108. package/dist/versioned-attribute/resolve.js +37 -0
  109. package/dist/versioned-attribute/types.d.ts +12 -0
  110. package/dist/versioned-attribute/types.js +6 -0
  111. package/dist/versioned-attribute/validate.d.ts +17 -0
  112. package/dist/versioned-attribute/validate.js +87 -0
  113. package/dist/webview/entry.js +11 -4
  114. package/dist/webview/render-applications.d.ts +15 -1
  115. package/dist/webview/render-applications.js +7 -2
  116. package/dist/webview/render-blocks.js +6 -4
  117. package/dist/webview/render-capability-map.d.ts +16 -1
  118. package/dist/webview/render-capability-map.js +4 -1
  119. package/dist/webview/render-process.d.ts +1 -1
  120. package/dist/webview/render-process.js +5 -5
  121. package/package.json +9 -6
  122. package/src/activity-card/types.ts +1 -1
  123. package/src/agreement.ts +71 -0
  124. package/src/applications/index.ts +3 -0
  125. package/src/applications/resolve-maturity.ts +66 -0
  126. package/src/applications/validate.ts +23 -0
  127. package/src/capability-map/index.ts +7 -0
  128. package/src/capability-map/resolve-maturity.ts +84 -0
  129. package/src/capability-map/validate.ts +1 -2
  130. package/src/codex/index.ts +1 -1
  131. package/src/codex/types.ts +11 -3
  132. package/src/codex/validate.ts +30 -2
  133. package/src/compliance/classify.ts +87 -14
  134. package/src/compliance/confidence.ts +1 -1
  135. package/src/compliance/gap-report.ts +91 -4
  136. package/src/compliance/html.ts +18 -6
  137. package/src/compliance/impact.ts +1 -1
  138. package/src/compliance/index.ts +6 -0
  139. package/src/compliance/markdown.ts +18 -4
  140. package/src/compliance/reverse-index.ts +35 -4
  141. package/src/compliance/trace.ts +7 -1
  142. package/src/compliance/types.ts +75 -2
  143. package/src/compliance/views.ts +1 -1
  144. package/src/compliance-matrix/build.ts +0 -0
  145. package/src/compliance-matrix/types.ts +2 -2
  146. package/src/confidence/score.ts +1 -1
  147. package/src/constraint/validate.ts +4 -0
  148. package/src/edge-path.ts +1 -1
  149. package/src/factor/validate.ts +2 -2
  150. package/src/fgca/chain-table.ts +1 -1
  151. package/src/fgca/parse-canonical.ts +2 -2
  152. package/src/fgca/preview-layout.ts +1 -1
  153. package/src/goals/layout.ts +1 -1
  154. package/src/goals/parse-canonical.ts +1 -1
  155. package/src/goals/types.ts +1 -1
  156. package/src/goals/validate.ts +2 -2
  157. package/src/link-suspicion.ts +181 -0
  158. package/src/metric/index.ts +4 -0
  159. package/src/metric/types.ts +38 -0
  160. package/src/metric/validate.ts +102 -0
  161. package/src/need/index.ts +3 -0
  162. package/src/need/types.ts +31 -0
  163. package/src/need/validate.ts +71 -0
  164. package/src/repo-validate/check-candidate-fields.ts +93 -0
  165. package/src/repo-validate/check-versioned-attributes.ts +112 -0
  166. package/src/repo-validate/validate-repo.ts +7 -0
  167. package/src/requirement/index.ts +2 -2
  168. package/src/requirement/types.ts +26 -1
  169. package/src/requirement/validate.ts +25 -1
  170. package/src/risk/index.ts +4 -0
  171. package/src/risk/types.ts +35 -0
  172. package/src/risk/validate.ts +121 -0
  173. package/src/schema-version.ts +9 -6
  174. package/src/theme/themes.ts +3 -2
  175. package/src/validation/index.ts +4 -0
  176. package/src/validation/types.ts +57 -0
  177. package/src/validation/validate.ts +113 -0
  178. package/src/verification/index.ts +4 -0
  179. package/src/verification/types.ts +48 -0
  180. package/src/verification/validate.ts +111 -0
  181. package/src/versioned-attribute/index.ts +4 -0
  182. package/src/versioned-attribute/resolve.ts +45 -0
  183. package/src/versioned-attribute/types.ts +19 -0
  184. package/src/versioned-attribute/validate.ts +109 -0
  185. package/src/webview/entry.ts +13 -6
  186. package/src/webview/render-applications.ts +25 -2
  187. package/src/webview/render-blocks.ts +8 -4
  188. package/src/webview/render-capability-map.ts +23 -1
  189. package/src/webview/render-process.ts +5 -5
  190. package/src/webview/styles.css +6 -0
@@ -1,7 +1,7 @@
1
1
  // Activity Card notation — single-project narrative view.
2
2
  //
3
3
  // Spec: transitrix/methodology `notations/views/18-activity-card.md` (v0.1).
4
- // Epic vkgeorgia/strategy#97, Studio track #134.
4
+ // Studio track #134.
5
5
  //
6
6
  // The Activity Card is the first MULTI-DOCUMENT Studio notation. The card
7
7
  // YAML itself holds only `id`, `project` (an Activity ID), `description`,
@@ -0,0 +1,15 @@
1
+ import type { ValidationError } from './validation-types.js';
2
+ export declare const AGREEMENT_VALUES: readonly ["draft", "agreed", "disputed"];
3
+ export type AgreementValue = (typeof AGREEMENT_VALUES)[number];
4
+ export declare function looksLikeTool(id: unknown): boolean;
5
+ /**
6
+ * AGREE-001..003 over an element's already-extracted `agreement` /
7
+ * `agreed_by` fields. Returns an empty list when `agreement` is absent
8
+ * (back-compat — absent ⇒ `agreed`, nothing to check) or when the fields
9
+ * are well-formed.
10
+ *
11
+ * AGREE-002 and AGREE-003 can both describe an `agreement: agreed` record
12
+ * with no `agreed_by` — this reports AGREE-003 only, the same choice
13
+ * `check-agreement.mjs` makes (CONTRACT.md §6.3.1 permits either or both).
14
+ */
15
+ export declare function checkAgreement(record: Record<string, unknown>): ValidationError[];
@@ -0,0 +1,61 @@
1
+ // Agreement axis — methodology CONTRACT.md §6.3 / §6.3.1 (AGREE-001..003).
2
+ //
3
+ // A closed three-value axis (`draft` | `agreed` | `disputed`) carried by
4
+ // REQUIREMENT, CONSTRAINT, and NEED — independent of admission (§6.1),
5
+ // recording whether the accountable party has committed to the statement.
6
+ // Absent ⇒ `agreed` (back-compat; a human-authored element that predates
7
+ // this axis needs no change).
8
+ //
9
+ // Ported from methodology's reference implementation
10
+ // (`scripts/check-agreement.mjs`'s `checkAgreement`/`looksLikeTool`) so a
11
+ // repo carrying the field validates identically here — same closed
12
+ // vocabulary, same tool-id heuristic, same "AGREE-003 wins over AGREE-002
13
+ // when both would fire" precedence.
14
+ export const AGREEMENT_VALUES = ['draft', 'agreed', 'disputed'];
15
+ /** Same convention as `ADMIT-007`'s footgun-catcher: an npm-scoped name, or
16
+ * a hyphenated `*-cli` / `*-reviewer[-…]` / `*-bot` / `*-scanner` id, reads
17
+ * as a tool; anything else reads as a human handle. Not a security
18
+ * boundary — catches the common mistake of a tool defaulting or
19
+ * copy-pasting `agreed`. */
20
+ const TOOL_ID_RE = /^@|-cli$|-reviewer(?:-\w+)?$|-bot$|-scanner$/i;
21
+ export function looksLikeTool(id) {
22
+ return TOOL_ID_RE.test(String(id ?? ''));
23
+ }
24
+ /**
25
+ * AGREE-001..003 over an element's already-extracted `agreement` /
26
+ * `agreed_by` fields. Returns an empty list when `agreement` is absent
27
+ * (back-compat — absent ⇒ `agreed`, nothing to check) or when the fields
28
+ * are well-formed.
29
+ *
30
+ * AGREE-002 and AGREE-003 can both describe an `agreement: agreed` record
31
+ * with no `agreed_by` — this reports AGREE-003 only, the same choice
32
+ * `check-agreement.mjs` makes (CONTRACT.md §6.3.1 permits either or both).
33
+ */
34
+ export function checkAgreement(record) {
35
+ const agreement = record.agreement;
36
+ if (agreement === undefined)
37
+ return [];
38
+ if (typeof agreement !== 'string' || !AGREEMENT_VALUES.includes(agreement)) {
39
+ return [{
40
+ code: 'AGREE-001',
41
+ message: `agreement "${String(agreement)}" must be one of ${AGREEMENT_VALUES.join(', ')}.`,
42
+ path: 'agreement',
43
+ }];
44
+ }
45
+ const agreedBy = record.agreed_by;
46
+ if (typeof agreedBy !== 'string' || agreedBy.trim() === '') {
47
+ return [{
48
+ code: 'AGREE-003',
49
+ message: 'agreed_by is required whenever agreement is present.',
50
+ path: 'agreed_by',
51
+ }];
52
+ }
53
+ if (agreement === 'agreed' && looksLikeTool(agreedBy)) {
54
+ return [{
55
+ code: 'AGREE-002',
56
+ message: `agreement: agreed but agreed_by "${agreedBy}" identifies a tool — a tool must never write "agreed".`,
57
+ path: 'agreed_by',
58
+ }];
59
+ }
60
+ return [];
61
+ }
@@ -1,2 +1,4 @@
1
1
  export type { ApplicationType, ApplicationStatus, IntegrationDirection, ApplicationIntegration, Application, ApplicationsCatalogueHeader, ApplicationsCatalogueFile, } from './types.js';
2
2
  export { validateApplicationsCatalogue } from './validate.js';
3
+ export type { ResolvedApplicationAttributes } from './resolve-maturity.js';
4
+ export { resolveApplicationAttributes, withResolvedAttributes } from './resolve-maturity.js';
@@ -1 +1,2 @@
1
1
  export { validateApplicationsCatalogue } from './validate.js';
2
+ export { resolveApplicationAttributes, withResolvedAttributes } from './resolve-maturity.js';
@@ -0,0 +1,16 @@
1
+ import type { Application } from './types.js';
2
+ export interface ResolvedApplicationAttributes {
3
+ owner_role?: string;
4
+ vendor?: string;
5
+ maturity?: number;
6
+ }
7
+ /** Pick every sidecar out of a raw canon/elements/** doc pool and resolve
8
+ * owner_role/vendor/maturity at `atDate`, keyed by the sidecar's target id
9
+ * (== an application's `app_id`, per the notation's element-file pairing). */
10
+ export declare function resolveApplicationAttributes(rawElementDocs: unknown[], atDate: string): Map<string, ResolvedApplicationAttributes>;
11
+ /** Merge resolved sidecar values into a rendering copy of an application row.
12
+ * An inline value would win if present, but VERSIONED-004 already forbids
13
+ * that on an admitted document — this is a display fallback, not a
14
+ * migration tool. The returned object is a plain copy; nothing here writes
15
+ * it anywhere. */
16
+ export declare function withResolvedAttributes(app: Application, resolved: Map<string, ResolvedApplicationAttributes>): Application;
@@ -0,0 +1,57 @@
1
+ // Render-time resolution of the applications-catalogue's sidecar-bound
2
+ // time_varying fields (owner_role, vendor, maturity — notations/views/
3
+ // 10-applications.md §5a, CONTRACT.md §9.4). VERSIONED-004 rejects these
4
+ // inline on an admitted catalogue entry, so a compliant document never
5
+ // carries them — a renderer that only reads the document straight shows
6
+ // blank cells for every field the maturity decision moved out.
7
+ //
8
+ // Pure: no I/O, no repo walk. The host (VS Code extension, IntelliJ/JCEF,
9
+ // CLI) already owns loading canon/elements/** (canon-loader.ts's shared FS
10
+ // layer) — this module only knows how to pick sidecars out of that pool and
11
+ // resolve them at a date.
12
+ //
13
+ // Per the 2026-08-05 hub decision (proposal #1022): this is a read model,
14
+ // never storage. Callers render an augmented, ephemeral copy of the
15
+ // application row and must never serialise it back — the sidecar stays the
16
+ // only place these fields are written.
17
+ import { parseSidecar, resolveAttributes } from '../versioned-attribute/index.js';
18
+ /** Pick every sidecar out of a raw canon/elements/** doc pool and resolve
19
+ * owner_role/vendor/maturity at `atDate`, keyed by the sidecar's target id
20
+ * (== an application's `app_id`, per the notation's element-file pairing). */
21
+ export function resolveApplicationAttributes(rawElementDocs, atDate) {
22
+ const byAppId = new Map();
23
+ for (const doc of rawElementDocs) {
24
+ if (!doc || typeof doc !== 'object' || Array.isArray(doc))
25
+ continue;
26
+ const sidecar = parseSidecar(doc);
27
+ if (!sidecar)
28
+ continue;
29
+ const resolved = resolveAttributes(sidecar, atDate);
30
+ const entry = {};
31
+ if (typeof resolved['owner_role'] === 'string')
32
+ entry.owner_role = resolved['owner_role'];
33
+ if (typeof resolved['vendor'] === 'string')
34
+ entry.vendor = resolved['vendor'];
35
+ if (typeof resolved['maturity'] === 'number')
36
+ entry.maturity = resolved['maturity'];
37
+ if (Object.keys(entry).length > 0)
38
+ byAppId.set(sidecar.target, entry);
39
+ }
40
+ return byAppId;
41
+ }
42
+ /** Merge resolved sidecar values into a rendering copy of an application row.
43
+ * An inline value would win if present, but VERSIONED-004 already forbids
44
+ * that on an admitted document — this is a display fallback, not a
45
+ * migration tool. The returned object is a plain copy; nothing here writes
46
+ * it anywhere. */
47
+ export function withResolvedAttributes(app, resolved) {
48
+ const r = resolved.get(app.app_id);
49
+ if (!r)
50
+ return app;
51
+ return {
52
+ ...app,
53
+ owner_role: app.owner_role ?? r.owner_role,
54
+ vendor: app.vendor ?? r.vendor,
55
+ maturity: app.maturity ?? r.maturity,
56
+ };
57
+ }
@@ -5,6 +5,16 @@ const VALID_SENSITIVITY = new Set(['public', 'internal', 'confidential', 'restri
5
5
  const VALID_DIRECTIONALITY = new Set(['producer', 'consumer', 'request_reply', 'bidirectional_stream']);
6
6
  const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
7
7
  const IFACE_CONDITIONAL = ['protocol', 'payload_class', 'sensitivity', 'directionality'];
8
+ // VERSIONED-004 (CONTRACT.md §9.3) — `owner_role`, `vendor`, `maturity` are
9
+ // declared `time_varying` by notations/views/10-applications.md §5/§5a and
10
+ // belong in the sidecar `<app_id>.history.yaml`, not inline on the catalogue
11
+ // entry. Unlike capability's VERSIONED-004 (packages/diagrams/src/
12
+ // repo-validate/check-versioned-attributes.ts), which walks standalone
13
+ // element files under canon/elements/**, an applications-catalogue entry has
14
+ // no file of its own to check inline-vs-sidecar on — the entry lives in this
15
+ // view document — so the check runs here, at the per-file notation
16
+ // validator, rather than in the repo-scope element sweep.
17
+ const TIME_VARYING_FIELDS = ['owner_role', 'vendor', 'maturity'];
8
18
  export function validateApplicationsCatalogue(input) {
9
19
  const errors = [];
10
20
  const warnings = [];
@@ -92,6 +102,16 @@ export function validateApplicationsCatalogue(input) {
92
102
  errors.push({ code: 'APP-006', message: `${idx}: maturity must be an integer 1–5, got "${m}"` });
93
103
  }
94
104
  }
105
+ // VERSIONED-004: time_varying fields must live in the sidecar, not inline.
106
+ for (const field of TIME_VARYING_FIELDS) {
107
+ if (a[field] !== undefined) {
108
+ errors.push({
109
+ code: 'VERSIONED-004',
110
+ message: `${idx}: '${field}' is time_varying (CONTRACT.md §9) and belongs in the sidecar ` +
111
+ `'${typeof a['app_id'] === 'string' ? a['app_id'] : idx}.history.yaml', not inline on the catalogue entry.`,
112
+ });
113
+ }
114
+ }
95
115
  // APP-009: integrations[].direction enum
96
116
  if (Array.isArray(a['integrations'])) {
97
117
  const integrations = a['integrations'];
@@ -15,5 +15,5 @@ export interface CapabilityCardNodeData {
15
15
  }
16
16
  declare const CapabilityCardNode: React.MemoExoticComponent<({ data }: {
17
17
  data: CapabilityCardNodeData;
18
- }) => import("react/jsx-runtime").JSX.Element>;
18
+ }) => React.JSX.Element>;
19
19
  export default CapabilityCardNode;
@@ -8,5 +8,5 @@ export interface CapabilityRootNodeData {
8
8
  * add/delete/collapse affordances (it isn't a mutable Capability). */
9
9
  declare const CapabilityRootNode: React.MemoExoticComponent<({ data }: {
10
10
  data: CapabilityRootNodeData;
11
- }) => import("react/jsx-runtime").JSX.Element>;
11
+ }) => React.JSX.Element>;
12
12
  export default CapabilityRootNode;
@@ -1,5 +1,7 @@
1
1
  export type { CapabilityType, CapabilityNode, CapabilityMapHeader, CapabilityMapFile, } from './types.js';
2
2
  export { validateCapabilityMap } from './validate.js';
3
+ export type { ResolvedCapabilityAttributes } from './resolve-maturity.js';
4
+ export { resolveCapabilityAttributes, withResolvedAttributes, withResolvedCapabilityMap, } from './resolve-maturity.js';
3
5
  export type { CapabilityTreeNode, CapabilityTreeEdge, CapabilityTreeLevelCounts, CapabilityTreeLayout, } from './layout-tree.js';
4
6
  export { layoutCapabilityTree, TREE_NODE_WIDTH, TREE_NODE_HEIGHT, TREE_RANK_SEP, TREE_NODE_SEP } from './layout-tree.js';
5
7
  export type { RenderCapabilityTreeOptions } from './render-capability-tree.js';
@@ -1,4 +1,5 @@
1
1
  export { validateCapabilityMap } from './validate.js';
2
+ export { resolveCapabilityAttributes, withResolvedAttributes, withResolvedCapabilityMap, } from './resolve-maturity.js';
2
3
  export { layoutCapabilityTree, TREE_NODE_WIDTH, TREE_NODE_HEIGHT, TREE_RANK_SEP, TREE_NODE_SEP } from './layout-tree.js';
3
4
  export { renderCapabilityTreeSvg } from './render-capability-tree.js';
4
5
  export { parseAddress, formatAddress, getLevel, getParentAddress, getFirstFreeAddress, isAddressTaken, } from './address.js';
@@ -0,0 +1,20 @@
1
+ import type { CapabilityMapHeader, CapabilityNode } from './types.js';
2
+ export interface ResolvedCapabilityAttributes {
3
+ current_maturity?: number;
4
+ target_maturity?: number;
5
+ owner_role?: string;
6
+ target_date?: string;
7
+ }
8
+ /** Pick every sidecar out of a raw canon/elements/** doc pool and resolve
9
+ * current_maturity/target_maturity/owner_role/target_date at `atDate`,
10
+ * keyed by the sidecar's target id (== a capability entry's `id`, per the
11
+ * CAPABILITY-* primitive that entry references). */
12
+ export declare function resolveCapabilityAttributes(rawElementDocs: unknown[], atDate: string): Map<string, ResolvedCapabilityAttributes>;
13
+ /** Merge resolved sidecar values into a rendering copy of a capability node
14
+ * and its descendants. An inline value always wins if present — this is a
15
+ * display fallback for fields the document doesn't carry inline, not a
16
+ * migration tool. Returns a new node tree; nothing here writes it
17
+ * anywhere. */
18
+ export declare function withResolvedAttributes(node: CapabilityNode, resolved: Map<string, ResolvedCapabilityAttributes>): CapabilityNode;
19
+ /** Same merge, applied across a capability map's whole top-level tree. */
20
+ export declare function withResolvedCapabilityMap(map: CapabilityMapHeader, resolved: Map<string, ResolvedCapabilityAttributes>): CapabilityMapHeader;
@@ -0,0 +1,72 @@
1
+ // Render-time resolution of a nested capability-map entry's sidecar-bound
2
+ // time_varying fields (current_maturity, target_maturity, owner_role,
3
+ // target_date — 05-capability-map.md §13/§14, CONTRACT.md §9.4).
4
+ // check-versioned-attributes.ts's VERSIONED-004 already rejects these inline
5
+ // on the standalone CAPABILITY-*.yaml primitive; a nested capability-map
6
+ // entry references that same primitive by id (the 2026-08-05 packages
7
+ // decision — no separate per-nested-entry sidecar convention), so this
8
+ // resolves the same way applications/resolve-maturity.ts does for the
9
+ // applications catalogue.
10
+ //
11
+ // Pure: no I/O, no repo walk. The host (VS Code extension, IntelliJ/JCEF,
12
+ // CLI) already owns loading canon/elements/** — this module only knows how
13
+ // to pick sidecars out of that pool and resolve them at a date.
14
+ //
15
+ // Per the 2026-08-05 packages decision: this is a read model, never
16
+ // storage. Callers render an augmented, ephemeral copy of the capability
17
+ // tree and must never serialise it back — the sidecar stays the only place
18
+ // these fields are written.
19
+ import { parseSidecar, resolveAttributes } from '../versioned-attribute/index.js';
20
+ /** Pick every sidecar out of a raw canon/elements/** doc pool and resolve
21
+ * current_maturity/target_maturity/owner_role/target_date at `atDate`,
22
+ * keyed by the sidecar's target id (== a capability entry's `id`, per the
23
+ * CAPABILITY-* primitive that entry references). */
24
+ export function resolveCapabilityAttributes(rawElementDocs, atDate) {
25
+ const byId = new Map();
26
+ for (const doc of rawElementDocs) {
27
+ if (!doc || typeof doc !== 'object' || Array.isArray(doc))
28
+ continue;
29
+ const sidecar = parseSidecar(doc);
30
+ if (!sidecar)
31
+ continue;
32
+ const resolved = resolveAttributes(sidecar, atDate);
33
+ const entry = {};
34
+ if (typeof resolved['current_maturity'] === 'number')
35
+ entry.current_maturity = resolved['current_maturity'];
36
+ if (typeof resolved['target_maturity'] === 'number')
37
+ entry.target_maturity = resolved['target_maturity'];
38
+ if (typeof resolved['owner_role'] === 'string')
39
+ entry.owner_role = resolved['owner_role'];
40
+ if (typeof resolved['target_date'] === 'string')
41
+ entry.target_date = resolved['target_date'];
42
+ if (Object.keys(entry).length > 0)
43
+ byId.set(sidecar.target, entry);
44
+ }
45
+ return byId;
46
+ }
47
+ /** Merge resolved sidecar values into a rendering copy of a capability node
48
+ * and its descendants. An inline value always wins if present — this is a
49
+ * display fallback for fields the document doesn't carry inline, not a
50
+ * migration tool. Returns a new node tree; nothing here writes it
51
+ * anywhere. */
52
+ export function withResolvedAttributes(node, resolved) {
53
+ const r = resolved.get(node.id);
54
+ const merged = r
55
+ ? {
56
+ ...node,
57
+ current_maturity: node.current_maturity ?? r.current_maturity,
58
+ target_maturity: node.target_maturity ?? r.target_maturity,
59
+ owner_role: node.owner_role ?? r.owner_role,
60
+ target_date: node.target_date ?? r.target_date,
61
+ }
62
+ : node;
63
+ if (!node.children || node.children.length === 0)
64
+ return merged;
65
+ return { ...merged, children: node.children.map((c) => withResolvedAttributes(c, resolved)) };
66
+ }
67
+ /** Same merge, applied across a capability map's whole top-level tree. */
68
+ export function withResolvedCapabilityMap(map, resolved) {
69
+ if (resolved.size === 0)
70
+ return map;
71
+ return { ...map, capabilities: map.capabilities.map((c) => withResolvedAttributes(c, resolved)) };
72
+ }
@@ -3,8 +3,7 @@ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
3
3
  // Canonical form per `IDS_AND_REFERENCES.md` §2: `CAPABILITY-V…` /
4
4
  // `CAPABILITY-H…` with the dotted address (`V1`, `V1.2.1`, `H1`). The bare
5
5
  // legacy form (`V1`, `H1`) is still accepted so existing maps without the
6
- // canonical prefix do not break — migration is tracked under
7
- // vkgeorgia/strategy#36.
6
+ // canonical prefix do not break; migration is tracked separately.
8
7
  const CAP_ID_RE = /^(CAPABILITY-)?(V|H)\d+(\.\d+)*$/;
9
8
  export function validateCapabilityMap(input) {
10
9
  const errors = [];
@@ -1,4 +1,4 @@
1
- export { CODEX_ARTEFACT_TYPES, EXTERNAL_CODEX_TYPES, INTERNAL_CODEX_TYPES } from './types.js';
1
+ export { CODEX_ARTEFACT_TYPES, EXTERNAL_CODEX_TYPES, INTERNAL_CODEX_TYPES, PRINCIPLE_CODEX_TYPES } from './types.js';
2
2
  export type { CodexArtefactType } from './types.js';
3
3
  export { validateCodex, isCodexDoc, folderJurisdictionFromPath } from './validate.js';
4
4
  export type { CodexValidateOptions } from './validate.js';
@@ -1,2 +1,2 @@
1
- export { CODEX_ARTEFACT_TYPES, EXTERNAL_CODEX_TYPES, INTERNAL_CODEX_TYPES } from './types.js';
1
+ export { CODEX_ARTEFACT_TYPES, EXTERNAL_CODEX_TYPES, INTERNAL_CODEX_TYPES, PRINCIPLE_CODEX_TYPES } from './types.js';
2
2
  export { validateCodex, isCodexDoc, folderJurisdictionFromPath } from './validate.js';
@@ -1,7 +1,14 @@
1
1
  /** TYPE prefixes admitted in the codex zone (REQ-003 / 14-codex.md). */
2
- export declare const CODEX_ARTEFACT_TYPES: readonly ["LAW", "REGULATION", "POLICY", "INTERNAL_STANDARD"];
2
+ export declare const CODEX_ARTEFACT_TYPES: readonly ["LAW", "REGULATION", "POLICY", "INTERNAL_STANDARD", "PRINCIPLE"];
3
3
  export type CodexArtefactType = (typeof CODEX_ARTEFACT_TYPES)[number];
4
4
  /** External codex artefacts (codex/external/<jurisdiction>/). */
5
5
  export declare const EXTERNAL_CODEX_TYPES: readonly CodexArtefactType[];
6
- /** Internal codex artefacts (codex/internal/). */
6
+ /** Internal codex artefacts (codex/internal/) that carry a named issuing authority (§4). */
7
7
  export declare const INTERNAL_CODEX_TYPES: readonly CodexArtefactType[];
8
+ /**
9
+ * Internal codex artefacts (codex/internal/) with the `PRINCIPLE` shape (§4.1) —
10
+ * `statement` + `rationale` required, `issuing_authority`/`effective_date`/`established_by`
11
+ * optional. Kept distinct from {@link INTERNAL_CODEX_TYPES} because the required-field set
12
+ * differs; both share the same file location.
13
+ */
14
+ export declare const PRINCIPLE_CODEX_TYPES: readonly CodexArtefactType[];
@@ -1,8 +1,15 @@
1
- // Codex artefact — external laws/regulations and internal policies/standards.
1
+ // Codex artefact — external laws/regulations and internal policies/standards/principles.
2
2
  // Schema: methodology notations/elements/14-codex.md §3–§4.
3
3
  /** TYPE prefixes admitted in the codex zone (REQ-003 / 14-codex.md). */
4
- export const CODEX_ARTEFACT_TYPES = ['LAW', 'REGULATION', 'POLICY', 'INTERNAL_STANDARD'];
4
+ export const CODEX_ARTEFACT_TYPES = ['LAW', 'REGULATION', 'POLICY', 'INTERNAL_STANDARD', 'PRINCIPLE'];
5
5
  /** External codex artefacts (codex/external/<jurisdiction>/). */
6
6
  export const EXTERNAL_CODEX_TYPES = ['LAW', 'REGULATION'];
7
- /** Internal codex artefacts (codex/internal/). */
7
+ /** Internal codex artefacts (codex/internal/) that carry a named issuing authority (§4). */
8
8
  export const INTERNAL_CODEX_TYPES = ['POLICY', 'INTERNAL_STANDARD'];
9
+ /**
10
+ * Internal codex artefacts (codex/internal/) with the `PRINCIPLE` shape (§4.1) —
11
+ * `statement` + `rationale` required, `issuing_authority`/`effective_date`/`established_by`
12
+ * optional. Kept distinct from {@link INTERNAL_CODEX_TYPES} because the required-field set
13
+ * differs; both share the same file location.
14
+ */
15
+ export const PRINCIPLE_CODEX_TYPES = ['PRINCIPLE'];
@@ -3,11 +3,22 @@
3
3
  // CODEX-001 — shape, zone, id grammar, admission envelope.
4
4
  // CODEX-002 — `type` field matches the id TYPE prefix when present.
5
5
  // CODEX-003 — external artefact frontmatter (jurisdiction, effective_date).
6
- // CODEX-004 — internal artefact frontmatter (issuing_authority, effective_date).
6
+ // CODEX-004 — internal artefact frontmatter (issuing_authority, effective_date for
7
+ // POLICY/INTERNAL_STANDARD; statement, rationale for PRINCIPLE — §4.1).
7
8
  // CODEX-005 — jurisdiction must match the parent folder under codex/external/
8
9
  // (when `folderJurisdiction` is supplied by the repo sweep).
10
+ // CODEX-006 — a PRINCIPLE artefact does not declare `established_by` (§4.1). The spec
11
+ // marks this "info" severity; this module has no info tier, so it is
12
+ // surfaced as a warning — the nearest existing severity that does not fail
13
+ // `valid`.
14
+ //
15
+ // Note: this file's CODEX-00x numbering predates the spec's own v0.2 renumbering
16
+ // (14-codex.md §6, §8.2) and does not track it code-for-code — e.g. the spec's current
17
+ // CODEX-001 is a folder/jurisdiction check this file assigns to CODEX-005. Realigning the
18
+ // full scheme is out of scope here; this change only adds the purely-additive PRINCIPLE
19
+ // TYPE (§4.1) under the existing local numbering.
9
20
  import { isCanonicalId, typeOfId } from '../typed-id.js';
10
- import { CODEX_ARTEFACT_TYPES, EXTERNAL_CODEX_TYPES, INTERNAL_CODEX_TYPES, } from './types.js';
21
+ import { CODEX_ARTEFACT_TYPES, EXTERNAL_CODEX_TYPES, INTERNAL_CODEX_TYPES, PRINCIPLE_CODEX_TYPES, } from './types.js';
11
22
  function isCodexType(type) {
12
23
  return type !== null && CODEX_ARTEFACT_TYPES.includes(type);
13
24
  }
@@ -31,7 +42,7 @@ export function validateCodex(input, options = {}) {
31
42
  if (!isCanonicalId(c.id) || !isCodexType(idType)) {
32
43
  errors.push({
33
44
  code: 'CODEX-001',
34
- message: `id "${String(c.id)}" must be a typed codex id (LAW, REGULATION, POLICY, or INTERNAL_STANDARD).`,
45
+ message: `id "${String(c.id)}" must be a typed codex id (LAW, REGULATION, POLICY, INTERNAL_STANDARD, or PRINCIPLE).`,
35
46
  path: 'id',
36
47
  });
37
48
  }
@@ -84,6 +95,21 @@ export function validateCodex(input, options = {}) {
84
95
  errors.push({ code: 'CODEX-004', message: 'effective_date is required for internal codex artefacts.', path: 'effective_date' });
85
96
  }
86
97
  }
98
+ if (artefactType && PRINCIPLE_CODEX_TYPES.includes(artefactType)) {
99
+ if (typeof c.statement !== 'string' || c.statement.trim() === '') {
100
+ errors.push({ code: 'CODEX-004', message: 'statement is required for a PRINCIPLE artefact.', path: 'statement' });
101
+ }
102
+ if (typeof c.rationale !== 'string' || c.rationale.trim() === '') {
103
+ errors.push({ code: 'CODEX-004', message: 'rationale is required for a PRINCIPLE artefact.', path: 'rationale' });
104
+ }
105
+ if (typeof c.established_by !== 'string' || c.established_by.trim() === '') {
106
+ warnings.push({
107
+ code: 'CODEX-006',
108
+ message: 'established_by is not declared on this PRINCIPLE artefact — admissible, but a review finding for whoever admits it.',
109
+ path: 'established_by',
110
+ });
111
+ }
112
+ }
87
113
  return { valid: errors.length === 0, errors, warnings };
88
114
  }
89
115
  /** True when a parsed document is a codex-zone artefact candidate. */
@@ -1,4 +1,4 @@
1
- import type { IndexAssertion, IndexRequirement } from './types.js';
1
+ import type { IndexAssertion, IndexRequirement, IndexVerification, IndexNeed, IndexValidation } from './types.js';
2
2
  export interface ComplianceProduct {
3
3
  id: string;
4
4
  name: string;
@@ -14,6 +14,8 @@ export interface ComplianceCanon {
14
14
  products: ComplianceProduct[];
15
15
  requirements: IndexRequirement[];
16
16
  assertions: IndexAssertion[];
17
+ /** VERIFICATION artefacts (27-verification.md) — the engineering V&V peer of `assertions`. */
18
+ verifications: IndexVerification[];
17
19
  codex: ComplianceCodexDoc[];
18
20
  /**
19
21
  * Named elements that can serve as assertion subjects beyond `products`:
@@ -21,6 +23,21 @@ export interface ComplianceCanon {
21
23
  * `ingestComplianceDoc` for the corresponding notation values.
22
24
  */
23
25
  subjects: ComplianceProduct[];
26
+ /** NEED elements (ELEMENT_PRIMITIVES.md §7.28) — upstream of `requirements`.
27
+ * Ingested so NEED-COVERAGE-001 / NEED-VALIDATION-COVERAGE-001..002 can
28
+ * compute coverage over the full needs catalogue. */
29
+ needs: IndexNeed[];
30
+ /** VALIDATION artefacts (28-validation.md) — the validation-domain peer of
31
+ * `verifications`, anchored on NEED instead of REQUIREMENT. */
32
+ validations: IndexValidation[];
33
+ /**
34
+ * Ids rejected by `ingestComplianceDoc` because that id was already present
35
+ * in the same bucket (two documents claiming one id — transitrix-hq#218).
36
+ * The second and any later document is dropped rather than silently
37
+ * duplicating a matrix column; callers that scan a filesystem can surface
38
+ * this list as a diagnostic.
39
+ */
40
+ duplicateIds: string[];
24
41
  }
25
42
  export declare function emptyCanon(): ComplianceCanon;
26
43
  /**
@@ -28,6 +45,8 @@ export declare function emptyCanon(): ComplianceCanon;
28
45
  * pushes its projection into `canon`. Products / requirements / assertions are
29
46
  * identified by their `notation` tag; codex source documents by `zone: codex`.
30
47
  * Returns the artefact id when ingested (so the caller can record its path), or
31
- * null when the document is not a (well-formed) compliance artefact.
48
+ * null when the document is not a (well-formed) compliance artefact, or when
49
+ * its id duplicates one already ingested into the same bucket (see
50
+ * `canon.duplicateIds`).
32
51
  */
33
52
  export declare function ingestComplianceDoc(canon: ComplianceCanon, doc: unknown): string | null;
@@ -1,18 +1,44 @@
1
- // Canon-artefact classification (vkgeorgia/strategy#84). The single authority
1
+ // Canon-artefact classification. The single authority
2
2
  // for "what is a compliance artefact" — used by both the Studio extension scan
3
3
  // (webview previews) and the CLI scan (`export-compliance`), so the recognition
4
4
  // rules live once. Pure: takes a parsed YAML document, no IO.
5
5
  export function emptyCanon() {
6
- return { products: [], requirements: [], assertions: [], codex: [], subjects: [] };
6
+ return {
7
+ products: [],
8
+ requirements: [],
9
+ assertions: [],
10
+ verifications: [],
11
+ codex: [],
12
+ subjects: [],
13
+ needs: [],
14
+ validations: [],
15
+ duplicateIds: [],
16
+ };
7
17
  }
8
18
  const str = (v) => (typeof v === 'string' ? v : undefined);
9
19
  const strArray = (v) => Array.isArray(v) ? v.filter((x) => typeof x === 'string') : undefined;
20
+ /**
21
+ * Pushes `item` onto `list` unless `list` already holds an entry with the same
22
+ * id, in which case the id is recorded in `canon.duplicateIds` and the item is
23
+ * dropped — two documents claiming one id is a defect (transitrix-hq#218), not
24
+ * a second matrix column.
25
+ */
26
+ function pushUnique(canon, list, item) {
27
+ if (list.some(existing => existing.id === item.id)) {
28
+ canon.duplicateIds.push(item.id);
29
+ return false;
30
+ }
31
+ list.push(item);
32
+ return true;
33
+ }
10
34
  /**
11
35
  * Classifies one parsed YAML document and, if it is a compliance artefact,
12
36
  * pushes its projection into `canon`. Products / requirements / assertions are
13
37
  * identified by their `notation` tag; codex source documents by `zone: codex`.
14
38
  * Returns the artefact id when ingested (so the caller can record its path), or
15
- * null when the document is not a (well-formed) compliance artefact.
39
+ * null when the document is not a (well-formed) compliance artefact, or when
40
+ * its id duplicates one already ingested into the same bucket (see
41
+ * `canon.duplicateIds`).
16
42
  */
17
43
  export function ingestComplianceDoc(canon, doc) {
18
44
  if (doc === null || typeof doc !== 'object' || Array.isArray(doc))
@@ -22,19 +48,17 @@ export function ingestComplianceDoc(canon, doc) {
22
48
  if (!id)
23
49
  return null;
24
50
  if (d.notation === 'product') {
25
- canon.products.push({ id, name: str(d.name) ?? id });
26
- return id;
51
+ return pushUnique(canon, canon.products, { id, name: str(d.name) ?? id }) ? id : null;
27
52
  }
28
53
  if (d.notation === 'capability' ||
29
54
  d.notation === 'process' ||
30
55
  d.notation === 'application' ||
31
56
  d.notation === 'system') {
32
- canon.subjects.push({ id, name: str(d.name) ?? id });
33
- return id;
57
+ return pushUnique(canon, canon.subjects, { id, name: str(d.name) ?? id }) ? id : null;
34
58
  }
35
59
  if (d.notation === 'requirement' || d.notation === 'constraint') {
36
60
  const origin = str(d.origin);
37
- canon.requirements.push({
61
+ const ok = pushUnique(canon, canon.requirements, {
38
62
  id,
39
63
  name: str(d.name) ?? id,
40
64
  severity: str(d.severity),
@@ -46,8 +70,26 @@ export function ingestComplianceDoc(canon, doc) {
46
70
  element_kind: d.notation,
47
71
  description: str(d.description),
48
72
  next_review_at: str(d.next_review_at),
73
+ serves: str(d.serves),
49
74
  });
50
- return id;
75
+ return ok ? id : null;
76
+ }
77
+ if (d.notation === 'need') {
78
+ return pushUnique(canon, canon.needs, { id, name: str(d.name) ?? id }) ? id : null;
79
+ }
80
+ if (d.notation === 'validation') {
81
+ const validates = str(d.validates);
82
+ const method = str(d.method);
83
+ const outcome = str(d.outcome);
84
+ if (!validates || !method || !outcome)
85
+ return null;
86
+ const ok = pushUnique(canon, canon.validations, {
87
+ id, validates, method, outcome,
88
+ performed_at: str(d.performed_at),
89
+ evidenceCount: Array.isArray(d.evidence) ? d.evidence.length : 0,
90
+ admitted_at: str(d.admitted_at),
91
+ });
92
+ return ok ? id : null;
51
93
  }
52
94
  if (d.notation === 'assertion') {
53
95
  const about = str(d.about);
@@ -55,7 +97,7 @@ export function ingestComplianceDoc(canon, doc) {
55
97
  const status = str(d.status);
56
98
  if (!about || !subject || !status)
57
99
  return null;
58
- canon.assertions.push({
100
+ const ok = pushUnique(canon, canon.assertions, {
59
101
  id, about, subject, status,
60
102
  assessed_at: str(d.assessed_at),
61
103
  next_review_at: str(d.next_review_at),
@@ -64,11 +106,24 @@ export function ingestComplianceDoc(canon, doc) {
64
106
  realised_via: strArray(d.realised_via),
65
107
  owner_to_confirm: str(d.owner_to_confirm),
66
108
  });
67
- return id;
109
+ return ok ? id : null;
110
+ }
111
+ if (d.notation === 'verification') {
112
+ const verifies = str(d.verifies);
113
+ const method = str(d.method);
114
+ const outcome = str(d.outcome);
115
+ if (!verifies || !method || !outcome)
116
+ return null;
117
+ const ok = pushUnique(canon, canon.verifications, {
118
+ id, verifies, method, outcome,
119
+ performed_at: str(d.performed_at),
120
+ evidenceCount: Array.isArray(d.evidence) ? d.evidence.length : 0,
121
+ admitted_at: str(d.admitted_at),
122
+ });
123
+ return ok ? id : null;
68
124
  }
69
125
  if (d.zone === 'codex') {
70
- canon.codex.push({ id, name: str(d.name) ?? id, type: str(d.type), jurisdiction: str(d.jurisdiction) });
71
- return id;
126
+ return pushUnique(canon, canon.codex, { id, name: str(d.name) ?? id, type: str(d.type), jurisdiction: str(d.jurisdiction) }) ? id : null;
72
127
  }
73
128
  return null;
74
129
  }
@@ -1,4 +1,4 @@
1
- // Confidence bridge for the compliance views (vkgeorgia/strategy#162 — DQ-2).
1
+ // Confidence bridge for the compliance views (DQ-2).
2
2
  // Maps the compliance index projections (IndexRequirement / IndexAssertion) onto
3
3
  // the DQ-1 ScoringElement shape, scores the view, and renders the §11.6 header
4
4
  // line. Lives in @transitrix/diagrams so Studio and DSM share one bridge and