@anarchitects/governance-core 0.0.1
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/README.md +239 -0
- package/dist/core/adapter.d.ts +65 -0
- package/dist/core/adapter.d.ts.map +1 -0
- package/dist/core/ai.d.ts +21 -0
- package/dist/core/ai.d.ts.map +1 -0
- package/dist/core/assessment.d.ts +23 -0
- package/dist/core/assessment.d.ts.map +1 -0
- package/dist/core/built-in-rule-pack.d.ts +5 -0
- package/dist/core/built-in-rule-pack.d.ts.map +1 -0
- package/dist/core/built-in-rules.d.ts +16 -0
- package/dist/core/built-in-rules.d.ts.map +1 -0
- package/dist/core/drift.d.ts +5 -0
- package/dist/core/drift.d.ts.map +1 -0
- package/dist/core/exceptions.d.ts +34 -0
- package/dist/core/exceptions.d.ts.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/models.d.ts +371 -0
- package/dist/core/models.d.ts.map +1 -0
- package/dist/core/profile.d.ts +105 -0
- package/dist/core/profile.d.ts.map +1 -0
- package/dist/core/rule-engine.d.ts +4 -0
- package/dist/core/rule-engine.d.ts.map +1 -0
- package/dist/core/rules.d.ts +37 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/signals.d.ts +21 -0
- package/dist/core/signals.d.ts.map +1 -0
- package/dist/core/snapshots.d.ts +12 -0
- package/dist/core/snapshots.d.ts.map +1 -0
- package/dist/extensions/capabilities.d.ts +15 -0
- package/dist/extensions/capabilities.d.ts.map +1 -0
- package/dist/extensions/contracts.d.ts +50 -0
- package/dist/extensions/contracts.d.ts.map +1 -0
- package/dist/extensions/diagnostics.d.ts +12 -0
- package/dist/extensions/diagnostics.d.ts.map +1 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/runtime.d.ts +50 -0
- package/dist/extensions/runtime.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1587 -0
- package/package.json +52 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1587 @@
|
|
|
1
|
+
function mn(e, n = { projectOverrides: {} }) {
|
|
2
|
+
const t = ae(e), o = se(e);
|
|
3
|
+
return {
|
|
4
|
+
id: e.workspaceId ?? e.workspace?.id ?? "workspace",
|
|
5
|
+
name: e.workspaceName ?? e.workspace?.name ?? "workspace",
|
|
6
|
+
root: e.workspaceRoot ?? e.workspace?.root ?? "",
|
|
7
|
+
projects: t.map((r) => {
|
|
8
|
+
const i = ce(r), a = r.tags ?? [], c = r.metadata ?? {}, s = n.projectOverrides[i] ?? {}, l = s.domain ?? r.domain ?? R(a, "domain") ?? R(a, "scope"), u = s.layer ?? r.layer ?? R(a, "layer"), y = de(c);
|
|
9
|
+
return {
|
|
10
|
+
id: r.id,
|
|
11
|
+
name: i,
|
|
12
|
+
root: r.root ?? "",
|
|
13
|
+
type: le(r.type),
|
|
14
|
+
tags: a,
|
|
15
|
+
domain: l,
|
|
16
|
+
layer: u,
|
|
17
|
+
ownership: pe(
|
|
18
|
+
y,
|
|
19
|
+
s.ownershipTeam,
|
|
20
|
+
r.ownership
|
|
21
|
+
),
|
|
22
|
+
metadata: {
|
|
23
|
+
...c,
|
|
24
|
+
...s.documentation !== void 0 ? { documentation: s.documentation } : {}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
dependencies: o.map((r) => ({
|
|
29
|
+
source: r.sourceProjectId,
|
|
30
|
+
target: r.targetProjectId,
|
|
31
|
+
type: ue(r.type),
|
|
32
|
+
sourceFile: r.sourceFile
|
|
33
|
+
}))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function ae(e) {
|
|
37
|
+
return e.projects ? e.projects : e.workspace ? e.workspace.projects.map((n) => ({
|
|
38
|
+
id: n.id,
|
|
39
|
+
name: n.name,
|
|
40
|
+
root: n.root,
|
|
41
|
+
type: n.type,
|
|
42
|
+
domain: n.domain,
|
|
43
|
+
layer: n.layer,
|
|
44
|
+
tags: n.tags,
|
|
45
|
+
ownership: n.ownership,
|
|
46
|
+
metadata: n.metadata
|
|
47
|
+
})) : [];
|
|
48
|
+
}
|
|
49
|
+
function se(e) {
|
|
50
|
+
return e.dependencies ? e.dependencies : e.workspace ? e.workspace.dependencies.map((n) => ({
|
|
51
|
+
sourceProjectId: n.source,
|
|
52
|
+
targetProjectId: n.target,
|
|
53
|
+
type: n.type,
|
|
54
|
+
sourceFile: n.sourceFile
|
|
55
|
+
})) : [];
|
|
56
|
+
}
|
|
57
|
+
function ce(e) {
|
|
58
|
+
return e.name ?? e.id;
|
|
59
|
+
}
|
|
60
|
+
function R(e, n) {
|
|
61
|
+
return e.find((o) => o.startsWith(`${n}:`))?.split(":").slice(1).join(":");
|
|
62
|
+
}
|
|
63
|
+
function le(e) {
|
|
64
|
+
return e === "application" || e === "app" ? "application" : e === "library" || e === "lib" ? "library" : e === "tool" ? "tool" : "unknown";
|
|
65
|
+
}
|
|
66
|
+
function ue(e) {
|
|
67
|
+
return e === "static" || e === "dynamic" || e === "implicit" ? e : "unknown";
|
|
68
|
+
}
|
|
69
|
+
function de(e) {
|
|
70
|
+
const n = e.ownership;
|
|
71
|
+
if (typeof n == "string" && n)
|
|
72
|
+
return n;
|
|
73
|
+
if (n && typeof n == "object") {
|
|
74
|
+
const t = n.team;
|
|
75
|
+
if (typeof t == "string" && t)
|
|
76
|
+
return t;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function pe(e, n, t) {
|
|
80
|
+
const o = t?.contacts ?? [], r = n ?? e ?? t?.team;
|
|
81
|
+
return r && o.length ? {
|
|
82
|
+
team: r,
|
|
83
|
+
contacts: o,
|
|
84
|
+
source: "merged"
|
|
85
|
+
} : r ? {
|
|
86
|
+
team: r,
|
|
87
|
+
contacts: [],
|
|
88
|
+
source: fe(t?.source)
|
|
89
|
+
} : o.length ? {
|
|
90
|
+
contacts: o,
|
|
91
|
+
source: "codeowners"
|
|
92
|
+
} : {
|
|
93
|
+
source: "none"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function fe(e) {
|
|
97
|
+
return e === "merged" || e === "project-metadata" ? e : e === "codeowners" ? "codeowners" : "project-metadata";
|
|
98
|
+
}
|
|
99
|
+
const M = [
|
|
100
|
+
"graph",
|
|
101
|
+
"conformance",
|
|
102
|
+
"policy",
|
|
103
|
+
"extension"
|
|
104
|
+
], me = [
|
|
105
|
+
"info",
|
|
106
|
+
"warning",
|
|
107
|
+
"error"
|
|
108
|
+
], ye = [
|
|
109
|
+
"structural-dependency",
|
|
110
|
+
"cross-domain-dependency",
|
|
111
|
+
"missing-domain-context",
|
|
112
|
+
"circular-dependency",
|
|
113
|
+
"conformance-violation",
|
|
114
|
+
"domain-boundary-violation",
|
|
115
|
+
"layer-boundary-violation",
|
|
116
|
+
"ownership-gap"
|
|
117
|
+
], ge = [
|
|
118
|
+
"architecture",
|
|
119
|
+
"boundaries",
|
|
120
|
+
"ownership",
|
|
121
|
+
"documentation"
|
|
122
|
+
], A = {
|
|
123
|
+
graph: 0,
|
|
124
|
+
conformance: 1,
|
|
125
|
+
policy: 2,
|
|
126
|
+
extension: 3
|
|
127
|
+
}, b = {
|
|
128
|
+
"structural-dependency": 0,
|
|
129
|
+
"cross-domain-dependency": 1,
|
|
130
|
+
"missing-domain-context": 2,
|
|
131
|
+
"circular-dependency": 3,
|
|
132
|
+
"conformance-violation": 4,
|
|
133
|
+
"domain-boundary-violation": 5,
|
|
134
|
+
"layer-boundary-violation": 6,
|
|
135
|
+
"ownership-gap": 7
|
|
136
|
+
}, q = {
|
|
137
|
+
error: 0,
|
|
138
|
+
warning: 1,
|
|
139
|
+
info: 2
|
|
140
|
+
};
|
|
141
|
+
function yn(e) {
|
|
142
|
+
const n = he(
|
|
143
|
+
e.violations,
|
|
144
|
+
e.reportType
|
|
145
|
+
), t = we(
|
|
146
|
+
e.signals,
|
|
147
|
+
e.reportType
|
|
148
|
+
), o = ve(
|
|
149
|
+
e.measurements,
|
|
150
|
+
e.reportType
|
|
151
|
+
);
|
|
152
|
+
return {
|
|
153
|
+
workspace: e.workspace,
|
|
154
|
+
profile: e.profile,
|
|
155
|
+
warnings: [...e.warnings ?? []],
|
|
156
|
+
exceptions: e.exceptions,
|
|
157
|
+
violations: n,
|
|
158
|
+
measurements: o,
|
|
159
|
+
signalBreakdown: Ie(t),
|
|
160
|
+
metricBreakdown: Pe(o),
|
|
161
|
+
topIssues: Se(t),
|
|
162
|
+
health: e.health,
|
|
163
|
+
recommendations: [...e.recommendations ?? []]
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function he(e, n) {
|
|
167
|
+
return n === "boundaries" ? e.filter((t) => t.category === "boundary") : n === "ownership" ? e.filter((t) => t.category === "ownership") : n === "architecture" ? e.filter((t) => t.category !== "ownership") : e;
|
|
168
|
+
}
|
|
169
|
+
function ve(e, n) {
|
|
170
|
+
return n === "boundaries" ? e.filter(
|
|
171
|
+
(t) => t.family === "boundaries"
|
|
172
|
+
) : n === "ownership" ? e.filter(
|
|
173
|
+
(t) => t.family === "ownership"
|
|
174
|
+
) : n === "architecture" ? e.filter(
|
|
175
|
+
(t) => t.family !== "ownership" && t.family !== "documentation"
|
|
176
|
+
) : e;
|
|
177
|
+
}
|
|
178
|
+
function we(e, n) {
|
|
179
|
+
return n === "boundaries" ? e.filter((t) => t.category === "boundary") : n === "ownership" ? e.filter((t) => t.category === "ownership") : n === "architecture" ? e.filter((t) => t.category !== "ownership") : e;
|
|
180
|
+
}
|
|
181
|
+
function Ie(e) {
|
|
182
|
+
const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
183
|
+
for (const r of e)
|
|
184
|
+
n.set(r.source, (n.get(r.source) ?? 0) + 1), t.set(r.type, (t.get(r.type) ?? 0) + 1), o.set(
|
|
185
|
+
r.severity,
|
|
186
|
+
(o.get(r.severity) ?? 0) + 1
|
|
187
|
+
);
|
|
188
|
+
return {
|
|
189
|
+
total: e.length,
|
|
190
|
+
bySource: [
|
|
191
|
+
...M.map((r) => ({
|
|
192
|
+
source: r,
|
|
193
|
+
count: n.get(r) ?? 0
|
|
194
|
+
})),
|
|
195
|
+
...B(
|
|
196
|
+
[...n.keys()],
|
|
197
|
+
M
|
|
198
|
+
).filter((r) => !M.includes(r)).map((r) => ({
|
|
199
|
+
source: r,
|
|
200
|
+
count: n.get(r) ?? 0
|
|
201
|
+
}))
|
|
202
|
+
],
|
|
203
|
+
byType: B(
|
|
204
|
+
[...t.keys()],
|
|
205
|
+
ye
|
|
206
|
+
).flatMap((r) => {
|
|
207
|
+
const i = t.get(r) ?? 0;
|
|
208
|
+
return i > 0 ? [{ type: r, count: i }] : [];
|
|
209
|
+
}),
|
|
210
|
+
bySeverity: me.map((r) => ({
|
|
211
|
+
severity: r,
|
|
212
|
+
count: o.get(r) ?? 0
|
|
213
|
+
}))
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function Pe(e) {
|
|
217
|
+
const n = /* @__PURE__ */ new Map();
|
|
218
|
+
for (const o of e) {
|
|
219
|
+
const r = n.get(o.family) ?? [];
|
|
220
|
+
r.push(o), n.set(o.family, r);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
families: B(
|
|
224
|
+
[...n.keys()],
|
|
225
|
+
ge
|
|
226
|
+
).flatMap((o) => {
|
|
227
|
+
const r = (n.get(o) ?? []).slice().sort((a, c) => a.id.localeCompare(c.id)).map((a) => ({
|
|
228
|
+
id: a.id,
|
|
229
|
+
name: a.name,
|
|
230
|
+
score: a.score
|
|
231
|
+
}));
|
|
232
|
+
if (r.length === 0)
|
|
233
|
+
return [];
|
|
234
|
+
const i = r.reduce(
|
|
235
|
+
(a, c) => a + c.score,
|
|
236
|
+
0
|
|
237
|
+
) / r.length;
|
|
238
|
+
return [
|
|
239
|
+
{
|
|
240
|
+
family: o,
|
|
241
|
+
score: Math.round(i),
|
|
242
|
+
measurements: r
|
|
243
|
+
}
|
|
244
|
+
];
|
|
245
|
+
})
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function Se(e) {
|
|
249
|
+
const n = /* @__PURE__ */ new Map();
|
|
250
|
+
for (const t of e) {
|
|
251
|
+
const o = be(t), r = n.get(o);
|
|
252
|
+
if (r) {
|
|
253
|
+
r.issue.count += 1, r.issue.projects = De(r.issue.projects, t), r.issue.ruleId || (r.issue.ruleId = V(t)), r.issue.sourcePluginId || (r.issue.sourcePluginId = t.sourcePluginId);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
n.set(o, {
|
|
257
|
+
issue: {
|
|
258
|
+
type: t.type,
|
|
259
|
+
source: t.source,
|
|
260
|
+
severity: t.severity,
|
|
261
|
+
count: 1,
|
|
262
|
+
projects: J(t),
|
|
263
|
+
ruleId: V(t),
|
|
264
|
+
message: t.message,
|
|
265
|
+
sourcePluginId: t.sourcePluginId
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return [...n.values()].map((t) => t.issue).sort(je);
|
|
270
|
+
}
|
|
271
|
+
function be(e) {
|
|
272
|
+
return [
|
|
273
|
+
e.type,
|
|
274
|
+
e.source,
|
|
275
|
+
e.severity,
|
|
276
|
+
e.sourceProjectId ?? "",
|
|
277
|
+
e.targetProjectId ?? "",
|
|
278
|
+
e.relatedProjectIds.join(",")
|
|
279
|
+
].join("|");
|
|
280
|
+
}
|
|
281
|
+
function J(e) {
|
|
282
|
+
return [
|
|
283
|
+
...new Set(
|
|
284
|
+
[
|
|
285
|
+
e.sourceProjectId,
|
|
286
|
+
e.targetProjectId,
|
|
287
|
+
...e.relatedProjectIds
|
|
288
|
+
].filter((n) => !!n)
|
|
289
|
+
)
|
|
290
|
+
].sort((n, t) => n.localeCompare(t));
|
|
291
|
+
}
|
|
292
|
+
function De(e, n) {
|
|
293
|
+
return [
|
|
294
|
+
.../* @__PURE__ */ new Set([...e, ...J(n)])
|
|
295
|
+
].sort((t, o) => t.localeCompare(o));
|
|
296
|
+
}
|
|
297
|
+
function V(e) {
|
|
298
|
+
const n = e.metadata?.ruleId;
|
|
299
|
+
return typeof n == "string" && n.length > 0 ? n : void 0;
|
|
300
|
+
}
|
|
301
|
+
function je(e, n) {
|
|
302
|
+
const t = q[e.severity] - q[n.severity];
|
|
303
|
+
if (t !== 0)
|
|
304
|
+
return t;
|
|
305
|
+
const o = n.count - e.count;
|
|
306
|
+
if (o !== 0)
|
|
307
|
+
return o;
|
|
308
|
+
const r = b[e.type], i = b[n.type], a = r - i;
|
|
309
|
+
if (r !== void 0 && i !== void 0 && a !== 0)
|
|
310
|
+
return a;
|
|
311
|
+
if (!(e.type in b) || !(n.type in b)) {
|
|
312
|
+
const l = e.type.localeCompare(n.type);
|
|
313
|
+
if (l !== 0)
|
|
314
|
+
return l;
|
|
315
|
+
}
|
|
316
|
+
const c = A[e.source] - A[n.source];
|
|
317
|
+
if (c !== 0)
|
|
318
|
+
return c;
|
|
319
|
+
const s = e.projects.join(",").localeCompare(n.projects.join(","));
|
|
320
|
+
return s !== 0 ? s : e.message.localeCompare(n.message);
|
|
321
|
+
}
|
|
322
|
+
function B(e, n) {
|
|
323
|
+
const t = new Set(e), o = n.filter((i) => t.has(i)), r = e.filter((i) => !n.includes(i)).sort((i, a) => i.localeCompare(a));
|
|
324
|
+
return [...o, ...r];
|
|
325
|
+
}
|
|
326
|
+
function S(e, n) {
|
|
327
|
+
return {
|
|
328
|
+
useCase: e,
|
|
329
|
+
request: n.request,
|
|
330
|
+
analysis: n.analysis,
|
|
331
|
+
...n.payloadScope ? { payloadScope: n.payloadScope } : {},
|
|
332
|
+
...n.metadata ? { metadata: n.metadata } : {}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function gn(e) {
|
|
336
|
+
return S("root-cause", e);
|
|
337
|
+
}
|
|
338
|
+
function hn(e) {
|
|
339
|
+
return S("pr-impact", e);
|
|
340
|
+
}
|
|
341
|
+
function vn(e) {
|
|
342
|
+
return S("drift", e);
|
|
343
|
+
}
|
|
344
|
+
function wn(e) {
|
|
345
|
+
return S("scorecard", e);
|
|
346
|
+
}
|
|
347
|
+
function In(e) {
|
|
348
|
+
return S("management-insights", e);
|
|
349
|
+
}
|
|
350
|
+
const Pn = {
|
|
351
|
+
goodMinScore: 85,
|
|
352
|
+
warningMinScore: 70
|
|
353
|
+
};
|
|
354
|
+
function z(e) {
|
|
355
|
+
return Object.fromEntries(
|
|
356
|
+
e.map((n, t) => [n, e.slice(t)])
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
function m(e, n = {}) {
|
|
360
|
+
const t = e.allowedLayerDependencies ?? z(e.layers), o = {
|
|
361
|
+
"domain-boundary": {
|
|
362
|
+
enabled: !0,
|
|
363
|
+
severity: "error",
|
|
364
|
+
options: {
|
|
365
|
+
allowedDependencies: e.allowedDomainDependencies
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"layer-boundary": {
|
|
369
|
+
enabled: !0,
|
|
370
|
+
severity: "warning",
|
|
371
|
+
options: {
|
|
372
|
+
allowedDependencies: t,
|
|
373
|
+
layers: [...e.layers],
|
|
374
|
+
usesExplicitDependencies: e.allowedLayerDependencies !== void 0
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
"ownership-presence": {
|
|
378
|
+
enabled: !0,
|
|
379
|
+
severity: "warning",
|
|
380
|
+
options: {
|
|
381
|
+
required: e.ownership.required,
|
|
382
|
+
metadataField: e.ownership.metadataField
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}, r = Object.fromEntries(
|
|
386
|
+
Object.entries(e.rules ?? {}).map(([i, a]) => [
|
|
387
|
+
i,
|
|
388
|
+
{
|
|
389
|
+
...o[i] ?? {},
|
|
390
|
+
...a,
|
|
391
|
+
...a.options !== void 0 ? { options: a.options } : o[i]?.options !== void 0 ? { options: o[i]?.options } : {}
|
|
392
|
+
}
|
|
393
|
+
])
|
|
394
|
+
);
|
|
395
|
+
return {
|
|
396
|
+
name: e.name,
|
|
397
|
+
description: e.description,
|
|
398
|
+
rules: {
|
|
399
|
+
...o,
|
|
400
|
+
...r
|
|
401
|
+
},
|
|
402
|
+
scoring: {
|
|
403
|
+
statusThresholds: e.health.statusThresholds,
|
|
404
|
+
metricWeights: e.metrics
|
|
405
|
+
},
|
|
406
|
+
exceptions: n.exceptions ?? [],
|
|
407
|
+
projectOverrides: n.projectOverrides ?? {},
|
|
408
|
+
compatibility: {
|
|
409
|
+
boundaryPolicySource: e.boundaryPolicySource
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
const w = {
|
|
414
|
+
id: "domain-boundary",
|
|
415
|
+
name: "Domain Boundary",
|
|
416
|
+
description: "Enforces allowed dependencies between projects in different domains.",
|
|
417
|
+
category: "boundary",
|
|
418
|
+
defaultSeverity: "error",
|
|
419
|
+
evaluate({ workspace: e, profile: n }) {
|
|
420
|
+
if (!n)
|
|
421
|
+
return {};
|
|
422
|
+
const o = m(n).rules[w.id];
|
|
423
|
+
if (o?.enabled === !1)
|
|
424
|
+
return {};
|
|
425
|
+
const r = o?.options, i = o?.severity ?? w.defaultSeverity, a = L(e.projects);
|
|
426
|
+
return { violations: e.dependencies.flatMap((s) => {
|
|
427
|
+
const l = a.get(s.source), u = a.get(s.target);
|
|
428
|
+
return Q(
|
|
429
|
+
l,
|
|
430
|
+
u,
|
|
431
|
+
s,
|
|
432
|
+
r ?? {
|
|
433
|
+
allowedDependencies: n.allowedDomainDependencies
|
|
434
|
+
},
|
|
435
|
+
i
|
|
436
|
+
);
|
|
437
|
+
}) };
|
|
438
|
+
}
|
|
439
|
+
}, I = {
|
|
440
|
+
id: "layer-boundary",
|
|
441
|
+
name: "Layer Boundary",
|
|
442
|
+
description: "Enforces allowed dependencies between declared architectural layers.",
|
|
443
|
+
category: "boundary",
|
|
444
|
+
defaultSeverity: "warning",
|
|
445
|
+
evaluate({ workspace: e, profile: n }) {
|
|
446
|
+
if (!n)
|
|
447
|
+
return {};
|
|
448
|
+
const o = m(n).rules[I.id];
|
|
449
|
+
if (o?.enabled === !1)
|
|
450
|
+
return {};
|
|
451
|
+
const i = o?.options ?? {
|
|
452
|
+
allowedDependencies: n.allowedLayerDependencies ?? z(n.layers),
|
|
453
|
+
layers: [...n.layers],
|
|
454
|
+
usesExplicitDependencies: n.allowedLayerDependencies !== void 0
|
|
455
|
+
}, a = o?.severity ?? I.defaultSeverity, c = L(e.projects), s = new Set(i.layers);
|
|
456
|
+
return { violations: e.dependencies.flatMap((u) => {
|
|
457
|
+
const y = c.get(u.source), g = c.get(u.target);
|
|
458
|
+
return X(
|
|
459
|
+
y,
|
|
460
|
+
g,
|
|
461
|
+
u,
|
|
462
|
+
s,
|
|
463
|
+
i,
|
|
464
|
+
a
|
|
465
|
+
);
|
|
466
|
+
}) };
|
|
467
|
+
}
|
|
468
|
+
}, P = {
|
|
469
|
+
id: "ownership-presence",
|
|
470
|
+
name: "Ownership Presence",
|
|
471
|
+
description: "Requires ownership metadata or CODEOWNERS coverage when profiles demand it.",
|
|
472
|
+
category: "ownership",
|
|
473
|
+
defaultSeverity: "warning",
|
|
474
|
+
evaluate({ workspace: e, profile: n }) {
|
|
475
|
+
if (!n)
|
|
476
|
+
return {};
|
|
477
|
+
const o = m(n).rules[P.id];
|
|
478
|
+
if (o?.enabled === !1)
|
|
479
|
+
return {};
|
|
480
|
+
const i = o?.options ?? {
|
|
481
|
+
required: n.ownership.required,
|
|
482
|
+
metadataField: n.ownership.metadataField
|
|
483
|
+
}, a = o?.severity ?? P.defaultSeverity;
|
|
484
|
+
return i.required ? { violations: e.projects.flatMap(
|
|
485
|
+
(s) => Z(s, a)
|
|
486
|
+
) } : {};
|
|
487
|
+
}
|
|
488
|
+
}, j = {
|
|
489
|
+
id: "project-name-convention",
|
|
490
|
+
name: "Project Name Convention",
|
|
491
|
+
description: "Validates project names against an explicitly configured regular expression.",
|
|
492
|
+
category: "convention",
|
|
493
|
+
defaultSeverity: "warning",
|
|
494
|
+
evaluate({ workspace: e, profile: n }) {
|
|
495
|
+
if (!n)
|
|
496
|
+
return {};
|
|
497
|
+
const o = m(n).rules[j.id], r = o?.options;
|
|
498
|
+
if (!o?.enabled || !r?.pattern)
|
|
499
|
+
return {};
|
|
500
|
+
const i = new RegExp(r.pattern), a = o.severity ?? j.defaultSeverity;
|
|
501
|
+
return {
|
|
502
|
+
violations: e.projects.flatMap(
|
|
503
|
+
(c) => ke(c, r, i, a)
|
|
504
|
+
)
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}, E = {
|
|
508
|
+
id: "tag-convention",
|
|
509
|
+
name: "Tag Convention",
|
|
510
|
+
description: "Validates required and allowed generic tag prefixes and tag value patterns.",
|
|
511
|
+
category: "metadata",
|
|
512
|
+
defaultSeverity: "warning",
|
|
513
|
+
evaluate({ workspace: e, profile: n }) {
|
|
514
|
+
if (!n)
|
|
515
|
+
return {};
|
|
516
|
+
const o = m(n).rules[E.id], r = o?.options;
|
|
517
|
+
if (!o?.enabled || !r || !Be(r))
|
|
518
|
+
return {};
|
|
519
|
+
const i = o.severity ?? E.defaultSeverity, a = r.valuePattern ? new RegExp(r.valuePattern) : void 0;
|
|
520
|
+
return {
|
|
521
|
+
violations: e.projects.flatMap(
|
|
522
|
+
(c) => xe(c, r, a, i)
|
|
523
|
+
)
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
}, k = {
|
|
527
|
+
id: "missing-domain",
|
|
528
|
+
name: "Missing Domain",
|
|
529
|
+
description: "Requires a domain on projects when explicitly configured.",
|
|
530
|
+
category: "metadata",
|
|
531
|
+
defaultSeverity: "warning",
|
|
532
|
+
evaluate({ workspace: e, profile: n }) {
|
|
533
|
+
if (!n)
|
|
534
|
+
return {};
|
|
535
|
+
const o = m(n).rules[k.id], r = o?.options;
|
|
536
|
+
if (!o?.enabled || !r?.required)
|
|
537
|
+
return {};
|
|
538
|
+
const i = o.severity ?? k.defaultSeverity;
|
|
539
|
+
return {
|
|
540
|
+
violations: e.projects.flatMap(
|
|
541
|
+
(a) => Re(a, i)
|
|
542
|
+
)
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
}, x = {
|
|
546
|
+
id: "missing-layer",
|
|
547
|
+
name: "Missing Layer",
|
|
548
|
+
description: "Requires a layer on projects when explicitly configured.",
|
|
549
|
+
category: "metadata",
|
|
550
|
+
defaultSeverity: "warning",
|
|
551
|
+
evaluate({ workspace: e, profile: n }) {
|
|
552
|
+
if (!n)
|
|
553
|
+
return {};
|
|
554
|
+
const o = m(n).rules[x.id], r = o?.options;
|
|
555
|
+
if (!o?.enabled || !r?.required)
|
|
556
|
+
return {};
|
|
557
|
+
const i = o.severity ?? x.defaultSeverity;
|
|
558
|
+
return {
|
|
559
|
+
violations: e.projects.flatMap(
|
|
560
|
+
(a) => Me(a, i)
|
|
561
|
+
)
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
}, Ee = [
|
|
565
|
+
w,
|
|
566
|
+
I,
|
|
567
|
+
P,
|
|
568
|
+
j,
|
|
569
|
+
E,
|
|
570
|
+
k,
|
|
571
|
+
x
|
|
572
|
+
];
|
|
573
|
+
function Sn(e) {
|
|
574
|
+
if (!e.profile)
|
|
575
|
+
return [];
|
|
576
|
+
const { workspace: n, profile: t } = e, o = m(t), r = o.rules[w.id], i = r?.enabled !== !1, a = r?.options ?? {
|
|
577
|
+
allowedDependencies: t.allowedDomainDependencies
|
|
578
|
+
}, c = r?.severity ?? w.defaultSeverity, s = o.rules[I.id], l = s?.enabled !== !1, u = s?.options ?? {
|
|
579
|
+
allowedDependencies: t.allowedLayerDependencies ?? z(t.layers),
|
|
580
|
+
layers: [...t.layers],
|
|
581
|
+
usesExplicitDependencies: t.allowedLayerDependencies !== void 0
|
|
582
|
+
}, y = s?.severity ?? I.defaultSeverity, g = o.rules[P.id], te = g?.enabled !== !1, re = g?.options ?? {
|
|
583
|
+
required: t.ownership.required,
|
|
584
|
+
metadataField: t.ownership.metadataField
|
|
585
|
+
}, oe = g?.severity ?? P.defaultSeverity, G = L(n.projects), ie = new Set(u.layers), h = [];
|
|
586
|
+
for (const f of n.dependencies) {
|
|
587
|
+
const F = G.get(f.source), _ = G.get(f.target);
|
|
588
|
+
i && h.push(
|
|
589
|
+
...Q(
|
|
590
|
+
F,
|
|
591
|
+
_,
|
|
592
|
+
f,
|
|
593
|
+
a,
|
|
594
|
+
c
|
|
595
|
+
)
|
|
596
|
+
), l && h.push(
|
|
597
|
+
...X(
|
|
598
|
+
F,
|
|
599
|
+
_,
|
|
600
|
+
f,
|
|
601
|
+
ie,
|
|
602
|
+
u,
|
|
603
|
+
y
|
|
604
|
+
)
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
if (te && re.required)
|
|
608
|
+
for (const f of n.projects)
|
|
609
|
+
h.push(...Z(f, oe));
|
|
610
|
+
for (const f of [
|
|
611
|
+
j,
|
|
612
|
+
E,
|
|
613
|
+
k,
|
|
614
|
+
x
|
|
615
|
+
])
|
|
616
|
+
h.push(...Ce(f, e));
|
|
617
|
+
return h;
|
|
618
|
+
}
|
|
619
|
+
function Q(e, n, t, o, r) {
|
|
620
|
+
return !e || !n ? [] : !e.domain || !n.domain || e.domain === n.domain || $e(
|
|
621
|
+
o.allowedDependencies,
|
|
622
|
+
e.domain,
|
|
623
|
+
n.domain
|
|
624
|
+
) ? [] : [
|
|
625
|
+
{
|
|
626
|
+
id: `${e.name}-${n.name}-domain`,
|
|
627
|
+
ruleId: "domain-boundary",
|
|
628
|
+
project: e.name,
|
|
629
|
+
severity: r,
|
|
630
|
+
category: "boundary",
|
|
631
|
+
message: `Project ${e.name} in domain ${e.domain} depends on ${n.name} in domain ${n.domain}.`,
|
|
632
|
+
details: {
|
|
633
|
+
targetProject: n.name,
|
|
634
|
+
sourceDomain: e.domain,
|
|
635
|
+
targetDomain: n.domain,
|
|
636
|
+
dependencyType: t.type
|
|
637
|
+
},
|
|
638
|
+
recommendation: "Move the dependency behind an API or adjust domain boundaries in the governance profile."
|
|
639
|
+
}
|
|
640
|
+
];
|
|
641
|
+
}
|
|
642
|
+
function X(e, n, t, o, r, i) {
|
|
643
|
+
return !e || !n ? [] : !e.layer || !n.layer || !o.has(e.layer) || !o.has(n.layer) || Oe(
|
|
644
|
+
r.allowedDependencies,
|
|
645
|
+
e.layer,
|
|
646
|
+
n.layer
|
|
647
|
+
) ? [] : [
|
|
648
|
+
{
|
|
649
|
+
id: `${e.name}-${n.name}-layer`,
|
|
650
|
+
ruleId: "layer-boundary",
|
|
651
|
+
project: e.name,
|
|
652
|
+
severity: i,
|
|
653
|
+
category: "boundary",
|
|
654
|
+
message: `Layer violation: ${e.name} (${e.layer}) depends on ${n.name} (${n.layer}).`,
|
|
655
|
+
details: {
|
|
656
|
+
targetProject: n.name,
|
|
657
|
+
sourceLayer: e.layer,
|
|
658
|
+
targetLayer: n.layer,
|
|
659
|
+
...r.usesExplicitDependencies ? {
|
|
660
|
+
allowedTargets: r.allowedDependencies[e.layer] ?? []
|
|
661
|
+
} : {
|
|
662
|
+
order: r.layers
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
recommendation: r.usesExplicitDependencies ? "Refactor the dependency or update allowedLayerDependencies in the governance profile when the dependency is intentional." : "Refactor dependency direction so higher-level layers depend on same or lower-level layers only."
|
|
666
|
+
}
|
|
667
|
+
];
|
|
668
|
+
}
|
|
669
|
+
function Z(e, n) {
|
|
670
|
+
return e.ownership?.team || (e.ownership?.contacts?.length ?? 0) > 0 ? [] : [
|
|
671
|
+
{
|
|
672
|
+
id: `${e.name}-ownership`,
|
|
673
|
+
ruleId: "ownership-presence",
|
|
674
|
+
project: e.name,
|
|
675
|
+
severity: n,
|
|
676
|
+
category: "ownership",
|
|
677
|
+
message: `Project ${e.name} has no ownership metadata or CODEOWNERS mapping.`,
|
|
678
|
+
recommendation: "Add ownership metadata in project configuration or ensure CODEOWNERS covers the project root."
|
|
679
|
+
}
|
|
680
|
+
];
|
|
681
|
+
}
|
|
682
|
+
function ke(e, n, t, o) {
|
|
683
|
+
return t.test(e.name) ? [] : [
|
|
684
|
+
{
|
|
685
|
+
id: `${e.name}-project-name-convention`,
|
|
686
|
+
ruleId: "project-name-convention",
|
|
687
|
+
project: e.name,
|
|
688
|
+
severity: o,
|
|
689
|
+
category: "convention",
|
|
690
|
+
message: n.message ?? `Project ${e.name} does not match the configured naming convention.`,
|
|
691
|
+
details: {
|
|
692
|
+
projectName: e.name,
|
|
693
|
+
pattern: n.pattern
|
|
694
|
+
},
|
|
695
|
+
recommendation: "Rename the project or update the configured name pattern when the convention is intentional."
|
|
696
|
+
}
|
|
697
|
+
];
|
|
698
|
+
}
|
|
699
|
+
function xe(e, n, t, o) {
|
|
700
|
+
const r = [], i = n.prefixSeparator ?? ":";
|
|
701
|
+
for (const a of n.requiredPrefixes ?? [])
|
|
702
|
+
e.tags.some(
|
|
703
|
+
(c) => c.startsWith(`${a}${i}`)
|
|
704
|
+
) || r.push({
|
|
705
|
+
id: `${e.name}-tag-convention-required-${a}`,
|
|
706
|
+
ruleId: "tag-convention",
|
|
707
|
+
project: e.name,
|
|
708
|
+
severity: o,
|
|
709
|
+
category: "metadata",
|
|
710
|
+
message: `Project ${e.name} is missing a tag with required prefix ${a}.`,
|
|
711
|
+
details: {
|
|
712
|
+
requiredPrefix: a,
|
|
713
|
+
tags: e.tags
|
|
714
|
+
},
|
|
715
|
+
recommendation: "Add a tag with the required prefix or relax the configured requiredPrefixes list."
|
|
716
|
+
});
|
|
717
|
+
for (const a of e.tags) {
|
|
718
|
+
const { prefix: c, value: s } = Te(a, i);
|
|
719
|
+
n.allowedPrefixes && n.allowedPrefixes.length > 0 && !n.allowedPrefixes.includes(c) && r.push({
|
|
720
|
+
id: `${e.name}-tag-convention-allowed-${a}`,
|
|
721
|
+
ruleId: "tag-convention",
|
|
722
|
+
project: e.name,
|
|
723
|
+
severity: o,
|
|
724
|
+
category: "metadata",
|
|
725
|
+
message: `Project ${e.name} uses tag ${a} with disallowed prefix ${c}.`,
|
|
726
|
+
details: {
|
|
727
|
+
tag: a,
|
|
728
|
+
prefix: c,
|
|
729
|
+
allowedPrefixes: n.allowedPrefixes
|
|
730
|
+
},
|
|
731
|
+
recommendation: "Rename the tag to use an allowed prefix or expand the allowedPrefixes rule configuration."
|
|
732
|
+
}), t && !t.test(s) && r.push({
|
|
733
|
+
id: `${e.name}-tag-convention-value-${a}`,
|
|
734
|
+
ruleId: "tag-convention",
|
|
735
|
+
project: e.name,
|
|
736
|
+
severity: o,
|
|
737
|
+
category: "metadata",
|
|
738
|
+
message: `Project ${e.name} has tag ${a} with a value that does not match the configured pattern.`,
|
|
739
|
+
details: {
|
|
740
|
+
tag: a,
|
|
741
|
+
value: s,
|
|
742
|
+
valuePattern: n.valuePattern
|
|
743
|
+
},
|
|
744
|
+
recommendation: "Normalize the tag value or update the configured valuePattern when the convention is intentional."
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
return r;
|
|
748
|
+
}
|
|
749
|
+
function Re(e, n) {
|
|
750
|
+
return e.domain ? [] : [
|
|
751
|
+
{
|
|
752
|
+
id: `${e.name}-missing-domain`,
|
|
753
|
+
ruleId: "missing-domain",
|
|
754
|
+
project: e.name,
|
|
755
|
+
severity: n,
|
|
756
|
+
category: "metadata",
|
|
757
|
+
message: `Project ${e.name} is missing domain metadata.`,
|
|
758
|
+
recommendation: "Populate the project domain through adapter normalization, metadata, or project overrides."
|
|
759
|
+
}
|
|
760
|
+
];
|
|
761
|
+
}
|
|
762
|
+
function Me(e, n) {
|
|
763
|
+
return e.layer ? [] : [
|
|
764
|
+
{
|
|
765
|
+
id: `${e.name}-missing-layer`,
|
|
766
|
+
ruleId: "missing-layer",
|
|
767
|
+
project: e.name,
|
|
768
|
+
severity: n,
|
|
769
|
+
category: "metadata",
|
|
770
|
+
message: `Project ${e.name} is missing layer metadata.`,
|
|
771
|
+
recommendation: "Populate the project layer through adapter normalization, metadata, or project overrides."
|
|
772
|
+
}
|
|
773
|
+
];
|
|
774
|
+
}
|
|
775
|
+
function Ce(e, n) {
|
|
776
|
+
return e.evaluate(n).violations ?? [];
|
|
777
|
+
}
|
|
778
|
+
function L(e) {
|
|
779
|
+
return new Map(e.map((n) => [n.name, n]));
|
|
780
|
+
}
|
|
781
|
+
function $e(e, n, t) {
|
|
782
|
+
const o = e[n];
|
|
783
|
+
if (o && (o.includes(t) || o.includes("*")))
|
|
784
|
+
return !0;
|
|
785
|
+
const r = e["*"];
|
|
786
|
+
return !!(r && (r.includes(t) || r.includes("*")));
|
|
787
|
+
}
|
|
788
|
+
function Oe(e, n, t) {
|
|
789
|
+
return (e[n] ?? []).includes(t);
|
|
790
|
+
}
|
|
791
|
+
function Be(e) {
|
|
792
|
+
return (e.requiredPrefixes?.length ?? 0) > 0 || (e.allowedPrefixes?.length ?? 0) > 0 || typeof e.valuePattern == "string";
|
|
793
|
+
}
|
|
794
|
+
function Te(e, n) {
|
|
795
|
+
const t = e.indexOf(n);
|
|
796
|
+
return t === -1 ? {
|
|
797
|
+
prefix: e,
|
|
798
|
+
value: e
|
|
799
|
+
} : {
|
|
800
|
+
prefix: e.slice(0, t),
|
|
801
|
+
value: e.slice(t + n.length)
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
const ze = "core", Le = {
|
|
805
|
+
id: ze,
|
|
806
|
+
name: "Governance Core Built-in Rules",
|
|
807
|
+
rules: Ee
|
|
808
|
+
}, bn = [Le], Ge = [
|
|
809
|
+
"graph",
|
|
810
|
+
"conformance",
|
|
811
|
+
"policy"
|
|
812
|
+
], Fe = ["info", "warning", "error"], _e = [
|
|
813
|
+
"structural-dependency",
|
|
814
|
+
"cross-domain-dependency",
|
|
815
|
+
"missing-domain-context",
|
|
816
|
+
"circular-dependency",
|
|
817
|
+
"conformance-violation",
|
|
818
|
+
"domain-boundary-violation",
|
|
819
|
+
"layer-boundary-violation",
|
|
820
|
+
"ownership-gap"
|
|
821
|
+
], Ae = [
|
|
822
|
+
"architecture",
|
|
823
|
+
"boundaries",
|
|
824
|
+
"ownership",
|
|
825
|
+
"documentation"
|
|
826
|
+
];
|
|
827
|
+
function Dn(e, n) {
|
|
828
|
+
return {
|
|
829
|
+
baseline: e,
|
|
830
|
+
current: n,
|
|
831
|
+
metricDeltas: N(e.metrics, n.metrics),
|
|
832
|
+
scoreDeltas: N(e.scores, n.scores),
|
|
833
|
+
newViolations: n.violations.filter(
|
|
834
|
+
(t) => !K(e.violations, t)
|
|
835
|
+
),
|
|
836
|
+
resolvedViolations: e.violations.filter(
|
|
837
|
+
(t) => !K(n.violations, t)
|
|
838
|
+
),
|
|
839
|
+
healthDelta: qe(e, n),
|
|
840
|
+
signalDeltas: Ve(e, n),
|
|
841
|
+
metricFamilyDeltas: Ne(e, n),
|
|
842
|
+
topIssueDeltas: He(e, n),
|
|
843
|
+
deliveryImpactIndexDeltas: Ue(e, n)
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function jn(e, n = 0.02) {
|
|
847
|
+
const t = [], o = e.scoreDeltas.find(
|
|
848
|
+
(r) => r.id === "workspaceHealth"
|
|
849
|
+
);
|
|
850
|
+
o && t.push(
|
|
851
|
+
C(
|
|
852
|
+
"workspaceHealth",
|
|
853
|
+
"workspace-health",
|
|
854
|
+
"Workspace Health",
|
|
855
|
+
o,
|
|
856
|
+
n,
|
|
857
|
+
e.healthDelta ? {
|
|
858
|
+
baselineStatus: e.healthDelta.baselineStatus,
|
|
859
|
+
currentStatus: e.healthDelta.currentStatus,
|
|
860
|
+
baselineGrade: e.healthDelta.baselineGrade,
|
|
861
|
+
currentGrade: e.healthDelta.currentGrade
|
|
862
|
+
} : void 0
|
|
863
|
+
)
|
|
864
|
+
);
|
|
865
|
+
for (const r of e.scoreDeltas)
|
|
866
|
+
r.id !== "workspaceHealth" && t.push(
|
|
867
|
+
C(
|
|
868
|
+
r.id,
|
|
869
|
+
"metric-score",
|
|
870
|
+
Xe(r.id),
|
|
871
|
+
r,
|
|
872
|
+
n
|
|
873
|
+
)
|
|
874
|
+
);
|
|
875
|
+
for (const r of e.metricFamilyDeltas ?? [])
|
|
876
|
+
t.push(
|
|
877
|
+
C(
|
|
878
|
+
`metric-family:${r.family}`,
|
|
879
|
+
"metric-family",
|
|
880
|
+
`Metric Family: ${Ze(r.family)}`,
|
|
881
|
+
r,
|
|
882
|
+
n
|
|
883
|
+
)
|
|
884
|
+
);
|
|
885
|
+
for (const r of e.signalDeltas?.bySource ?? [])
|
|
886
|
+
t.push(
|
|
887
|
+
D(
|
|
888
|
+
`signal-source:${r.source}`,
|
|
889
|
+
"signal-source",
|
|
890
|
+
`Signal Source: ${r.source}`,
|
|
891
|
+
r
|
|
892
|
+
)
|
|
893
|
+
);
|
|
894
|
+
for (const r of e.signalDeltas?.byType ?? [])
|
|
895
|
+
t.push(
|
|
896
|
+
D(
|
|
897
|
+
`signal-type:${r.type}`,
|
|
898
|
+
"signal-type",
|
|
899
|
+
`Signal Type: ${en(r.type)}`,
|
|
900
|
+
r
|
|
901
|
+
)
|
|
902
|
+
);
|
|
903
|
+
for (const r of e.signalDeltas?.bySeverity ?? [])
|
|
904
|
+
t.push(
|
|
905
|
+
D(
|
|
906
|
+
`signal-severity:${r.severity}`,
|
|
907
|
+
"signal-severity",
|
|
908
|
+
`Signal Severity: ${r.severity}`,
|
|
909
|
+
r
|
|
910
|
+
)
|
|
911
|
+
);
|
|
912
|
+
for (const r of e.topIssueDeltas ?? [])
|
|
913
|
+
t.push(
|
|
914
|
+
D(
|
|
915
|
+
Ke(r),
|
|
916
|
+
"top-issue",
|
|
917
|
+
`Top Issue: ${r.message}`,
|
|
918
|
+
{
|
|
919
|
+
baseline: r.baselineCount,
|
|
920
|
+
current: r.currentCount,
|
|
921
|
+
delta: r.delta
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
type: r.type,
|
|
925
|
+
source: r.source,
|
|
926
|
+
severity: r.severity,
|
|
927
|
+
ruleId: r.ruleId,
|
|
928
|
+
projects: r.projects
|
|
929
|
+
}
|
|
930
|
+
)
|
|
931
|
+
);
|
|
932
|
+
return t.push({
|
|
933
|
+
id: "violation-footprint",
|
|
934
|
+
kind: "violation-footprint",
|
|
935
|
+
label: "Violation Footprint",
|
|
936
|
+
status: ee(
|
|
937
|
+
e.newViolations.length - e.resolvedViolations.length
|
|
938
|
+
),
|
|
939
|
+
magnitude: Math.abs(
|
|
940
|
+
e.newViolations.length - e.resolvedViolations.length
|
|
941
|
+
),
|
|
942
|
+
baseline: e.baseline.violations.length,
|
|
943
|
+
current: e.current.violations.length,
|
|
944
|
+
delta: p(
|
|
945
|
+
e.current.violations.length - e.baseline.violations.length
|
|
946
|
+
),
|
|
947
|
+
details: {
|
|
948
|
+
newViolations: e.newViolations.length,
|
|
949
|
+
resolvedViolations: e.resolvedViolations.length
|
|
950
|
+
}
|
|
951
|
+
}), t.sort(Je);
|
|
952
|
+
}
|
|
953
|
+
function En(e) {
|
|
954
|
+
const n = e.filter((r) => r.status === "worsening").sort(Y), t = e.filter((r) => r.status === "improving").sort(Y), o = e.filter(
|
|
955
|
+
(r) => r.status === "stable"
|
|
956
|
+
).length;
|
|
957
|
+
return {
|
|
958
|
+
overallTrend: n.length > t.length ? "worsening" : t.length > n.length ? "improving" : "stable",
|
|
959
|
+
worseningCount: n.length,
|
|
960
|
+
improvingCount: t.length,
|
|
961
|
+
stableCount: o,
|
|
962
|
+
topWorsening: n.slice(0, 5),
|
|
963
|
+
topImproving: t.slice(0, 5)
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
function N(e, n) {
|
|
967
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(n)])].sort((o, r) => o.localeCompare(r)).map((o) => {
|
|
968
|
+
const r = e[o] ?? 0, i = n[o] ?? 0;
|
|
969
|
+
return {
|
|
970
|
+
id: o,
|
|
971
|
+
baseline: r,
|
|
972
|
+
current: i,
|
|
973
|
+
delta: p(i - r)
|
|
974
|
+
};
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
function qe(e, n) {
|
|
978
|
+
if (!(!e.health || !n.health))
|
|
979
|
+
return {
|
|
980
|
+
baselineScore: e.health.score,
|
|
981
|
+
currentScore: n.health.score,
|
|
982
|
+
scoreDelta: p(n.health.score - e.health.score),
|
|
983
|
+
baselineStatus: e.health.status,
|
|
984
|
+
currentStatus: n.health.status,
|
|
985
|
+
baselineGrade: e.health.grade,
|
|
986
|
+
currentGrade: n.health.grade
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
function Ve(e, n) {
|
|
990
|
+
if (!(!e.signalBreakdown || !n.signalBreakdown))
|
|
991
|
+
return {
|
|
992
|
+
bySource: Ge.map(
|
|
993
|
+
(t) => We(
|
|
994
|
+
t,
|
|
995
|
+
H(e, t),
|
|
996
|
+
H(n, t)
|
|
997
|
+
)
|
|
998
|
+
),
|
|
999
|
+
byType: _e.flatMap((t) => {
|
|
1000
|
+
const o = U(e, t), r = U(n, t);
|
|
1001
|
+
return o === 0 && r === 0 ? [] : [
|
|
1002
|
+
{
|
|
1003
|
+
type: t,
|
|
1004
|
+
baseline: o,
|
|
1005
|
+
current: r,
|
|
1006
|
+
delta: p(r - o)
|
|
1007
|
+
}
|
|
1008
|
+
];
|
|
1009
|
+
}),
|
|
1010
|
+
bySeverity: Fe.map(
|
|
1011
|
+
(t) => Ye(
|
|
1012
|
+
t,
|
|
1013
|
+
W(e, t),
|
|
1014
|
+
W(n, t)
|
|
1015
|
+
)
|
|
1016
|
+
)
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
function Ne(e, n) {
|
|
1020
|
+
if (!e.metricBreakdown || !n.metricBreakdown)
|
|
1021
|
+
return;
|
|
1022
|
+
const t = new Map(
|
|
1023
|
+
e.metricBreakdown.families.map((r) => [
|
|
1024
|
+
r.family,
|
|
1025
|
+
r.score
|
|
1026
|
+
])
|
|
1027
|
+
), o = new Map(
|
|
1028
|
+
n.metricBreakdown.families.map((r) => [
|
|
1029
|
+
r.family,
|
|
1030
|
+
r.score
|
|
1031
|
+
])
|
|
1032
|
+
);
|
|
1033
|
+
return Ae.flatMap((r) => {
|
|
1034
|
+
const i = t.get(r), a = o.get(r);
|
|
1035
|
+
return i === void 0 || a === void 0 ? [] : [
|
|
1036
|
+
{
|
|
1037
|
+
family: r,
|
|
1038
|
+
baseline: i,
|
|
1039
|
+
current: a,
|
|
1040
|
+
delta: p(a - i)
|
|
1041
|
+
}
|
|
1042
|
+
];
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
function He(e, n) {
|
|
1046
|
+
if (!e.topIssues || !n.topIssues)
|
|
1047
|
+
return;
|
|
1048
|
+
const t = new Map(
|
|
1049
|
+
e.topIssues.map((i) => [T(i), i])
|
|
1050
|
+
), o = new Map(
|
|
1051
|
+
n.topIssues.map((i) => [T(i), i])
|
|
1052
|
+
);
|
|
1053
|
+
return [.../* @__PURE__ */ new Set([...t.keys(), ...o.keys()])].sort((i, a) => i.localeCompare(a)).map((i) => {
|
|
1054
|
+
const a = t.get(i), c = o.get(i), s = c ?? a;
|
|
1055
|
+
if (!s)
|
|
1056
|
+
throw new Error(`Unable to resolve top issue delta for key "${i}".`);
|
|
1057
|
+
const l = [
|
|
1058
|
+
.../* @__PURE__ */ new Set([...a?.projects ?? [], ...c?.projects ?? []])
|
|
1059
|
+
].sort((u, y) => u.localeCompare(y));
|
|
1060
|
+
return {
|
|
1061
|
+
type: s.type,
|
|
1062
|
+
source: s.source,
|
|
1063
|
+
severity: s.severity,
|
|
1064
|
+
ruleId: s.ruleId,
|
|
1065
|
+
message: s.message,
|
|
1066
|
+
baselineCount: a?.count ?? 0,
|
|
1067
|
+
currentCount: c?.count ?? 0,
|
|
1068
|
+
delta: p((c?.count ?? 0) - (a?.count ?? 0)),
|
|
1069
|
+
projects: l
|
|
1070
|
+
};
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
function Ue(e, n) {
|
|
1074
|
+
const t = new Map(
|
|
1075
|
+
(e.deliveryImpact?.indices ?? []).map((i) => [i.id, i])
|
|
1076
|
+
), o = new Map(
|
|
1077
|
+
(n.deliveryImpact?.indices ?? []).map((i) => [i.id, i])
|
|
1078
|
+
), r = [...t.keys()].filter((i) => o.has(i)).sort((i, a) => i.localeCompare(a));
|
|
1079
|
+
if (r.length !== 0)
|
|
1080
|
+
return r.map((i) => {
|
|
1081
|
+
const a = t.get(i), c = o.get(i);
|
|
1082
|
+
return {
|
|
1083
|
+
id: i,
|
|
1084
|
+
baselineScore: a.score,
|
|
1085
|
+
currentScore: c.score,
|
|
1086
|
+
scoreDelta: p(c.score - a.score),
|
|
1087
|
+
baselineRisk: a.risk,
|
|
1088
|
+
currentRisk: c.risk
|
|
1089
|
+
};
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
function C(e, n, t, o, r, i) {
|
|
1093
|
+
return {
|
|
1094
|
+
id: e,
|
|
1095
|
+
kind: n,
|
|
1096
|
+
label: t,
|
|
1097
|
+
status: Qe(o.delta, r),
|
|
1098
|
+
magnitude: Math.abs(o.delta),
|
|
1099
|
+
baseline: o.baseline,
|
|
1100
|
+
current: o.current,
|
|
1101
|
+
delta: o.delta,
|
|
1102
|
+
details: i
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function D(e, n, t, o, r) {
|
|
1106
|
+
return {
|
|
1107
|
+
id: e,
|
|
1108
|
+
kind: n,
|
|
1109
|
+
label: t,
|
|
1110
|
+
status: ee(o.delta),
|
|
1111
|
+
magnitude: Math.abs(o.delta),
|
|
1112
|
+
baseline: o.baseline,
|
|
1113
|
+
current: o.current,
|
|
1114
|
+
delta: o.delta,
|
|
1115
|
+
details: r
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function We(e, n, t) {
|
|
1119
|
+
return {
|
|
1120
|
+
source: e,
|
|
1121
|
+
baseline: n,
|
|
1122
|
+
current: t,
|
|
1123
|
+
delta: p(t - n)
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
function Ye(e, n, t) {
|
|
1127
|
+
return {
|
|
1128
|
+
severity: e,
|
|
1129
|
+
baseline: n,
|
|
1130
|
+
current: t,
|
|
1131
|
+
delta: p(t - n)
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
function H(e, n) {
|
|
1135
|
+
return e.signalBreakdown?.bySource.find((t) => t.source === n)?.count ?? 0;
|
|
1136
|
+
}
|
|
1137
|
+
function U(e, n) {
|
|
1138
|
+
return e.signalBreakdown?.byType.find((t) => t.type === n)?.count ?? 0;
|
|
1139
|
+
}
|
|
1140
|
+
function W(e, n) {
|
|
1141
|
+
return e.signalBreakdown?.bySeverity.find(
|
|
1142
|
+
(t) => t.severity === n
|
|
1143
|
+
)?.count ?? 0;
|
|
1144
|
+
}
|
|
1145
|
+
function T(e) {
|
|
1146
|
+
return [
|
|
1147
|
+
e.type,
|
|
1148
|
+
e.source,
|
|
1149
|
+
e.severity,
|
|
1150
|
+
e.ruleId ?? "",
|
|
1151
|
+
e.message
|
|
1152
|
+
].join("|");
|
|
1153
|
+
}
|
|
1154
|
+
function Ke(e) {
|
|
1155
|
+
return `top-issue:${T(e)}`;
|
|
1156
|
+
}
|
|
1157
|
+
function Je(e, n) {
|
|
1158
|
+
return e.id.localeCompare(n.id);
|
|
1159
|
+
}
|
|
1160
|
+
function Y(e, n) {
|
|
1161
|
+
return n.magnitude - e.magnitude || e.id.localeCompare(n.id);
|
|
1162
|
+
}
|
|
1163
|
+
function Qe(e, n) {
|
|
1164
|
+
return Math.abs(e) < n ? "stable" : e > 0 ? "improving" : "worsening";
|
|
1165
|
+
}
|
|
1166
|
+
function ee(e) {
|
|
1167
|
+
return e === 0 ? "stable" : e < 0 ? "improving" : "worsening";
|
|
1168
|
+
}
|
|
1169
|
+
function Xe(e) {
|
|
1170
|
+
return e.split("-").map((n) => n[0]?.toUpperCase() + n.slice(1)).join(" ");
|
|
1171
|
+
}
|
|
1172
|
+
function Ze(e) {
|
|
1173
|
+
return e[0].toUpperCase() + e.slice(1);
|
|
1174
|
+
}
|
|
1175
|
+
function en(e) {
|
|
1176
|
+
return e.split("-").map((n) => n[0]?.toUpperCase() + n.slice(1)).join(" ");
|
|
1177
|
+
}
|
|
1178
|
+
function p(e) {
|
|
1179
|
+
return Math.round(e * 1e3) / 1e3;
|
|
1180
|
+
}
|
|
1181
|
+
function K(e, n) {
|
|
1182
|
+
return e.some(
|
|
1183
|
+
(t) => t.type === n.type && t.source === n.source && t.target === n.target
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
function kn(e) {
|
|
1187
|
+
const n = v(e.id, "Exception id"), t = rn(e.source), o = v(e.reason, "Exception reason"), r = v(e.owner, "Exception owner"), i = tn(e.review), a = ne(e.scope);
|
|
1188
|
+
if (a.source !== t)
|
|
1189
|
+
throw new Error(
|
|
1190
|
+
`Exception "${n}" has source "${t}" but scope source "${a.source}".`
|
|
1191
|
+
);
|
|
1192
|
+
return {
|
|
1193
|
+
id: n,
|
|
1194
|
+
source: t,
|
|
1195
|
+
scope: a,
|
|
1196
|
+
reason: o,
|
|
1197
|
+
owner: r,
|
|
1198
|
+
review: i
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
function xn(e) {
|
|
1202
|
+
const n = ne(e);
|
|
1203
|
+
return nn(n) ? [
|
|
1204
|
+
n.source,
|
|
1205
|
+
n.ruleId,
|
|
1206
|
+
n.projectId,
|
|
1207
|
+
n.targetProjectId ?? ""
|
|
1208
|
+
].join("|") : [
|
|
1209
|
+
n.source,
|
|
1210
|
+
n.ruleId ?? "",
|
|
1211
|
+
n.category ?? "",
|
|
1212
|
+
n.projectId ?? "",
|
|
1213
|
+
(n.relatedProjectIds ?? []).join(",")
|
|
1214
|
+
].join("|");
|
|
1215
|
+
}
|
|
1216
|
+
function nn(e) {
|
|
1217
|
+
return e.source === "policy";
|
|
1218
|
+
}
|
|
1219
|
+
function Rn(e) {
|
|
1220
|
+
return e.source === "conformance";
|
|
1221
|
+
}
|
|
1222
|
+
function tn(e) {
|
|
1223
|
+
const n = d(e.createdAt), t = d(e.reviewBy), o = d(e.expiresAt);
|
|
1224
|
+
if (!t && !o)
|
|
1225
|
+
throw new Error(
|
|
1226
|
+
"Governance exception review must define reviewBy or expiresAt."
|
|
1227
|
+
);
|
|
1228
|
+
return {
|
|
1229
|
+
...n ? { createdAt: n } : {},
|
|
1230
|
+
...t ? { reviewBy: t } : {},
|
|
1231
|
+
...o ? { expiresAt: o } : {}
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
function ne(e) {
|
|
1235
|
+
if (e.source === "policy")
|
|
1236
|
+
return {
|
|
1237
|
+
source: "policy",
|
|
1238
|
+
ruleId: v(e.ruleId, "Policy exception ruleId"),
|
|
1239
|
+
projectId: v(
|
|
1240
|
+
e.projectId,
|
|
1241
|
+
"Policy exception projectId"
|
|
1242
|
+
),
|
|
1243
|
+
...d(e.targetProjectId) ? { targetProjectId: d(e.targetProjectId) } : {}
|
|
1244
|
+
};
|
|
1245
|
+
const n = d(e.ruleId), t = an(e.category), o = d(e.projectId), r = on(e.relatedProjectIds);
|
|
1246
|
+
if (!n && !t && !o && r.length === 0)
|
|
1247
|
+
throw new Error(
|
|
1248
|
+
"Conformance exception scope must define ruleId, category, projectId, or relatedProjectIds."
|
|
1249
|
+
);
|
|
1250
|
+
return {
|
|
1251
|
+
source: "conformance",
|
|
1252
|
+
...n ? { ruleId: n } : {},
|
|
1253
|
+
...t ? { category: t } : {},
|
|
1254
|
+
...o ? { projectId: o } : {},
|
|
1255
|
+
...r.length > 0 ? { relatedProjectIds: r } : {}
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
function rn(e) {
|
|
1259
|
+
if (e === "policy" || e === "conformance")
|
|
1260
|
+
return e;
|
|
1261
|
+
throw new Error(`Unsupported governance exception source "${e}".`);
|
|
1262
|
+
}
|
|
1263
|
+
function v(e, n) {
|
|
1264
|
+
const t = d(e);
|
|
1265
|
+
if (!t)
|
|
1266
|
+
throw new Error(`${n} is required.`);
|
|
1267
|
+
return t;
|
|
1268
|
+
}
|
|
1269
|
+
function d(e) {
|
|
1270
|
+
if (typeof e != "string")
|
|
1271
|
+
return;
|
|
1272
|
+
const n = e.trim();
|
|
1273
|
+
return n.length > 0 ? n : void 0;
|
|
1274
|
+
}
|
|
1275
|
+
function on(e) {
|
|
1276
|
+
return Array.isArray(e) ? [
|
|
1277
|
+
...new Set(
|
|
1278
|
+
e.map(d).filter((n) => !!n)
|
|
1279
|
+
)
|
|
1280
|
+
].sort((n, t) => n.localeCompare(t)) : [];
|
|
1281
|
+
}
|
|
1282
|
+
function an(e) {
|
|
1283
|
+
return d(e);
|
|
1284
|
+
}
|
|
1285
|
+
async function sn(e, n) {
|
|
1286
|
+
const t = cn();
|
|
1287
|
+
for (const o of e) {
|
|
1288
|
+
const r = await o.evaluate(n);
|
|
1289
|
+
t.violations.push(...r.violations ?? []), t.signals.push(...r.signals ?? []), t.measurements.push(...r.measurements ?? []);
|
|
1290
|
+
}
|
|
1291
|
+
return t;
|
|
1292
|
+
}
|
|
1293
|
+
async function Mn(e, n) {
|
|
1294
|
+
return sn(e.rules, n);
|
|
1295
|
+
}
|
|
1296
|
+
function cn() {
|
|
1297
|
+
return {
|
|
1298
|
+
violations: [],
|
|
1299
|
+
signals: [],
|
|
1300
|
+
measurements: []
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
function Cn(e, n) {
|
|
1304
|
+
const t = Object.fromEntries(
|
|
1305
|
+
e.measurements.map((i) => [
|
|
1306
|
+
i.id,
|
|
1307
|
+
i.value
|
|
1308
|
+
])
|
|
1309
|
+
), o = {
|
|
1310
|
+
workspaceHealth: e.health.score,
|
|
1311
|
+
...Object.fromEntries(
|
|
1312
|
+
e.measurements.map((i) => [
|
|
1313
|
+
i.id,
|
|
1314
|
+
i.score
|
|
1315
|
+
])
|
|
1316
|
+
)
|
|
1317
|
+
}, r = e.violations.map(
|
|
1318
|
+
(i) => ({
|
|
1319
|
+
type: i.ruleId,
|
|
1320
|
+
source: i.project,
|
|
1321
|
+
target: ln(i.details?.target),
|
|
1322
|
+
ruleId: i.ruleId,
|
|
1323
|
+
severity: i.severity,
|
|
1324
|
+
message: i.message
|
|
1325
|
+
})
|
|
1326
|
+
);
|
|
1327
|
+
return {
|
|
1328
|
+
...n,
|
|
1329
|
+
metrics: t,
|
|
1330
|
+
scores: o,
|
|
1331
|
+
violations: r,
|
|
1332
|
+
health: {
|
|
1333
|
+
score: e.health.score,
|
|
1334
|
+
status: e.health.status,
|
|
1335
|
+
grade: e.health.grade
|
|
1336
|
+
},
|
|
1337
|
+
signalBreakdown: e.signalBreakdown,
|
|
1338
|
+
metricBreakdown: e.metricBreakdown,
|
|
1339
|
+
topIssues: e.topIssues,
|
|
1340
|
+
deliveryImpact: n.deliveryImpact
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
function ln(e) {
|
|
1344
|
+
return typeof e == "string" ? e : void 0;
|
|
1345
|
+
}
|
|
1346
|
+
class $n {
|
|
1347
|
+
capabilitiesById = /* @__PURE__ */ new Map();
|
|
1348
|
+
capabilities;
|
|
1349
|
+
constructor(n) {
|
|
1350
|
+
const t = n.map(
|
|
1351
|
+
(o) => Object.freeze({ ...o })
|
|
1352
|
+
);
|
|
1353
|
+
for (const o of t) {
|
|
1354
|
+
if (this.capabilitiesById.has(o.id))
|
|
1355
|
+
throw new Error(
|
|
1356
|
+
`Duplicate governance capability id "${o.id}" is not allowed.`
|
|
1357
|
+
);
|
|
1358
|
+
this.capabilitiesById.set(o.id, o);
|
|
1359
|
+
}
|
|
1360
|
+
this.capabilities = Object.freeze([...t]);
|
|
1361
|
+
}
|
|
1362
|
+
has(n) {
|
|
1363
|
+
return this.capabilitiesById.has(n);
|
|
1364
|
+
}
|
|
1365
|
+
get(n) {
|
|
1366
|
+
return this.capabilitiesById.get(n);
|
|
1367
|
+
}
|
|
1368
|
+
list() {
|
|
1369
|
+
return [...this.capabilities];
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
class $ extends Error {
|
|
1373
|
+
diagnostics;
|
|
1374
|
+
constructor(n, t) {
|
|
1375
|
+
super(n), this.name = "GovernanceExtensionRegistrationError", this.diagnostics = t;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
class un {
|
|
1379
|
+
context;
|
|
1380
|
+
registry = {
|
|
1381
|
+
metricProviders: [],
|
|
1382
|
+
signalProviders: [],
|
|
1383
|
+
rulePacks: [],
|
|
1384
|
+
enrichers: []
|
|
1385
|
+
};
|
|
1386
|
+
pluginId;
|
|
1387
|
+
constructor(n, t) {
|
|
1388
|
+
this.context = Object.freeze({
|
|
1389
|
+
...n,
|
|
1390
|
+
options: Object.freeze({ ...n.options })
|
|
1391
|
+
}), this.pluginId = t;
|
|
1392
|
+
}
|
|
1393
|
+
registerMetricProvider(n) {
|
|
1394
|
+
this.registry.metricProviders.push({
|
|
1395
|
+
pluginId: this.pluginId,
|
|
1396
|
+
contribution: n
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
registerSignalProvider(n) {
|
|
1400
|
+
this.registry.signalProviders.push({
|
|
1401
|
+
pluginId: this.pluginId,
|
|
1402
|
+
contribution: n
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
registerRulePack(n) {
|
|
1406
|
+
this.registry.rulePacks.push({
|
|
1407
|
+
pluginId: this.pluginId,
|
|
1408
|
+
contribution: n
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
registerEnricher(n) {
|
|
1412
|
+
this.registry.enrichers.push({
|
|
1413
|
+
pluginId: this.pluginId,
|
|
1414
|
+
contribution: n
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
toRegistry() {
|
|
1418
|
+
return {
|
|
1419
|
+
metricProviders: [...this.registry.metricProviders],
|
|
1420
|
+
signalProviders: [...this.registry.signalProviders],
|
|
1421
|
+
rulePacks: [...this.registry.rulePacks],
|
|
1422
|
+
enrichers: [...this.registry.enrichers]
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
async function On(e, n) {
|
|
1427
|
+
return (await dn(
|
|
1428
|
+
e,
|
|
1429
|
+
n
|
|
1430
|
+
)).registry;
|
|
1431
|
+
}
|
|
1432
|
+
async function dn(e, n, t = {}) {
|
|
1433
|
+
const o = {
|
|
1434
|
+
metricProviders: [],
|
|
1435
|
+
signalProviders: [],
|
|
1436
|
+
rulePacks: [],
|
|
1437
|
+
enrichers: []
|
|
1438
|
+
}, r = [...t.diagnostics ?? []], i = /* @__PURE__ */ new Map();
|
|
1439
|
+
for (const a of n) {
|
|
1440
|
+
try {
|
|
1441
|
+
fn(a);
|
|
1442
|
+
} catch (s) {
|
|
1443
|
+
throw r.push({
|
|
1444
|
+
code: "governance.extension.invalid_definition",
|
|
1445
|
+
severity: "error",
|
|
1446
|
+
message: O(s),
|
|
1447
|
+
packageName: a.sourceSpecifier,
|
|
1448
|
+
moduleSpecifier: a.moduleSpecifier,
|
|
1449
|
+
legacy: a.legacy
|
|
1450
|
+
}), new $(
|
|
1451
|
+
O(s),
|
|
1452
|
+
r
|
|
1453
|
+
);
|
|
1454
|
+
}
|
|
1455
|
+
const c = i.get(a.definition.id);
|
|
1456
|
+
if (c) {
|
|
1457
|
+
const s = `Duplicate governance extension id "${a.definition.id}" was found in "${c}" and "${a.moduleSpecifier}".`;
|
|
1458
|
+
throw r.push({
|
|
1459
|
+
code: "governance.extension.duplicate_id",
|
|
1460
|
+
severity: "error",
|
|
1461
|
+
message: s,
|
|
1462
|
+
packageName: a.sourceSpecifier,
|
|
1463
|
+
moduleSpecifier: a.moduleSpecifier,
|
|
1464
|
+
extensionId: a.definition.id,
|
|
1465
|
+
legacy: a.legacy
|
|
1466
|
+
}), new $(s, r);
|
|
1467
|
+
}
|
|
1468
|
+
i.set(a.definition.id, a.moduleSpecifier);
|
|
1469
|
+
try {
|
|
1470
|
+
const s = new un(
|
|
1471
|
+
e,
|
|
1472
|
+
a.definition.id
|
|
1473
|
+
);
|
|
1474
|
+
await a.definition.register(s), pn(o, s.toRegistry());
|
|
1475
|
+
} catch (s) {
|
|
1476
|
+
const l = `Governance extension "${a.definition.id}" from "${a.moduleSpecifier}" failed during registration: ${O(s)}`;
|
|
1477
|
+
throw r.push({
|
|
1478
|
+
code: "governance.extension.registration_failed",
|
|
1479
|
+
severity: "error",
|
|
1480
|
+
message: l,
|
|
1481
|
+
packageName: a.sourceSpecifier,
|
|
1482
|
+
moduleSpecifier: a.moduleSpecifier,
|
|
1483
|
+
extensionId: a.definition.id,
|
|
1484
|
+
legacy: a.legacy
|
|
1485
|
+
}), new $(l, r);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
return {
|
|
1489
|
+
registry: o,
|
|
1490
|
+
diagnostics: r
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
async function Bn(e, n) {
|
|
1494
|
+
let t = n.workspace;
|
|
1495
|
+
for (const o of e.enrichers)
|
|
1496
|
+
t = await o.contribution.enrichWorkspace({
|
|
1497
|
+
...n,
|
|
1498
|
+
workspace: t
|
|
1499
|
+
});
|
|
1500
|
+
return t;
|
|
1501
|
+
}
|
|
1502
|
+
async function Tn(e, n) {
|
|
1503
|
+
return (await Promise.all(
|
|
1504
|
+
e.rulePacks.map(async (o) => (await o.contribution.evaluate(n)).map((i) => ({
|
|
1505
|
+
...i,
|
|
1506
|
+
sourcePluginId: i.sourcePluginId ?? o.pluginId
|
|
1507
|
+
})))
|
|
1508
|
+
)).flat();
|
|
1509
|
+
}
|
|
1510
|
+
async function zn(e, n) {
|
|
1511
|
+
return (await Promise.all(
|
|
1512
|
+
e.signalProviders.map(async (o) => (await o.contribution.provideSignals(n)).map((i) => ({
|
|
1513
|
+
...i,
|
|
1514
|
+
source: "extension",
|
|
1515
|
+
sourcePluginId: i.sourcePluginId ?? o.pluginId
|
|
1516
|
+
})))
|
|
1517
|
+
)).flat();
|
|
1518
|
+
}
|
|
1519
|
+
async function Ln(e, n) {
|
|
1520
|
+
return (await Promise.all(
|
|
1521
|
+
e.metricProviders.map(async (o) => (await o.contribution.provideMetrics(n)).map((i) => ({
|
|
1522
|
+
...i,
|
|
1523
|
+
sourcePluginId: i.sourcePluginId ?? o.pluginId
|
|
1524
|
+
})))
|
|
1525
|
+
)).flat();
|
|
1526
|
+
}
|
|
1527
|
+
function pn(e, n) {
|
|
1528
|
+
e.metricProviders.push(...n.metricProviders), e.signalProviders.push(...n.signalProviders), e.rulePacks.push(...n.rulePacks), e.enrichers.push(...n.enrichers);
|
|
1529
|
+
}
|
|
1530
|
+
function fn(e) {
|
|
1531
|
+
if (typeof e.definition.id != "string" || e.definition.id.trim().length === 0)
|
|
1532
|
+
throw new Error(
|
|
1533
|
+
`Governance extension module "${e.moduleSpecifier}" must declare a non-empty "id".`
|
|
1534
|
+
);
|
|
1535
|
+
}
|
|
1536
|
+
function O(e) {
|
|
1537
|
+
return e instanceof Error ? e.message : String(e);
|
|
1538
|
+
}
|
|
1539
|
+
export {
|
|
1540
|
+
ze as CORE_BUILT_IN_RULE_PACK_ID,
|
|
1541
|
+
Pn as DEFAULT_HEALTH_STATUS_THRESHOLDS,
|
|
1542
|
+
$n as DefaultGovernanceCapabilityRegistry,
|
|
1543
|
+
$ as GovernanceExtensionRegistrationError,
|
|
1544
|
+
Bn as applyGovernanceEnrichers,
|
|
1545
|
+
vn as buildAiDriftHandoffPayload,
|
|
1546
|
+
S as buildAiHandoffPayload,
|
|
1547
|
+
In as buildAiManagementInsightsHandoffPayload,
|
|
1548
|
+
hn as buildAiPrImpactHandoffPayload,
|
|
1549
|
+
gn as buildAiRootCauseHandoffPayload,
|
|
1550
|
+
wn as buildAiScorecardHandoffPayload,
|
|
1551
|
+
En as buildDriftSummary,
|
|
1552
|
+
yn as buildGovernanceAssessment,
|
|
1553
|
+
xn as buildGovernanceExceptionScopeKey,
|
|
1554
|
+
mn as buildGovernanceWorkspace,
|
|
1555
|
+
Pe as buildMetricBreakdown,
|
|
1556
|
+
Cn as buildMetricSnapshot,
|
|
1557
|
+
Ie as buildSignalBreakdown,
|
|
1558
|
+
Se as buildTopIssues,
|
|
1559
|
+
Ln as collectGovernanceMeasurements,
|
|
1560
|
+
zn as collectGovernanceSignals,
|
|
1561
|
+
Dn as compareSnapshots,
|
|
1562
|
+
Ee as coreBuiltInPolicyRules,
|
|
1563
|
+
Le as coreBuiltInRulePack,
|
|
1564
|
+
bn as coreBuiltInRulePacks,
|
|
1565
|
+
z as deriveAllowedLayerDependenciesFromLayerOrder,
|
|
1566
|
+
w as domainBoundaryRule,
|
|
1567
|
+
Sn as evaluateCoreBuiltInPolicyViolations,
|
|
1568
|
+
Tn as evaluateGovernanceRulePacks,
|
|
1569
|
+
Mn as evaluateRulePack,
|
|
1570
|
+
sn as evaluateRules,
|
|
1571
|
+
ve as filterMeasurementsForReportType,
|
|
1572
|
+
we as filterSignalsForReportType,
|
|
1573
|
+
he as filterViolationsForReportType,
|
|
1574
|
+
Rn as isConformanceExceptionScope,
|
|
1575
|
+
nn as isPolicyExceptionScope,
|
|
1576
|
+
I as layerBoundaryRule,
|
|
1577
|
+
k as missingDomainRule,
|
|
1578
|
+
x as missingLayerRule,
|
|
1579
|
+
kn as normalizeGovernanceException,
|
|
1580
|
+
m as normalizeGovernanceProfile,
|
|
1581
|
+
P as ownershipPresenceRule,
|
|
1582
|
+
j as projectNameConventionRule,
|
|
1583
|
+
On as registerLoadedGovernanceExtensions,
|
|
1584
|
+
dn as registerLoadedGovernanceExtensionsWithDiagnostics,
|
|
1585
|
+
jn as summarizeDrift,
|
|
1586
|
+
E as tagConventionRule
|
|
1587
|
+
};
|