@getcodesentinel/codesentinel 1.23.1 → 1.25.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.
@@ -14,8 +14,8 @@
14
14
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap"
15
15
  rel="stylesheet"
16
16
  />
17
- <script type="module" crossorigin src="./assets/index-BJzktu6y.js"></script>
18
- <link rel="stylesheet" crossorigin href="./assets/index-CVTvBtpa.css">
17
+ <script type="module" crossorigin src="./assets/index-4ZaNK_oW.js"></script>
18
+ <link rel="stylesheet" crossorigin href="./assets/index-0O4aQ7tn.css">
19
19
  </head>
20
20
  <body>
21
21
  <div id="root"></div>
package/dist/index.js CHANGED
@@ -1853,6 +1853,13 @@ var diffScoreMap = (current, baseline) => {
1853
1853
  }).filter((entry) => entry.delta !== 0).sort((a, b) => Math.abs(b.delta) - Math.abs(a.delta) || a.target.localeCompare(b.target));
1854
1854
  };
1855
1855
  var cycleKey = (nodes) => [...nodes].sort((a, b) => a.localeCompare(b)).join(" -> ");
1856
+ var repositoryExternalDimension = (snapshot) => {
1857
+ const factor = snapshot.trace?.targets.find(
1858
+ (target) => target.targetType === "repository" && target.targetId === snapshot.analysis.structural.targetPath
1859
+ )?.factors.find((item) => item.factorId === "repository.external");
1860
+ const raw = factor?.rawMetrics["externalDimension"];
1861
+ return typeof raw === "number" ? round43(raw * 100) : null;
1862
+ };
1856
1863
  var compareSnapshots = (current, baseline) => {
1857
1864
  const currentFileScores = new Map(
1858
1865
  current.analysis.risk.fileScores.map((item) => [item.file, item.score])
@@ -1895,10 +1902,12 @@ var compareSnapshots = (current, baseline) => {
1895
1902
  const hotspots = diffSets(currentHotspots, baselineHotspots);
1896
1903
  const cycles = diffSets(currentCycles, baselineCycles);
1897
1904
  return {
1905
+ baselineGeneratedAt: baseline.generatedAt,
1898
1906
  riskScoreDelta: round43(current.analysis.risk.riskScore - baseline.analysis.risk.riskScore),
1899
1907
  normalizedScoreDelta: round43(
1900
1908
  current.analysis.risk.normalizedScore - baseline.analysis.risk.normalizedScore
1901
1909
  ),
1910
+ externalDimensionDelta: repositoryExternalDimension(current) === null || repositoryExternalDimension(baseline) === null ? null : round43(repositoryExternalDimension(current) - repositoryExternalDimension(baseline)),
1902
1911
  fileRiskChanges: diffScoreMap(currentFileScores, baselineFileScores),
1903
1912
  moduleRiskChanges: diffScoreMap(currentModuleScores, baselineModuleScores),
1904
1913
  newHotspots: hotspots.added,
@@ -2035,6 +2044,136 @@ var cycleDetails = (snapshot) => snapshot.analysis.structural.cycles.map((cycle,
2035
2044
  path: nodes.join(" -> ")
2036
2045
  };
2037
2046
  });
2047
+ var structuralArchitectureMetrics = (snapshot) => {
2048
+ const metrics = snapshot.analysis.structural.metrics;
2049
+ const nodeCount = metrics.nodeCount;
2050
+ const edgeCount = metrics.edgeCount;
2051
+ const maxPossibleEdges = nodeCount <= 1 ? 0 : nodeCount * (nodeCount - 1);
2052
+ const couplingDensity = maxPossibleEdges === 0 ? 0 : round43(edgeCount / maxPossibleEdges * 100);
2053
+ const entryPointCount = snapshot.analysis.structural.files.filter(
2054
+ (file) => file.fanIn === 0 && file.fanOut > 0
2055
+ ).length;
2056
+ return {
2057
+ nodeCount,
2058
+ edgeCount,
2059
+ graphDepth: metrics.graphDepth,
2060
+ maxFanIn: metrics.maxFanIn,
2061
+ maxFanOut: metrics.maxFanOut,
2062
+ couplingDensity,
2063
+ entryPointCount
2064
+ };
2065
+ };
2066
+ var structuralModuleAnatomy = (snapshot) => {
2067
+ const moduleMap = /* @__PURE__ */ new Map();
2068
+ for (const file of snapshot.analysis.structural.files) {
2069
+ const module = toPosixDirname(file.relativePath);
2070
+ const current = moduleMap.get(module) ?? {
2071
+ module,
2072
+ dependencyCount: 0,
2073
+ fanIn: 0,
2074
+ fanOut: 0,
2075
+ depth: 0
2076
+ };
2077
+ current.dependencyCount += file.directDependencies.length;
2078
+ current.fanIn = Math.max(current.fanIn, file.fanIn);
2079
+ current.fanOut = Math.max(current.fanOut, file.fanOut);
2080
+ current.depth = Math.max(current.depth, file.depth);
2081
+ moduleMap.set(module, current);
2082
+ }
2083
+ return [...moduleMap.values()].sort(
2084
+ (a, b) => b.dependencyCount - a.dependencyCount || b.fanIn - a.fanIn || b.depth - a.depth || a.module.localeCompare(b.module)
2085
+ ).slice(0, 5);
2086
+ };
2087
+ var average = (values) => values.length === 0 ? null : round43(values.reduce((sum, value) => sum + value, 0) / values.length);
2088
+ var toPercent = (value) => round43(value * 100);
2089
+ var LEGACY_NO_ACTIVE_OWNER_DAYS = 180;
2090
+ var changeOwnershipSummary = (snapshot) => {
2091
+ if (!snapshot.analysis.evolution.available) {
2092
+ return {
2093
+ available: false,
2094
+ reason: snapshot.analysis.evolution.reason
2095
+ };
2096
+ }
2097
+ const evolution = snapshot.analysis.evolution;
2098
+ const files = evolution.files;
2099
+ const ownershipReadyFiles = files.filter(
2100
+ (file) => file.topAuthorShareByCommits !== null && file.authorDistributionByCommits.length > 0
2101
+ );
2102
+ const sharedOwnershipCount = ownershipReadyFiles.filter(
2103
+ (file) => file.authorDistributionByCommits.length >= 2 && file.topAuthorShareByCommits <= 0.6
2104
+ ).length;
2105
+ const concentratedOwnershipCount = ownershipReadyFiles.filter(
2106
+ (file) => file.authorDistributionByCommits.length >= 2 && file.topAuthorShareByCommits > 0.6
2107
+ ).length;
2108
+ const singleMaintainerCount = ownershipReadyFiles.filter(
2109
+ (file) => file.authorDistributionByCommits.length <= 1
2110
+ ).length;
2111
+ const headCommitTimestamp = evolution.metrics.headCommitTimestamp;
2112
+ const legacyNoActiveOwnerCount = ownershipReadyFiles.filter(
2113
+ (file) => file.commitCount > 0 && file.lastCommitTimestamp !== null && headCommitTimestamp !== null && headCommitTimestamp - file.lastCommitTimestamp >= LEGACY_NO_ACTIVE_OWNER_DAYS * 86400
2114
+ ).length;
2115
+ const ownershipDivisor = ownershipReadyFiles.length || 0;
2116
+ const moduleKnowledgeMap = /* @__PURE__ */ new Map();
2117
+ for (const file of files) {
2118
+ const module = toPosixDirname(file.filePath);
2119
+ const current = moduleKnowledgeMap.get(module) ?? {
2120
+ module,
2121
+ totalCommits: 0,
2122
+ recentCommits: 0,
2123
+ authors: /* @__PURE__ */ new Set(),
2124
+ weightedTopAuthorShare: 0,
2125
+ weight: 0
2126
+ };
2127
+ current.totalCommits += file.commitCount;
2128
+ current.recentCommits += file.recentCommitCount;
2129
+ for (const author of file.authorDistributionByCommits) {
2130
+ current.authors.add(author.authorId);
2131
+ }
2132
+ current.weightedTopAuthorShare += file.topAuthorShareByCommits * Math.max(1, file.commitCount);
2133
+ current.weight += Math.max(1, file.commitCount);
2134
+ moduleKnowledgeMap.set(module, current);
2135
+ }
2136
+ const moduleKnowledge = [...moduleKnowledgeMap.values()].map((entry) => {
2137
+ const topAuthorShareByCommits = entry.weight <= 0 ? 0 : round43(entry.weightedTopAuthorShare / entry.weight);
2138
+ const activeAuthors = entry.authors.size;
2139
+ const ownershipLabel = activeAuthors <= 1 || topAuthorShareByCommits >= 0.85 ? "siloed" : activeAuthors <= 2 || topAuthorShareByCommits >= 0.65 ? "sparse" : "distributed";
2140
+ return {
2141
+ module: entry.module,
2142
+ totalCommits: entry.totalCommits,
2143
+ recentCommits: entry.recentCommits,
2144
+ activeAuthors,
2145
+ topAuthorShareByCommits,
2146
+ ownershipLabel
2147
+ };
2148
+ }).sort((a, b) => b.totalCommits - a.totalCommits || a.module.localeCompare(b.module)).slice(0, 8);
2149
+ const coChangePairs = [...evolution.coupling.pairs].sort(
2150
+ (a, b) => b.couplingScore - a.couplingScore || b.coChangeCommits - a.coChangeCommits || a.fileA.localeCompare(b.fileA) || a.fileB.localeCompare(b.fileB)
2151
+ ).slice(0, 5).map((pair) => ({
2152
+ fileA: pair.fileA,
2153
+ fileB: pair.fileB,
2154
+ coChangeCommits: pair.coChangeCommits,
2155
+ couplingScore: round43(pair.couplingScore)
2156
+ }));
2157
+ return {
2158
+ available: true,
2159
+ metrics: {
2160
+ totalCommits: evolution.metrics.totalCommits,
2161
+ totalFiles: evolution.metrics.totalFiles,
2162
+ recentWindowDays: evolution.metrics.recentWindowDays,
2163
+ meanBusFactorByCommits: average(
2164
+ files.map((file) => file.busFactorByCommits).filter((value) => value !== null)
2165
+ ),
2166
+ averageRecentVolatility: average(files.map((file) => toPercent(file.recentVolatility))),
2167
+ sharedOwnershipPercent: ownershipDivisor === 0 ? null : round43(sharedOwnershipCount / ownershipDivisor * 100),
2168
+ concentratedOwnershipPercent: ownershipDivisor === 0 ? null : round43(concentratedOwnershipCount / ownershipDivisor * 100),
2169
+ singleMaintainerPercent: ownershipDivisor === 0 ? null : round43(singleMaintainerCount / ownershipDivisor * 100),
2170
+ legacyNoActiveOwnerPercent: ownershipDivisor === 0 ? null : round43(legacyNoActiveOwnerCount / ownershipDivisor * 100)
2171
+ },
2172
+ recentActivity: evolution.recentActivity ?? [],
2173
+ coChangePairs,
2174
+ moduleKnowledge
2175
+ };
2176
+ };
2038
2177
  var riskyDependencies = (snapshot) => {
2039
2178
  if (!snapshot.analysis.external.available) {
2040
2179
  return [];
@@ -2052,6 +2191,18 @@ var riskyDependencies = (snapshot) => {
2052
2191
  dependencyScope: normalizeDependencyScope(dependency?.dependencyScope),
2053
2192
  direct: dependency?.direct ?? false,
2054
2193
  resolvedVersion: dependency?.resolvedVersion ?? null,
2194
+ transitiveDependencyCount: dependency?.transitiveDependencies.length ?? 0,
2195
+ dependentCount: dependency?.dependents ?? 0,
2196
+ fanOut: dependency?.fanOut ?? 0,
2197
+ dependencyDepth: dependency?.dependencyDepth ?? 0,
2198
+ weeklyDownloads: dependency?.weeklyDownloads ?? null,
2199
+ maintainerCount: dependency?.maintainerCount ?? null,
2200
+ releaseFrequencyDays: dependency?.releaseFrequencyDays ?? null,
2201
+ daysSinceLastRelease: dependency?.daysSinceLastRelease ?? null,
2202
+ repositoryActivity30d: dependency?.repositoryActivity30d ?? null,
2203
+ busFactor: dependency?.busFactor ?? null,
2204
+ ownRiskSignals: dependency?.ownRiskSignals ?? [],
2205
+ inheritedRiskSignals: dependency?.inheritedRiskSignals ?? [],
2055
2206
  riskSignals,
2056
2207
  reason: riskSignals.length === 0 ? "Derived from aggregate dependency risk signals." : riskSignals.join(", ")
2057
2208
  };
@@ -2106,6 +2257,8 @@ var createReport = (snapshot, diff) => {
2106
2257
  (cycle) => [...cycle.nodes].sort((a, b) => a.localeCompare(b)).join(" -> ")
2107
2258
  ),
2108
2259
  cycleDetails: cycleDetails(snapshot),
2260
+ metrics: structuralArchitectureMetrics(snapshot),
2261
+ moduleAnatomy: structuralModuleAnatomy(snapshot),
2109
2262
  fanInOutExtremes: {
2110
2263
  highestFanIn: topStructuralFiles(snapshot, (file) => file.fanIn),
2111
2264
  highestFanOut: topStructuralFiles(snapshot, (file) => file.fanOut),
@@ -2118,23 +2271,31 @@ var createReport = (snapshot, diff) => {
2118
2271
  files: [...cluster.files].sort((a, b) => a.localeCompare(b))
2119
2272
  }))
2120
2273
  },
2274
+ changeOwnership: changeOwnershipSummary(snapshot),
2121
2275
  external: !external.available ? {
2122
2276
  available: false,
2123
2277
  reason: external.reason
2124
2278
  } : {
2125
2279
  available: true,
2280
+ metrics: external.metrics,
2126
2281
  highRiskDependencies: [...external.highRiskDependencies].sort(
2127
2282
  (a, b) => a.localeCompare(b)
2128
2283
  ),
2129
2284
  highRiskDevelopmentDependencies: [...external.highRiskDevelopmentDependencies].sort(
2130
2285
  (a, b) => a.localeCompare(b)
2131
2286
  ),
2287
+ transitiveExposureDependencies: [...external.transitiveExposureDependencies].sort(
2288
+ (a, b) => a.localeCompare(b)
2289
+ ),
2132
2290
  singleMaintainerDependencies: [...external.singleMaintainerDependencies].sort(
2133
2291
  (a, b) => a.localeCompare(b)
2134
2292
  ),
2135
2293
  abandonedDependencies: [...external.abandonedDependencies].sort(
2136
2294
  (a, b) => a.localeCompare(b)
2137
2295
  ),
2296
+ centralityRanking: [...external.centralityRanking].sort(
2297
+ (a, b) => b.dependents - a.dependents || b.fanOut - a.fanOut || a.name.localeCompare(b.name)
2298
+ ),
2138
2299
  riskyDependencies: riskyDependencies(snapshot)
2139
2300
  },
2140
2301
  appendix: {
@@ -4624,6 +4785,9 @@ var buildProjectGraphSummary = (input) => {
4624
4785
  import { execFileSync } from "child_process";
4625
4786
  var pairKey = (a, b) => `${a}\0${b}`;
4626
4787
  var round44 = (value) => Number(value.toFixed(4));
4788
+ var dayBucketStart = (value) => Math.floor(value / 86400) * 86400;
4789
+ var utcDateStringFromBucket = (value) => new Date(value * 1e3).toISOString().slice(0, 10);
4790
+ var normalizeRatio = (value, max) => max <= 0 ? 0 : Math.max(0, Math.min(1, value / max));
4627
4791
  var normalizeName = (value) => value.toLowerCase().replace(/[^a-z0-9\s]/g, " ").replace(/\s+/g, " ").trim();
4628
4792
  var extractEmailStem = (authorId) => {
4629
4793
  const normalized = authorId.trim().toLowerCase();
@@ -4836,6 +5000,7 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
4836
5000
  const authorAliasById = config.authorIdentityMode === "likely_merge" ? buildAuthorAliasMap(commits) : /* @__PURE__ */ new Map();
4837
5001
  const fileStats = /* @__PURE__ */ new Map();
4838
5002
  const coChangeByPair = /* @__PURE__ */ new Map();
5003
+ const recentActivityByDay = /* @__PURE__ */ new Map();
4839
5004
  const headCommitTimestamp = commits.length === 0 ? null : commits[commits.length - 1]?.authoredAtUnix ?? null;
4840
5005
  const recentWindowStart = headCommitTimestamp === null ? Number.NEGATIVE_INFINITY : headCommitTimestamp - config.recentWindowDays * 24 * 60 * 60;
4841
5006
  let consideredCommits = 0;
@@ -4847,11 +5012,13 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
4847
5012
  const current = fileStats.get(fileChange.filePath) ?? {
4848
5013
  commitCount: 0,
4849
5014
  recentCommitCount: 0,
5015
+ lastCommitTimestamp: null,
4850
5016
  churnAdded: 0,
4851
5017
  churnDeleted: 0,
4852
5018
  authorsByCommits: /* @__PURE__ */ new Map(),
4853
5019
  authorsByChurn: /* @__PURE__ */ new Map()
4854
5020
  };
5021
+ current.lastCommitTimestamp = current.lastCommitTimestamp === null ? commit.authoredAtUnix : Math.max(current.lastCommitTimestamp, commit.authoredAtUnix);
4855
5022
  current.churnAdded += fileChange.additions;
4856
5023
  current.churnDeleted += fileChange.deletions;
4857
5024
  const effectiveAuthorId = authorAliasById.get(commit.authorId) ?? commit.authorId;
@@ -4880,6 +5047,25 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
4880
5047
  );
4881
5048
  }
4882
5049
  const orderedFiles = [...uniqueFiles].sort((a, b) => a.localeCompare(b));
5050
+ if (commit.authoredAtUnix >= recentWindowStart) {
5051
+ const bucketStartTimestamp = dayBucketStart(commit.authoredAtUnix);
5052
+ const activity = recentActivityByDay.get(bucketStartTimestamp) ?? {
5053
+ commitCount: 0,
5054
+ fileTouchCount: 0,
5055
+ churnTotal: 0,
5056
+ authors: /* @__PURE__ */ new Set()
5057
+ };
5058
+ const effectiveAuthorId = authorAliasById.get(commit.authorId) ?? commit.authorId;
5059
+ const commitChurn = commit.fileChanges.reduce(
5060
+ (sum, fileChange) => sum + fileChange.additions + fileChange.deletions,
5061
+ 0
5062
+ );
5063
+ activity.commitCount += 1;
5064
+ activity.fileTouchCount += uniqueFiles.size;
5065
+ activity.churnTotal += commitChurn;
5066
+ activity.authors.add(effectiveAuthorId);
5067
+ recentActivityByDay.set(bucketStartTimestamp, activity);
5068
+ }
4883
5069
  if (orderedFiles.length > 1) {
4884
5070
  if (orderedFiles.length <= config.maxFilesPerCommitForCoupling) {
4885
5071
  consideredCommits += 1;
@@ -4911,6 +5097,7 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
4911
5097
  churnAdded: stats.churnAdded,
4912
5098
  churnDeleted: stats.churnDeleted,
4913
5099
  churnTotal: stats.churnAdded + stats.churnDeleted,
5100
+ lastCommitTimestamp: stats.lastCommitTimestamp,
4914
5101
  recentCommitCount: stats.recentCommitCount,
4915
5102
  recentVolatility: stats.commitCount === 0 ? 0 : round44(stats.recentCommitCount / stats.commitCount),
4916
5103
  topAuthorShareByCommits,
@@ -4936,12 +5123,42 @@ var computeRepositoryEvolutionSummary = (targetPath, commits, config) => {
4936
5123
  config.maxCouplingPairs
4937
5124
  );
4938
5125
  const { hotspots, threshold } = selectHotspots(files, config);
5126
+ const recentActivityBase = headCommitTimestamp === null ? [] : Array.from({ length: config.recentWindowDays }, (_, index) => {
5127
+ const bucketStartTimestamp = dayBucketStart(headCommitTimestamp) - (config.recentWindowDays - 1 - index) * 86400;
5128
+ const activity = recentActivityByDay.get(bucketStartTimestamp);
5129
+ return {
5130
+ bucketStartUtcDate: utcDateStringFromBucket(bucketStartTimestamp),
5131
+ commitCount: activity?.commitCount ?? 0,
5132
+ fileTouchCount: activity?.fileTouchCount ?? 0,
5133
+ churnTotal: activity?.churnTotal ?? 0,
5134
+ activeAuthorCount: activity?.authors.size ?? 0
5135
+ };
5136
+ });
5137
+ const maxRecentCommitCount = Math.max(1, ...recentActivityBase.map((point) => point.commitCount));
5138
+ const maxRecentFileTouches = Math.max(
5139
+ 1,
5140
+ ...recentActivityBase.map((point) => point.fileTouchCount)
5141
+ );
5142
+ const maxRecentChurn = Math.max(1, ...recentActivityBase.map((point) => point.churnTotal));
5143
+ const maxRecentChurnLog = Math.log1p(maxRecentChurn);
5144
+ const recentActivity = recentActivityBase.map((point) => {
5145
+ const commitIntensity = normalizeRatio(point.commitCount, maxRecentCommitCount);
5146
+ const fileTouchIntensity = normalizeRatio(point.fileTouchCount, maxRecentFileTouches);
5147
+ const churnIntensity = point.churnTotal <= 0 ? 0 : Math.log1p(point.churnTotal) / maxRecentChurnLog;
5148
+ return {
5149
+ ...point,
5150
+ volatilityScore: round44(
5151
+ commitIntensity * 0.35 + fileTouchIntensity * 0.2 + churnIntensity * 0.45
5152
+ )
5153
+ };
5154
+ });
4939
5155
  return {
4940
5156
  targetPath,
4941
5157
  available: true,
4942
5158
  files,
4943
5159
  hotspots,
4944
5160
  coupling,
5161
+ recentActivity,
4945
5162
  metrics: {
4946
5163
  totalCommits: commits.length,
4947
5164
  totalFiles: files.length,
@@ -5180,7 +5397,7 @@ var clamp01 = (value) => {
5180
5397
  return value;
5181
5398
  };
5182
5399
  var round45 = (value) => Number(value.toFixed(4));
5183
- var average = (values) => {
5400
+ var average2 = (values) => {
5184
5401
  if (values.length === 0) {
5185
5402
  return 0;
5186
5403
  }
@@ -5312,7 +5529,7 @@ var computeRepositoryHealthSummary = (input) => {
5312
5529
  );
5313
5530
  const fanInConcentration = concentration(input.structural.files.map((file) => file.fanIn));
5314
5531
  const fanOutConcentration = concentration(input.structural.files.map((file) => file.fanOut));
5315
- const fanConcentration = average([fanInConcentration, fanOutConcentration]);
5532
+ const fanConcentration = average2([fanInConcentration, fanOutConcentration]);
5316
5533
  const centralityPressure = input.structural.files.map((file) => file.fanIn + file.fanOut);
5317
5534
  const centralityConcentration = concentration(centralityPressure);
5318
5535
  let structuralHotspotOverlap = 0;
@@ -5482,7 +5699,7 @@ var computeRepositoryHealthSummary = (input) => {
5482
5699
  12,
5483
5700
  0.3
5484
5701
  );
5485
- const coChangeRaw = average([
5702
+ const coChangeRaw = average2([
5486
5703
  clamp01(denseCoChangePairRatio / 0.2),
5487
5704
  couplingScoreConcentration
5488
5705
  ]);
@@ -5730,7 +5947,7 @@ var computeRepositoryHealthSummary = (input) => {
5730
5947
  const modulesDominatedBySingleContributorRatio = trackedModules === 0 ? 0 : clamp01(dominatedModules / trackedModules);
5731
5948
  const ownershipSampleSize = trackedFiles;
5732
5949
  const ownershipCommitVolume = totalAuthorCommits;
5733
- const ownershipReliability = average([
5950
+ const ownershipReliability = average2([
5734
5951
  clamp01(ownershipSampleSize / 12),
5735
5952
  clamp01(ownershipCommitVolume / 180)
5736
5953
  ]);
@@ -6077,7 +6294,7 @@ var DEFAULT_RISK_ENGINE_CONFIG = {
6077
6294
  };
6078
6295
  var toUnitInterval = (value) => Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
6079
6296
  var round46 = (value) => Number(value.toFixed(4));
6080
- var average2 = (values) => {
6297
+ var average3 = (values) => {
6081
6298
  if (values.length === 0) {
6082
6299
  return 0;
6083
6300
  }
@@ -6185,7 +6402,7 @@ var computeAggregatorAttenuation = (input) => {
6185
6402
  const fanOutSignal = toUnitInterval((fanOut - config.minFanOut) / Math.max(1, config.minFanOut));
6186
6403
  const lowChurnPerCommitSignal = 1 - toUnitInterval(churnPerCommit / config.maxChurnPerCommit);
6187
6404
  const lowChurnPerDependencySignal = 1 - toUnitInterval(churnPerDependency / config.maxChurnPerDependency);
6188
- const attenuationConfidence = average2([
6405
+ const attenuationConfidence = average3([
6189
6406
  fanInSignal,
6190
6407
  fanOutSignal,
6191
6408
  lowChurnPerCommitSignal,
@@ -6414,7 +6631,7 @@ var computeDependencyScores = (external, config) => {
6414
6631
  );
6415
6632
  const normalizedValues = dependencyScores.map((score) => score.normalizedScore);
6416
6633
  const highDependencyRisk = dependencyScores.length === 0 ? 0 : percentile(normalizedValues, config.externalDimension.topDependencyPercentile);
6417
- const averageDependencyRisk = average2(normalizedValues);
6634
+ const averageDependencyRisk = average3(normalizedValues);
6418
6635
  const depthRisk = halfLifeRisk(
6419
6636
  external.metrics.dependencyDepth,
6420
6637
  config.externalDimension.dependencyDepthHalfLife
@@ -6485,7 +6702,7 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
6485
6702
  continue;
6486
6703
  }
6487
6704
  files.sort((a, b) => a.localeCompare(b));
6488
- const averageRisk = average2(
6705
+ const averageRisk = average3(
6489
6706
  files.map((filePath) => fileScoresByFile.get(filePath)?.normalizedScore ?? 0)
6490
6707
  );
6491
6708
  const cycleSizeRisk = toUnitInterval((files.length - 1) / 5);
@@ -6559,10 +6776,10 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
6559
6776
  const componentPairs = selectedPairs.filter(
6560
6777
  (pair) => fileSet.has(pair.fileA) && fileSet.has(pair.fileB)
6561
6778
  );
6562
- const meanFileRisk = average2(
6779
+ const meanFileRisk = average3(
6563
6780
  files.map((filePath) => fileScoresByFile.get(filePath)?.normalizedScore ?? 0)
6564
6781
  );
6565
- const meanCoupling = average2(componentPairs.map((pair) => pair.couplingScore));
6782
+ const meanCoupling = average3(componentPairs.map((pair) => pair.couplingScore));
6566
6783
  const score = round46(toUnitInterval(meanFileRisk * 0.65 + meanCoupling * 0.35) * 100);
6567
6784
  couplingClusterCount += 1;
6568
6785
  clusters.push({
@@ -6838,7 +7055,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
6838
7055
  moduleFiles.set(moduleName, values);
6839
7056
  }
6840
7057
  const moduleScores = [...moduleFiles.entries()].map(([module, values]) => {
6841
- const averageScore = average2(values);
7058
+ const averageScore = average3(values);
6842
7059
  const peakScore = values.reduce((max, value) => Math.max(max, value), 0);
6843
7060
  const normalizedScore = toUnitInterval(averageScore * 0.65 + peakScore * 0.35);
6844
7061
  return {
@@ -6850,7 +7067,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
6850
7067
  }).sort((a, b) => b.score - a.score || a.module.localeCompare(b.module));
6851
7068
  if (collector !== void 0) {
6852
7069
  for (const [module, values] of moduleFiles.entries()) {
6853
- const averageScore = average2(values);
7070
+ const averageScore = average3(values);
6854
7071
  const peakScore = values.reduce((max, value) => Math.max(max, value), 0);
6855
7072
  const normalizedScore = toUnitInterval(averageScore * 0.65 + peakScore * 0.35);
6856
7073
  const totalScore = round46(normalizedScore * 100);
@@ -7012,16 +7229,16 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
7012
7229
  );
7013
7230
  }
7014
7231
  }
7015
- const structuralDimension = average2(fileScores.map((fileScore) => fileScore.factors.structural));
7016
- const evolutionDimension = average2(fileScores.map((fileScore) => fileScore.factors.evolution));
7232
+ const structuralDimension = average3(fileScores.map((fileScore) => fileScore.factors.structural));
7233
+ const evolutionDimension = average3(fileScores.map((fileScore) => fileScore.factors.evolution));
7017
7234
  const externalDimension = dependencyComputation.repositoryExternalPressure;
7018
7235
  const topCentralSlice = Math.max(1, Math.ceil(fileRiskContexts.length * 0.1));
7019
- const criticalInstability = average2(
7236
+ const criticalInstability = average3(
7020
7237
  [...fileRiskContexts].sort(
7021
7238
  (a, b) => b.structuralCentrality * b.factors.evolution - a.structuralCentrality * a.factors.evolution || a.file.localeCompare(b.file)
7022
7239
  ).slice(0, topCentralSlice).map((context) => context.structuralCentrality * context.factors.evolution)
7023
7240
  );
7024
- const dependencyAmplification = average2(
7241
+ const dependencyAmplification = average3(
7025
7242
  dependencyAmplificationZones.map(
7026
7243
  (zone) => toUnitInterval(zone.externalPressure * zone.score / 100)
7027
7244
  )