wabachi 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 (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/dist/architecture/canon/authority.d.ts +35 -0
  4. package/dist/architecture/canon/authority.js +76 -0
  5. package/dist/architecture/canon/authority.js.map +1 -0
  6. package/dist/architecture/canon/boundaries.d.ts +31 -0
  7. package/dist/architecture/canon/boundaries.js +73 -0
  8. package/dist/architecture/canon/boundaries.js.map +1 -0
  9. package/dist/architecture/canon/codec.d.ts +10 -0
  10. package/dist/architecture/canon/codec.js +516 -0
  11. package/dist/architecture/canon/codec.js.map +1 -0
  12. package/dist/architecture/canon/constraints.d.ts +60 -0
  13. package/dist/architecture/canon/constraints.js +116 -0
  14. package/dist/architecture/canon/constraints.js.map +1 -0
  15. package/dist/architecture/canon/decisions.d.ts +62 -0
  16. package/dist/architecture/canon/decisions.js +192 -0
  17. package/dist/architecture/canon/decisions.js.map +1 -0
  18. package/dist/architecture/canon/deployment.d.ts +89 -0
  19. package/dist/architecture/canon/deployment.js +156 -0
  20. package/dist/architecture/canon/deployment.js.map +1 -0
  21. package/dist/architecture/canon/document.d.ts +60 -0
  22. package/dist/architecture/canon/document.js +106 -0
  23. package/dist/architecture/canon/document.js.map +1 -0
  24. package/dist/architecture/canon/elements.d.ts +21 -0
  25. package/dist/architecture/canon/elements.js +87 -0
  26. package/dist/architecture/canon/elements.js.map +1 -0
  27. package/dist/architecture/canon/flows.d.ts +37 -0
  28. package/dist/architecture/canon/flows.js +82 -0
  29. package/dist/architecture/canon/flows.js.map +1 -0
  30. package/dist/architecture/canon/identity.d.ts +45 -0
  31. package/dist/architecture/canon/identity.js +83 -0
  32. package/dist/architecture/canon/identity.js.map +1 -0
  33. package/dist/architecture/canon/relationships.d.ts +48 -0
  34. package/dist/architecture/canon/relationships.js +181 -0
  35. package/dist/architecture/canon/relationships.js.map +1 -0
  36. package/dist/architecture/canon/repository-mappings.d.ts +51 -0
  37. package/dist/architecture/canon/repository-mappings.js +134 -0
  38. package/dist/architecture/canon/repository-mappings.js.map +1 -0
  39. package/dist/architecture/canon/responsibilities.d.ts +40 -0
  40. package/dist/architecture/canon/responsibilities.js +89 -0
  41. package/dist/architecture/canon/responsibilities.js.map +1 -0
  42. package/dist/architecture/canon/validate.d.ts +14 -0
  43. package/dist/architecture/canon/validate.js +389 -0
  44. package/dist/architecture/canon/validate.js.map +1 -0
  45. package/dist/architecture/canon/views.d.ts +101 -0
  46. package/dist/architecture/canon/views.js +182 -0
  47. package/dist/architecture/canon/views.js.map +1 -0
  48. package/dist/architecture/cli.d.ts +2 -0
  49. package/dist/architecture/cli.js +158 -0
  50. package/dist/architecture/cli.js.map +1 -0
  51. package/dist/architecture/documentation/html.d.ts +3 -0
  52. package/dist/architecture/documentation/html.js +143 -0
  53. package/dist/architecture/documentation/html.js.map +1 -0
  54. package/dist/architecture/documentation/model.d.ts +46 -0
  55. package/dist/architecture/documentation/model.js +13 -0
  56. package/dist/architecture/documentation/model.js.map +1 -0
  57. package/dist/architecture/documentation/project.d.ts +4 -0
  58. package/dist/architecture/documentation/project.js +166 -0
  59. package/dist/architecture/documentation/project.js.map +1 -0
  60. package/dist/architecture/documentation/site.d.ts +43 -0
  61. package/dist/architecture/documentation/site.js +147 -0
  62. package/dist/architecture/documentation/site.js.map +1 -0
  63. package/dist/architecture/projection/structurizr-export.d.ts +65 -0
  64. package/dist/architecture/projection/structurizr-export.js +136 -0
  65. package/dist/architecture/projection/structurizr-export.js.map +1 -0
  66. package/dist/architecture/projection/structurizr.d.ts +34 -0
  67. package/dist/architecture/projection/structurizr.js +667 -0
  68. package/dist/architecture/projection/structurizr.js.map +1 -0
  69. package/dist/cli.d.ts +1 -0
  70. package/dist/cli.js +143 -0
  71. package/dist/cli.js.map +1 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.js +6 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/runtime/correlation.d.ts +143 -0
  76. package/dist/runtime/correlation.js +919 -0
  77. package/dist/runtime/correlation.js.map +1 -0
  78. package/dist/runtime/facts.d.ts +138 -0
  79. package/dist/runtime/facts.js +614 -0
  80. package/dist/runtime/facts.js.map +1 -0
  81. package/dist/runtime/fixtureProvider.d.ts +10 -0
  82. package/dist/runtime/fixtureProvider.js +30 -0
  83. package/dist/runtime/fixtureProvider.js.map +1 -0
  84. package/dist/runtime/graftProvider.d.ts +8 -0
  85. package/dist/runtime/graftProvider.js +107 -0
  86. package/dist/runtime/graftProvider.js.map +1 -0
  87. package/dist/runtime/graftWiring.d.ts +30 -0
  88. package/dist/runtime/graftWiring.js +3 -0
  89. package/dist/runtime/graftWiring.js.map +1 -0
  90. package/dist/runtime/manifest.d.ts +17 -0
  91. package/dist/runtime/manifest.js +39 -0
  92. package/dist/runtime/manifest.js.map +1 -0
  93. package/dist/runtime/matrix.d.ts +337 -0
  94. package/dist/runtime/matrix.js +1485 -0
  95. package/dist/runtime/matrix.js.map +1 -0
  96. package/dist/runtime/observation.d.ts +36 -0
  97. package/dist/runtime/observation.js +3 -0
  98. package/dist/runtime/observation.js.map +1 -0
  99. package/dist/runtime/provider.d.ts +34 -0
  100. package/dist/runtime/provider.js +2 -0
  101. package/dist/runtime/provider.js.map +1 -0
  102. package/dist/runtime/repository.d.ts +20 -0
  103. package/dist/runtime/repository.js +55 -0
  104. package/dist/runtime/repository.js.map +1 -0
  105. package/dist/runtime/run.d.ts +21 -0
  106. package/dist/runtime/run.js +80 -0
  107. package/dist/runtime/run.js.map +1 -0
  108. package/dist/runtime/scipProvider.d.ts +11 -0
  109. package/dist/runtime/scipProvider.js +126 -0
  110. package/dist/runtime/scipProvider.js.map +1 -0
  111. package/dist/runtime/typescriptProvider.d.ts +10 -0
  112. package/dist/runtime/typescriptProvider.js +289 -0
  113. package/dist/runtime/typescriptProvider.js.map +1 -0
  114. package/dist/runtime/workflow.d.ts +30 -0
  115. package/dist/runtime/workflow.js +153 -0
  116. package/dist/runtime/workflow.js.map +1 -0
  117. package/package.json +72 -0
@@ -0,0 +1,181 @@
1
+ import { normalizeIdentityId } from "./identity.js";
2
+ /** The intentionally small vocabulary of canonical directed relationships. */
3
+ export const RELATIONSHIP_KINDS = ["depends-on", "calls", "uses", "data", "control"];
4
+ function assertRecord(value, label) {
5
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
6
+ throw new TypeError(`${label} must be an object`);
7
+ }
8
+ }
9
+ function normalizeText(value, label) {
10
+ if (typeof value !== "string") {
11
+ throw new TypeError(`${label} must be a string`);
12
+ }
13
+ const normalized = value.normalize("NFC").trim();
14
+ if (normalized.length === 0 || /[\p{Cc}\p{Cf}\p{Cs}]/u.test(normalized)) {
15
+ throw new TypeError(`${label} is malformed`);
16
+ }
17
+ return normalized;
18
+ }
19
+ function compareStrings(left, right) {
20
+ if (left < right)
21
+ return -1;
22
+ if (left > right)
23
+ return 1;
24
+ return 0;
25
+ }
26
+ function readId(record, field, label) {
27
+ const value = record[field];
28
+ if (typeof value !== "string") {
29
+ throw new TypeError(`${label} ${field} must be a string`);
30
+ }
31
+ return normalizeIdentityId(value);
32
+ }
33
+ function readRelationshipKind(value) {
34
+ if (typeof value !== "string" || !RELATIONSHIP_KINDS.includes(value)) {
35
+ throw new TypeError(`relationship kind is unsupported: ${String(value)}`);
36
+ }
37
+ return value;
38
+ }
39
+ /** Create one interface/port declaration without resolving its owner. */
40
+ export function createInterface(input) {
41
+ assertRecord(input, "interface");
42
+ const id = readId(input, "id", "interface");
43
+ const owner = readId(input, "owner", "interface");
44
+ const protocol = input.protocol === undefined ? undefined : normalizeText(input.protocol, "interface protocol");
45
+ const technology = input.technology === undefined ? undefined : normalizeText(input.technology, "interface technology");
46
+ return Object.freeze({
47
+ id,
48
+ owner,
49
+ ...(protocol === undefined ? {} : { protocol }),
50
+ ...(technology === undefined ? {} : { technology }),
51
+ });
52
+ }
53
+ /** Create one directed relationship declaration without resolving its references. */
54
+ export function createRelationship(input) {
55
+ assertRecord(input, "relationship");
56
+ const source = readId(input, "source", "relationship");
57
+ const target = readId(input, "target", "relationship");
58
+ const kind = readRelationshipKind(input.kind);
59
+ const interfaceId = input.interfaceId === undefined ? undefined : readId(input, "interfaceId", "relationship");
60
+ return Object.freeze({
61
+ source,
62
+ target,
63
+ kind,
64
+ ...(interfaceId === undefined ? {} : { interfaceId }),
65
+ });
66
+ }
67
+ function elementIds(elements) {
68
+ if (elements === undefined)
69
+ return undefined;
70
+ if (!Array.isArray(elements)) {
71
+ throw new TypeError("relationship validation elements must be an array");
72
+ }
73
+ const ids = new Set();
74
+ for (const element of elements) {
75
+ assertRecord(element, "relationship validation element");
76
+ const id = readId(element, "id", "relationship validation element");
77
+ if (ids.has(id))
78
+ throw new Error(`duplicate relationship validation element id: ${id}`);
79
+ ids.add(id);
80
+ }
81
+ return ids;
82
+ }
83
+ function interfaceById(interfaces) {
84
+ if (interfaces === undefined)
85
+ return undefined;
86
+ if (!Array.isArray(interfaces)) {
87
+ throw new TypeError("relationship validation interfaces must be an array");
88
+ }
89
+ const byId = new Map();
90
+ for (const item of interfaces) {
91
+ assertRecord(item, "relationship validation interface");
92
+ const id = readId(item, "id", "relationship validation interface");
93
+ if (byId.has(id))
94
+ throw new Error(`duplicate interface id: ${id}`);
95
+ byId.set(id, item);
96
+ }
97
+ return byId;
98
+ }
99
+ function interfaceKey(record) {
100
+ return record.id;
101
+ }
102
+ function compareInterfaces(left, right) {
103
+ return compareStrings(left.id, right.id);
104
+ }
105
+ /** Normalize interfaces, rejecting duplicate IDs and optionally unknown owners. */
106
+ export function normalizeInterfaces(inputs, elements) {
107
+ if (!Array.isArray(inputs)) {
108
+ throw new TypeError("interfaces must be an array");
109
+ }
110
+ const knownElements = elementIds(elements);
111
+ const interfaces = inputs.map(createInterface);
112
+ const seen = new Set();
113
+ for (const item of interfaces) {
114
+ if (seen.has(interfaceKey(item)))
115
+ throw new Error(`duplicate interface id: ${item.id}`);
116
+ seen.add(interfaceKey(item));
117
+ if (knownElements !== undefined && !knownElements.has(item.owner)) {
118
+ throw new Error(`unknown interface owner: ${item.owner}`);
119
+ }
120
+ }
121
+ interfaces.sort(compareInterfaces);
122
+ return Object.freeze(interfaces);
123
+ }
124
+ /** Alias matching the single-record constructor naming used by the canon modules. */
125
+ export const createInterfaces = normalizeInterfaces;
126
+ function compareRelationships(left, right) {
127
+ return (compareStrings(left.source, right.source) ||
128
+ compareStrings(left.target, right.target) ||
129
+ compareStrings(left.kind, right.kind) ||
130
+ compareStrings(left.interfaceId ?? "", right.interfaceId ?? ""));
131
+ }
132
+ function relationshipKey(record) {
133
+ return `${record.source}\u0000${record.target}\u0000${record.kind}\u0000${record.interfaceId ?? ""}`;
134
+ }
135
+ /**
136
+ * Normalize directed relationships. References are checked only against the
137
+ * supplied canonical context; no missing element or interface is synthesized.
138
+ */
139
+ export function normalizeRelationships(inputs, context = {}) {
140
+ if (!Array.isArray(inputs)) {
141
+ throw new TypeError("relationships must be an array");
142
+ }
143
+ const knownElements = elementIds(context.elements);
144
+ const knownInterfaces = interfaceById(context.interfaces);
145
+ const relationships = inputs.map(createRelationship);
146
+ const seen = new Set();
147
+ for (const relationship of relationships) {
148
+ if (knownElements !== undefined) {
149
+ if (!knownElements.has(relationship.source)) {
150
+ throw new Error(`unknown relationship source: ${relationship.source}`);
151
+ }
152
+ if (!knownElements.has(relationship.target)) {
153
+ throw new Error(`unknown relationship target: ${relationship.target}`);
154
+ }
155
+ }
156
+ if (relationship.interfaceId !== undefined) {
157
+ const contract = knownInterfaces?.get(relationship.interfaceId);
158
+ if (contract === undefined) {
159
+ throw new Error(`unknown relationship interface: ${relationship.interfaceId}`);
160
+ }
161
+ if (contract.owner !== relationship.source && contract.owner !== relationship.target) {
162
+ throw new Error(`relationship interface owner is not an endpoint: ${relationship.interfaceId}`);
163
+ }
164
+ }
165
+ const key = relationshipKey(relationship);
166
+ if (seen.has(key)) {
167
+ throw new Error(`duplicate relationship: ${relationship.source} -> ${relationship.target} (${relationship.kind})`);
168
+ }
169
+ seen.add(key);
170
+ }
171
+ relationships.sort(compareRelationships);
172
+ return Object.freeze(relationships);
173
+ }
174
+ /** Validate an already-created relationship set without changing its order. */
175
+ export function validateRelationships(relationships, context = {}) {
176
+ if (!Array.isArray(relationships)) {
177
+ throw new TypeError("relationships must be an array");
178
+ }
179
+ normalizeRelationships(relationships, context);
180
+ }
181
+ //# sourceMappingURL=relationships.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../../src/architecture/canon/relationships.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAiB,MAAM,eAAe,CAAC;AAGnE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAU,CAAC;AAqC9F,SAAS,YAAY,CAAC,KAAc,EAAE,KAAa;IACjD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,mBAAmB,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,C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C;IAED,sBAAsB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,51 @@
1
+ export type RepositoryPathScope = "file" | "directory";
2
+ export interface RepositoryPathMapping {
3
+ readonly path: string;
4
+ readonly scope: RepositoryPathScope;
5
+ }
6
+ export type RepositoryPathInput = string | {
7
+ readonly path: string;
8
+ readonly scope?: RepositoryPathScope;
9
+ };
10
+ export interface RepositorySymbolMapping {
11
+ readonly path: string;
12
+ readonly symbol: string;
13
+ readonly exportName?: string;
14
+ }
15
+ export interface RepositorySymbolInput {
16
+ readonly path: string;
17
+ readonly symbol: string;
18
+ readonly exportName?: string;
19
+ }
20
+ export interface RepositoryTestMapping {
21
+ readonly path: string;
22
+ readonly selector: string;
23
+ }
24
+ export interface RepositoryTestInput {
25
+ readonly path: string;
26
+ readonly selector: string;
27
+ }
28
+ export interface RepositoryMappingInput {
29
+ readonly canonId: string;
30
+ readonly paths?: readonly RepositoryPathInput[];
31
+ readonly symbols?: readonly RepositorySymbolInput[];
32
+ readonly tests?: readonly RepositoryTestInput[];
33
+ }
34
+ export interface RepositoryMapping {
35
+ readonly canonId: string;
36
+ readonly paths: readonly RepositoryPathMapping[];
37
+ readonly symbols: readonly RepositorySymbolMapping[];
38
+ readonly tests: readonly RepositoryTestMapping[];
39
+ }
40
+ /**
41
+ * Normalizes a declaration path without consulting the repository.
42
+ *
43
+ * Backslashes and dot segments are normalized so equivalent declarations
44
+ * serialize identically. Parent segments are rejected instead of resolved;
45
+ * this keeps the declaration rooted even when its starting path is unknown.
46
+ */
47
+ export declare function normalizeRepositoryPath(value: string): string;
48
+ export declare function createRepositoryMapping(input: RepositoryMappingInput): RepositoryMapping;
49
+ export declare function createRepositoryMappings(inputs: readonly RepositoryMappingInput[]): readonly RepositoryMapping[];
50
+ /** Serializes declarations in canonical order; no repository access occurs. */
51
+ export declare function serializeRepositoryMappings(mappings: readonly RepositoryMappingInput[]): string;
@@ -0,0 +1,134 @@
1
+ import { normalizeIdentityId } from "./identity.js";
2
+ function assertRecord(value, label) {
3
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4
+ throw new TypeError(`${label} must be an object`);
5
+ }
6
+ }
7
+ function normalizeText(value, label) {
8
+ if (typeof value !== "string") {
9
+ throw new TypeError(`${label} must be a string`);
10
+ }
11
+ const normalized = value.normalize("NFC").trim();
12
+ if (normalized.length === 0 || /[\p{Cc}\p{Cf}\p{Cs}]/u.test(normalized)) {
13
+ throw new TypeError(`${label} is malformed`);
14
+ }
15
+ return normalized;
16
+ }
17
+ /**
18
+ * Normalizes a declaration path without consulting the repository.
19
+ *
20
+ * Backslashes and dot segments are normalized so equivalent declarations
21
+ * serialize identically. Parent segments are rejected instead of resolved;
22
+ * this keeps the declaration rooted even when its starting path is unknown.
23
+ */
24
+ export function normalizeRepositoryPath(value) {
25
+ if (typeof value !== "string") {
26
+ throw new TypeError("repository path must be a string");
27
+ }
28
+ const normalized = value.normalize("NFC").replaceAll("\\", "/");
29
+ if (normalized.length === 0 ||
30
+ normalized.startsWith("/") ||
31
+ /^[A-Za-z]:($|\/)/u.test(normalized) ||
32
+ /[\p{Cc}\p{Cf}\p{Cs}]/u.test(normalized)) {
33
+ throw new TypeError("repository path must be relative to the repository root");
34
+ }
35
+ const segments = [];
36
+ for (const segment of normalized.split("/")) {
37
+ if (segment === "" || segment === ".")
38
+ continue;
39
+ if (segment === "..") {
40
+ throw new TypeError("repository path cannot escape the repository root");
41
+ }
42
+ segments.push(segment);
43
+ }
44
+ if (segments.length === 0) {
45
+ throw new TypeError("repository path must identify a repository-relative path");
46
+ }
47
+ return segments.join("/");
48
+ }
49
+ function compareStrings(left, right) {
50
+ if (left < right)
51
+ return -1;
52
+ if (left > right)
53
+ return 1;
54
+ return 0;
55
+ }
56
+ function comparePaths(left, right) {
57
+ return compareStrings(left.path, right.path) || compareStrings(left.scope, right.scope);
58
+ }
59
+ function compareSymbols(left, right) {
60
+ return (compareStrings(left.path, right.path) ||
61
+ compareStrings(left.symbol, right.symbol) ||
62
+ compareStrings(left.exportName ?? "", right.exportName ?? ""));
63
+ }
64
+ function compareTests(left, right) {
65
+ return compareStrings(left.path, right.path) || compareStrings(left.selector, right.selector);
66
+ }
67
+ function normalizePathMapping(input) {
68
+ const pathInput = typeof input === "string" ? { path: input } : input;
69
+ assertRecord(pathInput, "repository path mapping");
70
+ const scope = pathInput.scope ?? "file";
71
+ if (scope !== "file" && scope !== "directory") {
72
+ throw new TypeError("repository path mapping scope must be file or directory");
73
+ }
74
+ return Object.freeze({
75
+ path: normalizeRepositoryPath(pathInput.path),
76
+ scope,
77
+ });
78
+ }
79
+ function normalizeSymbolMapping(input) {
80
+ assertRecord(input, "repository symbol mapping");
81
+ const exportName = input.exportName === undefined ? undefined : normalizeText(input.exportName, "repository export name");
82
+ return Object.freeze({
83
+ path: normalizeRepositoryPath(input.path),
84
+ symbol: normalizeText(input.symbol, "repository symbol"),
85
+ ...(exportName === undefined ? {} : { exportName }),
86
+ });
87
+ }
88
+ function normalizeTestMapping(input) {
89
+ assertRecord(input, "repository test mapping");
90
+ return Object.freeze({
91
+ path: normalizeRepositoryPath(input.path),
92
+ selector: normalizeText(input.selector, "repository test selector"),
93
+ });
94
+ }
95
+ export function createRepositoryMapping(input) {
96
+ assertRecord(input, "repository mapping");
97
+ if (input.paths !== undefined && !Array.isArray(input.paths)) {
98
+ throw new TypeError("repository mapping paths must be an array");
99
+ }
100
+ if (input.symbols !== undefined && !Array.isArray(input.symbols)) {
101
+ throw new TypeError("repository mapping symbols must be an array");
102
+ }
103
+ if (input.tests !== undefined && !Array.isArray(input.tests)) {
104
+ throw new TypeError("repository mapping tests must be an array");
105
+ }
106
+ const paths = [...(input.paths ?? [])].map(normalizePathMapping).sort(comparePaths);
107
+ const symbols = [...(input.symbols ?? [])].map(normalizeSymbolMapping).sort(compareSymbols);
108
+ const tests = [...(input.tests ?? [])].map(normalizeTestMapping).sort(compareTests);
109
+ return Object.freeze({
110
+ canonId: normalizeIdentityId(input.canonId),
111
+ paths: Object.freeze(paths),
112
+ symbols: Object.freeze(symbols),
113
+ tests: Object.freeze(tests),
114
+ });
115
+ }
116
+ export function createRepositoryMappings(inputs) {
117
+ if (!Array.isArray(inputs)) {
118
+ throw new TypeError("repository mappings must be an array");
119
+ }
120
+ const mappings = inputs
121
+ .map(createRepositoryMapping)
122
+ .sort((left, right) => compareStrings(left.canonId, right.canonId));
123
+ for (let index = 1; index < mappings.length; index += 1) {
124
+ if (mappings[index - 1].canonId === mappings[index].canonId) {
125
+ throw new Error(`duplicate repository mapping canon id: ${mappings[index].canonId}`);
126
+ }
127
+ }
128
+ return Object.freeze(mappings);
129
+ }
130
+ /** Serializes declarations in canonical order; no repository access occurs. */
131
+ export function serializeRepositoryMappings(mappings) {
132
+ return JSON.stringify(createRepositoryMappings(mappings));
133
+ }
134
+ //# sourceMappingURL=repository-mappings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-mappings.js","sourceRoot":"","sources":["../../../src/architecture/canon/repository-mappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAoDpD,SAAS,YAAY,CAAC,KAAc,EAAE,KAAa;IACjD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,mBAAmB,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,UAAU,CAAC,MAAM,KAAK,CAA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E,CAAC;QAC3B,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM;SACpB,GAAG,CAAC,uBAAuB,CAAC;SAC5B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACxD,IAAI,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;YAC5D,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,2BAA2B,CAAC,QAA2C;IACrF,OAAO,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { type ArchitectureId, type ObjectId } from "./identity.js";
2
+ declare const responsibilityIdBrand: unique symbol;
3
+ export type ResponsibilityId = string & {
4
+ readonly [responsibilityIdBrand]: never;
5
+ };
6
+ export interface ResponsibilityTargetInput {
7
+ readonly kind: "architecture" | "object";
8
+ readonly id: string;
9
+ readonly displayName?: string;
10
+ }
11
+ export type ResponsibilityTarget = {
12
+ readonly kind: "architecture";
13
+ readonly id: ArchitectureId;
14
+ } | {
15
+ readonly kind: "object";
16
+ readonly id: ObjectId;
17
+ };
18
+ export interface ResponsibilityInput {
19
+ readonly id: string;
20
+ readonly target: ResponsibilityTargetInput;
21
+ readonly concern: string;
22
+ readonly displayName?: string;
23
+ }
24
+ export interface ResponsibilityFact {
25
+ readonly kind: "responsibility";
26
+ readonly id: ResponsibilityId;
27
+ readonly target: ResponsibilityTarget;
28
+ readonly concern: string;
29
+ }
30
+ export interface ResponsibilitySetInput {
31
+ readonly responsibilities?: readonly ResponsibilityInput[];
32
+ }
33
+ export interface ResponsibilitySet {
34
+ readonly responsibilities: readonly ResponsibilityFact[];
35
+ }
36
+ export declare function normalizeResponsibilityId(value: string): string;
37
+ export declare function createResponsibilityId(value: string): ResponsibilityId;
38
+ export declare function createResponsibility(input: ResponsibilityInput): ResponsibilityFact;
39
+ export declare function createResponsibilitySet(input: ResponsibilitySetInput): ResponsibilitySet;
40
+ export {};
@@ -0,0 +1,89 @@
1
+ import { createArchitectureId, createObjectId, normalizeIdentityId, } from "./identity.js";
2
+ function assertRecord(value, label) {
3
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4
+ throw new TypeError(`${label} must be an object`);
5
+ }
6
+ }
7
+ function normalizeConcern(value) {
8
+ if (typeof value !== "string") {
9
+ throw new TypeError("responsibility concern must be a string");
10
+ }
11
+ const normalized = value.normalize("NFC");
12
+ if (normalized.trim().length === 0 || /[\p{Cc}\p{Cf}\p{Cs}]/u.test(normalized)) {
13
+ throw new TypeError("responsibility concern is malformed");
14
+ }
15
+ return normalized;
16
+ }
17
+ export function normalizeResponsibilityId(value) {
18
+ return normalizeIdentityId(value);
19
+ }
20
+ export function createResponsibilityId(value) {
21
+ return normalizeResponsibilityId(value);
22
+ }
23
+ function createTarget(input) {
24
+ assertRecord(input, "responsibility target");
25
+ const candidate = input;
26
+ if (candidate.kind !== "architecture" && candidate.kind !== "object") {
27
+ throw new TypeError("responsibility target kind is invalid");
28
+ }
29
+ if (candidate.displayName !== undefined && typeof candidate.displayName !== "string") {
30
+ throw new TypeError("responsibility target displayName must be a string");
31
+ }
32
+ if (candidate.kind === "architecture") {
33
+ return Object.freeze({
34
+ kind: "architecture",
35
+ id: createArchitectureId(candidate.id),
36
+ });
37
+ }
38
+ return Object.freeze({
39
+ kind: "object",
40
+ id: createObjectId(candidate.id),
41
+ });
42
+ }
43
+ export function createResponsibility(input) {
44
+ assertRecord(input, "responsibility");
45
+ const candidate = input;
46
+ if (candidate.displayName !== undefined && typeof candidate.displayName !== "string") {
47
+ throw new TypeError("responsibility displayName must be a string");
48
+ }
49
+ return Object.freeze({
50
+ kind: "responsibility",
51
+ id: createResponsibilityId(candidate.id),
52
+ target: createTarget(candidate.target),
53
+ concern: normalizeConcern(candidate.concern),
54
+ });
55
+ }
56
+ function compareResponsibility(left, right) {
57
+ if (left.id < right.id)
58
+ return -1;
59
+ if (left.id > right.id)
60
+ return 1;
61
+ return 0;
62
+ }
63
+ function declarationKey(fact) {
64
+ return `${fact.target.kind}:${fact.target.id}\u0000${fact.concern}`;
65
+ }
66
+ export function createResponsibilitySet(input) {
67
+ assertRecord(input, "responsibility set");
68
+ const candidate = input;
69
+ if (candidate.responsibilities !== undefined && !Array.isArray(candidate.responsibilities)) {
70
+ throw new TypeError("responsibility set responsibilities must be an array");
71
+ }
72
+ const responsibilities = (candidate.responsibilities ?? []).map((item) => createResponsibility(item));
73
+ const ids = new Set();
74
+ const declarations = new Set();
75
+ for (const responsibility of responsibilities) {
76
+ if (ids.has(responsibility.id)) {
77
+ throw new Error(`duplicate responsibility id: ${responsibility.id}`);
78
+ }
79
+ ids.add(responsibility.id);
80
+ const key = declarationKey(responsibility);
81
+ if (declarations.has(key)) {
82
+ throw new Error(`duplicate responsibility declaration: ${responsibility.target.kind}:${responsibility.target.id}`);
83
+ }
84
+ declarations.add(key);
85
+ }
86
+ responsibilities.sort(compareResponsibility);
87
+ return Object.freeze({ responsibilities: Object.freeze(responsibilities) });
88
+ }
89
+ //# sourceMappingURL=responsibilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responsibilities.js","sourceRoot":"","sources":["../../../src/architecture/canon/responsibilities.ts"],"names":[],"mappings":"A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,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,CAClG,CAAC;QACJ,CAAC;QACD,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,gBAAgB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ArchitectureDocumentV1 } from "./document.js";
2
+ export declare const ARCHITECTURE_DIAGNOSTIC_CODES: readonly ["identity-registry-mismatch", "duplicate-identity-registry-entry", "unknown-reference", "invalid-reference-kind", "invalid-containment-reference", "invalid-interface-owner", "invalid-relationship-endpoint", "invalid-relationship-interface", "invalid-responsibility-target", "invalid-boundary-member", "invalid-authority-target", "invalid-constraint-target", "invalid-flow-reference", "invalid-deployment-reference", "invalid-repository-mapping", "invalid-decision-target", "invalid-decision-reference", "invalid-supersession", "invalid-view-reference"];
3
+ export type ArchitectureDiagnosticCode = (typeof ARCHITECTURE_DIAGNOSTIC_CODES)[number];
4
+ export interface ArchitectureDiagnostic {
5
+ readonly code: ArchitectureDiagnosticCode;
6
+ readonly path: string;
7
+ readonly message: string;
8
+ }
9
+ export interface ArchitectureDocumentValidationResult {
10
+ readonly valid: boolean;
11
+ readonly diagnostics: readonly ArchitectureDiagnostic[];
12
+ }
13
+ /** Validate complete-document Canon semantics without mutating the document. */
14
+ export declare function validateArchitectureDocument(document: ArchitectureDocumentV1): ArchitectureDocumentValidationResult;