isthmus-cli 0.5.0 → 0.7.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 (146) hide show
  1. package/README.ko.md +170 -45
  2. package/README.md +178 -36
  3. package/Skills/isthmus/SKILL.md +104 -5
  4. package/compatibility.json +10 -0
  5. package/dist/cli/check-command.d.ts +2 -2
  6. package/dist/cli/check-command.js +22 -9
  7. package/dist/cli/check-command.js.map +1 -1
  8. package/dist/cli/command-support.d.ts +20 -2
  9. package/dist/cli/command-support.js +38 -9
  10. package/dist/cli/command-support.js.map +1 -1
  11. package/dist/cli/diff-command.js +4 -3
  12. package/dist/cli/diff-command.js.map +1 -1
  13. package/dist/cli/doctor-command.d.ts +11 -0
  14. package/dist/cli/doctor-command.js +128 -0
  15. package/dist/cli/doctor-command.js.map +1 -0
  16. package/dist/cli/extract-js-command.d.ts +33 -0
  17. package/dist/cli/extract-js-command.js +233 -0
  18. package/dist/cli/extract-js-command.js.map +1 -0
  19. package/dist/cli/graph-command.js +13 -6
  20. package/dist/cli/graph-command.js.map +1 -1
  21. package/dist/cli/impact-command.d.ts +5 -0
  22. package/dist/cli/impact-command.js +111 -0
  23. package/dist/cli/impact-command.js.map +1 -0
  24. package/dist/cli/init-command.d.ts +11 -0
  25. package/dist/cli/init-command.js +115 -0
  26. package/dist/cli/init-command.js.map +1 -0
  27. package/dist/cli/main.js +67 -1
  28. package/dist/cli/main.js.map +1 -1
  29. package/dist/cli/mcp-server.d.ts +16 -0
  30. package/dist/cli/mcp-server.js +534 -0
  31. package/dist/cli/mcp-server.js.map +1 -0
  32. package/dist/cli/preflight-command.d.ts +5 -0
  33. package/dist/cli/preflight-command.js +83 -0
  34. package/dist/cli/preflight-command.js.map +1 -0
  35. package/dist/cli/query-command.js +13 -6
  36. package/dist/cli/query-command.js.map +1 -1
  37. package/dist/cli/retentions-command.js +14 -7
  38. package/dist/cli/retentions-command.js.map +1 -1
  39. package/dist/cli/runtime-command.d.ts +5 -0
  40. package/dist/cli/runtime-command.js +42 -0
  41. package/dist/cli/runtime-command.js.map +1 -0
  42. package/dist/cli/runtime-json-reader.d.ts +12 -0
  43. package/dist/cli/runtime-json-reader.js +37 -0
  44. package/dist/cli/runtime-json-reader.js.map +1 -0
  45. package/dist/cli/serve-command.d.ts +13 -0
  46. package/dist/cli/serve-command.js +43 -0
  47. package/dist/cli/serve-command.js.map +1 -0
  48. package/dist/exchange/capture-config.d.ts +18 -0
  49. package/dist/exchange/capture-config.js +100 -0
  50. package/dist/exchange/capture-config.js.map +1 -0
  51. package/dist/exchange/impact-selection.d.ts +13 -0
  52. package/dist/exchange/impact-selection.js +35 -0
  53. package/dist/exchange/impact-selection.js.map +1 -0
  54. package/dist/exchange/kartograph-impact.d.ts +4 -0
  55. package/dist/exchange/kartograph-impact.js +169 -0
  56. package/dist/exchange/kartograph-impact.js.map +1 -0
  57. package/dist/exchange/messages.d.ts +36 -0
  58. package/dist/exchange/messages.js +96 -0
  59. package/dist/exchange/messages.js.map +1 -0
  60. package/dist/exchange/parse.d.ts +69 -0
  61. package/dist/exchange/parse.js +127 -20
  62. package/dist/exchange/parse.js.map +1 -1
  63. package/dist/exchange/preflight-context.d.ts +71 -0
  64. package/dist/exchange/preflight-context.js +317 -0
  65. package/dist/exchange/preflight-context.js.map +1 -0
  66. package/dist/exchange/producer-impact.d.ts +17 -0
  67. package/dist/exchange/producer-impact.js +226 -0
  68. package/dist/exchange/producer-impact.js.map +1 -0
  69. package/dist/exchange/runtime.d.ts +69 -0
  70. package/dist/exchange/runtime.js +160 -0
  71. package/dist/exchange/runtime.js.map +1 -0
  72. package/dist/extract/js-document.d.ts +22 -0
  73. package/dist/extract/js-document.js +230 -0
  74. package/dist/extract/js-document.js.map +1 -0
  75. package/dist/extract/js-scan.d.ts +93 -0
  76. package/dist/extract/js-scan.js +1205 -0
  77. package/dist/extract/js-scan.js.map +1 -0
  78. package/dist/extract/lexer.d.ts +26 -0
  79. package/dist/extract/lexer.js +316 -0
  80. package/dist/extract/lexer.js.map +1 -0
  81. package/dist/join/join.d.ts +66 -1
  82. package/dist/join/join.js +171 -1
  83. package/dist/join/join.js.map +1 -1
  84. package/dist/join/message-address.d.ts +7 -0
  85. package/dist/join/message-address.js +37 -0
  86. package/dist/join/message-address.js.map +1 -0
  87. package/dist/join/messages.d.ts +26 -0
  88. package/dist/join/messages.js +87 -0
  89. package/dist/join/messages.js.map +1 -0
  90. package/dist/report/check-report.d.ts +20 -3
  91. package/dist/report/check-report.js +240 -8
  92. package/dist/report/check-report.js.map +1 -1
  93. package/dist/report/codequality.d.ts +45 -0
  94. package/dist/report/codequality.js +74 -0
  95. package/dist/report/codequality.js.map +1 -0
  96. package/dist/report/diff.d.ts +25 -3
  97. package/dist/report/diff.js +91 -10
  98. package/dist/report/diff.js.map +1 -1
  99. package/dist/report/graph.d.ts +10 -4
  100. package/dist/report/graph.js +60 -6
  101. package/dist/report/graph.js.map +1 -1
  102. package/dist/report/impact.d.ts +62 -0
  103. package/dist/report/impact.js +168 -0
  104. package/dist/report/impact.js.map +1 -0
  105. package/dist/report/preflight-runtime.d.ts +42 -0
  106. package/dist/report/preflight-runtime.js +193 -0
  107. package/dist/report/preflight-runtime.js.map +1 -0
  108. package/dist/report/preflight-view.d.ts +146 -0
  109. package/dist/report/preflight-view.js +216 -0
  110. package/dist/report/preflight-view.js.map +1 -0
  111. package/dist/report/preflight.d.ts +104 -0
  112. package/dist/report/preflight.js +331 -0
  113. package/dist/report/preflight.js.map +1 -0
  114. package/dist/report/query.d.ts +11 -4
  115. package/dist/report/query.js +84 -17
  116. package/dist/report/query.js.map +1 -1
  117. package/dist/report/retentions.d.ts +17 -5
  118. package/dist/report/retentions.js +85 -8
  119. package/dist/report/retentions.js.map +1 -1
  120. package/dist/report/rules.d.ts +16 -0
  121. package/dist/report/rules.js +30 -0
  122. package/dist/report/rules.js.map +1 -0
  123. package/dist/report/runtime-impact.d.ts +38 -0
  124. package/dist/report/runtime-impact.js +94 -0
  125. package/dist/report/runtime-impact.js.map +1 -0
  126. package/dist/report/runtime.d.ts +54 -0
  127. package/dist/report/runtime.js +137 -0
  128. package/dist/report/runtime.js.map +1 -0
  129. package/dist/report/sarif.d.ts +2 -8
  130. package/dist/report/sarif.js +2 -10
  131. package/dist/report/sarif.js.map +1 -1
  132. package/dist/report/sorted-json.d.ts +1 -1
  133. package/dist/report/sorted-json.js +2 -2
  134. package/dist/report/sorted-json.js.map +1 -1
  135. package/docs/BRIDGE-EVENTS.md +87 -0
  136. package/docs/BRIDGE-MESSAGES.md +117 -0
  137. package/docs/GRAPH-EXCHANGE.md +382 -0
  138. package/docs/IMPACT.md +96 -0
  139. package/docs/MCP.md +62 -0
  140. package/docs/PREFLIGHT.md +311 -0
  141. package/docs/RUNTIME.md +172 -0
  142. package/docs/TOOLCHAIN.md +101 -0
  143. package/package.json +14 -2
  144. package/scripts/build-preflight-toolchain.mjs +186 -0
  145. package/scripts/capture-preflight.mjs +380 -0
  146. package/scripts/run-child.mjs +17 -0
@@ -0,0 +1,317 @@
1
+ import { isProjectRelativePath, isSafeNonEmptyString, parseBridgeFactsDocument, BridgeFactsValidationError, } from "./parse.js";
2
+ import { parseImpactSelection } from "./impact-selection.js";
3
+ import { joinBridgeDocuments } from "../join/join.js";
4
+ import { compareStrings } from "../compare.js";
5
+ import { parseMessageBridgeDocument, validateMessageDocuments } from "./messages.js";
6
+ /** preflight 입력이 계약을 어겼음을 나타내며 원문 데이터를 오류에 넣지 않는다. */
7
+ export class PreflightValidationError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'PreflightValidationError';
11
+ }
12
+ }
13
+ export const MAX_PREFLIGHT_ANALYSES = 256;
14
+ export const MAX_PREFLIGHT_GRAPH_ITEMS = 50_000;
15
+ export const MAX_PREFLIGHT_BINDINGS = 100_000;
16
+ export const MAX_PREFLIGHT_DEPTH = 128;
17
+ export const MAX_PREFLIGHT_RELATIONSHIPS = 32;
18
+ /** 신뢰하지 않는 JSON을 정규화된 preflight-context v1으로 검증한다. */
19
+ export function parsePreflightContext(input) {
20
+ const value = object(input, 'Preflight context must be a JSON object.');
21
+ if (value.format !== 'isthmus-preflight-context' || value.version !== 1) {
22
+ fail('Expected isthmus-preflight-context version 1.');
23
+ }
24
+ const project = safeString(value.project, 'Invalid preflight project.');
25
+ const revision = safeString(value.revision, 'Invalid preflight revision.');
26
+ const selection = parseSelectionMap(value.selection);
27
+ const bridges = parseBridges(value.bridges, project);
28
+ const messages = value.messages === undefined ? undefined : parseMessages(value.messages, project);
29
+ const analyses = parseAnalyses(value.analyses);
30
+ validateSelectionCoverage(selection, analyses);
31
+ const bindings = parseBindings(value.bindings, [...bridges, ...(messages ?? [])]);
32
+ const limitations = strings(value.limitations, 'Invalid preflight limitations.');
33
+ return {
34
+ format: 'isthmus-preflight-context', version: 1, project, revision,
35
+ selection, bridges, ...(messages === undefined ? {} : { messages }), bindings, analyses, limitations,
36
+ };
37
+ }
38
+ function parseMessages(input, project) {
39
+ try {
40
+ const documents = array(input, 256, 'Invalid preflight message documents.').map(parseMessageBridgeDocument);
41
+ validateMessageDocuments(documents, project);
42
+ return documents;
43
+ }
44
+ catch (error) {
45
+ if (error instanceof BridgeFactsValidationError)
46
+ fail(`Invalid preflight messages: ${error.message}`);
47
+ throw error;
48
+ }
49
+ }
50
+ /** producer adapter가 만든 분석도 context parser와 같은 그래프 규칙을 사용하게 한다. */
51
+ export function validateLanguageImpact(input) {
52
+ const value = object(input, 'Language impact must be a JSON object.');
53
+ const id = safeString(value.id, 'Invalid language impact id.');
54
+ if (value.platform !== 'dart' && value.platform !== 'swift' && value.platform !== 'kotlin') {
55
+ fail('Unsupported language impact platform.');
56
+ }
57
+ const toolValue = object(value.tool, 'Invalid language impact tool.');
58
+ const tool = {
59
+ name: safeString(toolValue.name, 'Invalid language impact tool name.'),
60
+ version: safeString(toolValue.version, 'Invalid language impact tool version.'),
61
+ };
62
+ let requested;
63
+ try {
64
+ requested = parseImpactSelection({ format: 'isthmus-changes', version: 1, ...object(value.requested, 'Invalid language impact selection.') });
65
+ }
66
+ catch (error) {
67
+ if (error instanceof PreflightValidationError)
68
+ throw error;
69
+ fail('Invalid language impact selection.');
70
+ }
71
+ const trigger = value.trigger === undefined
72
+ ? undefined
73
+ : safeString(value.trigger, 'Invalid language impact trigger.');
74
+ const roots = array(value.roots, MAX_PREFLIGHT_GRAPH_ITEMS, 'Invalid language impact roots.')
75
+ .map((item) => parseSymbol(item, value.platform === 'kotlin'));
76
+ const affectedRaw = array(value.affected, MAX_PREFLIGHT_GRAPH_ITEMS, 'Invalid language impact affected symbols.');
77
+ const affected = affectedRaw.map((item) => parseAffected(item, value.platform === 'kotlin'));
78
+ const limitations = strings(value.limitations, 'Invalid language impact limitations.');
79
+ if (typeof value.truncated !== 'boolean')
80
+ fail('Invalid language impact truncation flag.');
81
+ if (roots.length + affected.length > MAX_PREFLIGHT_GRAPH_ITEMS) {
82
+ fail('Language impact graph exceeds its item limit.');
83
+ }
84
+ validateGraph(roots, affected);
85
+ if (trigger !== undefined && (value.platform !== 'dart' || requested.files.length !== 0 ||
86
+ requested.symbols.length !== 1 || requested.symbols[0] !== trigger ||
87
+ !roots.some((root) => root.id === trigger))) {
88
+ fail('Continuation impact must be a Dart analysis rooted at its trigger symbol.');
89
+ }
90
+ return {
91
+ id, platform: value.platform, tool, requested,
92
+ ...(trigger === undefined ? {} : { trigger }), roots, affected, limitations,
93
+ truncated: value.truncated,
94
+ };
95
+ }
96
+ function parseSelectionMap(input) {
97
+ const value = object(input, 'Preflight selection must be a JSON object.');
98
+ for (const key of Object.keys(value)) {
99
+ if (key !== 'dart' && key !== 'swift' && key !== 'kotlin')
100
+ fail('Unsupported preflight selection platform.');
101
+ }
102
+ const selection = {};
103
+ for (const platform of ['dart', 'swift', 'kotlin']) {
104
+ if (value[platform] === undefined)
105
+ continue;
106
+ try {
107
+ selection[platform] = parseImpactSelection({
108
+ format: 'isthmus-changes', version: 1,
109
+ ...object(value[platform], 'Invalid preflight platform selection.'),
110
+ });
111
+ }
112
+ catch (error) {
113
+ if (error instanceof PreflightValidationError)
114
+ throw error;
115
+ fail('Invalid preflight platform selection.');
116
+ }
117
+ }
118
+ return selection;
119
+ }
120
+ function parseBridges(input, project) {
121
+ const raw = array(input, 256, 'Invalid preflight bridges.');
122
+ const bridges = raw.map((item) => {
123
+ const candidate = object(item, 'Invalid preflight bridge document.');
124
+ if (candidate.platform !== 'dart' && candidate.platform !== 'swift' && candidate.platform !== 'kotlin') {
125
+ fail('Preflight context supports only Dart, Swift and Kotlin bridge documents.');
126
+ }
127
+ try {
128
+ const parsed = parseBridgeFactsDocument(candidate);
129
+ if (parsed.project !== project)
130
+ fail('Bridge project differs from preflight project.');
131
+ return parsed;
132
+ }
133
+ catch (error) {
134
+ if (error instanceof PreflightValidationError)
135
+ throw error;
136
+ fail('Invalid preflight bridge document.');
137
+ }
138
+ });
139
+ try {
140
+ const joined = joinBridgeDocuments(bridges);
141
+ if (joined.deferred)
142
+ fail('Mixed bridge targets cannot be used in preflight context.');
143
+ }
144
+ catch (error) {
145
+ if (error instanceof PreflightValidationError)
146
+ throw error;
147
+ fail('Bridge documents cannot be joined for preflight.');
148
+ }
149
+ return bridges;
150
+ }
151
+ function parseAnalyses(input) {
152
+ const raw = array(input, MAX_PREFLIGHT_ANALYSES, 'Invalid preflight analyses.');
153
+ const ids = new Set();
154
+ let graphItems = 0;
155
+ const analyses = raw.map((item) => {
156
+ const analysis = validateLanguageImpact(item);
157
+ if (ids.has(analysis.id))
158
+ fail('Language impact ids must be unique.');
159
+ ids.add(analysis.id);
160
+ graphItems += analysis.roots.length + analysis.affected.length;
161
+ if (graphItems > MAX_PREFLIGHT_GRAPH_ITEMS)
162
+ fail('Preflight impact graphs exceed their total item limit.');
163
+ return analysis;
164
+ });
165
+ return analyses;
166
+ }
167
+ function validateSelectionCoverage(selection, analyses) {
168
+ for (const platform of ['dart', 'swift', 'kotlin']) {
169
+ const initial = analyses.filter((analysis) => analysis.platform === platform && analysis.trigger === undefined);
170
+ const declared = selection[platform];
171
+ if (initial.length === 0) {
172
+ if (declared !== undefined)
173
+ fail('Declared selection has no initial analysis.');
174
+ continue;
175
+ }
176
+ const files = [...new Set(initial.flatMap(({ requested }) => requested.files))].sort(compareStrings);
177
+ const symbols = [...new Set(initial.flatMap(({ requested }) => requested.symbols))].sort(compareStrings);
178
+ if (declared === undefined || files.length !== declared.files.length || symbols.length !== declared.symbols.length ||
179
+ files.some((file, index) => file !== declared.files[index]) || symbols.some((symbol, index) => symbol !== declared.symbols[index])) {
180
+ fail('Initial impact selections must exactly cover the declared platform selections.');
181
+ }
182
+ }
183
+ if (analyses.length === 0 && Object.keys(selection).length !== 0) {
184
+ fail('An empty analysis set requires an empty selection.');
185
+ }
186
+ }
187
+ function parseBindings(input, bridges) {
188
+ const raw = array(input, MAX_PREFLIGHT_BINDINGS, 'Invalid preflight bindings.');
189
+ const facts = new Map();
190
+ for (const document of bridges) {
191
+ if (document.platform !== 'dart')
192
+ continue;
193
+ for (const fact of document.facts) {
194
+ if (fact.symbol === undefined)
195
+ continue;
196
+ const key = locationKey(fact.location);
197
+ const entries = facts.get(key) ?? [];
198
+ entries.push({ path: fact.location.path, qualifiedName: fact.symbol.qualifiedName });
199
+ facts.set(key, entries);
200
+ }
201
+ }
202
+ const used = new Map();
203
+ return raw.map((item) => {
204
+ const value = object(item, 'Invalid caller binding.');
205
+ if (value.platform !== 'dart')
206
+ fail('Caller bindings must be Dart bindings.');
207
+ const location = parseLocation(value.location, 'Invalid caller binding location.');
208
+ const requested = safeString(value.requested, 'Invalid caller binding request.');
209
+ const symbol = parseSymbol(value.symbol);
210
+ // requested는 AST의 짧은 이름이고 query qualifiedName은 producer의 전체 ID일 수 있다.
211
+ if (symbol.location === undefined || symbol.location.path !== location.path) {
212
+ fail('Caller binding symbol does not match its fact path.');
213
+ }
214
+ const matches = (facts.get(locationKey(location)) ?? []).filter((fact) => fact.qualifiedName === requested);
215
+ if (matches.length === 0)
216
+ fail('Caller binding does not reference an observed Dart fact.');
217
+ const key = locationKey(location);
218
+ const identity = `${requested}\u0000${symbol.id}`;
219
+ const prior = used.get(key);
220
+ if (prior !== undefined && prior !== identity)
221
+ fail('Conflicting caller bindings share one fact location.');
222
+ used.set(key, identity);
223
+ return { platform: 'dart', location, requested, symbol };
224
+ });
225
+ }
226
+ function parseAffected(input, partialLocation = false) {
227
+ const value = object(input, 'Invalid affected symbol.');
228
+ const symbol = parseSymbol(value.symbol, partialLocation);
229
+ const via = safeString(value.via, 'Invalid affected symbol parent.');
230
+ if (!Number.isSafeInteger(value.depth) || value.depth < 1 || value.depth > MAX_PREFLIGHT_DEPTH) {
231
+ fail('Affected symbol depth must be between 1 and 128.');
232
+ }
233
+ const relationships = safeStrings(value.relationships, 'Invalid affected symbol relationships.');
234
+ if (relationships.length > MAX_PREFLIGHT_RELATIONSHIPS)
235
+ fail('Affected symbol relationships exceed their limit.');
236
+ return { symbol, via, depth: value.depth, relationships };
237
+ }
238
+ function validateGraph(roots, affected) {
239
+ const depths = new Map();
240
+ for (const root of roots) {
241
+ if (depths.has(root.id))
242
+ fail('Language impact symbol ids must be unique.');
243
+ depths.set(root.id, 0);
244
+ }
245
+ for (const row of affected) {
246
+ if (depths.has(row.symbol.id))
247
+ fail('Language impact symbol ids must be unique.');
248
+ depths.set(row.symbol.id, row.depth);
249
+ }
250
+ for (const row of affected) {
251
+ const parentDepth = depths.get(row.via);
252
+ if (parentDepth === undefined || parentDepth + 1 !== row.depth) {
253
+ fail('Affected symbol depth does not match its observed parent.');
254
+ }
255
+ }
256
+ }
257
+ function parseSymbol(input, partialLocation = false) {
258
+ const value = object(input, 'Invalid impact symbol.');
259
+ const result = {
260
+ id: safeString(value.id, 'Invalid impact symbol id.'),
261
+ qualifiedName: safeString(value.qualifiedName, 'Invalid impact symbol qualified name.'),
262
+ ...(value.kind === undefined ? {} : { kind: safeString(value.kind, 'Invalid impact symbol kind.') }),
263
+ ...(value.location === undefined ? {} : { location: partialLocation ? parseKotlinLocation(value.location)
264
+ : parseLocation(value.location, 'Invalid impact symbol location.') }),
265
+ };
266
+ return result;
267
+ }
268
+ /** JVM line tables가 제공하지 않은 좌표를 1로 채워 넣지 않는다. */
269
+ function parseKotlinLocation(input) {
270
+ const value = object(input, 'Invalid Kotlin symbol location.');
271
+ if (!isProjectRelativePath(value.path) ||
272
+ (value.line !== undefined && (!Number.isSafeInteger(value.line) || value.line < 1)) ||
273
+ (value.column !== undefined && (value.line === undefined || !Number.isSafeInteger(value.column) || value.column < 1))) {
274
+ fail('Invalid Kotlin symbol location.');
275
+ }
276
+ return { path: value.path, ...(value.line === undefined ? {} : { line: value.line }),
277
+ ...(value.column === undefined ? {} : { column: value.column }) };
278
+ }
279
+ function parseLocation(input, message) {
280
+ const value = object(input, message);
281
+ if (!isProjectRelativePath(value.path) || !Number.isSafeInteger(value.line) || value.line < 1 ||
282
+ !Number.isSafeInteger(value.column) || value.column < 1)
283
+ fail(message);
284
+ return { path: value.path, line: value.line, column: value.column };
285
+ }
286
+ function object(input, message) {
287
+ if (typeof input !== 'object' || input === null || Array.isArray(input))
288
+ fail(message);
289
+ return input;
290
+ }
291
+ function array(input, maximum, message) {
292
+ if (!Array.isArray(input) || input.length > maximum)
293
+ fail(message);
294
+ return input;
295
+ }
296
+ function strings(input, message) {
297
+ if (!Array.isArray(input) || !input.every((item) => typeof item === 'string'))
298
+ fail(message);
299
+ return [...input];
300
+ }
301
+ function safeStrings(input, message) {
302
+ if (!Array.isArray(input) || !input.every(isSafeNonEmptyString))
303
+ fail(message);
304
+ return [...input];
305
+ }
306
+ function safeString(input, message) {
307
+ if (!isSafeNonEmptyString(input))
308
+ fail(message);
309
+ return input;
310
+ }
311
+ function locationKey(location) {
312
+ return `${location.path}\u0000${location.line}\u0000${location.column}`;
313
+ }
314
+ function fail(message) {
315
+ throw new PreflightValidationError(message);
316
+ }
317
+ //# sourceMappingURL=preflight-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight-context.js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,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,OAAe;IAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;QAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7F,OAAO,CAAC,GAAG,KAAK,CAAa,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,OAAe;IAClD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC;QAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,KAAK,CAAa,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,OAAe;IACjD,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;QAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,QAAwB;IAC3C,OAAO,GAAG,QAAQ,CAAC,IAAI,SAAS,QAAQ,CAAC,IAAI,SAAS,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,IAAI,CAAC,OAAe;IAC3B,MAAM,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import {\n isProjectRelativePath,\n isSafeNonEmptyString,\n parseBridgeFactsDocument,\n BridgeFactsValidationError,\n} from './parse.ts';\nimport type {\n BridgeFactsDocument,\n BridgeLocation,\n} from './parse.ts';\nimport { parseImpactSelection } from './impact-selection.ts';\nimport type { ImpactSelection } from './impact-selection.ts';\nimport { joinBridgeDocuments } from '../join/join.ts';\nimport { compareStrings } from '../compare.ts';\nimport { parseMessageBridgeDocument, validateMessageDocuments } from './messages.ts';\nimport type { BridgeMessageDocument } from './messages.ts';\n\n/** 영향 분석에서 사용하는, 생산자가 증명한 심볼 식별자다. */\nexport interface ImpactSymbol {\n readonly id: string;\n readonly qualifiedName: string;\n readonly kind?: string;\n readonly location?: Readonly<{ path: string; line?: number; column?: number }>;\n}\n\n/** 한 언어 producer가 한 선택에 대해 관찰한 영향 범위다. */\nexport interface LanguageImpact {\n readonly id: string;\n readonly platform: 'dart' | 'swift' | 'kotlin';\n readonly tool: Readonly<{ name: string; version: string }>;\n readonly requested: ImpactSelection;\n readonly trigger?: string;\n readonly roots: readonly ImpactSymbol[];\n readonly affected: readonly {\n readonly symbol: ImpactSymbol;\n readonly via: string;\n readonly depth: number;\n readonly relationships: readonly string[];\n }[];\n readonly limitations: readonly string[];\n readonly truncated: boolean;\n}\n\n/** Dart fact와 query symbol을 추측 없이 연결하는 호출자 근거다. */\nexport interface CallerBinding {\n readonly platform: 'dart';\n readonly location: BridgeLocation;\n readonly requested: string;\n readonly symbol: ImpactSymbol;\n}\n\n/** 변경 사전 점검이 재사용할 입력·분석·호출자 근거를 묶은 문서다. */\nexport interface PreflightContext {\n readonly format: 'isthmus-preflight-context';\n readonly version: 1;\n readonly project: string;\n readonly revision: string;\n readonly selection: Readonly<{\n readonly dart?: ImpactSelection;\n readonly swift?: ImpactSelection;\n readonly kotlin?: ImpactSelection;\n }>;\n readonly bridges: readonly BridgeFactsDocument[];\n readonly messages?: readonly BridgeMessageDocument[];\n readonly bindings: readonly CallerBinding[];\n readonly analyses: readonly LanguageImpact[];\n readonly limitations: readonly string[];\n}\n\n/** preflight 입력이 계약을 어겼음을 나타내며 원문 데이터를 오류에 넣지 않는다. */\nexport class PreflightValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'PreflightValidationError';\n }\n}\n\nexport const MAX_PREFLIGHT_ANALYSES = 256;\nexport const MAX_PREFLIGHT_GRAPH_ITEMS = 50_000;\nexport const MAX_PREFLIGHT_BINDINGS = 100_000;\nexport const MAX_PREFLIGHT_DEPTH = 128;\nexport const MAX_PREFLIGHT_RELATIONSHIPS = 32;\n\n/** 신뢰하지 않는 JSON을 정규화된 preflight-context v1으로 검증한다. */\nexport function parsePreflightContext(input: unknown): PreflightContext {\n const value = object(input, 'Preflight context must be a JSON object.');\n if (value.format !== 'isthmus-preflight-context' || value.version !== 1) {\n fail('Expected isthmus-preflight-context version 1.');\n }\n const project = safeString(value.project, 'Invalid preflight project.');\n const revision = safeString(value.revision, 'Invalid preflight revision.');\n const selection = parseSelectionMap(value.selection);\n const bridges = parseBridges(value.bridges, project);\n const messages = value.messages === undefined ? undefined : parseMessages(value.messages, project);\n const analyses = parseAnalyses(value.analyses);\n validateSelectionCoverage(selection, analyses);\n const bindings = parseBindings(value.bindings, [...bridges, ...(messages ?? [])]);\n const limitations = strings(value.limitations, 'Invalid preflight limitations.');\n return {\n format: 'isthmus-preflight-context', version: 1, project, revision,\n selection, bridges, ...(messages === undefined ? {} : { messages }), bindings, analyses, limitations,\n };\n}\n\nfunction parseMessages(input: unknown, project: string): readonly BridgeMessageDocument[] {\n try {\n const documents = array(input, 256, 'Invalid preflight message documents.').map(parseMessageBridgeDocument);\n validateMessageDocuments(documents, project);\n return documents;\n } catch (error) {\n if (error instanceof BridgeFactsValidationError) fail(`Invalid preflight messages: ${error.message}`);\n throw error;\n }\n}\n\n/** producer adapter가 만든 분석도 context parser와 같은 그래프 규칙을 사용하게 한다. */\nexport function validateLanguageImpact(input: unknown): LanguageImpact {\n const value = object(input, 'Language impact must be a JSON object.');\n const id = safeString(value.id, 'Invalid language impact id.');\n if (value.platform !== 'dart' && value.platform !== 'swift' && value.platform !== 'kotlin') {\n fail('Unsupported language impact platform.');\n }\n const toolValue = object(value.tool, 'Invalid language impact tool.');\n const tool = {\n name: safeString(toolValue.name, 'Invalid language impact tool name.'),\n version: safeString(toolValue.version, 'Invalid language impact tool version.'),\n };\n let requested: ImpactSelection;\n try {\n requested = parseImpactSelection({ format: 'isthmus-changes', version: 1, ...object(value.requested, 'Invalid language impact selection.') });\n } catch (error) {\n if (error instanceof PreflightValidationError) throw error;\n fail('Invalid language impact selection.');\n }\n const trigger = value.trigger === undefined\n ? undefined\n : safeString(value.trigger, 'Invalid language impact trigger.');\n const roots = array(value.roots, MAX_PREFLIGHT_GRAPH_ITEMS, 'Invalid language impact roots.')\n .map((item) => parseSymbol(item, value.platform === 'kotlin'));\n const affectedRaw = array(value.affected, MAX_PREFLIGHT_GRAPH_ITEMS, 'Invalid language impact affected symbols.');\n const affected = affectedRaw.map((item) => parseAffected(item, value.platform === 'kotlin'));\n const limitations = strings(value.limitations, 'Invalid language impact limitations.');\n if (typeof value.truncated !== 'boolean') fail('Invalid language impact truncation flag.');\n if (roots.length + affected.length > MAX_PREFLIGHT_GRAPH_ITEMS) {\n fail('Language impact graph exceeds its item limit.');\n }\n validateGraph(roots, affected);\n if (trigger !== undefined && (value.platform !== 'dart' || requested.files.length !== 0 ||\n requested.symbols.length !== 1 || requested.symbols[0] !== trigger ||\n !roots.some((root) => root.id === trigger))) {\n fail('Continuation impact must be a Dart analysis rooted at its trigger symbol.');\n }\n return {\n id, platform: value.platform, tool, requested,\n ...(trigger === undefined ? {} : { trigger }), roots, affected, limitations,\n truncated: value.truncated,\n };\n}\n\nfunction parseSelectionMap(input: unknown): PreflightContext['selection'] {\n const value = object(input, 'Preflight selection must be a JSON object.');\n for (const key of Object.keys(value)) {\n if (key !== 'dart' && key !== 'swift' && key !== 'kotlin') fail('Unsupported preflight selection platform.');\n }\n const selection: { dart?: ImpactSelection; swift?: ImpactSelection; kotlin?: ImpactSelection } = {};\n for (const platform of ['dart', 'swift', 'kotlin'] as const) {\n if (value[platform] === undefined) continue;\n try {\n selection[platform] = parseImpactSelection({\n format: 'isthmus-changes', version: 1,\n ...object(value[platform], 'Invalid preflight platform selection.'),\n });\n } catch (error) {\n if (error instanceof PreflightValidationError) throw error;\n fail('Invalid preflight platform selection.');\n }\n }\n return selection;\n}\n\nfunction parseBridges(input: unknown, project: string): BridgeFactsDocument[] {\n const raw = array(input, 256, 'Invalid preflight bridges.');\n const bridges = raw.map((item) => {\n const candidate = object(item, 'Invalid preflight bridge document.');\n if (candidate.platform !== 'dart' && candidate.platform !== 'swift' && candidate.platform !== 'kotlin') {\n fail('Preflight context supports only Dart, Swift and Kotlin bridge documents.');\n }\n try {\n const parsed = parseBridgeFactsDocument(candidate);\n if (parsed.project !== project) fail('Bridge project differs from preflight project.');\n return parsed;\n } catch (error) {\n if (error instanceof PreflightValidationError) throw error;\n fail('Invalid preflight bridge document.');\n }\n });\n try {\n const joined = joinBridgeDocuments(bridges);\n if (joined.deferred) fail('Mixed bridge targets cannot be used in preflight context.');\n } catch (error) {\n if (error instanceof PreflightValidationError) throw error;\n fail('Bridge documents cannot be joined for preflight.');\n }\n return bridges;\n}\n\nfunction parseAnalyses(input: unknown): LanguageImpact[] {\n const raw = array(input, MAX_PREFLIGHT_ANALYSES, 'Invalid preflight analyses.');\n const ids = new Set<string>();\n let graphItems = 0;\n const analyses = raw.map((item) => {\n const analysis = validateLanguageImpact(item);\n if (ids.has(analysis.id)) fail('Language impact ids must be unique.');\n ids.add(analysis.id);\n graphItems += analysis.roots.length + analysis.affected.length;\n if (graphItems > MAX_PREFLIGHT_GRAPH_ITEMS) fail('Preflight impact graphs exceed their total item limit.');\n return analysis;\n });\n return analyses;\n}\n\nfunction validateSelectionCoverage(\n selection: PreflightContext['selection'], analyses: readonly LanguageImpact[],\n): void {\n for (const platform of ['dart', 'swift', 'kotlin'] as const) {\n const initial = analyses.filter((analysis) => analysis.platform === platform && analysis.trigger === undefined);\n const declared = selection[platform];\n if (initial.length === 0) {\n if (declared !== undefined) fail('Declared selection has no initial analysis.');\n continue;\n }\n const files = [...new Set(initial.flatMap(({ requested }) => requested.files))].sort(compareStrings);\n const symbols = [...new Set(initial.flatMap(({ requested }) => requested.symbols))].sort(compareStrings);\n if (declared === undefined || files.length !== declared.files.length || symbols.length !== declared.symbols.length ||\n files.some((file, index) => file !== declared.files[index]) || symbols.some((symbol, index) => symbol !== declared.symbols[index])) {\n fail('Initial impact selections must exactly cover the declared platform selections.');\n }\n }\n if (analyses.length === 0 && Object.keys(selection).length !== 0) {\n fail('An empty analysis set requires an empty selection.');\n }\n}\n\nfunction parseBindings(input: unknown, bridges: readonly (BridgeFactsDocument | BridgeMessageDocument)[]): CallerBinding[] {\n const raw = array(input, MAX_PREFLIGHT_BINDINGS, 'Invalid preflight bindings.');\n const facts = new Map<string, { path: string; qualifiedName: string }[]>();\n for (const document of bridges) {\n if (document.platform !== 'dart') continue;\n for (const fact of document.facts) {\n if (fact.symbol === undefined) continue;\n const key = locationKey(fact.location);\n const entries = facts.get(key) ?? [];\n entries.push({ path: fact.location.path, qualifiedName: fact.symbol.qualifiedName });\n facts.set(key, entries);\n }\n }\n const used = new Map<string, string>();\n return raw.map((item) => {\n const value = object(item, 'Invalid caller binding.');\n if (value.platform !== 'dart') fail('Caller bindings must be Dart bindings.');\n const location = parseLocation(value.location, 'Invalid caller binding location.');\n const requested = safeString(value.requested, 'Invalid caller binding request.');\n const symbol = parseSymbol(value.symbol);\n // requested는 AST의 짧은 이름이고 query qualifiedName은 producer의 전체 ID일 수 있다.\n if (symbol.location === undefined || symbol.location.path !== location.path) {\n fail('Caller binding symbol does not match its fact path.');\n }\n const matches = (facts.get(locationKey(location)) ?? []).filter((fact) => fact.qualifiedName === requested);\n if (matches.length === 0) fail('Caller binding does not reference an observed Dart fact.');\n const key = locationKey(location);\n const identity = `${requested}\\u0000${symbol.id}`;\n const prior = used.get(key);\n if (prior !== undefined && prior !== identity) fail('Conflicting caller bindings share one fact location.');\n used.set(key, identity);\n return { platform: 'dart', location, requested, symbol };\n });\n}\n\nfunction parseAffected(input: unknown, partialLocation = false): LanguageImpact['affected'][number] {\n const value = object(input, 'Invalid affected symbol.');\n const symbol = parseSymbol(value.symbol, partialLocation);\n const via = safeString(value.via, 'Invalid affected symbol parent.');\n if (!Number.isSafeInteger(value.depth) || (value.depth as number) < 1 || (value.depth as number) > MAX_PREFLIGHT_DEPTH) {\n fail('Affected symbol depth must be between 1 and 128.');\n }\n const relationships = safeStrings(value.relationships, 'Invalid affected symbol relationships.');\n if (relationships.length > MAX_PREFLIGHT_RELATIONSHIPS) fail('Affected symbol relationships exceed their limit.');\n return { symbol, via, depth: value.depth as number, relationships };\n}\n\nfunction validateGraph(\n roots: readonly ImpactSymbol[], affected: readonly LanguageImpact['affected'][number][],\n): void {\n const depths = new Map<string, number>();\n for (const root of roots) {\n if (depths.has(root.id)) fail('Language impact symbol ids must be unique.');\n depths.set(root.id, 0);\n }\n for (const row of affected) {\n if (depths.has(row.symbol.id)) fail('Language impact symbol ids must be unique.');\n depths.set(row.symbol.id, row.depth);\n }\n for (const row of affected) {\n const parentDepth = depths.get(row.via);\n if (parentDepth === undefined || parentDepth + 1 !== row.depth) {\n fail('Affected symbol depth does not match its observed parent.');\n }\n }\n}\n\nfunction parseSymbol(input: unknown, partialLocation = false): ImpactSymbol {\n const value = object(input, 'Invalid impact symbol.');\n const result: ImpactSymbol = {\n id: safeString(value.id, 'Invalid impact symbol id.'),\n qualifiedName: safeString(value.qualifiedName, 'Invalid impact symbol qualified name.'),\n ...(value.kind === undefined ? {} : { kind: safeString(value.kind, 'Invalid impact symbol kind.') }),\n ...(value.location === undefined ? {} : { location: partialLocation ? parseKotlinLocation(value.location)\n : parseLocation(value.location, 'Invalid impact symbol location.') }),\n };\n return result;\n}\n\n/** JVM line tables가 제공하지 않은 좌표를 1로 채워 넣지 않는다. */\nfunction parseKotlinLocation(input: unknown): NonNullable<ImpactSymbol['location']> {\n const value = object(input, 'Invalid Kotlin symbol location.');\n if (!isProjectRelativePath(value.path) ||\n (value.line !== undefined && (!Number.isSafeInteger(value.line) || (value.line as number) < 1)) ||\n (value.column !== undefined && (value.line === undefined || !Number.isSafeInteger(value.column) || (value.column as number) < 1))) {\n fail('Invalid Kotlin symbol location.');\n }\n return { path: value.path, ...(value.line === undefined ? {} : { line: value.line as number }),\n ...(value.column === undefined ? {} : { column: value.column as number }) };\n}\n\nfunction parseLocation(input: unknown, message: string): BridgeLocation {\n const value = object(input, message);\n if (!isProjectRelativePath(value.path) || !Number.isSafeInteger(value.line) || (value.line as number) < 1 ||\n !Number.isSafeInteger(value.column) || (value.column as number) < 1) fail(message);\n return { path: value.path as string, line: value.line as number, column: value.column as number };\n}\n\nfunction object(input: unknown, message: string): Record<string, unknown> {\n if (typeof input !== 'object' || input === null || Array.isArray(input)) fail(message);\n return input as Record<string, unknown>;\n}\n\nfunction array(input: unknown, maximum: number, message: string): unknown[] {\n if (!Array.isArray(input) || input.length > maximum) fail(message);\n return input;\n}\n\nfunction strings(input: unknown, message: string): string[] {\n if (!Array.isArray(input) || !input.every((item) => typeof item === 'string')) fail(message);\n return [...input] as string[];\n}\n\nfunction safeStrings(input: unknown, message: string): string[] {\n if (!Array.isArray(input) || !input.every(isSafeNonEmptyString)) fail(message);\n return [...input] as string[];\n}\n\nfunction safeString(input: unknown, message: string): string {\n if (!isSafeNonEmptyString(input)) fail(message);\n return input;\n}\n\nfunction locationKey(location: BridgeLocation): string {\n return `${location.path}\\u0000${location.line}\\u0000${location.column}`;\n}\n\nfunction fail(message: string): never {\n throw new PreflightValidationError(message);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { ImpactSelection } from './impact-selection.ts';
2
+ import { type LanguageImpact } from './preflight-context.ts';
3
+ /** producer 영향 문서에 주입할 isthmus 실행 문맥이다. */
4
+ export interface ProducerImpactMetadata {
5
+ readonly id: string;
6
+ readonly project: string;
7
+ readonly requested: ImpactSelection;
8
+ readonly tool: Readonly<{
9
+ name: string;
10
+ version: string;
11
+ }>;
12
+ readonly trigger?: string;
13
+ }
14
+ /** Cartograph `change-impact` v1을 isthmus 공통 영향 형식으로 투영한다. */
15
+ export declare function adaptCartographImpact(raw: unknown, metadata: ProducerImpactMetadata): LanguageImpact;
16
+ /** Dartograph `_document` v1을 isthmus 공통 영향 형식으로 투영한다. */
17
+ export declare function adaptDartographImpact(raw: unknown, metadata: ProducerImpactMetadata): LanguageImpact;
@@ -0,0 +1,226 @@
1
+ import { isProjectRelativePath, isSafeNonEmptyString } from "./parse.js";
2
+ import { parseImpactSelection } from "./impact-selection.js";
3
+ import { validateLanguageImpact, PreflightValidationError, } from "./preflight-context.js";
4
+ /** Cartograph `change-impact` v1을 isthmus 공통 영향 형식으로 투영한다. */
5
+ export function adaptCartographImpact(raw, metadata) {
6
+ const value = object(raw, 'Cartograph impact must be a JSON object.');
7
+ if (value.format !== 'change-impact' || value.version !== 1 || value.level !== 'symbol') {
8
+ fail('Expected Cartograph change-impact version 1 at symbol level.');
9
+ }
10
+ const context = normalizeMetadata(metadata, 'swift');
11
+ const limitations = textStrings(value.limitations, 'Invalid Cartograph limitations.');
12
+ for (const [field, code] of [['selectionIssues', 'selection-issues'], ['runtimeReview', 'runtime-review'],
13
+ ['runtimeDependencies', 'runtime-dependencies']]) {
14
+ if (value[field] === undefined)
15
+ continue;
16
+ const rows = rawArray(value[field], `Invalid Cartograph ${field}.`);
17
+ if (rows.length > 0)
18
+ limitations.push(`cartograph-${code}: ${rows.length} item(s) require review in the producer report`);
19
+ }
20
+ let outsideLocations = 0;
21
+ const roots = rawArray(value.changeScope, 'Invalid Cartograph change scope.').map((item) => {
22
+ const parsed = parseCartographSymbol(item, context.project, () => outsideLocations++);
23
+ return parsed;
24
+ });
25
+ const affected = rawArray(value.affected, 'Invalid Cartograph affected symbols.').map((item) => {
26
+ const row = object(item, 'Invalid Cartograph affected symbol.');
27
+ const symbol = parseCartographSymbol(row.symbol, context.project, () => outsideLocations++);
28
+ const via = safe(row.via, 'Invalid Cartograph affected parent.');
29
+ const depth = positiveDepth(row.depth);
30
+ const relationship = safe(row.relationship, 'Invalid Cartograph relationship.');
31
+ const edges = row.edges === undefined ? [] : rawStrings(row.edges, 'Invalid Cartograph edges.');
32
+ const relationships = [...new Set([relationship, ...edges])];
33
+ if (relationships.length > 32)
34
+ fail('Cartograph relationships exceed their limit.');
35
+ return { symbol, via, depth, relationships };
36
+ });
37
+ if (outsideLocations > 0) {
38
+ limitations.push(`cartograph-location-outside-project: ${outsideLocations} symbol location(s) omitted`);
39
+ }
40
+ const result = {
41
+ ...context,
42
+ roots,
43
+ affected,
44
+ limitations,
45
+ truncated: truncation(value.truncated),
46
+ };
47
+ return validateLanguageImpact(result);
48
+ }
49
+ /** Dartograph `_document` v1을 isthmus 공통 영향 형식으로 투영한다. */
50
+ export function adaptDartographImpact(raw, metadata) {
51
+ const value = object(raw, 'Dartograph impact must be a JSON object.');
52
+ if (value.version !== 1)
53
+ fail('Expected Dartograph impact version 1.');
54
+ const context = normalizeMetadata(metadata, 'dart');
55
+ const changed = object(value.changed, 'Invalid Dartograph changed scope.');
56
+ const changedSymbols = rawStrings(changed.symbols, 'Invalid Dartograph changed symbols.');
57
+ const changedLibraries = changed.libraries === undefined ? [] : rawStrings(changed.libraries, 'Invalid Dartograph changed libraries.');
58
+ if (changed.sources !== undefined) {
59
+ rawStrings(changed.sources, 'Invalid Dartograph changed sources.').forEach(dartSource);
60
+ }
61
+ const roots = [
62
+ ...changedLibraries.map((id) => ({ id, qualifiedName: id, kind: 'library' })),
63
+ ...changedSymbols.map((id) => ({ id, qualifiedName: id, kind: 'declaration' })),
64
+ ];
65
+ const rootIds = new Set(roots.map(({ id }) => id));
66
+ const impacted = rawArray(value.impacted, 'Invalid Dartograph impacted symbols.');
67
+ const rows = impacted.map((item) => {
68
+ const row = object(item, 'Invalid Dartograph impacted symbol.');
69
+ const id = safe(row.id, 'Invalid Dartograph impacted symbol id.');
70
+ const depth = positiveDepth(row.depth);
71
+ const path = rawStrings(row.path, 'Invalid Dartograph impact path.');
72
+ if (path.length !== depth + 1 || path[0] !== id || !rootIds.has(path[path.length - 1]) ||
73
+ new Set(path).size !== path.length) {
74
+ fail('Dartograph impact path is not a complete parent-safe path.');
75
+ }
76
+ const location = dartLocation(row);
77
+ if (row.source !== undefined)
78
+ dartSource(row.source);
79
+ return {
80
+ symbol: { id, qualifiedName: id, ...(location === undefined ? {} : { location }),
81
+ ...(row.kind === undefined ? {} : { kind: safe(row.kind, 'Invalid Dartograph impacted kind.') }) },
82
+ via: path[1],
83
+ depth,
84
+ relationships: [],
85
+ path,
86
+ };
87
+ });
88
+ const known = new Set([...roots.map((root) => root.id), ...rows.map((row) => row.symbol.id)]);
89
+ for (const row of rows) {
90
+ if (row.path.some((id) => !known.has(id)))
91
+ fail('Dartograph impact path contains an omitted intermediate symbol.');
92
+ }
93
+ const limitations = textStrings(value.limitations, 'Invalid Dartograph limitations.');
94
+ const missing = value.missingSymbols === undefined ? [] : rawStrings(value.missingSymbols, 'Invalid Dartograph missing symbols.');
95
+ const unattributed = changed.unattributedSources === undefined ? [] : rawStrings(changed.unattributedSources, 'Invalid Dartograph unattributed sources.');
96
+ unattributed.forEach(dartSource);
97
+ if (missing.length > 0)
98
+ limitations.push(`dartograph-missing-symbols: ${missing.length} requested symbol(s) were not found`);
99
+ if (unattributed.length > 0)
100
+ limitations.push(`dartograph-unattributed-sources: ${unattributed.length} changed source(s) could not be attributed`);
101
+ const result = {
102
+ ...context,
103
+ roots,
104
+ affected: rows.map(({ path: _path, ...row }) => row),
105
+ limitations,
106
+ truncated: dartTruncation(value.truncated),
107
+ };
108
+ return validateLanguageImpact(result);
109
+ }
110
+ function normalizeMetadata(metadata, platform) {
111
+ const id = safe(metadata.id, 'Invalid producer impact id.');
112
+ const project = safe(metadata.project, 'Invalid producer impact project.');
113
+ const tool = {
114
+ name: safe(metadata.tool?.name, 'Invalid producer impact tool name.'),
115
+ version: safe(metadata.tool?.version, 'Invalid producer impact tool version.'),
116
+ };
117
+ let requested;
118
+ try {
119
+ requested = parseImpactSelection({ format: 'isthmus-changes', version: 1, ...metadata.requested });
120
+ }
121
+ catch {
122
+ fail('Invalid producer impact selection.');
123
+ }
124
+ return { id, project, requested, tool, ...(metadata.trigger === undefined ? {} : { trigger: safe(metadata.trigger, 'Invalid producer impact trigger.') }), platform };
125
+ }
126
+ function parseCartographSymbol(input, project, outside) {
127
+ const value = object(input, 'Invalid Cartograph symbol.');
128
+ const id = safe(value.usr, 'Cartograph symbols require a stable usr identity.');
129
+ const qualifiedName = safe(value.qualifiedName, 'Invalid Cartograph symbol qualified name.');
130
+ const kind = value.kind === undefined ? undefined : safe(value.kind, 'Invalid Cartograph symbol kind.');
131
+ const rawLocation = value.location;
132
+ if (rawLocation === undefined || rawLocation === null)
133
+ return { id, qualifiedName, ...(kind === undefined ? {} : { kind }) };
134
+ const location = rebaseLocation(rawLocation, project, outside);
135
+ return location === undefined ? { id, qualifiedName, ...(kind === undefined ? {} : { kind }) } : { id, qualifiedName, ...(kind === undefined ? {} : { kind }), location };
136
+ }
137
+ function rebaseLocation(input, project, outside) {
138
+ const value = object(input, 'Invalid Cartograph symbol location.');
139
+ const path = safe(value.path, 'Invalid Cartograph symbol location path.');
140
+ if (!Number.isSafeInteger(value.line) || value.line < 1 ||
141
+ !Number.isSafeInteger(value.column) || value.column < 1) {
142
+ fail('Invalid Cartograph symbol location coordinates.');
143
+ }
144
+ if (!path.startsWith('/'))
145
+ fail('Cartograph symbol locations must be absolute paths.');
146
+ const root = project === '/' ? '/' : project.replace(/\/+$/u, '');
147
+ if (path === root) {
148
+ outside();
149
+ return undefined;
150
+ }
151
+ const prefix = root === '/' ? '/' : `${root}/`;
152
+ if (!path.startsWith(prefix)) {
153
+ outside();
154
+ return undefined;
155
+ }
156
+ const relative = path.slice(prefix.length);
157
+ if (!isProjectRelativePath(relative))
158
+ fail('Invalid rebased Cartograph symbol location.');
159
+ return { path: relative, line: value.line, column: value.column };
160
+ }
161
+ function dartLocation(value) {
162
+ if (value.line === undefined && value.column === undefined)
163
+ return undefined;
164
+ if (!Number.isSafeInteger(value.line) || value.line < 1 ||
165
+ !Number.isSafeInteger(value.column) || value.column < 1) {
166
+ fail('Invalid Dartograph impact location.');
167
+ }
168
+ // producer가 GraphNode에서 실은 선언 위치만 사용하며 경로나 좌표를 추측하지 않는다.
169
+ return value.source === undefined ? undefined
170
+ : { path: dartSource(value.source), line: value.line, column: value.column };
171
+ }
172
+ function dartTruncation(input) {
173
+ if (!Number.isSafeInteger(input) || input < 0)
174
+ fail('Invalid Dartograph truncation count.');
175
+ return input > 0;
176
+ }
177
+ function dartSource(input) {
178
+ const source = safe(input, 'Invalid Dartograph impact source.');
179
+ const path = source.startsWith('project:') ? source.slice('project:'.length) : source;
180
+ if (!isProjectRelativePath(path))
181
+ fail('Dartograph impact source must be project-relative.');
182
+ return path;
183
+ }
184
+ function truncation(input) {
185
+ if (typeof input === 'boolean')
186
+ return input;
187
+ const value = object(input, 'Invalid impact truncation.');
188
+ if (typeof value.depth !== 'boolean' || typeof value.output !== 'boolean' || !Array.isArray(value.sections) ||
189
+ !value.sections.every((section) => isSafeNonEmptyString(section)))
190
+ fail('Invalid impact truncation.');
191
+ return value.depth || value.output || value.sections.length > 0;
192
+ }
193
+ function positiveDepth(input) {
194
+ if (!Number.isSafeInteger(input) || input < 1 || input > 128)
195
+ fail('Impact depth must be between 1 and 128.');
196
+ return input;
197
+ }
198
+ function object(input, message) {
199
+ if (typeof input !== 'object' || input === null || Array.isArray(input))
200
+ fail(message);
201
+ return input;
202
+ }
203
+ function rawArray(input, message) {
204
+ if (!Array.isArray(input) || input.length > 50_000)
205
+ fail(message);
206
+ return input;
207
+ }
208
+ function rawStrings(input, message) {
209
+ if (!Array.isArray(input) || input.length > 50_000 || !input.every((item) => isSafeNonEmptyString(item)))
210
+ fail(message);
211
+ return [...input];
212
+ }
213
+ function textStrings(input, message) {
214
+ if (!Array.isArray(input) || input.length > 50_000 || !input.every((item) => typeof item === 'string'))
215
+ fail(message);
216
+ return [...input];
217
+ }
218
+ function safe(input, message) {
219
+ if (!isSafeNonEmptyString(input))
220
+ fail(message);
221
+ return input;
222
+ }
223
+ function fail(message) {
224
+ throw new PreflightValidationError(message);
225
+ }
226
+ //# sourceMappingURL=producer-impact.js.map