@getcodesentinel/codesentinel 1.12.0 → 1.12.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/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4429,6 +4429,29 @@ var computeDependencySignalScore = (ownSignals, inheritedSignals, inheritedSigna
|
|
|
4429
4429
|
return toUnitInterval(weightedTotal / maxWeightedTotal);
|
|
4430
4430
|
};
|
|
4431
4431
|
var clampConfidence = (value) => round45(toUnitInterval(value));
|
|
4432
|
+
var computeExternalMetadataConfidence = (external) => {
|
|
4433
|
+
if (!external.available) {
|
|
4434
|
+
return 0;
|
|
4435
|
+
}
|
|
4436
|
+
return round45(toUnitInterval(0.35 + external.metrics.metadataCoverage * 0.65));
|
|
4437
|
+
};
|
|
4438
|
+
var computeEvolutionHistoryConfidence = (structural, evolution, evolutionByFile) => {
|
|
4439
|
+
if (!evolution.available) {
|
|
4440
|
+
return 0;
|
|
4441
|
+
}
|
|
4442
|
+
const totalFiles = structural.files.length;
|
|
4443
|
+
if (totalFiles === 0) {
|
|
4444
|
+
return 1;
|
|
4445
|
+
}
|
|
4446
|
+
let coveredFiles = 0;
|
|
4447
|
+
for (const file of structural.files) {
|
|
4448
|
+
if (evolutionByFile.has(normalizePath2(file.id))) {
|
|
4449
|
+
coveredFiles += 1;
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4452
|
+
const coverage = coveredFiles / totalFiles;
|
|
4453
|
+
return round45(toUnitInterval(0.3 + coverage * 0.7));
|
|
4454
|
+
};
|
|
4432
4455
|
var buildFactorTraces = (totalScore, inputs) => {
|
|
4433
4456
|
const positiveInputs = inputs.filter((input) => input.strength > 0);
|
|
4434
4457
|
const strengthTotal = positiveInputs.reduce((sum, input) => sum + input.strength, 0);
|
|
@@ -4529,6 +4552,7 @@ var computeDependencyScores = (external, config) => {
|
|
|
4529
4552
|
config.quantileClamp.upper
|
|
4530
4553
|
);
|
|
4531
4554
|
const dependencyContexts = /* @__PURE__ */ new Map();
|
|
4555
|
+
const metadataConfidence = computeExternalMetadataConfidence(external);
|
|
4532
4556
|
const dependencyScores = external.dependencies.map((dependency) => {
|
|
4533
4557
|
const signalScore = computeDependencySignalScore(
|
|
4534
4558
|
dependency.ownRiskSignals,
|
|
@@ -4563,7 +4587,7 @@ var computeDependencyScores = (external, config) => {
|
|
|
4563
4587
|
dependency.busFactor,
|
|
4564
4588
|
dependency.weeklyDownloads
|
|
4565
4589
|
].filter((value) => value !== null).length;
|
|
4566
|
-
const confidence = toUnitInterval(0.5 + availableMetricCount * 0.125);
|
|
4590
|
+
const confidence = toUnitInterval((0.5 + availableMetricCount * 0.125) * metadataConfidence);
|
|
4567
4591
|
dependencyContexts.set(dependency.name, {
|
|
4568
4592
|
signalScore: round45(signalScore),
|
|
4569
4593
|
stalenessRisk: round45(stalenessRisk),
|
|
@@ -4762,7 +4786,13 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
4762
4786
|
var computeRiskSummary = (structural, evolution, external, config, traceCollector) => {
|
|
4763
4787
|
const collector = traceCollector;
|
|
4764
4788
|
const dependencyComputation = computeDependencyScores(external, config);
|
|
4789
|
+
const externalMetadataConfidence = computeExternalMetadataConfidence(external);
|
|
4765
4790
|
const evolutionByFile = mapEvolutionByFile(evolution);
|
|
4791
|
+
const evolutionHistoryConfidence = computeEvolutionHistoryConfidence(
|
|
4792
|
+
structural,
|
|
4793
|
+
evolution,
|
|
4794
|
+
evolutionByFile
|
|
4795
|
+
);
|
|
4766
4796
|
const evolutionScales = computeEvolutionScales(evolutionByFile, config);
|
|
4767
4797
|
const cycleFileSet = new Set(
|
|
4768
4798
|
structural.cycles.flatMap((cycle) => cycle.nodes.map((node) => normalizePath2(node)))
|
|
@@ -4946,7 +4976,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
4946
4976
|
weight: dimensionWeights.evolution,
|
|
4947
4977
|
amplification: null,
|
|
4948
4978
|
evidence: [{ kind: "file_metric", target: context.file, metric: "commitCount" }],
|
|
4949
|
-
confidence: evolution.available ? 1 : 0
|
|
4979
|
+
confidence: evolution.available ? evolutionHistoryConfidence * (context.rawMetrics.commitCount === null ? 0.5 : 1) : 0
|
|
4950
4980
|
},
|
|
4951
4981
|
{
|
|
4952
4982
|
factorId: "file.external",
|
|
@@ -4962,7 +4992,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
4962
4992
|
weight: dimensionWeights.external,
|
|
4963
4993
|
amplification: null,
|
|
4964
4994
|
evidence: [{ kind: "repository_metric", metric: "repositoryExternalPressure" }],
|
|
4965
|
-
confidence: external.available ? 0.7 : 0
|
|
4995
|
+
confidence: external.available ? 0.7 * externalMetadataConfidence : 0
|
|
4966
4996
|
},
|
|
4967
4997
|
{
|
|
4968
4998
|
factorId: "file.composite.interactions",
|
|
@@ -5090,7 +5120,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5090
5120
|
weight: config.dependencyFactorWeights.signals,
|
|
5091
5121
|
amplification: config.dependencySignals.inheritedSignalMultiplier,
|
|
5092
5122
|
evidence: [{ kind: "dependency_metric", target: dependency.name, metric: "riskSignals" }],
|
|
5093
|
-
confidence: 0.95
|
|
5123
|
+
confidence: 0.95 * externalMetadataConfidence
|
|
5094
5124
|
},
|
|
5095
5125
|
{
|
|
5096
5126
|
factorId: "dependency.staleness",
|
|
@@ -5103,7 +5133,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5103
5133
|
evidence: [
|
|
5104
5134
|
{ kind: "dependency_metric", target: dependency.name, metric: "daysSinceLastRelease" }
|
|
5105
5135
|
],
|
|
5106
|
-
confidence: hasMetadata ? 0.9 : 0.5
|
|
5136
|
+
confidence: (hasMetadata ? 0.9 : 0.5) * externalMetadataConfidence
|
|
5107
5137
|
},
|
|
5108
5138
|
{
|
|
5109
5139
|
factorId: "dependency.maintainer_concentration",
|
|
@@ -5118,7 +5148,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5118
5148
|
evidence: [
|
|
5119
5149
|
{ kind: "dependency_metric", target: dependency.name, metric: "maintainerCount" }
|
|
5120
5150
|
],
|
|
5121
|
-
confidence: hasMetadata ? 0.9 : 0.5
|
|
5151
|
+
confidence: (hasMetadata ? 0.9 : 0.5) * externalMetadataConfidence
|
|
5122
5152
|
},
|
|
5123
5153
|
{
|
|
5124
5154
|
factorId: "dependency.topology",
|
|
@@ -5139,7 +5169,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5139
5169
|
evidence: [
|
|
5140
5170
|
{ kind: "dependency_metric", target: dependency.name, metric: "dependencyDepth" }
|
|
5141
5171
|
],
|
|
5142
|
-
confidence: 1
|
|
5172
|
+
confidence: 1 * externalMetadataConfidence
|
|
5143
5173
|
},
|
|
5144
5174
|
{
|
|
5145
5175
|
factorId: "dependency.bus_factor",
|
|
@@ -5150,7 +5180,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5150
5180
|
weight: config.dependencyFactorWeights.busFactorRisk,
|
|
5151
5181
|
amplification: null,
|
|
5152
5182
|
evidence: [{ kind: "dependency_metric", target: dependency.name, metric: "busFactor" }],
|
|
5153
|
-
confidence: context.rawMetrics.busFactor === null ? 0.5 : 0.85
|
|
5183
|
+
confidence: (context.rawMetrics.busFactor === null ? 0.5 : 0.85) * externalMetadataConfidence
|
|
5154
5184
|
},
|
|
5155
5185
|
{
|
|
5156
5186
|
factorId: "dependency.popularity_dampening",
|
|
@@ -5163,7 +5193,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5163
5193
|
evidence: [
|
|
5164
5194
|
{ kind: "dependency_metric", target: dependency.name, metric: "weeklyDownloads" }
|
|
5165
5195
|
],
|
|
5166
|
-
confidence: context.rawMetrics.weeklyDownloads === null ? 0.4 : 0.9
|
|
5196
|
+
confidence: (context.rawMetrics.weeklyDownloads === null ? 0.4 : 0.9) * externalMetadataConfidence
|
|
5167
5197
|
}
|
|
5168
5198
|
]);
|
|
5169
5199
|
collector.record(
|
|
@@ -5220,7 +5250,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5220
5250
|
weight: dimensionWeights.evolution,
|
|
5221
5251
|
amplification: null,
|
|
5222
5252
|
evidence: [{ kind: "repository_metric", metric: "evolutionDimension" }],
|
|
5223
|
-
confidence: evolution.available ?
|
|
5253
|
+
confidence: evolution.available ? evolutionHistoryConfidence : 0
|
|
5224
5254
|
},
|
|
5225
5255
|
{
|
|
5226
5256
|
factorId: "repository.external",
|
|
@@ -5231,7 +5261,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
5231
5261
|
weight: dimensionWeights.external,
|
|
5232
5262
|
amplification: null,
|
|
5233
5263
|
evidence: [{ kind: "repository_metric", metric: "externalDimension" }],
|
|
5234
|
-
confidence: external.available ? 0.8 : 0
|
|
5264
|
+
confidence: external.available ? 0.8 * externalMetadataConfidence : 0
|
|
5235
5265
|
},
|
|
5236
5266
|
{
|
|
5237
5267
|
factorId: "repository.composite.interactions",
|