@tienne/gestalt 0.150.0 → 0.151.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.
- package/dist/package.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/skills/architecture/SKILL.md +103 -16
- package/dist/plugin/skills/architecture/references/domain-flow.md +1 -1
- package/dist/plugin/skills/architecture/references/merge-analyses.md +4 -3
- package/dist/plugin/skills/architecture/references/rerun.md +5 -5
- package/dist/schemas/architecture-ir.schema.json +18 -1
- package/dist/src/architecture/commit-policy.d.ts +31 -0
- package/dist/src/architecture/commit-policy.d.ts.map +1 -0
- package/dist/src/architecture/commit-policy.js +95 -0
- package/dist/src/architecture/commit-policy.js.map +1 -0
- package/dist/src/architecture/csp.d.ts +14 -0
- package/dist/src/architecture/csp.d.ts.map +1 -0
- package/dist/src/architecture/csp.js +56 -0
- package/dist/src/architecture/csp.js.map +1 -0
- package/dist/src/architecture/delta-renderer.d.ts.map +1 -1
- package/dist/src/architecture/delta-renderer.js +12 -9
- package/dist/src/architecture/delta-renderer.js.map +1 -1
- package/dist/src/architecture/delta.d.ts +2 -1
- package/dist/src/architecture/delta.d.ts.map +1 -1
- package/dist/src/architecture/delta.js +4 -2
- package/dist/src/architecture/delta.js.map +1 -1
- package/dist/src/architecture/did-you-mean.d.ts +14 -0
- package/dist/src/architecture/did-you-mean.d.ts.map +1 -0
- package/dist/src/architecture/did-you-mean.js +63 -0
- package/dist/src/architecture/did-you-mean.js.map +1 -0
- package/dist/src/architecture/drilldown.d.ts +53 -1
- package/dist/src/architecture/drilldown.d.ts.map +1 -1
- package/dist/src/architecture/drilldown.js +441 -32
- package/dist/src/architecture/drilldown.js.map +1 -1
- package/dist/src/architecture/endpoint-match.d.ts +33 -2
- package/dist/src/architecture/endpoint-match.d.ts.map +1 -1
- package/dist/src/architecture/endpoint-match.js +295 -42
- package/dist/src/architecture/endpoint-match.js.map +1 -1
- package/dist/src/architecture/git-facts.d.ts +54 -0
- package/dist/src/architecture/git-facts.d.ts.map +1 -0
- package/dist/src/architecture/git-facts.js +225 -0
- package/dist/src/architecture/git-facts.js.map +1 -0
- package/dist/src/architecture/html-client.d.ts +9 -0
- package/dist/src/architecture/html-client.d.ts.map +1 -1
- package/dist/src/architecture/html-client.js +397 -40
- package/dist/src/architecture/html-client.js.map +1 -1
- package/dist/src/architecture/html-renderer.d.ts +2 -0
- package/dist/src/architecture/html-renderer.d.ts.map +1 -1
- package/dist/src/architecture/html-renderer.js +230 -24
- package/dist/src/architecture/html-renderer.js.map +1 -1
- package/dist/src/architecture/html-theme.d.ts +17 -10
- package/dist/src/architecture/html-theme.d.ts.map +1 -1
- package/dist/src/architecture/html-theme.js +271 -137
- package/dist/src/architecture/html-theme.js.map +1 -1
- package/dist/src/architecture/index.d.ts +3 -0
- package/dist/src/architecture/index.d.ts.map +1 -1
- package/dist/src/architecture/index.js +3 -0
- package/dist/src/architecture/index.js.map +1 -1
- package/dist/src/architecture/ir-schema.d.ts +296 -264
- package/dist/src/architecture/ir-schema.d.ts.map +1 -1
- package/dist/src/architecture/ir-schema.js +75 -0
- package/dist/src/architecture/ir-schema.js.map +1 -1
- package/dist/src/architecture/layout-tuning.d.ts +49 -0
- package/dist/src/architecture/layout-tuning.d.ts.map +1 -0
- package/dist/src/architecture/layout-tuning.js +51 -0
- package/dist/src/architecture/layout-tuning.js.map +1 -0
- package/dist/src/architecture/layout.d.ts +35 -3
- package/dist/src/architecture/layout.d.ts.map +1 -1
- package/dist/src/architecture/layout.js +75 -15
- package/dist/src/architecture/layout.js.map +1 -1
- package/dist/src/architecture/live-ask.d.ts +35 -0
- package/dist/src/architecture/live-ask.d.ts.map +1 -0
- package/dist/src/architecture/live-ask.js +69 -0
- package/dist/src/architecture/live-ask.js.map +1 -0
- package/dist/src/architecture/live-client.d.ts +17 -0
- package/dist/src/architecture/live-client.d.ts.map +1 -0
- package/dist/src/architecture/live-client.js +272 -0
- package/dist/src/architecture/live-client.js.map +1 -0
- package/dist/src/architecture/live-port.d.ts +17 -0
- package/dist/src/architecture/live-port.d.ts.map +1 -0
- package/dist/src/architecture/live-port.js +23 -0
- package/dist/src/architecture/live-port.js.map +1 -0
- package/dist/src/architecture/live-server.d.ts +79 -0
- package/dist/src/architecture/live-server.d.ts.map +1 -0
- package/dist/src/architecture/live-server.js +409 -0
- package/dist/src/architecture/live-server.js.map +1 -0
- package/dist/src/architecture/live-session.d.ts +13 -0
- package/dist/src/architecture/live-session.d.ts.map +1 -0
- package/dist/src/architecture/live-session.js +48 -0
- package/dist/src/architecture/live-session.js.map +1 -0
- package/dist/src/architecture/merge.d.ts +17 -0
- package/dist/src/architecture/merge.d.ts.map +1 -1
- package/dist/src/architecture/merge.js +27 -3
- package/dist/src/architecture/merge.js.map +1 -1
- package/dist/src/architecture/packs/generic.d.ts +2 -2
- package/dist/src/architecture/packs/generic.js +2 -2
- package/dist/src/architecture/packs/generic.js.map +1 -1
- package/dist/src/architecture/packs/index.d.ts +2 -2
- package/dist/src/architecture/repo-visibility.d.ts +32 -0
- package/dist/src/architecture/repo-visibility.d.ts.map +1 -0
- package/dist/src/architecture/repo-visibility.js +93 -0
- package/dist/src/architecture/repo-visibility.js.map +1 -0
- package/dist/src/architecture/secret-mask.d.ts +61 -0
- package/dist/src/architecture/secret-mask.d.ts.map +1 -0
- package/dist/src/architecture/secret-mask.js +618 -0
- package/dist/src/architecture/secret-mask.js.map +1 -0
- package/dist/src/architecture/store.d.ts +88 -6
- package/dist/src/architecture/store.d.ts.map +1 -1
- package/dist/src/architecture/store.js +419 -50
- package/dist/src/architecture/store.js.map +1 -1
- package/dist/src/architecture/types.d.ts +8 -0
- package/dist/src/architecture/types.d.ts.map +1 -1
- package/dist/src/architecture/types.js.map +1 -1
- package/dist/src/architecture/validator.d.ts +75 -3
- package/dist/src/architecture/validator.d.ts.map +1 -1
- package/dist/src/architecture/validator.js +318 -45
- package/dist/src/architecture/validator.js.map +1 -1
- package/dist/src/digest/blocks.d.ts +14 -14
- package/dist/src/digest/diagram-schema.d.ts +2 -2
- package/dist/src/digest/lens-schema.d.ts +38 -38
- package/dist/src/digest/lens-source.d.ts +2 -2
- package/dist/src/digest/lens-widget-schema.d.ts +58 -58
- package/dist/src/digest/lint-lens-context.d.ts +8 -8
- package/dist/src/digest/prd-guide.d.ts +1 -1
- package/dist/src/digest/prd-schema.d.ts +18 -18
- package/dist/src/digest/schema.d.ts +1046 -1046
- package/dist/src/digest/session-request.d.ts +2 -2
- package/dist/src/lens/attach.d.ts +42 -42
- package/dist/src/mcp/schemas.d.ts +16 -8
- package/dist/src/mcp/schemas.d.ts.map +1 -1
- package/dist/src/mcp/schemas.js +11 -2
- package/dist/src/mcp/schemas.js.map +1 -1
- package/dist/src/mcp/tools/architecture-passthrough.d.ts +18 -0
- package/dist/src/mcp/tools/architecture-passthrough.d.ts.map +1 -1
- package/dist/src/mcp/tools/architecture-passthrough.js +244 -33
- package/dist/src/mcp/tools/architecture-passthrough.js.map +1 -1
- package/dist/src/research/schema.d.ts +395 -395
- package/dist/src/research/source-schema.d.ts +5 -5
- package/dist/src/research/target.d.ts +37 -37
- package/package.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/mcp.json +1 -1
- package/plugin/skills/architecture/SKILL.md +103 -16
- package/plugin/skills/architecture/references/domain-flow.md +1 -1
- package/plugin/skills/architecture/references/merge-analyses.md +4 -3
- package/plugin/skills/architecture/references/rerun.md +5 -5
- package/schemas/architecture-ir.schema.json +18 -1
|
@@ -4,6 +4,8 @@ import { dirname, join } from 'node:path';
|
|
|
4
4
|
import { readJsonOrQuarantine, writeJsonAtomic } from '../core/json-file.js';
|
|
5
5
|
import { deriveBlueprint } from './blueprint-layout.js';
|
|
6
6
|
import { parseArchitectureIr } from './ir-schema.js';
|
|
7
|
+
import { maskIrSecrets } from './secret-mask.js';
|
|
8
|
+
import { FLOW_REF_KINDS, hasCardDescription, } from './types.js';
|
|
7
9
|
import { erNonTableParticipants, flowHasNothingToDraw, idCarriesCloudId, stripPrivateExcerpts, } from './validator.js';
|
|
8
10
|
/** `<repoRoot>/.gestalt/architecture/` 아래 뷰별 IR과 HTML을 읽고 쓴다 */
|
|
9
11
|
export class ArchitectureStore {
|
|
@@ -25,10 +27,20 @@ export class ArchitectureStore {
|
|
|
25
27
|
const parsed = parseArchitectureIr(raw);
|
|
26
28
|
return parsed.ok ? parsed.value : null;
|
|
27
29
|
}
|
|
28
|
-
/**
|
|
30
|
+
/** load와 같지만 깨졌거나 스키마에 안 맞아도 파일을 옮기지 않고 null만 돌려준다. 라이브 서버의 질문 확인처럼 읽기만 하는 자리에서 쓴다 */
|
|
31
|
+
peek(view) {
|
|
32
|
+
const raw = readJsonOrQuarantine(this.irPath(view), (value) => parseArchitectureIr(value).ok, {
|
|
33
|
+
quarantine: false,
|
|
34
|
+
});
|
|
35
|
+
if (raw === undefined)
|
|
36
|
+
return null;
|
|
37
|
+
const parsed = parseArchitectureIr(raw);
|
|
38
|
+
return parsed.ok ? parsed.value : null;
|
|
39
|
+
}
|
|
40
|
+
/** private 근거의 excerpt와 글자 칸의 비밀값은 디스크에 남기지 않는다. 저장한 경로를 돌려준다 */
|
|
29
41
|
save(ir) {
|
|
30
42
|
const path = this.irPath(ir.view);
|
|
31
|
-
writeJsonAtomic(path,
|
|
43
|
+
writeJsonAtomic(path, forDisk(ir));
|
|
32
44
|
return path;
|
|
33
45
|
}
|
|
34
46
|
viewPath(view, projectionId) {
|
|
@@ -40,7 +52,7 @@ export class ArchitectureStore {
|
|
|
40
52
|
* 이번 IR에 없는 같은 그림의 옛 파일은 지운다. 저장한 경로를 돌려준다
|
|
41
53
|
*/
|
|
42
54
|
saveViews(ir) {
|
|
43
|
-
const stripped =
|
|
55
|
+
const stripped = forDisk(ir);
|
|
44
56
|
const paths = (stripped.projections ?? []).map((pr) => {
|
|
45
57
|
const path = this.viewPath(ir.view, pr.id);
|
|
46
58
|
writeJsonAtomic(path, projectionSlice(stripped, pr));
|
|
@@ -74,6 +86,9 @@ export class ArchitectureStore {
|
|
|
74
86
|
return path;
|
|
75
87
|
}
|
|
76
88
|
}
|
|
89
|
+
function forDisk(ir) {
|
|
90
|
+
return maskIrSecrets(stripPrivateExcerpts(ir)).ir;
|
|
91
|
+
}
|
|
77
92
|
/** blueprint 칸에 선 노드와 칸을 채우려 따라간 엣지. 저장 시점엔 검증 결과가 없어 근거가 있는 엣지와 모든 노드를 그릴 수 있다고 본다 */
|
|
78
93
|
function blueprintChain(ir, flow) {
|
|
79
94
|
const model = deriveBlueprint(flow, {
|
|
@@ -135,7 +150,7 @@ function projectionSlice(ir, pr) {
|
|
|
135
150
|
};
|
|
136
151
|
}
|
|
137
152
|
// 브라우저가 열어둔 HTML을 새로고침할 때 반쯤 쓰인 파일을 보지 않게 json과 같은 방식으로 갈아 끼운다
|
|
138
|
-
function writeTextAtomic(path, content) {
|
|
153
|
+
export function writeTextAtomic(path, content) {
|
|
139
154
|
mkdirSync(dirname(path), { recursive: true });
|
|
140
155
|
const tmp = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
141
156
|
writeFileSync(tmp, content, 'utf-8');
|
|
@@ -154,12 +169,54 @@ function writeTextAtomic(path, content) {
|
|
|
154
169
|
}
|
|
155
170
|
/** 같은 노드를 알아보는 키. 재실행 병합과 분석 합치기가 같은 기준을 쓴다 */
|
|
156
171
|
export function nodeKey(node) {
|
|
157
|
-
const label = node.label
|
|
172
|
+
const label = normalizeLabel(node.label);
|
|
158
173
|
// 호스트 분석은 리모트를 자기 레포 노드로 적고 리모트 분석은 리모트 레포로 적는다. Module Federation 이름은 런타임에서 하나라 레포를 빼야 둘이 만난다
|
|
159
174
|
if (node.kind === 'micro_app')
|
|
160
175
|
return `${node.kind}\u0000\u0000${label}`;
|
|
161
176
|
return `${node.kind}\u0000${node.repo}\u0000${label}`;
|
|
162
177
|
}
|
|
178
|
+
function normalizeLabel(label) {
|
|
179
|
+
return label.trim().replace(/\s+/g, ' ').toLowerCase();
|
|
180
|
+
}
|
|
181
|
+
/** nodeKey에서 label만 뺀 자리. 2차 매칭은 이 자리 안에서만 짝을 찾는다 */
|
|
182
|
+
function slotKey(node) {
|
|
183
|
+
return node.kind === 'micro_app' ? `${node.kind}\u0000` : `${node.kind}\u0000${node.repo}`;
|
|
184
|
+
}
|
|
185
|
+
function keyText(node) {
|
|
186
|
+
return `${node.kind}/${node.kind === 'micro_app' ? '*' : node.repo}/${normalizeLabel(node.label)}`;
|
|
187
|
+
}
|
|
188
|
+
function codeFiles(node) {
|
|
189
|
+
return new Set(node.evidence
|
|
190
|
+
.filter((ev) => ev.type === 'code')
|
|
191
|
+
.map((ev) => ev.location.replace(/:\d+(?:-\d+)?$/, '')));
|
|
192
|
+
}
|
|
193
|
+
// 라우터 파일 하나에 화면 여럿이 걸리듯 같은 자리의 다른 노드도 근거로 댄 파일은 그 노드만의 표지가 아니다.
|
|
194
|
+
// 이런 파일로 짝을 지으면 지운 화면의 id와 답이 새 화면으로 넘어간다
|
|
195
|
+
function sharedCodeFiles(ir) {
|
|
196
|
+
const count = new Map();
|
|
197
|
+
for (const node of ir.nodes) {
|
|
198
|
+
for (const file of codeFiles(node)) {
|
|
199
|
+
const key = `${slotKey(node)}\u0001${file}`;
|
|
200
|
+
count.set(key, (count.get(key) ?? 0) + 1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return new Set([...count].flatMap(([key, n]) => (n > 1 ? [key] : [])));
|
|
204
|
+
}
|
|
205
|
+
// 줄 번호는 코드가 조금만 밀려도 바뀐다. 같은 노드인지는 어느 파일을 근거로 댔는지로 본다
|
|
206
|
+
function codeFileSignature(node, shared) {
|
|
207
|
+
const slot = slotKey(node);
|
|
208
|
+
const files = [...codeFiles(node)].filter((file) => !shared.has(`${slot}\u0001${file}`));
|
|
209
|
+
if (files.length === 0)
|
|
210
|
+
return undefined;
|
|
211
|
+
return files.sort().join('\n');
|
|
212
|
+
}
|
|
213
|
+
function evidenceOverlapOf(prevNode, node) {
|
|
214
|
+
const prevFiles = codeFiles(prevNode);
|
|
215
|
+
const files = codeFiles(node);
|
|
216
|
+
if (prevFiles.size === 0 || files.size === 0)
|
|
217
|
+
return {};
|
|
218
|
+
return { evidenceOverlap: [...files].some((file) => prevFiles.has(file)) };
|
|
219
|
+
}
|
|
163
220
|
function edgeKey(edge) {
|
|
164
221
|
return `${edge.from}\u0000${edge.to}\u0000${edge.kind}`;
|
|
165
222
|
}
|
|
@@ -168,55 +225,152 @@ function isAnswered(q) {
|
|
|
168
225
|
}
|
|
169
226
|
/**
|
|
170
227
|
* 재실행 IR(next)이 이전 IR(prev)의 id를 물려받게 맞춘다.
|
|
228
|
+
* 입력은 바꾸지 않는다. 무엇을 이어받았는지 알릴 필요가 없으면 이 함수를, 알려야 하면 mergeWithPreviousDetailed를 쓴다.
|
|
229
|
+
*/
|
|
230
|
+
export function mergeWithPrevious(prev, next, options = {}) {
|
|
231
|
+
return mergeWithPreviousDetailed(prev, next, options).ir;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 재실행 IR(next)이 이전 IR(prev)의 id를 물려받게 맞추고 무엇을 이어받았는지 함께 돌려준다.
|
|
171
235
|
*
|
|
172
236
|
* 생성할 때마다 id가 새로 매겨지면 사람이 단 답이나 화면 위치 기억이 전부 끊긴다.
|
|
173
|
-
* 노드는 kind, repo, 정규화한 label이 같으면 같은 것으로
|
|
174
|
-
*
|
|
175
|
-
*
|
|
237
|
+
* 노드는 kind, repo, 정규화한 label이 같으면 같은 것으로 본다. 이걸로 못 찾으면 같은 kind와 repo 자리 안에서
|
|
238
|
+
* 같은 id가 있는지, 그다음 code 근거 파일 집합이 1:1로 하나뿐인 짝이 있는지 본다. label만 바꿔 쓴 노드를 놓치지 않으려고다.
|
|
239
|
+
* 엣지는 바뀐 노드 id 기준 (from, to, kind)가 같으면 같은 것으로 본다. next의 다른 id와 부딪히면 바꾸지 않는다.
|
|
240
|
+
* 짝지은 노드의 description과 summary, IR 최상위 summary와 note가 next에 없으면 prev 것을 잇는다.
|
|
241
|
+
* 빈 문자열은 지운 것이라 그대로 둔다.
|
|
242
|
+
* prev에서 답이 달린 질문과 이번에 안 나온 흐름, 투영은 가리키는 대상이 merge 결과에 남아 있을 때만 이어 붙인다.
|
|
176
243
|
* 입력은 바꾸지 않는다.
|
|
177
244
|
*/
|
|
178
|
-
export function
|
|
179
|
-
const
|
|
245
|
+
export function mergeWithPreviousDetailed(prev, next, options = {}) {
|
|
246
|
+
const prevNodeByKey = new Map();
|
|
180
247
|
for (const node of prev.nodes) {
|
|
181
248
|
const key = nodeKey(node);
|
|
182
|
-
if (!
|
|
183
|
-
|
|
249
|
+
if (!prevNodeByKey.has(key))
|
|
250
|
+
prevNodeByKey.set(key, node);
|
|
184
251
|
}
|
|
185
252
|
const nodeIdMap = new Map();
|
|
253
|
+
const mapNodeId = (id) => nodeIdMap.get(id) ?? id;
|
|
186
254
|
// 비워진 옛 id를 다시 쓰지 않는다. 연쇄로 바꾸다 보면 한 바퀴 돌아 id가 겹칠 수 있다
|
|
187
255
|
const takenNodeIds = new Set(next.nodes.map((n) => n.id));
|
|
256
|
+
// next 노드 자리 번호 → 짝지은 prev 노드. id를 못 물려받아도 같은 노드로 본 짝은 남겨 description을 잇는다
|
|
257
|
+
const pairOf = new Map();
|
|
258
|
+
const usedPrev = new Set();
|
|
259
|
+
const relabeled = [];
|
|
260
|
+
const link = (index, prevNode) => {
|
|
261
|
+
const node = next.nodes[index];
|
|
262
|
+
pairOf.set(index, prevNode);
|
|
263
|
+
usedPrev.add(prevNode);
|
|
264
|
+
const prevId = prevNode.id;
|
|
265
|
+
if (prevId === node.id || takenNodeIds.has(prevId) || nodeIdMap.has(node.id))
|
|
266
|
+
return;
|
|
267
|
+
// 지난 실행이 계정 ID나 배포 ID를 id에 박았으면 물려받지 않는다. 지금 검증기가 그런 id를 거부한다
|
|
268
|
+
if (idCarriesCloudId(prevId, node.kind))
|
|
269
|
+
return;
|
|
270
|
+
takenNodeIds.add(prevId);
|
|
271
|
+
nodeIdMap.set(node.id, prevId);
|
|
272
|
+
};
|
|
273
|
+
const relink = (index, prevNode, matchedBy) => {
|
|
274
|
+
link(index, prevNode);
|
|
275
|
+
const node = next.nodes[index];
|
|
276
|
+
if (prevNode.label !== node.label) {
|
|
277
|
+
relabeled.push({
|
|
278
|
+
id: mapNodeId(node.id),
|
|
279
|
+
previousLabel: prevNode.label,
|
|
280
|
+
label: node.label,
|
|
281
|
+
matchedBy,
|
|
282
|
+
...(matchedBy === 'id' ? evidenceOverlapOf(prevNode, node) : {}),
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
188
286
|
const claimedKeys = new Set();
|
|
189
|
-
|
|
287
|
+
next.nodes.forEach((node, i) => {
|
|
190
288
|
const key = nodeKey(node);
|
|
191
289
|
if (claimedKeys.has(key))
|
|
192
|
-
|
|
290
|
+
return;
|
|
193
291
|
claimedKeys.add(key);
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
292
|
+
const prevNode = prevNodeByKey.get(key);
|
|
293
|
+
if (prevNode !== undefined)
|
|
294
|
+
link(i, prevNode);
|
|
295
|
+
});
|
|
296
|
+
const prevNodeById = new Map();
|
|
297
|
+
for (const node of prev.nodes)
|
|
298
|
+
if (!prevNodeById.has(node.id))
|
|
299
|
+
prevNodeById.set(node.id, node);
|
|
300
|
+
next.nodes.forEach((node, i) => {
|
|
301
|
+
if (pairOf.has(i))
|
|
302
|
+
return;
|
|
303
|
+
const prevNode = prevNodeById.get(node.id);
|
|
304
|
+
if (prevNode === undefined || usedPrev.has(prevNode))
|
|
305
|
+
return;
|
|
306
|
+
if (slotKey(prevNode) !== slotKey(node))
|
|
307
|
+
return;
|
|
308
|
+
relink(i, prevNode, 'id');
|
|
309
|
+
});
|
|
310
|
+
// 근거 파일이 같은 후보가 어느 쪽이든 둘 이상이면 어느 것이 어느 것인지 모른다. 잘못 이으면 답이 엉뚱한 노드에 붙어 잇지 않는다
|
|
311
|
+
const prevShared = sharedCodeFiles(prev);
|
|
312
|
+
const nextShared = sharedCodeFiles(next);
|
|
313
|
+
const bucketOf = (node, shared) => {
|
|
314
|
+
const signature = codeFileSignature(node, shared);
|
|
315
|
+
return signature === undefined ? undefined : `${slotKey(node)}\u0001${signature}`;
|
|
316
|
+
};
|
|
317
|
+
const nextBuckets = new Map();
|
|
318
|
+
next.nodes.forEach((node, i) => {
|
|
319
|
+
if (pairOf.has(i))
|
|
320
|
+
return;
|
|
321
|
+
const bucket = bucketOf(node, nextShared);
|
|
322
|
+
if (bucket === undefined)
|
|
323
|
+
return;
|
|
324
|
+
nextBuckets.set(bucket, [...(nextBuckets.get(bucket) ?? []), i]);
|
|
325
|
+
});
|
|
326
|
+
const prevBuckets = new Map();
|
|
327
|
+
for (const node of prev.nodes) {
|
|
328
|
+
if (usedPrev.has(node))
|
|
196
329
|
continue;
|
|
197
|
-
|
|
330
|
+
const bucket = bucketOf(node, prevShared);
|
|
331
|
+
if (bucket === undefined)
|
|
198
332
|
continue;
|
|
199
|
-
|
|
200
|
-
|
|
333
|
+
prevBuckets.set(bucket, [...(prevBuckets.get(bucket) ?? []), node]);
|
|
334
|
+
}
|
|
335
|
+
for (const [bucket, indexes] of nextBuckets) {
|
|
336
|
+
const prevNodes = prevBuckets.get(bucket);
|
|
337
|
+
if (indexes.length !== 1 || prevNodes?.length !== 1)
|
|
201
338
|
continue;
|
|
202
|
-
|
|
203
|
-
nodeIdMap.set(node.id, prevId);
|
|
339
|
+
relink(indexes[0], prevNodes[0], 'evidence');
|
|
204
340
|
}
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
341
|
+
const descriptionCarried = [];
|
|
342
|
+
const summaryCarried = [];
|
|
343
|
+
const nodes = next.nodes.map((n, i) => {
|
|
344
|
+
const prevNode = pairOf.get(i);
|
|
345
|
+
const carryDescription = prevNode !== undefined &&
|
|
346
|
+
n.description === undefined &&
|
|
347
|
+
hasCardDescription(prevNode.description);
|
|
348
|
+
if (carryDescription)
|
|
349
|
+
descriptionCarried.push(mapNodeId(n.id));
|
|
350
|
+
const carrySummary = prevNode !== undefined && n.summary === undefined && hasCardDescription(prevNode.summary);
|
|
351
|
+
if (carrySummary)
|
|
352
|
+
summaryCarried.push(mapNodeId(n.id));
|
|
353
|
+
return {
|
|
354
|
+
...n,
|
|
355
|
+
id: mapNodeId(n.id),
|
|
356
|
+
...(carryDescription ? { description: prevNode.description } : {}),
|
|
357
|
+
...(carrySummary ? { summary: prevNode.summary } : {}),
|
|
358
|
+
...(n.parent !== undefined ? { parent: mapNodeId(n.parent) } : {}),
|
|
359
|
+
...(n.account !== undefined ? { account: mapNodeId(n.account) } : {}),
|
|
360
|
+
...(n.placedIn !== undefined ? { placedIn: mapNodeId(n.placedIn) } : {}),
|
|
361
|
+
...(n.columns !== undefined
|
|
362
|
+
? {
|
|
363
|
+
columns: n.columns.map((c) => c.references !== undefined
|
|
364
|
+
? { ...c, references: { ...c.references, table: mapNodeId(c.references.table) } }
|
|
365
|
+
: { ...c }),
|
|
366
|
+
}
|
|
367
|
+
: {}),
|
|
368
|
+
};
|
|
369
|
+
});
|
|
370
|
+
const warnings = [
|
|
371
|
+
...lostLabelWarnings(prev, next, pairOf, usedPrev, mapNodeId),
|
|
372
|
+
...duplicateKeyWarnings(next, prevNodeByKey, mapNodeId),
|
|
373
|
+
];
|
|
220
374
|
const prevEdgeIdByKey = new Map();
|
|
221
375
|
for (const edge of prev.edges) {
|
|
222
376
|
const key = edgeKey(edge);
|
|
@@ -256,12 +410,27 @@ export function mergeWithPrevious(prev, next) {
|
|
|
256
410
|
...(q.subject.edgeId !== undefined ? { edgeId: mapEdgeId(q.subject.edgeId) } : {}),
|
|
257
411
|
},
|
|
258
412
|
}));
|
|
259
|
-
|
|
260
|
-
|
|
413
|
+
const nodeKindById = new Map(nodes.map((n) => [n.id, n.kind]));
|
|
414
|
+
// 지난 흐름과 투영, 질문은 지난 노드 id로 적혀 있다. 짝지은 노드의 이번 id로 옮긴다.
|
|
415
|
+
// 짝을 못 찾은 지난 노드는 null이다. 그 id를 이번 IR의 다른 노드가 쓰고 있어도 같은 노드가 아니라서다
|
|
416
|
+
const finalIdOfPrev = new Map();
|
|
417
|
+
for (const node of prev.nodes)
|
|
418
|
+
finalIdOfPrev.set(node.id, null);
|
|
419
|
+
for (const [i, prevNode] of pairOf)
|
|
420
|
+
finalIdOfPrev.set(prevNode.id, mapNodeId(next.nodes[i].id));
|
|
421
|
+
const resolvePrevNodeId = (id) => finalIdOfPrev.get(id) ?? null;
|
|
422
|
+
// 노드 id가 바뀌었으면 이번 흐름이 가리키는 쪽만 따라 바꾼다
|
|
423
|
+
const nextFlows = next.flows?.map((f) => ({
|
|
261
424
|
...f,
|
|
262
425
|
...(f.service !== undefined ? { service: mapNodeId(f.service) } : {}),
|
|
263
426
|
steps: f.steps.map((st) => st.refs !== undefined ? { ...st, refs: st.refs.map(mapNodeId) } : { ...st }),
|
|
264
427
|
}));
|
|
428
|
+
// 질문 하나에 맞춰 돈 실행은 다른 흐름을 안 적는다. 이번에 안 나온 지난 흐름은 가리키는 노드가 다 살아 있을 때만 이어 싣는다
|
|
429
|
+
const { carried: carriedFlows, dropped: droppedFlows } = carryFlows(prev.flows ?? [], nextFlows ?? [], nodeKindById, resolvePrevNodeId, options.evidenceOk);
|
|
430
|
+
warnings.push(...droppedFlows.map(flowDroppedWarning));
|
|
431
|
+
const flows = nextFlows !== undefined || carriedFlows.length > 0
|
|
432
|
+
? [...(nextFlows ?? []), ...carriedFlows]
|
|
433
|
+
: undefined;
|
|
265
434
|
const projections = next.projections?.map((pr) => ({
|
|
266
435
|
...pr,
|
|
267
436
|
...(pr.participants !== undefined ? { participants: pr.participants.map(mapNodeId) } : {}),
|
|
@@ -275,12 +444,12 @@ export function mergeWithPrevious(prev, next) {
|
|
|
275
444
|
...(m.edge !== undefined ? { edge: mapEdgeId(m.edge) } : {}),
|
|
276
445
|
})),
|
|
277
446
|
}));
|
|
278
|
-
const nodeKindById = new Map(nodes.map((n) => [n.id, n.kind]));
|
|
279
447
|
const nodeIds = new Set(nodeKindById.keys());
|
|
280
448
|
const edgeIds = new Set(edges.map((e) => e.id));
|
|
281
449
|
const edgeById = new Map(edges.map((e) => [e.id, e]));
|
|
282
450
|
// 질문 하나에 답한 그림은 다음 실행이 다른 질문을 물어도 남아야 한다. 이번에 안 나온 지난 투영은 가리키는 것이 다 살아 있을 때만 이어 싣는다
|
|
283
|
-
const carried = carryProjections(prev.projections ?? [], projections ?? [], nodeKindById, edgeById, new Map(flows?.map((f) => [f.id, f]) ?? []));
|
|
451
|
+
const { carried, dropped: droppedProjections } = carryProjections(prev.projections ?? [], projections ?? [], nodeKindById, edgeById, new Map(flows?.map((f) => [f.id, f]) ?? []), resolvePrevNodeId, options.evidenceOk);
|
|
452
|
+
warnings.push(...droppedProjections.map(projectionDroppedWarning));
|
|
284
453
|
const allProjections = projections !== undefined || carried.length > 0
|
|
285
454
|
? [...(projections ?? []), ...carried]
|
|
286
455
|
: undefined;
|
|
@@ -293,10 +462,15 @@ export function mergeWithPrevious(prev, next) {
|
|
|
293
462
|
a.subject.stepId === b.subject.stepId &&
|
|
294
463
|
a.subject.transitionId === b.subject.transitionId &&
|
|
295
464
|
a.subject.messageId === b.subject.messageId;
|
|
296
|
-
for (const
|
|
297
|
-
if (!isAnswered(
|
|
465
|
+
for (const answeredQ of prev.unresolved) {
|
|
466
|
+
if (!isAnswered(answeredQ))
|
|
467
|
+
continue;
|
|
468
|
+
const { edgeId, stepId, transitionId, messageId } = answeredQ.subject;
|
|
469
|
+
const nodeId = answeredQ.subject.nodeId !== undefined
|
|
470
|
+
? resolvePrevNodeId(answeredQ.subject.nodeId)
|
|
471
|
+
: undefined;
|
|
472
|
+
if (nodeId === null)
|
|
298
473
|
continue;
|
|
299
|
-
const { nodeId, edgeId, stepId, transitionId, messageId } = prevQ.subject;
|
|
300
474
|
if (nodeId !== undefined && !nodeIds.has(nodeId))
|
|
301
475
|
continue;
|
|
302
476
|
if (edgeId !== undefined && !edgeIds.has(edgeId))
|
|
@@ -307,6 +481,9 @@ export function mergeWithPrevious(prev, next) {
|
|
|
307
481
|
continue;
|
|
308
482
|
if (messageId !== undefined && !messageIds.has(messageId))
|
|
309
483
|
continue;
|
|
484
|
+
const prevQ = nodeId !== undefined
|
|
485
|
+
? { ...answeredQ, subject: { ...answeredQ.subject, nodeId } }
|
|
486
|
+
: answeredQ;
|
|
310
487
|
// 같은 대상에 같은 질문을 다시 물었으면 새로 추가하지 않고 답만 옮긴다
|
|
311
488
|
const twin = unresolved.find((q) => sameSubject(q, prevQ) && q.question.trim() === prevQ.question.trim());
|
|
312
489
|
if (twin) {
|
|
@@ -320,8 +497,17 @@ export function mergeWithPrevious(prev, next) {
|
|
|
320
497
|
questionIds.add(id);
|
|
321
498
|
unresolved.push({ ...prevQ, id, subject: { ...prevQ.subject } });
|
|
322
499
|
}
|
|
323
|
-
|
|
500
|
+
const topLevelCarried = [];
|
|
501
|
+
const topLevel = {};
|
|
502
|
+
for (const field of ['summary', 'note']) {
|
|
503
|
+
if (next[field] !== undefined || !hasCardDescription(prev[field]))
|
|
504
|
+
continue;
|
|
505
|
+
topLevel[field] = prev[field];
|
|
506
|
+
topLevelCarried.push(field);
|
|
507
|
+
}
|
|
508
|
+
const ir = {
|
|
324
509
|
...next,
|
|
510
|
+
...topLevel,
|
|
325
511
|
nodes,
|
|
326
512
|
edges,
|
|
327
513
|
unresolved,
|
|
@@ -337,17 +523,195 @@ export function mergeWithPrevious(prev, next) {
|
|
|
337
523
|
}
|
|
338
524
|
: {}),
|
|
339
525
|
};
|
|
526
|
+
return {
|
|
527
|
+
ir,
|
|
528
|
+
report: {
|
|
529
|
+
descriptionCarried,
|
|
530
|
+
summaryCarried,
|
|
531
|
+
topLevelCarried,
|
|
532
|
+
relabeled,
|
|
533
|
+
flowsCarried: carriedFlows.map((f) => f.id),
|
|
534
|
+
flowsDropped: droppedFlows.map((d) => d.flowId),
|
|
535
|
+
projectionsDropped: droppedProjections,
|
|
536
|
+
warnings,
|
|
537
|
+
},
|
|
538
|
+
};
|
|
340
539
|
}
|
|
341
|
-
|
|
342
|
-
function
|
|
540
|
+
// 끝까지 짝을 못 찾은 지난 노드에 사람이 남긴 것(답, 설명, 요약)이 있고 같은 자리에 새 노드가 생겼으면 label과 id를 함께 바꿔 끊겼을 가능성이 크다
|
|
541
|
+
function lostLabelWarnings(prev, next, pairOf, usedPrev, mapNodeId) {
|
|
542
|
+
const answeredNodeIds = new Set(prev.unresolved.flatMap((q) => isAnswered(q) && q.subject.nodeId !== undefined ? [q.subject.nodeId] : []));
|
|
543
|
+
const warnings = [];
|
|
544
|
+
for (const prevNode of prev.nodes) {
|
|
545
|
+
if (usedPrev.has(prevNode))
|
|
546
|
+
continue;
|
|
547
|
+
if (!answeredNodeIds.has(prevNode.id) &&
|
|
548
|
+
!hasCardDescription(prevNode.description) &&
|
|
549
|
+
!hasCardDescription(prevNode.summary))
|
|
550
|
+
continue;
|
|
551
|
+
const slot = slotKey(prevNode);
|
|
552
|
+
const candidates = next.nodes.flatMap((n, i) => !pairOf.has(i) && slotKey(n) === slot ? [mapNodeId(n.id)] : []);
|
|
553
|
+
if (candidates.length === 0)
|
|
554
|
+
continue;
|
|
555
|
+
warnings.push({
|
|
556
|
+
code: 'LABEL_CHANGED_ID_LOST',
|
|
557
|
+
previousId: prevNode.id,
|
|
558
|
+
previousLabel: prevNode.label,
|
|
559
|
+
kind: prevNode.kind,
|
|
560
|
+
repo: prevNode.repo,
|
|
561
|
+
candidates,
|
|
562
|
+
message: `지난 실행의 "${prevNode.label}"(${prevNode.id})와 짝을 못 찾아 설명과 요약, 답이 이어지지 않았다. label과 id를 함께 바꿨다면 후보 ${candidates.join(', ')} 중 하나에 지난 id를 다시 쓴다.`,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return warnings;
|
|
566
|
+
}
|
|
567
|
+
// 이번 실행에 같은 키가 여럿이면 첫 노드만 지난 id를 받는다. 순서만 바뀌어도 id가 뒤바뀔 수 있어 알린다
|
|
568
|
+
function duplicateKeyWarnings(next, prevNodeByKey, mapNodeId) {
|
|
569
|
+
const byKey = new Map();
|
|
570
|
+
for (const node of next.nodes) {
|
|
571
|
+
const key = nodeKey(node);
|
|
572
|
+
byKey.set(key, [...(byKey.get(key) ?? []), node]);
|
|
573
|
+
}
|
|
574
|
+
const warnings = [];
|
|
575
|
+
for (const [key, group] of byKey) {
|
|
576
|
+
if (group.length < 2 || !prevNodeByKey.has(key))
|
|
577
|
+
continue;
|
|
578
|
+
const nodeIds = group.map((n) => mapNodeId(n.id));
|
|
579
|
+
const shown = keyText(group[0]);
|
|
580
|
+
warnings.push({
|
|
581
|
+
code: 'MERGE_KEY_DUPLICATE',
|
|
582
|
+
key: shown,
|
|
583
|
+
nodeIds,
|
|
584
|
+
message: `병합 키 ${shown}를 노드 ${nodeIds.join(', ')}가 함께 써서 첫 노드만 지난 id를 받았다. label을 서로 다르게 적는다.`,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return warnings;
|
|
588
|
+
}
|
|
589
|
+
function flowEvidence(flow) {
|
|
590
|
+
return [
|
|
591
|
+
...flow.steps.flatMap((st) => st.evidence),
|
|
592
|
+
...flow.transitions.flatMap((t) => t.evidence),
|
|
593
|
+
];
|
|
594
|
+
}
|
|
595
|
+
// 흐름은 코드에 붙은 노드를 근거로 남는다. 가리키던 노드가 사라지면 그 코드가 없어진 것이라 흐름도 함께 지운다.
|
|
596
|
+
// 노드를 하나도 안 가리키는 흐름은 언제 지울지 판단할 근거가 없어 이어 싣지 않는다
|
|
597
|
+
function carryFlows(prev, next, nodeKindById, resolvePrevNodeId, evidenceOk) {
|
|
598
|
+
const flowIds = new Set(next.map((f) => f.id));
|
|
599
|
+
// 단계와 전이 id는 흐름 전체에서 겹치면 안 된다. 겹치는 지난 흐름은 실으면 검증에서 막힌다
|
|
600
|
+
const stepIds = new Set(next.flatMap((f) => f.steps.map((st) => st.id)));
|
|
601
|
+
const transitionIds = new Set(next.flatMap((f) => f.transitions.map((t) => t.id)));
|
|
602
|
+
const carried = [];
|
|
603
|
+
const dropped = [];
|
|
604
|
+
for (const prevFlow of prev) {
|
|
605
|
+
if (flowIds.has(prevFlow.id))
|
|
606
|
+
continue;
|
|
607
|
+
const refs = prevFlow.steps.flatMap((st) => st.refs ?? []);
|
|
608
|
+
if (prevFlow.service === undefined && refs.length === 0) {
|
|
609
|
+
dropped.push({ flowId: prevFlow.id, reason: 'no_refs', missingNodeIds: [] });
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
const kindOfPrev = (id) => {
|
|
613
|
+
const finalId = resolvePrevNodeId(id);
|
|
614
|
+
return finalId === null ? undefined : nodeKindById.get(finalId);
|
|
615
|
+
};
|
|
616
|
+
const missing = [
|
|
617
|
+
...(prevFlow.service !== undefined && kindOfPrev(prevFlow.service) !== 'service'
|
|
618
|
+
? [prevFlow.service]
|
|
619
|
+
: []),
|
|
620
|
+
...refs.filter((id) => {
|
|
621
|
+
const kind = kindOfPrev(id);
|
|
622
|
+
return kind === undefined || !FLOW_REF_KINDS.includes(kind);
|
|
623
|
+
}),
|
|
624
|
+
];
|
|
625
|
+
if (missing.length > 0) {
|
|
626
|
+
dropped.push({
|
|
627
|
+
flowId: prevFlow.id,
|
|
628
|
+
reason: 'node_gone',
|
|
629
|
+
missingNodeIds: [...new Set(missing)],
|
|
630
|
+
});
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
// 위에서 다 살아 있음을 확인해 null이 나오지 않는다
|
|
634
|
+
const toFinal = (id) => resolvePrevNodeId(id) ?? id;
|
|
635
|
+
const flow = {
|
|
636
|
+
...prevFlow,
|
|
637
|
+
...(prevFlow.service !== undefined ? { service: toFinal(prevFlow.service) } : {}),
|
|
638
|
+
steps: prevFlow.steps.map((st) => st.refs !== undefined ? { ...st, refs: st.refs.map(toFinal) } : st),
|
|
639
|
+
};
|
|
640
|
+
// 지난 흐름은 세션 IR에 없어 근거가 낡아도 고칠 자리가 안 보인다. 실으면 render 전체가 근거 오류로 막힌다
|
|
641
|
+
if (evidenceOk !== undefined && !evidenceOk(flowEvidence(flow))) {
|
|
642
|
+
dropped.push({ flowId: flow.id, reason: 'evidence_stale', missingNodeIds: [] });
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
if (flow.steps.some((st) => stepIds.has(st.id)) ||
|
|
646
|
+
flow.transitions.some((t) => transitionIds.has(t.id))) {
|
|
647
|
+
dropped.push({ flowId: flow.id, reason: 'id_conflict', missingNodeIds: [] });
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
flowIds.add(flow.id);
|
|
651
|
+
for (const st of flow.steps)
|
|
652
|
+
stepIds.add(st.id);
|
|
653
|
+
for (const t of flow.transitions)
|
|
654
|
+
transitionIds.add(t.id);
|
|
655
|
+
carried.push(flow);
|
|
656
|
+
}
|
|
657
|
+
return { carried, dropped };
|
|
658
|
+
}
|
|
659
|
+
function flowDroppedWarning(d) {
|
|
660
|
+
const why = d.reason === 'node_gone'
|
|
661
|
+
? `가리키던 노드 ${d.missingNodeIds.join(', ')}가 이번 IR에 없어`
|
|
662
|
+
: d.reason === 'no_refs'
|
|
663
|
+
? '노드를 하나도 가리키지 않아'
|
|
664
|
+
: d.reason === 'evidence_stale'
|
|
665
|
+
? '단계나 전이의 code 근거가 지금 코드에 없어'
|
|
666
|
+
: '이번 흐름과 단계나 전이 id가 겹쳐';
|
|
667
|
+
return {
|
|
668
|
+
code: 'FLOW_DROPPED',
|
|
669
|
+
flowId: d.flowId,
|
|
670
|
+
reason: d.reason,
|
|
671
|
+
missingNodeIds: d.missingNodeIds,
|
|
672
|
+
message: d.reason === 'evidence_stale'
|
|
673
|
+
? `지난 흐름 ${d.flowId}는 ${why} 이어 싣지 않았다. 아직 필요한 흐름이면 근거를 다시 찾아 이번 IR에 적는다.`
|
|
674
|
+
: `지난 흐름 ${d.flowId}는 ${why} 이어 싣지 않았다. 아직 필요한 흐름이면 이번 IR에 다시 적는다.`,
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
// 메시지에 투영 title이 실리지 않게 id만 쓴다
|
|
678
|
+
function projectionDroppedWarning(projectionId) {
|
|
679
|
+
return {
|
|
680
|
+
code: 'PROJECTION_DROPPED',
|
|
681
|
+
projectionId,
|
|
682
|
+
reason: 'evidence_stale',
|
|
683
|
+
message: `지난 투영 ${projectionId}는 메시지의 code 근거가 지금 코드에 없어 이어 싣지 않았다. 아직 필요한 그림이면 근거를 다시 찾아 이번 IR에 적는다.`,
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
/** 이어 실을 지난 투영과, 근거가 낡아 버린 투영 id. 구조가 깨져 버린 투영은 dropped에 안 싣는다 */
|
|
687
|
+
function carryProjections(prev, next, nodeKindById, edgeById, flowById, resolvePrevNodeId, evidenceOk) {
|
|
343
688
|
const projectionIds = new Set(next.map((pr) => pr.id));
|
|
344
689
|
const messageIds = new Set(next.flatMap((pr) => pr.messages.map((m) => m.id)));
|
|
345
690
|
const out = [];
|
|
346
|
-
|
|
347
|
-
|
|
691
|
+
const dropped = [];
|
|
692
|
+
for (const prevPr of prev) {
|
|
693
|
+
if (projectionIds.has(prevPr.id))
|
|
694
|
+
continue;
|
|
695
|
+
if (prevPr.messages.some((m) => messageIds.has(m.id)))
|
|
348
696
|
continue;
|
|
349
|
-
|
|
697
|
+
const pointed = [
|
|
698
|
+
...(prevPr.participants ?? []),
|
|
699
|
+
...(prevPr.sides ?? []).flatMap((side) => side.nodes),
|
|
700
|
+
...prevPr.messages.flatMap((m) => [m.from, m.to]),
|
|
701
|
+
];
|
|
702
|
+
if (pointed.some((id) => resolvePrevNodeId(id) === null))
|
|
350
703
|
continue;
|
|
704
|
+
const toFinal = (id) => resolvePrevNodeId(id) ?? id;
|
|
705
|
+
const pr = {
|
|
706
|
+
...prevPr,
|
|
707
|
+
...(prevPr.participants !== undefined
|
|
708
|
+
? { participants: prevPr.participants.map(toFinal) }
|
|
709
|
+
: {}),
|
|
710
|
+
...(prevPr.sides !== undefined
|
|
711
|
+
? { sides: prevPr.sides.map((side) => ({ ...side, nodes: side.nodes.map(toFinal) })) }
|
|
712
|
+
: {}),
|
|
713
|
+
messages: prevPr.messages.map((m) => ({ ...m, from: toFinal(m.from), to: toFinal(m.to) })),
|
|
714
|
+
};
|
|
351
715
|
const listed = [...(pr.participants ?? []), ...(pr.sides ?? []).flatMap((side) => side.nodes)];
|
|
352
716
|
if (!listed.every((id) => nodeKindById.has(id)))
|
|
353
717
|
continue;
|
|
@@ -369,13 +733,18 @@ function carryProjections(prev, next, nodeKindById, edgeById, flowById) {
|
|
|
369
733
|
});
|
|
370
734
|
if (!alive)
|
|
371
735
|
continue;
|
|
736
|
+
if (evidenceOk !== undefined && !evidenceOk(pr.messages.flatMap((m) => m.evidence))) {
|
|
737
|
+
dropped.push(pr.id);
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
372
740
|
projectionIds.add(pr.id);
|
|
373
741
|
for (const m of pr.messages)
|
|
374
742
|
messageIds.add(m.id);
|
|
375
743
|
out.push(pr);
|
|
376
744
|
}
|
|
377
|
-
return out;
|
|
745
|
+
return { carried: out, dropped };
|
|
378
746
|
}
|
|
747
|
+
/** 이전 실행을 한 줄로 보여줄 때 쓰는 요약 */
|
|
379
748
|
export function previousRunSummary(prev) {
|
|
380
749
|
return {
|
|
381
750
|
generatedAt: prev.generatedAt,
|